<?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.tc.mapper.AssetMiniProgramsMapper">
    <update id="deleteById">
        update asset_mini_programs
        set del_flag = '2'
        where id = #{id}
    </update>
    <delete id="deleteIdList" >
        DELETE FROM asset_mini_programs
        WHERE id IN
        <foreach item="id" index="index" collection="idList" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="page" resultType="com.ruoyi.tc.entity.AssetMiniPrograms">
        select a.* from asset_mini_programs a
        left join unit_info b on a.ssdw = b.nick_name
        left join sys_dept c on b.dept_id = c.dept_id
        <where>
            a.del_flag = '0'
            <if test="req.xcxmc!=null and req.xcxmc!='' ">
                and a.xcxmc like concat('%',#{req.xcxmc},'%')
            </if>
            <if test="req.dwmc!=null and req.dwmc!='' ">
                and a.ssdw like concat('%',#{req.dwmc},'%')
            </if>
            <if test="req.startTime != null ">
                and a.create_time &gt;= #{req.startTime}
            </if>
            <if test="req.endTime != null">
                and a.create_time &lt;= #{req.endTime}
            </if>
            <if test="req.xtzt != null">
                and a.state = #{req.xtzt}
            </if>
            <if test="req.deptId != null">
                AND (b.dept_id = #{req.deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
                find_in_set(#{req.deptId}, ancestors) ))
            </if>
        </where>
        order by a.create_time desc
    </select>

    <select id="findBydwmc" resultType="java.lang.Integer" parameterType="java.lang.String">
        select count(*)
        from asset_mini_programs
        where ssdw = #{part} and del_flag=0
    </select>
</mapper>

