zxl
2025-12-22 cc4a3ff932b1e768914a4aff0eeaa866d08f9b91
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?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.mapper.ReportMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.ReportVO">
        <result column="content" property="content" />
        <result column="project_id" property="projectId" />
        <result column="project_name" property="projectName" />
        <result column="user_id" property="userId" />
        <result column="file_url" property="fileUrl"/>
        <result column="user_name" property="userName"/>
        <result column="status" property="status"/>
        <result column="remake" property="remake"/>
    </resultMap>
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TR.content,
            TR.project_id,
            TR.project_name,
            TR.user_id,
            TR.id
        FROM
            t_report TR
        WHERE
            TR.id = #{id} AND TR.deleted = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            TR.user_id,
            TR.content,
            TR.status,
            TR.file_url,
            TR.project_id,
            TR.project_name,
            TR.gmt_create,
            TR.gmt_update,
            SU.user_name,
            TR.remake,
            TR.id
        FROM
            t_report TR
        LEFT JOIN
                sys_user SU on TR.user_id = SU.user_id
        WHERE
            TR.deleted = 0
        <if test="query.projectName !=null and query.projectName !=''">
            and TR.project_name like concat('%', #{query.projectName}, '%')
        </if>
        <if test="query.startTime != null">
            and TR.gmt_create >= #{query.startTime}
        </if>
        <if test="query.endTime != null">
            and TR.gmt_create &lt;= #{query.startTime}
        </if>
        <if test="query.status != null and query.status !=''">
            and TR.status = #{query.status}
        </if>
        order by TR.gmt_create desc
    </select>
 
 
    <select id="groupByProjectAndDate" resultMap="BaseResultMap">
 
        SELECT
            TR.content,
            TR.project_id,
            TR.project_name,
            TR.user_id,
            TR.id,
            TR.gmt_create,
            TR.file_url,
            TR.status
        FROM
            t_report TR
        LEFT JOIN t_project_info TPI on TR.project_id = TPI.id
        WHERE
            TR.deleted = 0
        AND TR.gmt_create BETWEEN #{startTime} AND #{endTime}
        <if test="projectId != null">
            AND TR.project_id = #{projectId}
        </if>
    </select>
 
</mapper>