123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?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.liang.dao.SysUserPostDao">
- <resultMap type="com.liang.entity.SysUserPost" id="SysUserPostMap">
- <result property="userId" column="user_id" jdbcType="INTEGER"/>
- <result property="postId" column="post_id" jdbcType="INTEGER"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
- </resultMap>
- <!--查询单个-->
- <select id="queryById" resultMap="SysUserPostMap">
- select
- user_id, post_id, create_time, update_time
- from sys_user_post
- where user_id = #{userId}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="SysUserPostMap">
- select
- user_id, post_id, create_time, update_time
- from sys_user_post
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="postId != null">
- and post_id = #{postId}
- </if>
- <if test="createTime != null">
- and create_time = #{createTime}
- </if>
- <if test="updateTime != null">
- and update_time = #{updateTime}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from sys_user_post
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="postId != null">
- and post_id = #{postId}
- </if>
- <if test="createTime != null">
- and create_time = #{createTime}
- </if>
- <if test="updateTime != null">
- and update_time = #{updateTime}
- </if>
- </where>
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="userId" useGeneratedKeys="true">
- insert into sys_user_post(create_time, update_time)
- values (#{createTime}, #{updateTime})
- </insert>
- <insert id="insertBatch" keyProperty="userId" useGeneratedKeys="true">
- insert into sys_user_post(create_time, update_time)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.createTime}, #{entity.updateTime})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="userId" useGeneratedKeys="true">
- insert into sys_user_post(create_time, update_time)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.createTime}, #{entity.updateTime})
- </foreach>
- on duplicate key update
- create_time = values(create_time),
- update_time = values(update_time)
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update sys_user_post
- <set>
- <if test="createTime != null">
- create_time = #{createTime},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime},
- </if>
- </set>
- where user_id = #{userId}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete from sys_user_post where user_id = #{userId}
- update sys_user_post
- set del_flag = 1,
- update_user = #{updateUser},
- update_time = GETDATE()
- where user_id = #{userId}
- </delete>
- <!--获取全部岗位信息XmSelect列表-->
- <select id="listAllPost" resultType="com.liang.vo.PostXmSelect" parameterType="string">
- SELECT
- a.post_id AS value,
- a.post_name AS name,
- 0 AS selected
- FROM sys_post_info a
- WHERE a.status = '0'
- </select>
- <!--获取用户岗位信息XmSelect列表-->
- <select id="listPostByUserId" resultType="com.liang.vo.PostXmSelect" parameterType="java.lang.Integer">
- SELECT
- a.post_id AS value,
- a.post_name AS name,
- ( CASE WHEN b.user_id IS NULL THEN 0 ELSE 1 END ) AS selected
- FROM
- sys_post_info a
- LEFT JOIN sys_user_post b ON ( a.post_id = b.post_id AND b.user_id = #{userId} )
- WHERE a.status = '0'
- </select>
- <!--删除用户岗位-->
- <delete id="deleteUserPostByUserId" parameterType="java.lang.Integer">
- delete from sys_user_post where user_id = #{userId}
- </delete>
- <!--批量保存用户岗位-->
- <insert id="batchSaveUserPost" parameterType="java.util.List">
- insert into sys_user_post(user_id, post_id, create_time)
- <foreach collection="list" item="item" index="index" separator="UNION ALL">
- select
- #{item.userId, jdbcType=INTEGER},
- #{item.postId, jdbcType=INTEGER},
- GETDATE()
- </foreach>
- </insert>
- <!--岗位用户列表-->
- <select id="getPostUserList" resultMap="SysUserPostMap">
- select p.post_id, u.user_id, u.account, u.name, u.status
- from sys_user_post p
- left join sys_user_info u on u.user_id = p.user_id
- where u.status = '0' and u.del_flag = '0'
- <if test="postId!= null and postId!= ''">
- and p.post_id = #{postId}
- </if>
- <if test="userName!= null and userName!= ''">
- and u.name like '%'+#{userName}+'%'
- </if>
- </select>
- <!--用户岗位列表-->
- <select id="getUserPostList" resultMap="SysUserPostMap">
- select u.user_id, p.post_id, p.post_name
- from sys_user_post u
- left join sys_post_info p on p.post_id = u.post_id
- where p.status = '0'
- <if test="userId!= null and userId!= ''">
- and u.user_id = #{userId}
- </if>
- <if test="postName!= null and postName!= ''">
- and p.post_name like '%'+#{postName}+'%'
- </if>
- </select>
- </mapper>
|