123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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.juxiao.xchat.module.system.mapper.PostMapper">
- <resultMap type="com.juxiao.xchat.module.system.domain.Post" id="PostResult">
- <id property="postId" column="post_id" />
- <result property="postCode" column="post_code" />
- <result property="postName" column="post_name" />
- <result property="postSort" column="post_sort" />
- <result property="status" column="status" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- </resultMap>
-
- <sql id="selectPostVo">
- select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
- from sys_post
- </sql>
-
- <select id="selectPostList" parameterType="com.juxiao.xchat.module.system.domain.Post" resultMap="PostResult">
- <include refid="selectPostVo"/>
- <where>
- <if test="postCode != null and postCode != ''">
- AND post_code like concat('%', #{postCode}, '%')
- </if>
- <if test="status != null and status != ''">
- AND status = #{status}
- </if>
- <if test="postName != null and postName != ''">
- AND post_name like concat('%', #{postName}, '%')
- </if>
- </where>
- </select>
-
- <select id="selectPostAll" resultMap="PostResult">
- <include refid="selectPostVo"/>
- </select>
-
- <select id="selectPostsByUserId" parameterType="java.lang.Long" resultMap="PostResult">
- SELECT p.post_id, p.post_name, p.post_code
- FROM sys_user u
- LEFT JOIN sys_user_post up ON u.user_id = up.user_id
- LEFT JOIN sys_post p ON up.post_id = p.post_id
- WHERE up.user_id = #{userId}
- </select>
-
- <select id="selectPostById" parameterType="java.lang.Long" resultMap="PostResult">
- <include refid="selectPostVo"/>
- where post_id = #{postId}
- </select>
-
- <select id="checkPostNameUnique" parameterType="java.lang.String" resultMap="PostResult">
- <include refid="selectPostVo"/>
- where post_name=#{postName}
- </select>
-
- <select id="checkPostCodeUnique" parameterType="java.lang.String" resultMap="PostResult">
- <include refid="selectPostVo"/>
- where post_code=#{postCode}
- </select>
-
- <delete id="deletePostByIds" parameterType="java.lang.Long">
- delete from sys_post where post_id in
- <foreach collection="array" item="postId" open="(" separator="," close=")">
- #{postId}
- </foreach>
- </delete>
-
- <update id="updatePost" parameterType="com.juxiao.xchat.module.system.domain.Post">
- update sys_post
- <set>
- <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
- <if test="postName != null and postName != ''">post_name = #{postName},</if>
- <if test="postSort != null and postSort != ''">post_sort = #{postSort},</if>
- <if test="status != null and status != ''">status = #{status},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate()
- </set>
- where post_id = #{postId}
- </update>
-
- <insert id="insertPost" parameterType="com.juxiao.xchat.module.system.domain.Post" useGeneratedKeys="true" keyProperty="postId">
- insert into sys_post(
- <if test="postId != null and postId != 0">post_id,</if>
- <if test="postCode != null and postCode != ''">post_code,</if>
- <if test="postName != null and postName != ''">post_name,</if>
- <if test="postSort != null and postSort != ''">post_sort,</if>
- <if test="status != null and status != ''">status,</if>
- <if test="remark != null and remark != ''">remark,</if>
- <if test="createBy != null and createBy != ''">create_by,</if>
- create_time
- )values(
- <if test="postId != null and postId != 0">#{postId},</if>
- <if test="postCode != null and postCode != ''">#{postCode},</if>
- <if test="postName != null and postName != ''">#{postName},</if>
- <if test="postSort != null and postSort != ''">#{postSort},</if>
- <if test="status != null and status != ''">#{status},</if>
- <if test="remark != null and remark != ''">#{remark},</if>
- <if test="createBy != null and createBy != ''">#{createBy},</if>
- sysdate()
- )
- </insert>
- </mapper>
|