<?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.system.mapper.zb.WeekReportExtMapper">
    <select id="listByParamForApp" resultType="com.ruoyi.system.domain.zb.ZbWeekReport">
        select * from zb_week_report where 1=1
        <if test="title != null and title != ''">
            and title like concat('%',#{title},'%')
        </if>
        <if test="userId != null and userId !=''">
            and (show_flag = 1 or (show_flag = 0 and id in(
            select report_id from zb_report_relationship where user_id = #{userId}
            )))
        </if>
        order by create_time desc
    </select>
    <select id="specialList" resultType="com.ruoyi.system.domain.zb.ZbSpecialWork">
        select * from zb_special_work where valid = '1'
        <if test="type != null and type != ''">
            and type = #{type}
        </if>
        <if test="title != null and title != ''">
            and title like concat('%', #{title}, '%')
        </if>
        <if test="username != null and username != ''">
            and create_user_name like concat('%', #{username}, '%')
        </if>
        <if test="userId != null and userId != ''">
            and (create_user = #{userId} or id in(select work_id from zb_work_range where user_id = #{userId}))
        </if>
        order by create_time desc
    </select>
</mapper>