SysUserMapper.xml 4.3 KB
<?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.sibu.orderHelper.integral.web.dao.SysUserDao">
    
    <resultMap type="com.sibu.orderHelper.integral.sys.response.SysUserListResponse" id="listSysUser">
    	<id column="id" property="id"/>
        <result column="username" property="userName" />
        <result column="locked" property="locked" />
        <result column="nick_name" property="nickName" />
        <result column="type_id" property="roleId" />
        <result column="role_name" property="roleName" />
        <result column="create_dt" property="createDt" jdbcType="TIMESTAMP"/>
        <result column="supplier_id" property="supplierId" />
        <result column="supplierName" property="supplierName" />
    </resultMap>
    <resultMap type="com.sibu.orderHelper.integral.sys.response.SysUserResponse" id="sysUser">
    	<id column="id" property="id"/>
        <result column="username" property="userName" />
        <result column="phone" property="phone" />
        <result column="locked" property="locked" />
        <result column="type_id" property="roleId" />
        <result column="nick_name" property="nickName" />
        <result column="password" property="password" />
        <result column="hotel_id" property="hotelId" />
        <result column="create_dt" property="createDt" jdbcType="TIMESTAMP"/>
        <result column="supplier_id" property="supplierId" />
        <result column="platform_flag" property="platformFlag" />
    </resultMap>
    
    <sql id="Base_Column_List" >
    	id,username,locked,type_id,create_dt,nick_name,phone,password,hotel_id ,supplier_id,platform_flag
  	</sql>
    
    <!-- 添加用户 -->
    <insert id="addSysUser" parameterType="com.sibu.orderHelper.integral.sys.request.SysUserAddRequest">
    	insert into sys_user(username,password,locked,type_id,nick_name, phone,supplier_id,platform_flag)
    	value(#{userName},#{password},#{locked},#{roleId},#{nickName}, #{phone},#{supplierId},#{platformFlag})
    </insert>
    
    <!-- 编辑用户 -->
    <update id="editSysUser" parameterType="com.sibu.orderHelper.integral.sys.request.SysUserEditRequest">
    	update sys_user set username=#{userName},nick_name=#{nickName},type_id=#{roleId},phone=#{phone},
    	  supplier_id=#{supplierId},platform_flag=#{platformFlag}
    	where id = #{id} limit 1 
    </update>
    
    <!-- 获取用户详情 -->
    <select id="getSysUser" parameterType="java.lang.Integer" resultMap="sysUser">
    	select <include refid="Base_Column_List" /> from sys_user where id=${id} limit 1
    </select>
    
    <!-- 用户登录 -->
    <select id="loginByUser" parameterType="java.lang.String" resultMap="sysUser">
    	select <include refid="Base_Column_List" /> from sys_user where username=#{username} limit 1
    </select>
    
    <!-- 获取用户列表 -->
    <select id="listSysUser" parameterType="com.sibu.orderHelper.integral.request.CommonPageRequest" resultMap="listSysUser">
    	select su.id,su.username,su.locked,su.create_dt,su.type_id,su.nick_name,sr.name role_name,su.supplier_id,s.name as supplierName
    	from sys_user su
    	left join sys_role sr on su.type_id=sr.id
    	left join im_supplier s on su.supplier_id=s.id
        where 1=1
        <if test="supplierName !=null and supplierName!=''">
            and s.name = #{supplierName}
        </if>
        <if test="userName !=null and userName!=''">
            and su.username = #{userName}
        </if>
        <if test="nickName !=null and nickName!=''">
            and su.nick_name = #{nickName}
        </if>
        <if test="locked !=null and locked!=''">
            and su.locked = #{locked}
        </if>
    	limit ${pageNow},${pageSize}
    </select>
	<select id="countSysUser" resultType="int">
		select count(*) from sys_user
	</select>
	
	<!-- 设置用户禁止登录 -->
	<update id="lockedUser" parameterType="com.sibu.orderHelper.integral.sys.request.SysUserEditRequest">
		update sys_user set locked = #{locked}, update_dt=now() where id = #{id} limit 1
	</update>
	
	<!-- 重置用户密码 -->
	<update id="resetUserPassword" parameterType="com.sibu.orderHelper.integral.sys.request.SysUserResetPasswordRequest">
		update sys_user set password = #{password}, update_dt=now() where id = #{id} limit 1
	</update>
	
</mapper>