Blame view

backend/i18n/src/main/resources/mapper/I18nMessageMapper.xml 10.1 KB
8d73e917   陈威   初始化提交
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?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.hotent.i18n.persistence.dao.I18nMessageDao">
    <resultMap id="I18nMessage" type="com.hotent.i18n.persistence.model.I18nMessage">
        <id property="id" column="ID_" jdbcType="VARCHAR"/>
        <result property="type" column="TYPE_" jdbcType="VARCHAR"/>
        <result property="key" column="KEY_" jdbcType="VARCHAR"/>
        <result property="value" column="VALUE_" jdbcType="LONGVARCHAR"/>
        <result property="types" column="types" jdbcType="VARCHAR"/>
        <result property="vals" column="vals" jdbcType="VARCHAR"/>
        <result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
        <result property="createOrgId" column="CREATE_ORG_ID_" jdbcType="VARCHAR"/>
        <result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP"/>
        <result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
        <result property="updateTime" column="UPDATE_TIME_" jdbcType="TIMESTAMP"/>
    </resultMap>

    <select id="getList" parameterType="java.util.Map" resultType="java.util.Map">
        select * from (
            select * from
                (select t.key_ "key_"
                <if test="params.types!=null">
                    ,
                </if>
                <foreach collection="params.types" item="type" separator=",">
                    max(case when t.TYPE_ = '${type}' then t.VALUE_ else null end) as "${type}"
                </foreach>
                from portal_i18n_message t
                group BY t.KEY_ order by t.create_time_ desc) a
        WHERE
        1 = 1
        <if test="params.key!=null">
            and ( a.key_ like concat('%',#{params.key},'%')
                <foreach collection="params.types" item="type" >
                    or a.`${type}` like concat('%', #{params.key}, '%')
                </foreach>
            )
        </if>
        ) as m
        where 1=1
        <!--  <if test="params.relation==null">
             <if test="params.key!=null">
                 and lower(m.key_) like concat("%",#{params.key},"%")
                 OR(
                 <foreach collection="params.types" item="type" separator="or">
                     lower(m.`${type}`) like concat("%",#{params.val},"%")
                 </foreach>
                 )
             </if>
         </if> -->

    </select>
    <select id="getList" databaseId="pg" parameterType="java.util.Map" resultType="java.util.Map">
        select * from (
        select t.key_ "key_"
        <if test="params.types!=null">
            ,
        </if>
        <foreach collection="params.types" item="type" separator=",">
            max(case when t.TYPE_ = '${type}' then t.VALUE_ else null end) as "${type}"
        </foreach>
        from portal_i18n_message t
        WHERE
        1 = 1
        <if test="params.key!=null">
            and ( t.key_ like concat('%',#{params.key},'%') or  t.VALUE_ like concat('%',#{params.val},'%'))
        </if>
        group BY t.KEY_
        ) as m
        where 1=1

    </select>

    <select id="getList" databaseId="oracle" parameterType="java.util.Map" resultType="java.util.Map">
        select m.* from (
        select t.key_ "key_"
        <if test="params.types!=null">
            ,
        </if>
        <foreach collection="params.types" item="type" separator=",">
            max(decode(t.TYPE_,'${type}',to_char(t.VALUE_),null)) "${type}"
        </foreach>
        from portal_i18n_message t where 1=1
        group BY t.KEY_ order by t.KEY_
        ) m where 1=1
        <if test="params.relation==null">
            <if test="params.key!=null">
                and lower(m."key_") like concat(concat('%',#{params.key}),'%')
                OR(
                <foreach collection="params.types" item="type" separator="or">
                    lower(m."${type}") like concat(concat('%',#{params.val}),'%')
                </foreach>
                )
            </if>
        </if>
        <if test="params.relation!=null">
            <if test="params.key!=null">
                and lower(m.key_) like concat(concat('%',#{params.key}),'%')
            </if>
            <if test="params.val!=null">
                AND(
                <foreach collection="params.types" item="type" separator="or">
                    lower(m."${type}") like concat(concat('%',#{params.val}),'%')
                </foreach>
                )
            </if>
        </if>
    </select>

    <select id="getByMesKey_mysql" parameterType="java.util.Map" resultType="java.util.Map">
        select t.key_
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(if(t.TYPE_='${type}',t.VALUE_,null)) '${type}'
        </foreach>
        from portal_i18n_message t
        where t.key_ = #{key}
        group BY t.KEY_
    </select>

    <select id="getByMesKey_h2" parameterType="java.util.Map" resultType="java.util.Map">
        select t.key_
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(case when t.TYPE_='${type}' then concat_ws('',t.VALUE_,'') else null end) '${type}'
        </foreach>
        from portal_i18n_message t
        where t.key_ = #{key}
        group BY t.KEY_
    </select>

    <select id="getByMesKey_oracle" parameterType="java.util.Map" resultType="java.util.Map">
        select t.key_ "key_"
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(decode(t.TYPE_,'${type}',to_char(t.VALUE_),null)) "${type}"
        </foreach>
        from portal_i18n_message t
        where t.key_ = #{key}
        group BY t.KEY_
    </select>

    <select id="getByMesKey_pgsql" parameterType="java.util.Map" resultType="java.util.Map">
        select t.key_ "key_"
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(case when t.TYPE_='${type}' then concat_ws('',t.VALUE_,'') else null end) "${type}"
        </foreach>
        from portal_i18n_message t
        where t.key_ = #{key}
        group BY t.KEY_
    </select>

    <delete id="delByKey" parameterType="java.lang.String">
		DELETE FROM portal_i18n_message WHERE key_ = #{key}
	</delete>

    <delete id="delByKeyAndType" parameterType="java.util.Map">
		delete from portal_i18n_message where key_=#{key} and type_=#{type}
	</delete>

    <select id="getByKeyAndType" parameterType="java.util.Map" resultMap="I18nMessage">
		select * from portal_i18n_message WHERE KEY_ = #{key} and TYPE_ = #{type}
	</select>

    <select id="getI18nInfo" resultType="java.util.Map">
		SELECT
            m.ID_ ID_,
            m.KEY_ KEY_,
            m.VALUE_ VALUE_,
            mt.TYPE_ TYPE_,
            mt.DESC_ DESC_
        FROM
            portal_i18n_message m
            INNER JOIN portal_i18n_message_type mt ON m.TYPE_ = mt.TYPE_
        <where>
            <if test="keys!=null">
                m.key_ in (
                <foreach collection="keys" item="item" separator=",">
                    #{item}
                </foreach>
                )
            </if>
        </where>
	</select>

    <select id="getI18nInfo" databaseId="oracle" resultType="java.util.Map" >
		SELECT
            m.ID_ ID_,
            m.KEY_ KEY_,
            DBMS_LOB.SUBSTR( m.VALUE_, 4000, 1 ) AS VALUE_,
            mt.TYPE_ TYPE_,
            mt.DESC_ DESC_
        FROM
            portal_i18n_message m
            INNER JOIN portal_i18n_message_type mt ON m.TYPE_ = mt.TYPE_
        <where>
            <if test="keys!=null">
                m.key_ in
                <foreach collection="keys" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
	</select>

    <select id="searchList" databaseId="oracle" parameterType="java.util.Map" resultType="java.util.Map">
        select m.* from (
        select t.key_ key_
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(decode(t.TYPE_,'${type}',to_char(t.VALUE_),null)) "${type}"
        </foreach>
        from portal_i18n_message t group BY t.KEY_
        ) m
        where 1=1
        <if test="val!=null">
            and (
            <foreach collection="types" item="type" separator="or">
                lower(m."${type}") like '${val}'
            </foreach>
            )
        </if>
    </select>

    <select id="searchList" databaseId="h2" parameterType="java.util.Map" resultType="java.util.Map">
        select * from (
        select t.key_ "key_"
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(case when t.TYPE_='${type}' then concat_ws('',t.VALUE_,'') else null end) '${type}'
        </foreach>
        from portal_i18n_message t group BY t.KEY_
        ) as m
        where 1=1
        <if test="val!=null">
            and (
            <foreach collection="types" item="type" separator="or">
                lower(m.`${type}`) like '${val}'
            </foreach>
            )
        </if>
    </select>

    <select id="searchList" parameterType="java.util.Map" resultType="java.util.Map">
        select * from (
        select t.key_ "key_"
        <if test="types!=null">
            ,
        </if>
        <foreach collection="types" item="type" separator=",">
            max(if(t.TYPE_='${type}',t.VALUE_,null)) '${type}'
        </foreach>
        from portal_i18n_message t group BY t.KEY_
        ) as m
        where 1=1
        <if test="val!=null">
            and (
            <foreach collection="types" item="type" separator="or">
                lower(m.`${type}`) like '${val}'
            </foreach>
            )
        </if>
    </select>

    <select id="hasSourceKey" resultType="java.lang.Integer">
        SELECT 1 FROM portal_i18n_message
        <where>
            <if test="key != null and key != ''">
                key_ = #{key}
            </if>
            LIMIT 1
        </where>
    </select>

</mapper>