<?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.ruoyi.project.check.mapper.TCheckStandardgasesMapper">

    <resultMap type="TCheckStandardgases" id="TCheckStandardgasesResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="concentration"    column="concentration"    />
        <result property="lifespan"    column="lifespan"    />
        <result property="factory"    column="factory"    />
        <result property="cylinderCode"    column="cylinder_code"    />
        <result property="remarks"    column="remarks"    />
        <result property="deptId"    column="dept_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updater"    column="user_name"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="describe"    column="describe"    />
    </resultMap>

    <sql id="selectTCheckStandardgasesVo">
        select id, code, name, concentration, lifespan, factory, cylinder_code, remarks, dept_id, del_flag, creater_code, createdate, updater_code, updatedate from t_check_standardgases
    </sql>

    <select id="selectTCheckStandardgasesList" parameterType="TCheckStandardgases" resultMap="TCheckStandardgasesResult">
        select d.*,su.user_name from t_check_standardgases d
        left join sys_user su on su.user_id=d.updater_code
        <where>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="concentration != null  and concentration != ''"> and concentration = #{concentration}</if>
            <if test="lifespan != null  and lifespan != ''"> and lifespan = #{lifespan}</if>
            <if test="factory != null  and factory != ''"> and factory = #{factory}</if>
            <if test="cylinderCode != null  and cylinderCode != ''"> and cylinder_code = #{cylinderCode}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="deptId != null "> and d.dept_id = #{deptId}</if>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
        and d.del_flag = 0
        </where>
    </select>

    <select id="selectAllStandardgases"  resultMap="TCheckStandardgasesResult">
        select d.*,concat(d.name, '_',d.code) `describe` from t_check_standardgases d where d.del_flag = 0
    </select>

    <select id="selectTCheckStandardgasesById" parameterType="Long" resultMap="TCheckStandardgasesResult">
        <include refid="selectTCheckStandardgasesVo"/>
        where id = #{id}
    </select>

    <insert id="insertTCheckStandardgases" parameterType="TCheckStandardgases" useGeneratedKeys="true" keyProperty="id">
        insert into t_check_standardgases
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="name != null">name,</if>
            <if test="concentration != null">concentration,</if>
            <if test="lifespan != null">lifespan,</if>
            <if test="factory != null">factory,</if>
            <if test="cylinderCode != null">cylinder_code,</if>
            <if test="remarks != null">remarks,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="name != null">#{name},</if>
            <if test="concentration != null">#{concentration},</if>
            <if test="lifespan != null">#{lifespan},</if>
            <if test="factory != null">#{factory},</if>
            <if test="cylinderCode != null">#{cylinderCode},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
         </trim>
    </insert>

    <update id="updateTCheckStandardgases" parameterType="TCheckStandardgases">
        update t_check_standardgases
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="name != null">name = #{name},</if>
            <if test="concentration != null">concentration = #{concentration},</if>
            <if test="lifespan != null">lifespan = #{lifespan},</if>
            <if test="factory != null">factory = #{factory},</if>
            <if test="cylinderCode != null">cylinder_code = #{cylinderCode},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTCheckStandardgasesById" parameterType="Long">
        update t_check_standardgases set del_flag=1 where id = #{id}
    </delete>

    <delete id="deleteTCheckStandardgasesByIds" parameterType="String">
        update t_check_standardgases set del_flag=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
