SiteGroupMapper.xml
5.62 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?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.runsa.crmapp.common.mapper.SiteGroupMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.crmapp.common.entity.SiteGroup" >
<id column="GRP_ID" property="grpId" jdbcType="BIGINT" />
<result column="ACT_ID" property="actId" jdbcType="BIGINT" />
<result column="GRP_NAME" property="grpName" jdbcType="VARCHAR" />
<result column="GRP_DESC" property="grpDesc" jdbcType="VARCHAR" />
<result column="GRP_INDEX" property="grpIndex" jdbcType="INTEGER" />
<result column="REC_TIME" property="recTime" jdbcType="TIMESTAMP" />
<result column="REC_USER" property="recUser" jdbcType="BIGINT" />
<result column="GZH_ID" property="gzhId" jdbcType="VARCHAR" />
<result column="GZH_TYPE" property="gzhType" jdbcType="INTEGER" />
<result column="NICK_NAME" property="nickName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
`GRP_ID`, `ACT_ID`, `GRP_NAME`, `GRP_DESC`, `GRP_INDEX`, `REC_TIME`, `REC_USER`
</sql>
<select id="findList" resultMap="BaseResultMap" parameterType="java.lang.Long" >
SELECT
t1.`GRP_ID`,
t1.`ACT_ID`,
t1.`GRP_NAME`,
t1.`GRP_DESC`,
t1.`GRP_INDEX`,
t1.`REC_TIME`,
t1.`REC_USER`,
t3.GZH_ID,
t3.GZH_TYPE,
t3.NICK_NAME
FROM
crm_site_group t1
LEFT JOIN crm_site_group_wxgzh t2 ON t2.GRP_ID = t1.GRP_ID
LEFT JOIN crm_wxgzh t3 ON t3.GZH_ID = t2.GZH_ID
WHERE
ACT_ID = #{actId,jdbcType=INTEGER}
ORDER BY
GRP_INDEX
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="grpId" parameterType="cn.runsa.crmapp.common.entity.SiteGroup" >
insert into crm_site_group
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="actId != null" >
`ACT_ID`,
</if>
<if test="grpName != null" >
`GRP_NAME`,
</if>
<if test="grpDesc != null" >
`GRP_DESC`,
</if>
<if test="grpIndex != null" >
`GRP_INDEX`,
</if>
<if test="recTime != null" >
`REC_TIME`,
</if>
<if test="recUser != null" >
`REC_USER`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="actId != null" >
#{actId,jdbcType=BIGINT},
</if>
<if test="grpName != null" >
#{grpName,jdbcType=VARCHAR},
</if>
<if test="grpDesc != null" >
#{grpDesc,jdbcType=VARCHAR},
</if>
<if test="grpIndex != null" >
#{grpIndex,jdbcType=INTEGER},
</if>
<if test="recTime != null" >
#{recTime,jdbcType=TIMESTAMP},
</if>
<if test="recUser != null" >
#{recUser,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="update" useGeneratedKeys="true" keyProperty="grpId" parameterType="cn.runsa.crmapp.common.entity.SiteGroup">
update crm_site_group
<set >
<if test="actId != null" >
`ACT_ID` = #{actId,jdbcType=BIGINT},
</if>
<if test="grpName != null" >
`GRP_NAME` = #{grpName,jdbcType=VARCHAR},
</if>
<if test="grpDesc != null" >
`GRP_DESC` = #{grpDesc,jdbcType=VARCHAR},
</if>
<if test="grpIndex != null" >
`GRP_INDEX` = #{grpIndex,jdbcType=INTEGER},
</if>
<if test="recTime != null" >
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
</if>
<if test="recUser != null" >
`REC_USER` = #{recUser,jdbcType=BIGINT},
</if>
</set>
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</update>
<insert id="insertSiteGroupWxgzh" useGeneratedKeys="true" keyProperty="grpId" parameterType="cn.runsa.crmapp.common.entity.SiteGroup" >
insert ignore into crm_site_group_wxgzh
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="grpId != null" >
`GRP_ID`,
</if>
<if test="gzhId != null" >
`GZH_ID`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="grpId != null" >
#{grpId,jdbcType=BIGINT},
</if>
<if test="gzhId != null" >
#{gzhId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<insert id="insertSiteGroupSite" useGeneratedKeys="true" keyProperty="grpId" parameterType="cn.runsa.crmapp.common.entity.SiteGroup" >
insert into crm_site_group_site
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="grpId != null" >
`GRP_ID`,
</if>
<if test="sitIt != null" >
`SIT_ID`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="grpId != null" >
#{grpId,jdbcType=BIGINT},
</if>
<if test="sitIt != null" >
#{sitIt,jdbcType=INTEGER},
</if>
</trim>
</insert>
<delete id="delete" parameterType="java.lang.Long" >
delete from crm_site_group
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</delete>
<delete id="deleteByGroupId" parameterType="java.lang.Long" >
delete from crm_site_group
where `GRP_ID` = #{grpId,jdbcType=BIGINT}
</delete>
<delete id="deleteWxgzhByGroupId" parameterType="java.lang.Long" >
delete from crm_site_group_wxgzh
where `GRP_ID` = #{grpId,jdbcType=BIGINT}
</delete>
<delete id="deleteSiteGroupWxgzh" parameterType="java.lang.Long" >
delete from crm_site_group_wxgzh
where `GRP_ID` IN (select GRP_ID from crm_site_group where ACT_ID = #{actId,jdbcType=BIGINT} )
</delete>
<delete id="deleteSiteGroupSite" parameterType="java.lang.Long" >
delete from crm_site_group_site
where `GRP_ID` IN (select GRP_ID from crm_site_group where ACT_ID = #{actId,jdbcType=BIGINT} )
</delete>
</mapper>