329 lines
18 KiB
XML
329 lines
18 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="top.fatweb.oxygen.api.mapper.permission.UserMapper">
|
|
<select id="selectOneWithPowerInfoByAccount" resultMap="userWithPowerInfoMap">
|
|
select t_s_user.id as user_id,
|
|
t_s_user.username as user_username,
|
|
t_s_user.password as user_password,
|
|
t_s_user.verify as user_verify,
|
|
t_s_user.forget as user_forget,
|
|
t_s_user.locking as user_locking,
|
|
t_s_user.expiration as user_expiration,
|
|
t_s_user.credentials_expiration as user_credentials_expiration,
|
|
t_s_user.enable as user_enable,
|
|
t_s_user.current_login_time as user_current_login_time,
|
|
t_s_user.current_login_ip as user_current_login_ip,
|
|
t_s_user.last_login_time as user_last_login_time,
|
|
t_s_user.last_login_ip as user_last_login_ip,
|
|
t_s_user.create_time as user_create_time,
|
|
t_s_user.update_time as user_update_time,
|
|
t_s_user.deleted as user_deleted,
|
|
t_s_user.version as user_version,
|
|
tsui.id as user_info_id,
|
|
tsui.user_id as user_info_user_id,
|
|
tsui.nickname as user_info_nickname,
|
|
tsui.avatar as user_info_avatar,
|
|
tsui.email as user_info_email,
|
|
tsui.create_time as user_info_create_time,
|
|
tsui.update_time as user_info_update_time,
|
|
tsui.deleted as user_info_deleted,
|
|
tsui.version as user_info_version,
|
|
tsmo.id as module_id,
|
|
tsmo.name as module_name,
|
|
tsm.id as menu_id,
|
|
tsm.name as menu_name,
|
|
tsm.url as menu_url,
|
|
tsm.parent_id as menu_parent_id,
|
|
tsf.id as func_id,
|
|
tsf.name as func_name,
|
|
tsf.parent_id as func_parent_id,
|
|
tsf.menu_id as func_menu_id,
|
|
tso.id as operation_id,
|
|
tso.name as operation_name,
|
|
tso.code as operation_code,
|
|
tso.func_id as operation_func_id
|
|
from t_s_user
|
|
left join (select * from t_s_user_info where deleted = 0) as tsui on t_s_user.id = tsui.user_id
|
|
left join (select * from t_r_user_group where deleted = 0) as trug on t_s_user.id = trug.user_id
|
|
left join (select * from t_s_group where deleted = 0 and enable = 1) as tsg on tsg.id = trug.group_id
|
|
left join (select * from t_r_role_group where deleted = 0) as trrg on tsg.id = trrg.group_id
|
|
left join (select * from t_r_user_role where deleted = 0) as trur on t_s_user.id = trur.user_id
|
|
left join (select * from t_s_role where deleted = 0 and enable = 1) as tsr
|
|
on tsr.id = trrg.role_id or tsr.id = trur.role_id
|
|
left join (select * from t_r_power_role where deleted = 0) as trpr on tsr.id = trpr.role_id
|
|
left join t_s_power as tsp on tsp.id = trpr.power_id
|
|
left join t_s_module as tsmo on tsp.id = tsmo.id
|
|
left join t_s_menu as tsm on tsp.id = tsm.id
|
|
left join t_s_func as tsf on tsp.id = tsf.id
|
|
left join t_s_operation as tso on tsp.id = tso.id
|
|
where t_s_user.deleted = 0
|
|
and (tsui.email = #{account} or t_s_user.username = #{account});
|
|
</select>
|
|
|
|
<select id="selectPage" resultType="long">
|
|
select t_s_user.id
|
|
from t_s_user
|
|
left join (select * from t_s_user_info where deleted = 0) as tsui on t_s_user.id = tsui.user_id
|
|
<where>
|
|
t_s_user.deleted = 0
|
|
<if test="searchValue != null">
|
|
<choose>
|
|
<when test="searchType == 'ID'">
|
|
<choose>
|
|
<when test="searchRegex == true">
|
|
and t_s_user.id regexp #{searchValue}
|
|
</when>
|
|
<otherwise>
|
|
and t_s_user.id like concat('%' ,#{searchValue}, '%')
|
|
</otherwise>
|
|
</choose>
|
|
</when>
|
|
<when test="searchType == 'USERNAME'">
|
|
<choose>
|
|
<when test="searchRegex == true">
|
|
and t_s_user.username regexp #{searchValue}
|
|
</when>
|
|
<otherwise>
|
|
and t_s_user.username like concat('%' ,#{searchValue}, '%')
|
|
</otherwise>
|
|
</choose>
|
|
</when>
|
|
<when test="searchType == 'NICKNAME'">
|
|
<choose>
|
|
<when test="searchRegex == true">
|
|
and tsui.nickname regexp #{searchValue}
|
|
</when>
|
|
<otherwise>
|
|
and tsui.nickname like concat('%' ,#{searchValue}, '%')
|
|
</otherwise>
|
|
</choose>
|
|
</when>
|
|
<when test="searchType == 'EMAIL'">
|
|
<choose>
|
|
<when test="searchRegex == true">
|
|
and tsui.email regexp #{searchValue}
|
|
</when>
|
|
<otherwise>
|
|
and tsui.email like concat('%' ,#{searchValue}, '%')
|
|
</otherwise>
|
|
</choose>
|
|
</when>
|
|
<otherwise>
|
|
<choose>
|
|
<when test="searchRegex == true">
|
|
and ( t_s_user.username regexp #{searchValue} or tui.nickname regexp #{searchValue} or
|
|
tsui.email regexp #{searchValue})
|
|
</when>
|
|
<otherwise>
|
|
and (t_s_user.username like concat('%' ,#{searchValue}, '%') or tsui.nickname like
|
|
concat('%' ,#{searchValue}, '%') or tsui.email like concat('%' ,#{searchValue}, '%'))
|
|
</otherwise>
|
|
</choose>
|
|
</otherwise>
|
|
</choose>
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectListWithRoleInfoByIds" resultMap="userWithRoleInfoMap">
|
|
select t_s_user.id as user_id,
|
|
t_s_user.username as user_username,
|
|
t_s_user.verify as user_verify,
|
|
t_s_user.forget as user_forget,
|
|
t_s_user.locking as user_locking,
|
|
t_s_user.expiration as user_expiration,
|
|
t_s_user.credentials_expiration as user_credentials_expiration,
|
|
t_s_user.enable as user_enable,
|
|
t_s_user.current_login_time as user_current_login_time,
|
|
t_s_user.current_login_ip as user_current_login_ip,
|
|
t_s_user.last_login_time as user_last_login_time,
|
|
t_s_user.last_login_ip as user_last_login_ip,
|
|
t_s_user.create_time as user_create_time,
|
|
t_s_user.update_time as user_update_time,
|
|
t_s_user.deleted as user_deleted,
|
|
t_s_user.version as user_version,
|
|
tsui.id as user_info_id,
|
|
tsui.user_id as user_info_user_id,
|
|
tsui.nickname as user_info_nickname,
|
|
tsui.avatar as user_info_avatar,
|
|
tsui.email as user_info_email,
|
|
tsui.create_time as user_info_create_time,
|
|
tsui.update_time as user_info_update_time,
|
|
tsui.deleted as user_info_deleted,
|
|
tsui.version as user_info_version,
|
|
tsr.id as role_id,
|
|
tsr.name as role_name,
|
|
tsr.enable as role_enable,
|
|
tsr.deleted as role_deleted,
|
|
tsr.version as role_version,
|
|
tsg.id as group_id,
|
|
tsg.name as group_name,
|
|
tsg.enable as group_enable,
|
|
tsg.deleted as group_deleted,
|
|
tsg.version as group_version
|
|
from t_s_user
|
|
left join (select * from t_s_user_info where deleted = 0) as tsui on t_s_user.id = tsui.user_id
|
|
left join (select * from t_r_user_group where deleted = 0) as trug on t_s_user.id = trug.user_id
|
|
left join (select * from t_s_group where deleted = 0) as tsg on tsg.id = trug.group_id
|
|
left join (select * from t_r_role_group where deleted = 0) as trrg on tsg.id = trrg.group_id
|
|
left join (select * from t_r_user_role where deleted = 0) as trur on t_s_user.id = trur.user_id
|
|
left join (select * from t_s_role where deleted = 0) as tsr
|
|
on tsr.id = trrg.role_id or tsr.id = trur.role_id
|
|
<where>
|
|
<foreach collection="userIds" item="item" index="index" open="and t_s_user.id in (" separator="," close=")"
|
|
nullable="true">
|
|
#{item}
|
|
</foreach>
|
|
</where>
|
|
<foreach collection="userIds" item="item" index="index" open="order by field(t_s_user.id," separator=","
|
|
close=")" nullable="true">
|
|
#{item}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectOneWithRoleInfoById" resultMap="userWithRoleInfoMap">
|
|
select t_s_user.id as user_id,
|
|
t_s_user.username as user_username,
|
|
t_s_user.verify as user_verify,
|
|
t_s_user.forget as user_forget,
|
|
t_s_user.locking as user_locking,
|
|
t_s_user.expiration as user_expiration,
|
|
t_s_user.credentials_expiration as user_credentials_expiration,
|
|
t_s_user.enable as user_enable,
|
|
t_s_user.current_login_time as user_current_login_time,
|
|
t_s_user.current_login_ip as user_current_login_ip,
|
|
t_s_user.last_login_time as user_last_login_time,
|
|
t_s_user.last_login_ip as user_last_login_ip,
|
|
t_s_user.create_time as user_create_time,
|
|
t_s_user.update_time as user_update_time,
|
|
t_s_user.deleted as user_deleted,
|
|
t_s_user.version as user_version,
|
|
tsui.id as user_info_id,
|
|
tsui.user_id as user_info_user_id,
|
|
tsui.nickname as user_info_nickname,
|
|
tsui.avatar as user_info_avatar,
|
|
tsui.email as user_info_email,
|
|
tsui.create_time as user_info_create_time,
|
|
tsui.update_time as user_info_update_time,
|
|
tsui.deleted as user_info_deleted,
|
|
tsui.version as user_info_version,
|
|
tsr.id as role_id,
|
|
tsr.name as role_name,
|
|
tsr.enable as role_enable,
|
|
tsr.deleted as role_deleted,
|
|
tsr.version as role_version,
|
|
tsg.id as group_id,
|
|
tsg.name as group_name,
|
|
tsg.enable as group_enable,
|
|
tsg.deleted as group_deleted,
|
|
tsg.version as group_version
|
|
from t_s_user
|
|
left join (select * from t_s_user_info where deleted = 0) as tsui on t_s_user.id = tsui.user_id
|
|
left join (select * from t_r_user_group where deleted = 0) as trug on t_s_user.id = trug.user_id
|
|
left join (select * from t_s_group where deleted = 0) as tsg on tsg.id = trug.group_id
|
|
left join (select * from t_r_role_group where deleted = 0) as trrg on tsg.id = trrg.group_id
|
|
left join (select * from t_r_user_role where deleted = 0) as trur on t_s_user.id = trur.user_id
|
|
left join (select * from t_s_role where deleted = 0) as tsr
|
|
on tsr.id = trrg.role_id or tsr.id = trur.role_id
|
|
where t_s_user.deleted = 0
|
|
and t_s_user.id = #{id}
|
|
</select>
|
|
|
|
<select id="selectListWithInfo" resultMap="userWithInfoMap">
|
|
select t_s_user.id as user_id,
|
|
t_s_user.username as user_username,
|
|
t_s_user.verify as user_verify,
|
|
t_s_user.locking as user_locking,
|
|
t_s_user.forget as user_forget,
|
|
t_s_user.expiration as user_expiration,
|
|
t_s_user.credentials_expiration as user_credentials_expiration,
|
|
t_s_user.enable as user_enable,
|
|
t_s_user.current_login_time as user_current_login_time,
|
|
t_s_user.current_login_ip as user_current_login_ip,
|
|
t_s_user.last_login_time as user_last_login_time,
|
|
t_s_user.last_login_ip as user_last_login_ip,
|
|
t_s_user.create_time as user_create_time,
|
|
t_s_user.update_time as user_update_time,
|
|
t_s_user.deleted as user_deleted,
|
|
t_s_user.version as user_version,
|
|
tsui.id as user_info_id,
|
|
tsui.user_id as user_info_user_id,
|
|
tsui.nickname as user_info_nickname,
|
|
tsui.avatar as user_info_avatar,
|
|
tsui.email as user_info_email,
|
|
tsui.create_time as user_info_create_time,
|
|
tsui.update_time as user_info_update_time,
|
|
tsui.deleted as user_info_deleted,
|
|
tsui.version as user_info_version
|
|
from t_s_user
|
|
left join (select * from t_s_user_info where deleted = 0) as tsui on t_s_user.id = tsui.user_id
|
|
where t_s_user.deleted = 0
|
|
</select>
|
|
|
|
<select id="selectIdsWithRoleIds" resultType="long">
|
|
select t_s_user.id
|
|
from t_s_user
|
|
left join (select * from t_r_user_role where deleted = 0) as trur on t_s_user.id = trur.user_id
|
|
left join (select * from t_s_role where deleted = 0) as tsr on tsr.id = trur.role_id
|
|
<where>
|
|
t_s_user.deleted = 0
|
|
<foreach collection="roleIds" item="item" index="index" open="and tsr.id in (" separator="," close=")"
|
|
nullable="true">
|
|
#{item}
|
|
</foreach>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectIdsWithGroupIds" resultType="long">
|
|
select t_s_user.id
|
|
from t_s_user
|
|
left join (select * from t_r_user_group where deleted = 0) as trug on t_s_user.id = trug.user_id
|
|
left join (select * from t_s_group where deleted = 0) as tsg on tsg.id = trug.group_id
|
|
<where>
|
|
t_s_user.deleted = 0
|
|
<foreach collection="groupIds" item="item" index="index" open="and tsg.id in (" separator="," close=")"
|
|
nullable="true">
|
|
#{item}
|
|
</foreach>
|
|
</where>
|
|
</select>
|
|
|
|
<resultMap id="userBaseMap" type="user">
|
|
<id property="id" column="user_id"/>
|
|
<result property="username" column="user_username"/>
|
|
<result property="verify" column="user_verify"/>
|
|
<result property="forget" column="user_forget"/>
|
|
<result property="locking" column="user_locking"/>
|
|
<result property="expiration" column="user_expiration"/>
|
|
<result property="credentialsExpiration" column="user_credentials_expiration"/>
|
|
<result property="enable" column="user_enable"/>
|
|
<result property="currentLoginTime" column="user_current_login_time"/>
|
|
<result property="currentLoginIp" column="user_current_login_ip"/>
|
|
<result property="lastLoginTime" column="user_last_login_time"/>
|
|
<result property="lastLoginIp" column="user_last_login_ip"/>
|
|
<result property="createTime" column="user_create_time"/>
|
|
<result property="updateTime" column="user_update_time"/>
|
|
<result property="deleted" column="user_deleted"/>
|
|
<result property="version" column="user_version"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="userWithInfoMap" type="user" extends="userBaseMap">
|
|
<association property="userInfo"
|
|
resultMap="top.fatweb.oxygen.api.mapper.permission.UserInfoMapper.userInfoMap"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="userWithPowerInfoMap" type="user" extends="userWithInfoMap">
|
|
<result property="password" column="user_password"/>
|
|
<collection property="modules" resultMap="top.fatweb.oxygen.api.mapper.permission.ModuleMapper.moduleMap"/>
|
|
<collection property="menus" resultMap="top.fatweb.oxygen.api.mapper.permission.MenuMapper.menuMap"/>
|
|
<collection property="funcs" resultMap="top.fatweb.oxygen.api.mapper.permission.FuncMapper.funcMap"/>
|
|
<collection property="operations"
|
|
resultMap="top.fatweb.oxygen.api.mapper.permission.OperationMapper.operationMap"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="userWithRoleInfoMap" type="user" extends="userWithInfoMap">
|
|
<collection property="roles" resultMap="top.fatweb.oxygen.api.mapper.permission.RoleMapper.roleMap"/>
|
|
<collection property="groups" resultMap="top.fatweb.oxygen.api.mapper.permission.GroupMapper.groupMap"/>
|
|
</resultMap>
|
|
</mapper>
|