中国算力平台算力登记系统2.0
yanzhaofeige
2024-09-30 3c4fee1db116c11d4f04727cfe076d7c94daeaf2
commit | author | age
43dc29 1 <?xml version="1.0" encoding="UTF-8" ?>
Y 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.odcc.cpzidc.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         <include refid="selectPostVo"/>
67          where post_name=#{postName} limit 1
68     </select>
69     
70     <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
71         <include refid="selectPostVo"/>
72          where post_code=#{postCode} limit 1
73     </select>
74     
75     <update id="updatePost" parameterType="SysPost">
76          update sys_post
77          <set>
78              <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
79              <if test="postName != null and postName != ''">post_name = #{postName},</if>
80              <if test="postSort != null">post_sort = #{postSort},</if>
81              <if test="status != null and status != ''">status = #{status},</if>
82              <if test="remark != null">remark = #{remark},</if>
83              <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
84              update_time = sysdate()
85          </set>
86          where post_id = #{postId}
87     </update>
88      
89      <insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
90          insert into sys_post(
91              <if test="postId != null and postId != 0">post_id,</if>
92              <if test="postCode != null and postCode != ''">post_code,</if>
93              <if test="postName != null and postName != ''">post_name,</if>
94              <if test="postSort != null">post_sort,</if>
95              <if test="status != null and status != ''">status,</if>
96              <if test="remark != null and remark != ''">remark,</if>
97              <if test="createBy != null and createBy != ''">create_by,</if>
98              create_time
99          )values(
100              <if test="postId != null and postId != 0">#{postId},</if>
101              <if test="postCode != null and postCode != ''">#{postCode},</if>
102              <if test="postName != null and postName != ''">#{postName},</if>
103              <if test="postSort != null">#{postSort},</if>
104              <if test="status != null and status != ''">#{status},</if>
105              <if test="remark != null and remark != ''">#{remark},</if>
106              <if test="createBy != null and createBy != ''">#{createBy},</if>
107              sysdate()
108          )
109     </insert>
110     
111     <delete id="deletePostById" parameterType="Long">
112         delete from sys_post where post_id = #{postId}
113     </delete>
114     
115     <delete id="deletePostByIds" parameterType="Long">
116          delete from sys_post where post_id in
117          <foreach collection="array" item="postId" open="(" separator="," close=")">
118              #{postId}
119         </foreach> 
120      </delete>
121
122 </mapper>