<?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.gxwebsoft.oa.mapper.OaTaskMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM oa_task a
        <where>
            <if test="param.taskId != null">
                AND a.task_id = #{param.taskId}
            </if>
            <if test="param.taskType != null">
                AND a.task_type LIKE CONCAT('%', #{param.taskType}, '%')
            </if>
            <if test="param.name != null">
                AND a.name LIKE CONCAT('%', #{param.name}, '%')
            </if>
            <if test="param.content != null">
                AND a.content LIKE CONCAT('%', #{param.content}, '%')
            </if>
            <if test="param.files != null">
                AND a.files LIKE CONCAT('%', #{param.files}, '%')
            </if>
            <if test="param.promoter != null">
                AND a.promoter = #{param.promoter}
            </if>
            <if test="param.commander != null">
                AND a.commander = #{param.commander}
            </if>
            <if test="param.progress != null">
                AND a.progress = #{param.progress}
            </if>
            <if test="param.priority != null">
                AND a.priority LIKE CONCAT('%', #{param.priority}, '%')
            </if>
            <if test="param.quality != null">
                AND a.quality LIKE CONCAT('%', #{param.quality}, '%')
            </if>
            <if test="param.day != null">
                AND a.day = #{param.day}
            </if>
            <if test="param.phone != null">
                AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
            </if>
            <if test="param.startTime != null">
                AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
            </if>
            <if test="param.endTime != null">
                AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
            </if>
            <if test="param.overdueDays != null">
                AND a.overdue_days = #{param.overdueDays}
            </if>
            <if test="param.appId != null">
                AND a.app_id = #{param.appId}
            </if>
            <if test="param.organizationId != null">
                AND a.organization_id = #{param.organizationId}
            </if>
            <if test="param.projectId != null">
                AND a.project_id = #{param.projectId}
            </if>
            <if test="param.customerId != null">
                AND a.customer_id = #{param.customerId}
            </if>
            <if test="param.assetsId != null">
                AND a.assets_id = #{param.assetsId}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.isRead != null">
                AND a.is_read = #{param.isRead}
            </if>
            <if test="param.lastReadUser != null">
                AND a.last_read_user = #{param.lastReadUser}
            </if>
            <if test="param.nickname != null">
                AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%')
            </if>
            <if test="param.avatar != null">
                AND a.avatar LIKE CONCAT('%', #{param.avatar}, '%')
            </if>
            <if test="param.lastAvatar != null">
                AND a.last_avatar LIKE CONCAT('%', #{param.lastAvatar}, '%')
            </if>
            <if test="param.lastNickname != null">
                AND a.last_nickname LIKE CONCAT('%', #{param.lastNickname}, '%')
            </if>
            <if test="param.isSettled != null">
                AND a.is_settled = #{param.isSettled}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaTask">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaTask">
        <include refid="selectSql"></include>
    </select>

</mapper>
