提交 | 用户 | 时间
|
fd2207
|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
懒 |
2 |
<!DOCTYPE mapper |
|
3 |
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
4 |
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
5 |
<mapper namespace="com.jcdm.system.mapper.SysPostMapper"> |
|
6 |
|
|
7 |
<resultMap type="SysPost" id="SysPostResult"> |
|
8 |
<id property="postId" column="post_id" /> |
|
9 |
<result property="postCode" column="post_code" /> |
|
10 |
<result property="postName" column="post_name" /> |
|
11 |
<result property="postSort" column="post_sort" /> |
|
12 |
<result property="status" column="status" /> |
|
13 |
<result property="createBy" column="create_by" /> |
|
14 |
<result property="createTime" column="create_time" /> |
|
15 |
<result property="updateBy" column="update_by" /> |
|
16 |
<result property="updateTime" column="update_time" /> |
|
17 |
<result property="remark" column="remark" /> |
|
18 |
</resultMap> |
|
19 |
|
|
20 |
<sql id="selectPostVo"> |
|
21 |
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark |
|
22 |
from sys_post |
|
23 |
</sql> |
|
24 |
|
|
25 |
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult"> |
|
26 |
<include refid="selectPostVo"/> |
|
27 |
<where> |
|
28 |
<if test="postCode != null and postCode != ''"> |
|
29 |
AND post_code like concat('%', #{postCode}, '%') |
|
30 |
</if> |
|
31 |
<if test="status != null and status != ''"> |
|
32 |
AND status = #{status} |
|
33 |
</if> |
|
34 |
<if test="postName != null and postName != ''"> |
|
35 |
AND post_name like concat('%', #{postName}, '%') |
|
36 |
</if> |
|
37 |
</where> |
|
38 |
</select> |
|
39 |
|
|
40 |
<select id="selectPostAll" resultMap="SysPostResult"> |
|
41 |
<include refid="selectPostVo"/> |
|
42 |
</select> |
|
43 |
|
|
44 |
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult"> |
|
45 |
<include refid="selectPostVo"/> |
|
46 |
where post_id = #{postId} |
|
47 |
</select> |
|
48 |
|
|
49 |
<select id="selectPostListByUserId" parameterType="Long" resultType="Long"> |
|
50 |
select p.post_id |
|
51 |
from sys_post p |
|
52 |
left join sys_user_post up on up.post_id = p.post_id |
|
53 |
left join sys_user u on u.user_id = up.user_id |
|
54 |
where u.user_id = #{userId} |
|
55 |
</select> |
|
56 |
|
|
57 |
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult"> |
|
58 |
select p.post_id, p.post_name, p.post_code |
|
59 |
from sys_post p |
|
60 |
left join sys_user_post up on up.post_id = p.post_id |
|
61 |
left join sys_user u on u.user_id = up.user_id |
|
62 |
where u.user_name = #{userName} |
|
63 |
</select> |
|
64 |
|
|
65 |
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult"> |
|
66 |
select top(1) post_id, post_code, post_name, post_sort, status, create_by, create_time, remark |
|
67 |
from sys_post |
|
68 |
where post_name=#{postName} |
|
69 |
</select> |
|
70 |
|
|
71 |
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult"> |
|
72 |
select top(1) post_id, post_code, post_name, post_sort, status, create_by, create_time, remark |
|
73 |
from sys_post |
|
74 |
where post_code=#{postCode} |
|
75 |
</select> |
|
76 |
|
|
77 |
<update id="updatePost" parameterType="SysPost"> |
|
78 |
update sys_post |
|
79 |
<set> |
|
80 |
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if> |
|
81 |
<if test="postName != null and postName != ''">post_name = #{postName},</if> |
|
82 |
<if test="postSort != null">post_sort = #{postSort},</if> |
|
83 |
<if test="status != null and status != ''">status = #{status},</if> |
|
84 |
<if test="remark != null">remark = #{remark},</if> |
|
85 |
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
|
86 |
update_time = getdate() |
|
87 |
</set> |
|
88 |
where post_id = #{postId} |
|
89 |
</update> |
|
90 |
|
|
91 |
<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId"> |
|
92 |
insert into sys_post( |
|
93 |
<if test="postId != null and postId != 0">post_id,</if> |
|
94 |
<if test="postCode != null and postCode != ''">post_code,</if> |
|
95 |
<if test="postName != null and postName != ''">post_name,</if> |
|
96 |
<if test="postSort != null">post_sort,</if> |
|
97 |
<if test="status != null and status != ''">status,</if> |
|
98 |
<if test="remark != null and remark != ''">remark,</if> |
|
99 |
<if test="createBy != null and createBy != ''">create_by,</if> |
|
100 |
create_time |
|
101 |
)values( |
|
102 |
<if test="postId != null and postId != 0">#{postId},</if> |
|
103 |
<if test="postCode != null and postCode != ''">#{postCode},</if> |
|
104 |
<if test="postName != null and postName != ''">#{postName},</if> |
|
105 |
<if test="postSort != null">#{postSort},</if> |
|
106 |
<if test="status != null and status != ''">#{status},</if> |
|
107 |
<if test="remark != null and remark != ''">#{remark},</if> |
|
108 |
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|
109 |
getdate() |
|
110 |
) |
|
111 |
</insert> |
|
112 |
|
|
113 |
<delete id="deletePostById" parameterType="Long"> |
|
114 |
delete from sys_post where post_id = #{postId} |
|
115 |
</delete> |
|
116 |
|
|
117 |
<delete id="deletePostByIds" parameterType="Long"> |
|
118 |
delete from sys_post where post_id in |
|
119 |
<foreach collection="array" item="postId" open="(" separator="," close=")"> |
|
120 |
#{postId} |
|
121 |
</foreach> |
|
122 |
</delete> |
|
123 |
|
|
124 |
</mapper> |