<?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="org.springblade.complaints.mapper.BladeCustomerComplaintsReportMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="org.springblade.complaints.entity.BladeCustomerComplaintsReport">
        <id column="id" property="id" />
        <result column="report_name" property="reportName" />
        <result column="complaint_id" property="complaintId" />
        <result column="report_path" property="reportPath" />
        <result column="create_user" property="createUser" />
        <result column="create_dept" property="createDept" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="update_user" property="updateUser" />
        <result column="status" property="status" />
        <result column="is_deleted" property="isDeleted" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, report_name, complaint_id, report_path, create_user, create_dept, create_time, update_time, update_user, status, is_deleted
    </sql>

    <select id="getPageByQuery" resultMap="BaseResultMap">
        SELECT
        *
        FROM
        blade_customer_complaints_report
        where is_deleted = 0
        <if test="query.reportName != null and query.reportName != ''">
            and report_name LIKE CONCAT('%',#{query.reportName},'%')
        </if>
        <if test="query.complaintId != null and query.complaintId != ''">
            and complaint_id = #{query.complaintId}
        </if>
        <if test="query.startTime != null and query.startTime != ''">
            and DATE_FORMAT(create_time, '%Y-%m-%d') <![CDATA[>=]]> #{query.startTime}
        </if>
        <if test="query.endTime != null and query.endTime != ''">
            and DATE_FORMAT(create_time, '%Y-%m-%d') <![CDATA[<=]]> #{query.endTime}
        </if>
        ORDER BY
        create_time DESC
    </select>

</mapper>
