<?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.AssetOfficialAccountMapper">
    <update id="deleteById">
        update asset_official_account
        set del_flag = '2'
        where id = #{id}
    </update>
    <delete id="deleteIdList" >
        DELETE FROM asset_official_account
        WHERE id IN
        <foreach item="id" index="index" collection="idList" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="findBydwmc" resultType="java.lang.Integer" parameterType="java.lang.String">
        select count(*)
        from asset_official_account
        where ssdw = #{part}and del_flag=0
    </select>
    <select id="page" resultType="com.ruoyi.tc.entity.AssetOfficialAccount">
        select a.* from asset_official_account 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.gzhmc!=null and req.gzhmc!='' ">
                and a.gzhmc like concat('%',#{req.gzhmc},'%')
            </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.gzhzt = #{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>
</mapper>