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.wisenergy.chnmuseum.party.mapper.IndexMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="Index">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="creator" property="creator" />
<result column="creatorName" property="creatorName" />
<result column="createTime" property="createTime" />
<result column="updateTime" property="updateTime" />
<result column="type" property="type" />
<result column="typeName" property="typeName" />
<result column="branchName" property="branchName" />
<result column="bankBranchId" property="bankBranchId" />
</resultMap>
<select id="getIndexList" resultMap="BaseResultMap">
SELECT
*
FROM
(
SELECT
bi.id AS id,
bi.`name` AS `name`,
bi.creator AS creator,
crep.`name` AS creatorName,
bi.create_time AS createTime,
bi.update_time AS updateTime,
'1' AS type,
'业务服务指南' AS typeName,
bbi.`name` AS branchName,
bi.bank_branch_id AS bankBranchId
FROM
business_info bi
LEFT JOIN employee crep ON crep.id = bi.creator
LEFT JOIN bank_branch_info bbi ON bbi.id = bi.bank_branch_id
<if test=" roleId == 2 ">
WHERE bi.`status` = 2 OR bi.`status` = 3
</if>
<if test=" roleId == 3 ">
WHERE bi.`status` = 1 OR bi.`status` = 6
</if>
UNION ALL
SELECT
bbi.id AS id,
bbi.`name` AS `name`,
bbi.modifier AS creator,
crep.`name` AS creatorName,
bbi.create_time AS createTime,
bbi.update_time AS updateTime,
'2' AS type,
'网点地图' AS typeName,
bbi.`name` AS branchName,
bbi.id AS bankBranchId
FROM
bank_branch_info bbi
LEFT JOIN employee crep ON crep.id = bbi.modifier
<if test=" roleId == 2 ">
WHERE bbi.is_show = 2 OR bbi.is_show = 3
</if>
<if test=" roleId == 3 ">
WHERE bbi.is_show = 1 OR bbi.is_show = 6
</if>
UNION ALL
SELECT
hp.id AS id,
hp.`name` AS `name`,
hp.creator AS creator,
crep.`name` AS creatorName,
hp.create_time AS createTime,
hp.update_time AS updateTime,
'3' AS type,
'热门产品' AS typeName,
bbi.`name` AS branchName,
hp.bank_branch_id AS bankBranchId
FROM
hot_product_activity hp
LEFT JOIN employee crep ON crep.id = hp.creator
LEFT JOIN bank_branch_info bbi ON bbi.id = hp.bank_branch_id
WHERE
hp.type = 1
<if test=" roleId == 2 ">
AND (hp.is_show = 2 OR hp.is_show = 3)
</if>
<if test=" roleId == 3 ">
AND (hp.is_show = 1 OR hp.is_show = 6)
</if>
UNION ALL
SELECT
ha.id AS id,
ha.`name` AS `name`,
ha.creator AS creator,
crep.`name` AS creatorName,
ha.create_time AS createTime,
ha.update_time AS updateTime,
'4' AS type,
'热门活动' AS typeName,
bbi.`name` AS branchName,
ha.bank_branch_id AS bankBranchId
FROM
hot_product_activity ha
LEFT JOIN employee crep ON crep.id = ha.creator
LEFT JOIN bank_branch_info bbi ON bbi.id = ha.bank_branch_id
WHERE
ha.type = 2
<if test=" roleId == 2 ">
AND (ha.is_show = 2 OR ha.is_show = 3)
</if>
<if test=" roleId == 3 ">
AND (ha.is_show = 1 OR ha.is_show = 6)
</if>
) T
<where>
<if test=" bankBranchId != null and bankBranchId != '' and roleId == 3">
T.bankBranchId = #{bankBranchId}
</if>
</where>
ORDER BY
T.updateTime DESC
</select>
</mapper>