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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.lz.modules.equipment.entity.TCount">
        <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="num" property="num"/>
    </resultMap>


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




    <select id="selectTCountById" resultType="TCount" >
        select * from equipment_t_count  where id=#{id} and is_delete = 0 limit 1
    </select>


    <insert id="insertTCount" parameterType="TCount" useGeneratedKeys="true" keyProperty="id" >
        insert into equipment_t_count(
        <if test="num != null">num, </if>
        is_delete,
        gmt_create,
        gmt_modified
        )values(
        <if test="num != null">#{ num}, </if>
        0,
        now(),
        now()
        )
    </insert>


    <update id="updateTCountById" parameterType="TCount" >
        update
        equipment_t_count
        <trim prefix="set" suffixOverrides=",">
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
            <if test="num != null">num = #{num}</if>
        </trim>
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="updateCoverTCountById" parameterType="TCount" >
        update
            equipment_t_count
        set
            is_delete = #{isDelete},
            gmt_create = #{gmtCreate},
            num = #{num}
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="deleteTCountById" parameterType="java.lang.Long">
        update equipment_t_count set is_delete = 1 where id=#{id} and is_delete = 0 limit 1
    </update>

    <select id="selectMaxCount" resultType="com.lz.modules.equipment.entity.TCount">
         select * from equipment_t_count where is_delete = 0 order by id desc limit 1
    </select>
    <select id="selectListLimit" resultType="com.lz.modules.equipment.entity.TCount">
         select * from equipment_t_count where is_delete = 0 order by id desc limit #{limit}
    </select>

    <select id="selectByReq" resultType="com.lz.modules.equipment.entity.TCount">
         select * from equipment_t_count where is_delete = 0 order by id desc
    </select>

</mapper>

