<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nantian.cloud.jljc.mapper.EnterpriseStandardMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.EnterpriseStandard">
        <id column="id" property="id" />
        <result column="epc" property="epc" />
        <result column="industry_code" property="industryCode" />
        <result column="product" property="product" />
        <result column="index_code" property="indexCode" />
        <result column="standard_value" property="standardValue" />
        <result column="advanced_value" property="advancedValue" />
        <result column="access_value" property="accessValue" />
        <result column="year" property="year" />
        <result column="current_value" property="currentValue" />
        <result column="name_index" property="nameIndex" />
        <result column="industry" property="industry" />
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
    </resultMap>

    <select id="selectall" resultType="com.nantian.cloud.jljc.entity.EnterpriseStandard">
        select a.*,b.name_index as name_index,b.industry as industry from enterprise_standard a ,standard_library b
        <trim prefix="where" prefixOverrides="and">
            <if test="EnterpriseStandard.id !=null and EnterpriseStandard.id !=''">
                and a.id = #{EnterpriseStandard.id}
            </if>
            <if test="EnterpriseStandard.epc !=null and EnterpriseStandard.epc !=''">
               and a.epc = #{EnterpriseStandard.epc}
            </if>
            <if test="EnterpriseStandard.indexCode !=null and EnterpriseStandard.indexCode !=''">
               and a.index_code = #{EnterpriseStandard.indexCode}
            </if>
            <if test="EnterpriseStandard.product !=null and EnterpriseStandard.product !=''">
               and a.product like concat('%', #{EnterpriseStandard.product},'%')
            </if>
            <if test="EnterpriseStandard.industryCode !=null and EnterpriseStandard.industryCode !=''">
               and a.industry_code = #{EnterpriseStandard.industryCode}
            </if>
            and a.index_code =b.num_index
        </trim>
    </select>

    <update id="updateall" parameterType="com.nantian.cloud.jljc.entity.EnterpriseStandard">
        update enterprise_standard a set
        a.epc = #{epc},
        a.access_value = #{accessValue},
        a.advanced_value = #{advancedValue},
        a.current_value =#{currentValue},
        a.index_code =#{indexCode},
        a.industry_code = #{industryCode},
        a.product = #{product},
        a.standard_value =#{standardValue},
        a.`year` =#{year}
        WHERE a.id =#{id}
    </update>


</mapper>
