<?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.lz.modules.equipment.dao.SpecialApplyInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.lz.modules.equipment.entity.SpecialApplyInfo">
        <id column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="type_desc" property="typeDesc"/>
    </resultMap>


    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, type_desc AS typeDesc
    </sql>




    <select id="selectSpecialApplyInfoById" resultType="SpecialApplyInfo" >
        select * from equipment_special_apply_info  where id=#{id} and is_delete = 0 limit 1 
    </select>



    <insert id="insertSpecialApplyInfo" parameterType="SpecialApplyInfo" useGeneratedKeys="true" keyProperty="id" >
        insert into equipment_special_apply_info(
        <if test="typeDesc != null">type_desc, </if>
        is_delete,
        gmt_create,
        gmt_modified
        )values(
        <if test="typeDesc != null">#{ typeDesc}, </if>
        0,
        now(),
        now()
        )
    </insert>


    <update id="updateSpecialApplyInfoById" parameterType="SpecialApplyInfo" >
        update
        equipment_special_apply_info
        <trim prefix="set" suffixOverrides=",">
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
            <if test="typeDesc != null">type_desc = #{typeDesc}</if>
        </trim>
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="updateCoverSpecialApplyInfoById" parameterType="SpecialApplyInfo" >
        update
            equipment_special_apply_info
        set
            is_delete = #{isDelete},
            gmt_create = #{gmtCreate},
            type_desc = #{typeDesc}
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="deleteSpecialApplyInfoById" parameterType="java.lang.Long">
        update equipment_special_apply_info set is_delete = 1 where id=#{id} limit 1  
    </update>


    <select id="selectSpecialApplyInfoByTypeDesc"
            resultType="com.lz.modules.equipment.entity.SpecialApplyInfo">
        select * from equipment_special_apply_info  where type_desc=#{owner} and is_delete = 0 limit 1
    </select>

    <select id="selectBySearchName" resultType="SpecialApplyInfo" >
        select * from equipment_special_apply_info  where is_delete = 0
        <if test="model.name != null and model.name != ''">
            and  type_desc LIKE CONCAT('%',#{model.name},'%')
        </if>
    </select>

</mapper>

