PostMapper.xml
5.03 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
<?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.portal.base.dao.PostMapper">
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Post">
<id column="poId" property="id" />
<result column="deId" property="deid" />
<result column="poCode" property="code" />
<result column="poName" property="name" />
<result column="poSort" property="sort" />
<result column="ptRemark1" property="remark1" />
<result column="ptRemark2" property="remark2" />
<result column="ptRemark3" property="remark3" />
<result column="ptUpTime" property="uptime" />
<result column="ptUpdater" property="updater" />
</resultMap>
<select id="selectByDeId" resultMap="BaseResultMap"
parameterType="java.lang.String">
SELECT poId,poName
FROM
mtPost
where deId in
<foreach item="item" index="index" collection="array" open="("
separator="," close=")">
#{item}
</foreach>
order by poSort ASC
</select>
<sql id="Base_Column_List">
poId, deId, poCode, poName, poSort, ptRemark1, ptRemark2,
ptRemark3,
ptUpTime, ptUpdater
</sql>
<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from mtPost
where poId = #{id,jdbcType=INTEGER}
</select>
<insert id="insertPost" parameterType="cn.runsa.portal.base.entity.Post">
<selectKey resultType="java.lang.Integer" keyProperty="id"
order="AFTER">
SELECT LAST_INSERT_ID()
</selectKey>
insert into mtPost (deId, poCode,
poName, poSort, ptRemark1,
ptRemark2,
ptRemark3, ptUpTime,
ptUpdater)
values (#{deid,jdbcType=INTEGER},
#{code,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER},
#{remark1,jdbcType=VARCHAR},
#{remark2,jdbcType=VARCHAR}, #{remark3,jdbcType=VARCHAR}, now(),
#{updater,jdbcType=INTEGER})
</insert>
<update id="updateById" parameterType="cn.runsa.portal.base.entity.Post">
update mtPost set poName = #{name,jdbcType=VARCHAR},ptUpTime = now()
<if test="code != null">
,poCode = #{code,jdbcType=VARCHAR}
</if>
<if test="sort != null">
,poSort = #{sort,jdbcType=INTEGER}
</if>
<if test="remark1 != null">
,ptRemark1 = #{remark1,jdbcType=VARCHAR}
</if>
<if test="remark2 != null">
,ptRemark2 = #{remark2,jdbcType=VARCHAR}
</if>
<if test="remark3 != null">
,ptRemark3 = #{remark3,jdbcType=VARCHAR}
</if>
<if test="updater != null">
,ptUpdater = #{updater,jdbcType=INTEGER}
</if>
where poId = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteById" parameterType="java.lang.Integer">
delete from mtPost where
poId = #{id,jdbcType=INTEGER}
</delete>
<select id="existsPoName" resultType="Boolean" parameterType="cn.runsa.portal.base.entity.Post">
SELECT COUNT(a.deId) FROM mtpost a,mtdept b WHERE a.deId = b.deId AND
b.coId = #{coId,jdbcType=INTEGER} AND a.poName =
#{name,jdbcType=VARCHAR}
<if test="id!=null and id!=''">
AND a.poId != #{id}
</if>
</select>
<select id="existsPoCode" resultType="Boolean" parameterType="cn.runsa.portal.base.entity.Post">
SELECT COUNT(a.deId) FROM mtpost a,mtdept b WHERE a.deId = b.deId AND
b.coId = #{coId,jdbcType=INTEGER} AND a.poCode =
#{code,jdbcType=VARCHAR}
<if test="id!=null and id!=''">
AND a.poId != #{id}
</if>
</select>
<select id="existsEmployee" resultType="Boolean"
parameterType="cn.runsa.portal.base.entity.Post">
SELECT COUNT(*) FROM mtEmployeePost WHERE poId = #{poId}
</select>
<select id="existsEmployeeBydeIds" resultType="Boolean"
parameterType="java.util.List">
SELECT COUNT(b.emId) FROM mtpost a,mtemployeepost b
WHERE a.poId =
b.poId AND a.deId IN
<foreach item="item" collection="list" separator="," open="("
close=")" index="">
#{item}
</foreach>
</select>
<select id="selectMaxSort" resultType="java.lang.Integer">
SELECT MAX(poSort) FROM
mtpost WHERE deId = #{deId,jdbcType=INTEGER}
</select>
<delete id="deletePostsBydeIds" parameterType="java.util.List">
delete from mtpost
where
deId IN
<foreach item="item" collection="list" separator="," open="("
close=")" index="">
#{item}
</foreach>
</delete>
<select id="selectPreviousPost" resultMap="BaseResultMap"
parameterType="cn.runsa.portal.base.entity.Post">
SELECT
<include refid="Base_Column_List" />
FROM mtpost WHERE poSort = ( SELECT MAX(poSort) FROM mtpost
WHERE
poSort <![CDATA[<]]>
#{sort,jdbcType=INTEGER} ) AND deId = #{deid,jdbcType=INTEGER} ORDER
BY poSort
</select>
<select id="selectNextPost" resultMap="BaseResultMap"
parameterType="cn.runsa.portal.base.entity.Post">
SELECT
<include refid="Base_Column_List" />
FROM mtpost WHERE poSort = ( SELECT MIN(poSort) FROM mtpost
WHERE
poSort <![CDATA[>]]>
#{sort,jdbcType=INTEGER} ) AND deId = #{deid,jdbcType=INTEGER} ORDER
BY poSort
</select>
<delete id="deleteEmployeePostBydeId">
delete from mtEmployeePost WHERE emId = #{emId,jdbcType=INTEGER}
AND poId IN (SELECT poId FROM mtpost WHERE #{deId,jdbcType=INTEGER})
</delete>
</mapper>