You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/resources/mybatis/mapper/auth/AuthAdminDao.xml

348 lines
12 KiB
XML

<?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.glxp.api.dao.auth.AuthAdminDao">
<select id="listAdminPage" parameterType="com.glxp.api.req.auth.FilterAuthUserRequest"
resultType="com.glxp.api.entity.auth.AuthAdmin">
SELECT auth_user.*, auth_dept.name deptName,aw.name invName
FROM auth_user
left join auth_dept_user adu on adu.userId = auth_user.id
left join auth_dept on adu.deptId = auth_dept.id
left join auth_warehouse aw on aw.code = auth_user.locInvCode
<where>
<if test="ids != null and ids.size > 0">
AND id IN
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="userFlag != null">
AND userFlag = #{userFlag}
</if>
<if test="userName != null and '' != userName">
AND userName LIKE CONCAT('%', #{userName}, '%')
</if>
<if test="neUserName != null and '' != neUserName">
AND userName != #{neUserName}
</if>
<if test="invCode != null and '' != invCode">
AND locInvCode = #{invCode}
</if>
<if test="deptName != null and '' != deptName">
AND auth_dept.name LIKE CONCAT('%', #{deptName}, '%')
</if>
<if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[
and DATE_FORMAT(lastModifyTime
, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}
, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test="userKey != null and userKey != ''">
AND (auth_user.userName like concat('%', #{userKey}, '%')
or auth_user.employeeName like concat('%', #{userKey}, '%')
)
</if>
<if test="deptCode != null and deptCode != ''">
AND auth_dept.code = #{deptCode}
</if>
</where>
GROUP BY
auth_user.userName
ORDER BY id DESC
</select>
<select id="findByUserName" parameterType="hashmap" resultType="com.glxp.api.entity.auth.AuthAdmin">
SELECT *
FROM auth_user
<where>
userName = #{userName}
</where>
LIMIT 1
</select>
<select id="findById" parameterType="hashmap" resultType="com.glxp.api.entity.auth.AuthAdmin">
SELECT *
FROM auth_user
<where>
id = #{id}
</where>
LIMIT 1
</select>
<select id="findPwdById" parameterType="hashmap" resultType="com.glxp.api.entity.auth.AuthAdmin">
SELECT passWord
FROM auth_user
<where>
id = #{id}
</where>
LIMIT 1
</select>
<insert id="insertAuthAdmin" keyProperty="id" parameterType="com.glxp.api.entity.auth.AuthAdmin">
INSERT INTO auth_user( id, userName, passWord, lastLoginIp, lastLoginTime, createTime, userFlag
, employeeName, CustomerId, lastModifyTime, locDeptCode, locInvCode, comments
, lastUpdatePwdTime)
values
(#{id}, #{userName},
<choose>
<when test="passWord != null">
#{passWord},
</when>
<otherwise>
'',
</otherwise>
</choose>
<choose>
<when test="lastLoginIp != null">
#{lastLoginIp},
</when>
<otherwise>
'',
</otherwise>
</choose>
<choose>
<when test="lastLoginTime != null">
#{lastLoginTime},
</when>
<otherwise>
'0001-01-01 00:00:00',
</otherwise>
</choose>
#{createTime},
#{userFlag,jdbcType=INTEGER},
#{employeeName},
#{CustomerId},
#{lastModifyTime},
#{locDeptCode},
#{locInvCode}, #{comments}, #{lastUpdatePwdTime})
</insert>
<insert id="replaceAuthAdmin" keyProperty="id" parameterType="com.glxp.api.entity.auth.AuthAdmin">
replace
INTO auth_user(id, userName, passWord, lastLoginIp,
lastLoginTime, createTime, userFlag, lastModifyTime, employeeName, CustomerId,
locDeptCode, locInvCode, comments, lastUpdatePwdTime)
values (#{id},
#{userName},
#{passWord},
#{lastLoginIp},
#{lastLoginTime},
#{createTime},
#{userFlag,jdbcType=INTEGER},
#{lastModifyTime},
#{employeeName},
#{CustomerId},
#{locDeptCode},
#{locInvCode},
#{comments}, #{lastUpdatePwdTime})
</insert>
<update id="updateAuthAdmin" parameterType="com.glxp.api.entity.auth.AuthAdmin">
UPDATE auth_user
<set>
<if test="userName != null">
userName=#{userName},
</if>
<if test="passWord != null">
passWord=#{passWord},
</if>
<if test="lastLoginIp != null">
lastLoginIp=#{lastLoginIp},
</if>
<if test="lastLoginTime != null">
lastLoginTime=#{lastLoginTime},
</if>
<if test="lastModifyTime != null">
lastModifyTime=#{lastModifyTime},
</if>
<if test="lastUpdatePwdTime != null">
lastUpdatePwdTime=#{lastUpdatePwdTime},
</if>
<if test="userFlag != null">
userFlag=#{userFlag},
</if>
<if test="employeeName != null">
employeeName=#{employeeName},
</if>
<if test="locDeptCode != null">
locDeptCode=#{locDeptCode},
</if>
<if test="locInvCode != null">
locInvCode=#{locInvCode},
</if>
<if test="comments != null">
comments=#{comments},
</if>
<if test="lastUpdatePwdTime != null">
lastUpdatePwdTime=#{lastUpdatePwdTime},
</if>
</set>
WHERE id = #{id}
</update>
<update id="updateUser" parameterType="com.glxp.api.req.auth.UpdateUserRequset">
UPDATE auth_user
<set>
<if test="passWord != null">
passWord=#{newPassword},
</if>
</set>
WHERE id = #{id}
</update>
<delete id="deleteById" parameterType="java.lang.Long">
delete
from auth_user
where id = #{id}
</delete>
<select id="selectHospitalUser" resultType="com.glxp.api.entity.auth.AuthAdmin">
select *
from auth_user
where userFlag != 0
</select>
<select id="selectNotSelectUser" resultType="com.glxp.api.entity.auth.AuthAdmin">
select *
from auth_user
left join auth_dept_user on auth_user.id = auth_dept_user.userId
<where>
userFlag != 0
<if test="deptId != null and '' != deptId">
AND auth_dept_user.deptId = #{deptId}
</if>
<if test="userIds != null and userIds.size() != 0">
and auth_user.id not in
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getUserByIds" resultType="com.glxp.api.entity.auth.AuthAdmin">
select *
from auth_user
<where>
userFlag != 0
<if test="key != null and key != ''">
AND (auth_user.userName like concat('%', #{key}, '%')
or auth_user.employeeName like concat('%', #{key}, '%')
)
</if>
<if test="userIds != null and userIds.size() != 0">
and auth_user.id in
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectAllocatedList" parameterType="com.glxp.api.req.auth.FilterAuthUserRequest"
resultType="com.glxp.api.entity.auth.AuthAdmin">
select u.*
from auth_user u
left join auth_user_role sur on u.id = sur.user_id
left join auth_role r on r.role_id = sur.role_id
<where>
<if test="roleId != null and '' != roleId">
AND r.role_id = #{roleId}
</if>
</where>
</select>
<select id="selectUnallocatedList" parameterType="com.glxp.api.req.auth.FilterAuthUserRequest"
resultType="com.glxp.api.entity.auth.AuthAdmin">
select u.*
from auth_user u
left join auth_user_role sur on u.id = sur.user_id
left join auth_role r on r.role_id = sur.role_id
<where>
<if test="ids != null and ids.size() != 0">
u.id not in
<foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="roleId != null and '' != roleId">
AND r.role_id <![CDATA[ <> ]]> #{roleId}
</if>
<if test="userName != null and '' != userName">
AND u.user_name LIKE concat('%', #{userName}, '%')
</if>
</where>
</select>
<select id="companyUserList" parameterType="com.glxp.api.req.auth.FilterInvLinkDataRequest"
resultType="com.glxp.api.entity.auth.AuthAdmin">
select u.*
from auth_user u
<where>
<if test="param.userName != null and param.userName != ''">
(
u.userName like concat('%', #{param.userName}, '%')
or u.id like concat('%', #{param.userName}, '%')
or u.employeeName like concat('%', #{param.userName}, '%')
)
</if>
</where>
order by u.createTime desc
</select>
<select id="getDepts" resultType="com.glxp.api.entity.auth.AuthAdmin">
SELECT auth_user.*, auth_dept.name deptName
FROM auth_dept_user adu
left join auth_user on adu.userId = auth_user.id
left join auth_dept on adu.deptId = auth_dept.id
<where>
<if test="ids != null and ids.size > 0">
AND auth_user.id IN
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="userFlag != null">
AND auth_user.userFlag = #{userFlag}
</if>
<if test="userName != null and '' != userName">
AND auth_user.userName LIKE CONCAT('%', #{userName}, '%')
</if>
<if test="neUserName != null and '' != neUserName">
AND auth_user.userName != #{neUserName}
</if>
<if test="invCode != null and '' != invCode">
AND auth_user.locInvCode = #{invCode}
</if>
<if test="deptName != null and '' != deptName">
AND auth_dept.name LIKE CONCAT('%', #{deptName}, '%')
</if>
<if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[
and DATE_FORMAT(auth_user.lastModifyTime
, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}
, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test="userKey != null and userKey != ''">
AND (auth_user.userName like concat('%', #{userKey}, '%')
or auth_user.employeeName like concat('%', #{userKey}, '%')
)
</if>
<if test="deptCode != null and deptCode != ''">
AND auth_user.locDeptCode = #{deptCode}
</if>
</where>
ORDER BY auth_user.id DESC
</select>
</mapper>