DigitalManagementTemplateMapper.xml
5.23 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?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="cn.com.glsx.dj.mindworkplate.mapper.digitalmanagement.DigitalManagementTemplateMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.digitalmanagement.DigitalManagementTemplate" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="VARCHAR" />
<result column="type_name" property="typeName" jdbcType="VARCHAR" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="display_summary" property="displaySummary" jdbcType="INTEGER" />
<result column="extend_field" property="extendField" jdbcType="VARCHAR" />
<result column="scene_type" property="sceneType" jdbcType="INTEGER" />
<result column="business_type" property="businessType" jdbcType="INTEGER" />
<result column="report_type" property="reportType" jdbcType="INTEGER" />
</resultMap>
<resultMap id="SimpleDTOResult" type="cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementTemplateDTO" extends="BaseResultMap" />
<resultMap id="DTOResult" type="cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementTemplateDTO" extends="BaseResultMap">
<collection property="types"
resultMap="cn.com.glsx.dj.mindworkplate.mapper.digitalmanagement.DigitalManagementTemplateItemMapper.DTOResult"
columnPrefix="item_" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, code, name, type, type_name, created_by, created_date, updated_by, updated_date,
deleted_flag,extend_field, display_summary ,scene_type ,business_type ,report_type
</sql>
<select id="findAllType" resultMap="SimpleDTOResult">
select type, max(type_name) as type_name
from digital_management_template
where deleted_flag = 'N' group by type
</select>
<select id="findLastOne" resultMap="SimpleDTOResult">
select *
from digital_management_template t
<where>
t.deleted_flag = 'N'
<if test="typeName != null and typeName != ''">
and t.type_name = #{typeName}
</if>
<if test="createdDate != null">
and date(t.created_date) <= date(#{createdDate})
</if>
</where>
order by t.created_date desc
limit 1
</select>
<select id="findDetail" resultMap="DTOResult"
parameterType="cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementTemplateDTO">
select t.*,
<include refid="cn.com.glsx.dj.mindworkplate.mapper.digitalmanagement.DigitalManagementTemplateItemMapper.Prefix_Column">
<property name="prefix" value="item"/>
</include>
from digital_management_template t
left join digital_management_template_item item on t.code = item.template_code
<where>
t.deleted_flag = 'N' and item.deleted_flag = 'N'
and t.code = #{code}
<if test="createdDate != null">
and date(t.created_date) <= date(#{createdDate})
</if>
<if test="endTime != null">
and date(t.created_date) <= date(#{endTime})
</if>
</where>
order by t.created_date desc
</select>
<select id="queryUserTemplate" resultMap="BaseResultMap">
SELECT
t.*
FROM digital_management_template t
inner join digital_management_template_staff_ref r1 on r1.template_code = t.code
inner join (
SELECT r2.template_code as template_code, max(r2.id) as id
FROM digital_management_template_staff_ref r2
where r2.deleted_flag = 'N'
<if test="includeTempCode != null and includeTempCode != ''">
and r2.template_code = #{includeTempCode}
</if>
<if test="excludeTempCode != null and excludeTempCode != ''">
and r2.template_code != #{excludeTempCode}
</if>
and r2.effective_date <= date(#{date})
group by r2.template_code
) temp on temp.template_code = r1.template_code
where FIND_IN_SET(#{uuid}, r1.staff_uuid_list) > 0
and r1.effective_date <= date(#{date})
and r1.id = temp.id
and r1.deleted_flag = 'N'
order by r1.id desc
limit 1
</select>
<select id="findStaffTemplateByDate" resultMap="BaseResultMap">
select
t.*
from digital_management_template t
inner join digital_management_template_staff_ref tsr on tsr.template_code = t.code
where t.deleted_flag = 'N'
and tsr.deleted_flag = 'N'
and FIND_IN_SET(#{uuid}, tsr.staff_uuid_list) > 0
and tsr.effective_date <= date(#{date})
order by tsr.effective_date desc
limit 1
</select>
<select id="findByCode" resultMap="DTOResult">
select * from digital_management_template
where deleted_flag = 'N' and code = #{code}
</select>
</mapper>