CommonMapper.xml
5.75 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
<?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.base.dao.CommonDao">
<cache/>
<select id="query" parameterType="java.util.Map" resultType="java.util.HashMap">
${sql}
</select>
<select id="queryByPage" parameterType="java.util.Map" resultType="java.util.HashMap">
${sql}
</select>
<select id="queryByQueryFilter" parameterType="java.util.Map" resultType="java.util.HashMap">
${sql} ${ew.customSqlSegment}
</select>
<select id="queryByCustomSql" parameterType="java.util.Map" resultType="java.util.HashMap">
${sql}
<if test="@com.hotent.base.ognl.Ognl@containsWhere(sql) and @com.hotent.base.ognl.Ognl@isNotEmpty(@com.hotent.base.ognl.Ognl@withOutWhere(@com.hotent.base.ognl.Ognl@insertBeforeOrderBy(ew.customSqlSegment,ew.paramNameValuePairs.filterSql)))">
<!--mybatisPlus的sql带where(表明有查询条件)|| 追加过滤sql不为空。用and拼接.-->
<if test="@com.hotent.base.ognl.Ognl@containsWhere(ew.customSqlSegment) or @com.hotent.base.ognl.Ognl@isNotEmpty(ew.paramNameValuePairs.filterSql)">
and
</if>
<!--本身的sql里面带有where,则去掉拼接sql里面的where-->
${@com.hotent.base.ognl.Ognl@withOutWhere( @com.hotent.base.ognl.Ognl@insertBeforeOrderBy(ew.customSqlSegment,ew.paramNameValuePairs.filterSql))}
</if>
<if test="!@com.hotent.base.ognl.Ognl@containsWhere(sql)">
${@com.hotent.base.ognl.Ognl@insertBeforeOrderBy(ew.customSqlSegment,ew.paramNameValuePairs.filterSql)}
</if>
</select>
<insert id ="batchInsert" parameterType="java.util.Map">
insert into ${tableName} (${insertFields}) values
<foreach collection="valueList" item="item" index="index" separator="," >
(
<foreach collection="item.keys" item="key" index="j" open="" close="" separator="," >
${@com.hotent.base.ognl.Ognl@encodeValue(valueList,index,key)}
</foreach>
)
</foreach>
</insert >
<insert id="batchInsert4Oracle" parameterType="java.util.Map" statementType="CALLABLE">
<foreach collection="valueList" item="item" index="index" separator=";" open="begin" close=";end;" >
insert into ${tableName} (${insertFields}) values
(
<foreach collection="item.keys" item="key" index="j" open="" close="" separator="," >
${@com.hotent.base.ognl.Ognl@encodeValue(valueList,index,key)}
</foreach>
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List" >
<foreach collection="valueList" item="mapParam" index="index" open="" close="" separator=";">
update ${tableName}
set
<foreach collection="mapParam.keys" item="key" open="" close="" separator=",">
${key} = ${@com.hotent.base.ognl.Ognl@encodeValue(valueList,index,key)}
</foreach>
where ${pkField} = #{valueList[${index}].${pkField}}
<if test="!ignoreDataVersion and @com.hotent.base.ognl.Ognl@containsKey(valueList,index,'form_data_rev_')">
and (form_data_rev_ = ${@com.hotent.base.ognl.Ognl@getOldFormDataRev(valueList,index,'form_data_rev_')} or form_data_rev_ is null)
</if>
<if test="!ignoreDataVersion and @com.hotent.base.ognl.Ognl@containsKey(valueList,index,'f_form_data_rev_')">
and (f_form_data_rev_ = ${@com.hotent.base.ognl.Ognl@getOldFormDataRev(valueList,index,'f_form_data_rev_')} or f_form_data_rev_ is null)
</if>
</foreach>
</update>
<delete id="batchDelete" parameterType="java.util.List" >
delete from ${tableName} where ${pkField} in
<foreach collection="pkValues" item="pkValue" index="index" open="(" close=")" separator=",">
#{pkValue}
</foreach>
</delete>
<update id="updateByCustom">
update ${tableName}
set
<foreach collection="mapParam.keys" item="key" open="" close=""
separator=",">
${key} = #{mapParam[${key}]}
</foreach>
where ${pkField}=#{mapParam[${pkField}]}
</update>
<select id="documentationQueryByField" resultType="java.util.HashMap">
SELECT * FROM ${tableName} WHERE ${pkField} IN
<foreach collection="pkValues" item="pkValue" open="(" close=")" separator=",">
#{pkValue}
</foreach>
</select>
<select id="documentationQuery" resultType="java.util.HashMap">
${sql}
</select>
<insert id ="documentationBatchInsert" parameterType="java.util.Map">
insert into ${tableName} (${insertFields}) values
<foreach collection="valueList" item="item" index="index" separator="," >
(
<foreach collection="item.keys" item="key" index="j" open="" close="" separator="," >
${@com.hotent.base.ognl.Ognl@documentationEncodeValue(valueList,index,j,insertFields)}
</foreach>
)
</foreach>
</insert >
<insert id ="documentationInsert" parameterType="java.util.Map">
insert into ${tableName} (${insertFields}) values
(
<foreach collection="mapValue.keys" item="key" index="index" open="" close="" separator="," >
${@com.hotent.base.ognl.Ognl@documentationEncodeValue(mapValue,index,insertFields)}
</foreach>
)
</insert >
<insert id ="documentationBatchInsert" databaseId="oracle" parameterType="java.util.Map">
insert into ${tableName} (${insertFields}) values
<foreach collection="valueList" item="item" index="index" separator="," >
(
<foreach collection="item.keys" item="key" index="j" open="" close="" separator="," >
${@com.hotent.base.ognl.Ognl@documentationOracleEncodeValue(valueList,index,j,insertFields)}
</foreach>
)
</foreach>
</insert >
<delete id="documentationBatchDelete" parameterType="java.util.List" >
delete from ${tableName} where ${pkField} in
<foreach collection="pkValues" item="pkValue" index="index" open="(" close=")" separator=",">
#{pkValue}
</foreach>
</delete>
</mapper>