-
admin
7 天以前 a95ad9fef48fd7ebaae3e5c9ba67d51dd21444ff
提交 | 用户 | 时间
a6316e 1 <?xml version="1.0" encoding="UTF-8" ?>
A 2 <!DOCTYPE mapper
110d30 3         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
A 4         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
a6316e 5 <mapper namespace="com.billion.system.mapper.SysPostMapper">
A 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>
110d30 19
a6316e 20     <sql id="selectPostVo">
110d30 21         select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
a6316e 22         from sys_post
110d30 23     </sql>
A 24
a6316e 25     <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
110d30 26         <include refid="selectPostVo"/>
a6316e 27         <where>
A 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>
110d30 39
a6316e 40     <select id="selectPostAll" resultMap="SysPostResult">
A 41         <include refid="selectPostVo"/>
42     </select>
110d30 43
a6316e 44     <select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
A 45         <include refid="selectPostVo"/>
46         where post_id = #{postId}
47     </select>
110d30 48
a6316e 49     <select id="selectPostListByUserId" parameterType="Long" resultType="Long">
A 50         select p.post_id
110d30 51         from sys_post p
A 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}
a6316e 55     </select>
110d30 56
a6316e 57     <select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
A 58         select p.post_id, p.post_name, p.post_code
59         from sys_post p
110d30 60                  left join sys_user_post up on up.post_id = p.post_id
A 61                  left join sys_user u on u.user_id = up.user_id
a6316e 62         where u.user_name = #{userName}
A 63     </select>
110d30 64
a6316e 65     <select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
110d30 66         select top(1) post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
A 67         from sys_post
68         where post_name=#{postName}
a6316e 69     </select>
110d30 70
a6316e 71     <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
110d30 72         select top(1) post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
A 73         from sys_post
74         where post_code=#{postCode}
a6316e 75     </select>
110d30 76
a6316e 77     <update id="updatePost" parameterType="SysPost">
110d30 78         update sys_post
A 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}
a6316e 89     </update>
110d30 90
A 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         )
a6316e 111     </insert>
110d30 112
a6316e 113     <delete id="deletePostById" parameterType="Long">
A 114         delete from sys_post where post_id = #{postId}
115     </delete>
110d30 116
a6316e 117     <delete id="deletePostByIds" parameterType="Long">
110d30 118         delete from sys_post where post_id in
A 119         <foreach collection="array" item="postId" open="(" separator="," close=")">
120             #{postId}
121         </foreach>
122     </delete>
a6316e 123
A 124 </mapper>