<?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.StandardLibraryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.StandardLibrary">
        <id column="id" property="id" />
        <result column="product_category" property="productCategory" />
        <result column="product_category_num" property="productCategoryNum" />
        <result column="industry_code" property="industryCode" />
        <result column="industry" property="industry" />
        <result column="denominator_unit" property="denominatorUnit" />
        <result column="name_index" property="nameIndex" />
        <result column="num_index" property="numIndex" />
        <result column="type_index" property="typeIndex" />
        <result column="molecular_unit" property="molecularUnit" />
        <result column="standard_value" property="standardValue" />
        <result column="advanced_value" property="advancedValue" />
        <result column="access_value" property="accessValue" />
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
        <result column="epc" property="epc"/>
    </resultMap>

    <select id="selectall" resultType="com.nantian.cloud.jljc.entity.StandardLibrary">
        SELECT a.* from standard_library a
        <trim prefix="where" prefixOverrides="and">
            <if test="param2.id != null and param2.id != ''">
                and a.id = #{param2.id}
            </if>
            <if test="param2.industryCode != null and param2.industryCode != ''">
              and a.industry_code = #{param2.industryCode}
            </if>
            <if test="param2.industry != null and param2.industry != ''">
              and a.industry = #{param2.industry}
            </if>
            <if test="param2.nameIndex != null and param2.nameIndex != ''">
                and a.name_index like concat('%', #{param2.nameIndex},'%')
            </if>
            <if test="param2.typeIndex != null and param2.typeIndex != ''">
              and a.type_index like concat('%', #{param2.typeIndex},'%')
            </if>
            <if test="param2.productCategoryNum != null and param2.productCategoryNum != ''">
              and a.product_category_num like concat('%', #{param2.productCategoryNum},'%')
            </if>
            <if test="param2.productCategory != null and param2.productCategory != ''">
              and a.product_category like concat('%', #{param2.productCategory},'%')
            </if>
            <if test="param2.epc != null and param2.epc != ''">
                and a.epc = #{param2.epc}
            </if>
            and a.del_flag = '1'
        </trim>

    </select>

    <!--修改方法-->
    <update id="updateall" parameterType="com.nantian.cloud.jljc.entity.StandardLibrary">
        UPDATE standard_library a
        set a.access_value=#{accessValue},
        a.advanced_value=#{advancedValue},
        a.denominator_unit=#{denominatorUnit},
        a.industry=#{industry},
        a.industry_code=#{industryCode},
        a.molecular_unit=#{molecularUnit},
        a.name_index=#{nameIndex},
        a.num_index=#{numIndex},
        a.product_category=#{productCategory},
        a.product_category_num=#{productCategoryNum},
        a.standard_value=#{standardValue},
        a.type_index=#{typeIndex},
        a.update_time =#{updateTime},
        a.userid=#{userid}
        where a.id=#{id}
    </update>


    <update id="deleteall" parameterType="com.nantian.cloud.jljc.entity.StandardLibrary">
        UPDATE standard_library a set
        a.del_flag = '4'
        WHERE a.id = #{standardLibrary.id}
    </update>

    <insert id="insertall" parameterType="com.nantian.cloud.jljc.entity.StandardLibrary">
       INSERT into standard_library
        (industry,
       denominator_unit,
       industry_code,
       molecular_unit,
       name_index,
       num_index,
       product_category,
       product_category_num,
       type_index,
       update_time,
       userid,
       dept_id,
       standard_value,
       advanced_value,
       access_value,
       epc
       )
       VALUES
       (
       #{industry},
       #{denominatorUnit},
       #{industryCode},
       #{molecularUnit},
       #{nameIndex},
       #{numIndex},
       #{productCategory},
       #{productCategoryNum},
       #{typeIndex},
       #{updateTime},
       #{userid},
       #{deptId},
       #{standardValue},
       #{advancedValue},
       #{accessValue},
       #{epc}
       )
    </insert>
</mapper>
