IntelligentRemindServiceMapper.xml
7.32 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
<?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.weapp.mapper.IntelligentRemindServiceMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.weapp.model.IntelligentRemindService" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="title" property="title" jdbcType="VARCHAR" />
<result column="video_url" property="videoUrl" jdbcType="VARCHAR" />
<result column="online_flag" property="onlineFlag" jdbcType="CHAR" />
<result column="cover_url" property="coverUrl" jdbcType="VARCHAR" />
<result column="share_recommend" property="shareRecommend" jdbcType="VARCHAR" />
<result column="remind_rule_id" property="remindRuleId" jdbcType="INTEGER" />
<result column="activity_id" property="activityId" jdbcType="INTEGER" />
<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" />
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.weapp.dto.IntelligentRemindServiceDTO" extends="BaseResultMap">
<result column="mile_rule" property="searchKey" jdbcType="VARCHAR" />
<result column="time_rule" property="searchKey" jdbcType="VARCHAR" />
<result column="season_rule" property="searchKey" jdbcType="VARCHAR" />
<result column="rule_name" property="projectName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, merchant_id, title, video_url, online_flag, cover_url, share_recommend, remind_rule_id, activity_id,
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="selectByPage" resultMap="DTOResultMap" parameterType="cn.com.glsx.dj.weapp.dto.IntelligentRemindServiceDTO" >
select a.*
from dj_weapp_intelligent_remind_service a
WHERE a.deleted_flag='N'
and a.merchant_id = #{merchantId,jdbcType=INTEGER}
<if test="searchKey != null">
<choose>
<when test='searchKey=="1"'>
and EXISTS(select 1 from dj_weapp_intelligent_remind_rule b WHERE b.id = a.remind_rule_id and b.deleted_flag='N'
and (b.mile_rule is not null and b.mile_rule != '' or (b.season_rule is not null and b.season_rule != '')))
</when>
<when test='searchKey=="2"'>
and EXISTS(select 1 from dj_weapp_intelligent_remind_rule b WHERE b.id = a.remind_rule_id and b.deleted_flag='N'
and (b.time_rule is not null and b.time_rule != '' or (b.season_rule is not null and b.season_rule != '')))
</when>
<otherwise>
and a.remind_rule_id is null
</otherwise>
</choose>
</if>
<if test="onlineFlag != null">
and a.online_flag = #{onlineFlag, jdbcType=VARCHAR}
</if>
order by a.updated_date desc
</select>
<select id="getById" resultMap="DTOResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from dj_weapp_intelligent_remind_service
WHERE id = #{id,jdbcType=INTEGER} and deleted_flag='N'
</select>
<select id="getByMerchantId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from dj_weapp_intelligent_remind_service
WHERE merchant_id = #{merchantId,jdbcType=INTEGER} and deleted_flag='N' order by updated_date desc
</select>
<select id="getByCondition" resultMap="DTOResultMap">
select a.*
from dj_weapp_intelligent_remind_service a
WHERE a.deleted_flag='N' and a.online_flag = 'Y'
and a.merchant_id = #{record.merchantId,jdbcType=INTEGER}
<if test="record.searchKey != null">
<choose>
<when test='record.searchKey=="1"'>
and EXISTS(select 1 from dj_weapp_intelligent_remind_rule b WHERE b.id = a.remind_rule_id and b.deleted_flag='N'
and (b.mile_rule is not null and b.mile_rule != '' or (b.season_rule is not null and b.season_rule != '')))
</when>
<when test='record.searchKey=="2"'>
and EXISTS(select 1 from dj_weapp_intelligent_remind_rule b WHERE b.id = a.remind_rule_id and b.deleted_flag='N'
and (b.time_rule is not null and b.time_rule != '' or (b.season_rule is not null and b.season_rule != '')))
</when>
<when test='record.searchKey=="3"'>
and a.remind_rule_id is null
</when>
</choose>
</if>
order by a.updated_date desc
</select>
<select id="getByRemindRuleId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from dj_weapp_intelligent_remind_service
WHERE remind_rule_id = #{remindRuleId,jdbcType=INTEGER} and deleted_flag='N' order by updated_date desc
</select>
<update id="update" parameterType="cn.com.glsx.dj.weapp.model.IntelligentRemindService" >
update dj_weapp_intelligent_remind_service
<set >
<if test="record.merchantId != null" >
merchant_id = #{record.merchantId,jdbcType=INTEGER},
</if>
<if test="record.title != null" >
title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.videoUrl != null" >
video_url = #{record.videoUrl,jdbcType=VARCHAR},
</if>
<if test="record.onlineFlag != null" >
online_flag = #{record.onlineFlag,jdbcType=CHAR},
</if>
<if test="record.coverUrl != null" >
cover_url = #{record.coverUrl,jdbcType=VARCHAR},
</if>
share_recommend = #{record.shareRecommend,jdbcType=VARCHAR},
remind_rule_id = #{record.remindRuleId,jdbcType=INTEGER},
activity_id = #{record.activityId,jdbcType=INTEGER},
<if test="record.createdBy != null" >
created_by = #{record.createdBy,jdbcType=VARCHAR},
</if>
<if test="record.createdDate != null" >
created_date = #{record.createdDate,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedBy != null" >
updated_by = #{record.updatedBy,jdbcType=VARCHAR},
</if>
<if test="record.updatedDate != null" >
updated_date = #{record.updatedDate,jdbcType=TIMESTAMP},
</if>
<if test="record.deletedFlag != null" >
deleted_flag = #{record.deletedFlag,jdbcType=CHAR},
</if>
</set>
where id = #{record.id}
</update>
<update id="deleteById" parameterType="java.lang.Integer">
update dj_weapp_intelligent_remind_service
set deleted_flag = 'D'
where id = #{id}
</update>
<select id="getRemindServiceList" parameterType="cn.com.glsx.dj.weapp.dto.IntelligentRemindServiceListConditionDTO" resultMap="BaseResultMap">
select a.*
from
dj_weapp_intelligent_remind_service a
left join
dj_weapp_intelligent_remind_service_classify_tag_ref b
on a.id = b.service_id
WHERE a.deleted_flag='N'
and a.online_flag = 'Y'
and b.deleted_flag='N'
and a.merchant_id = #{condition.merchantId}
<if test="condition.classifyTagId != null">
and b.classify_tag_id = #{condition.classifyTagId}
</if>
</select>
</mapper>