zxl
昨天 0d243e7f5dc593cdc6e0608bb52cd635f8fc6982
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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.ycl.platform.mapper.DemeritRecordMapper">
    <resultMap type="com.ycl.platform.domain.vo.screen.DemeritRecordVO" id="baseResult">
        <result property="id" column="id"/>
        <result property="deptId" column="dept_id"/>
        <result property="demerit" column="demerit"/>
        <result property="createTime" column="create_time"/>
        <result property="constructionType" column="construction_type"/>
    </resultMap>
 
 
    <select id="getPage" resultMap="baseResult">
        select
            ter.id,
            ter.dept_id,
            ter.create_time,
            ter.construction_type,
            ter.demerit
        from t_demerit_record ter where ter.deleted = 0
        <if test="query.deptId != null and query.deptId != ''">
            AND ter.dept_id = #{query.deptId}
        </if>
        <if test="query.constructionType != null and query.constructionType != ''">
            AND ter.construction_type = #{query.constructionType}
        </if>
        <!-- 时间范围筛选:按日查询 -->
        <if test="query.searchType == 'day' and query.dayDate != null">
            AND ter.create_time >= #{query.dayDate}  <!-- 当天00:00:00 -->
            AND ter.create_time &lt;DATE_ADD(#{query.dayDate}, INTERVAL 1 DAY)  <!-- 次日00:00:00(不包含) -->
        </if>
        <!-- 时间范围筛选:按月查询 -->
        <if test="query.searchType == 'month' and query.monthDate != null">
            AND ter.create_time >= #{query.monthDate}  <!-- 当月1日00:00:00 -->
            AND ter.create_time &lt;DATE_ADD(LAST_DAY(#{query.monthDate}), INTERVAL 1 DAY)  <!-- 下月1日00:00:00(不包含) -->
        </if>
    </select>
</mapper>