✨ 用户添加组织机构绑定关系
This commit is contained in:
@@ -10,6 +10,7 @@ import com.hccake.ballcat.admin.modules.sys.model.dto.SysUserScope;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.entity.SysRole;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.entity.SysUser;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.qo.SysUserQO;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.vo.SysUserVO;
|
||||
import com.hccake.ballcat.admin.modules.sys.service.SysUserRoleService;
|
||||
import com.hccake.ballcat.admin.modules.sys.service.SysUserService;
|
||||
import com.hccake.ballcat.commom.log.operation.annotation.CreateOperationLogging;
|
||||
@@ -36,8 +37,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2018/12/16
|
||||
* 组织架构
|
||||
*
|
||||
* @author hccake 2020-09-24 20:16:15
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -57,8 +59,8 @@ public class SysUserController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@per.hasPermission('sys:sysuser:read')")
|
||||
public R<IPage<SysUser>> getUserPage(Page<SysUser> page, SysUserQO qo) {
|
||||
return R.ok(sysUserService.page(page, qo));
|
||||
public R<IPage<SysUserVO>> getUserPage(Page<?> page, SysUserQO qo) {
|
||||
return R.ok(sysUserService.selectPageVo(page, qo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.hccake.ballcat.admin.modules.sys.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.entity.SysUser;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.vo.SysUserVO;
|
||||
import com.hccake.ballcat.common.core.vo.SelectData;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -14,16 +18,24 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param wrapper 查询条件wrapper
|
||||
* @return Page<SysUserVO>
|
||||
*/
|
||||
IPage<SysUserVO> selectPageVo(IPage<?> page, @Param(Constants.WRAPPER) QueryWrapper<SysUser> wrapper);
|
||||
|
||||
/**
|
||||
* 根据RoleCode 查询对应用户
|
||||
* @param roleCode
|
||||
* @return
|
||||
* @param roleCode 角色标识
|
||||
* @return List<SysUser> 该角色标识对应的用户列表
|
||||
*/
|
||||
List<SysUser> selectUsersByRoleCode(String roleCode);
|
||||
|
||||
/**
|
||||
* 返回用户的select数据 name=> username value => userId
|
||||
* @param type
|
||||
* @param type 用户类型
|
||||
* @return List<SelectData>
|
||||
*/
|
||||
List<SelectData<?>> getSelectData(@Param("type") Integer type);
|
||||
|
||||
@@ -66,4 +66,10 @@ public class SysUserDTO {
|
||||
@ApiModelProperty(value = "状态(1-正常,2-冻结)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 组织机构ID
|
||||
*/
|
||||
@ApiModelProperty(value = "organizationId")
|
||||
private Integer organizationId;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
* @date 2019-09-12 20:39:31
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user")
|
||||
@TableName("sys_user su")
|
||||
@ApiModel(value = "系统用户表")
|
||||
public class SysUser implements Serializable {
|
||||
|
||||
@@ -82,6 +82,15 @@ public class SysUser implements Serializable {
|
||||
@ApiModelProperty(value = "状态(1-正常, 0-冻结)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 组织机构ID
|
||||
*/
|
||||
@ApiModelProperty(value = "组织机构ID")
|
||||
private Integer organizationId;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
@ApiModelProperty(value = "1:系统用户, 2:客户用户")
|
||||
private Integer type;
|
||||
|
||||
|
||||
@@ -49,13 +49,19 @@ public class SysUserQO {
|
||||
@ApiModelProperty(value = "状态(1-正常,2-冻结)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 组织机构ID
|
||||
*/
|
||||
@ApiModelProperty(value = "organizationId")
|
||||
private Integer organizationId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型:1:系统用户, 2:客户用户")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty(value = "用户类型:1:系统用户, 2:客户用户")
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,18 @@ public class SysUserVO implements Serializable {
|
||||
@ApiModelProperty(value = "1:系统用户, 2:客户用户")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 组织机构ID
|
||||
*/
|
||||
@ApiModelProperty(value = "组织机构ID")
|
||||
private Integer organizationId;
|
||||
|
||||
/**
|
||||
* 组织机构名称
|
||||
*/
|
||||
@ApiModelProperty(value = "组织机构名称")
|
||||
private String organizationName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.hccake.ballcat.admin.modules.sys.model.dto.SysUserScope;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.entity.SysUser;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.qo.SysUserQO;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.dto.UserInfoDTO;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.vo.SysUserVO;
|
||||
import com.hccake.ballcat.common.core.vo.SelectData;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -22,12 +23,12 @@ import java.util.List;
|
||||
public interface SysUserService extends IService<SysUser> {
|
||||
|
||||
/**
|
||||
* 查询系统用户列表
|
||||
* @param page 分页对象
|
||||
* @param qo 查询参数
|
||||
* @return IPage<SysUser>
|
||||
* 根据QueryObject查询系统用户列表
|
||||
* @param page 分页参数
|
||||
* @param qo 查询参数对象
|
||||
* @return IPage<SysUserVO> 分页数据
|
||||
*/
|
||||
IPage<SysUser> page(IPage<SysUser> page, SysUserQO qo);
|
||||
IPage<SysUserVO> selectPageVo(IPage<?> page, SysUserQO qo);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
|
||||
@@ -5,7 +5,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -22,6 +22,7 @@ import com.hccake.ballcat.admin.modules.sys.model.entity.SysRole;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.entity.SysUser;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.qo.SysUserQO;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.vo.PermissionVO;
|
||||
import com.hccake.ballcat.admin.modules.sys.model.vo.SysUserVO;
|
||||
import com.hccake.ballcat.admin.modules.sys.service.*;
|
||||
import com.hccake.ballcat.admin.oauth.util.SecurityUtils;
|
||||
import com.hccake.ballcat.common.core.util.PasswordUtil;
|
||||
@@ -62,22 +63,32 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Value("${password.secret-key}")
|
||||
private String secretKey;
|
||||
|
||||
private final static String TABLE_ALIAS_PREFIX = "su.";
|
||||
|
||||
/**
|
||||
* 根据QueryObject查询分页数据
|
||||
* @param page 分页参数
|
||||
* @param qo 查询参数对象
|
||||
* @return IPage<SysUserVO> 分页数据
|
||||
*/
|
||||
@Override
|
||||
public IPage<SysUser> page(IPage<SysUser> page, SysUserQO qo) {
|
||||
public IPage<SysUserVO> selectPageVo(IPage<?> page, SysUserQO qo) {
|
||||
|
||||
LambdaQueryWrapper<SysUser> wrapper = Wrappers.<SysUser>lambdaQuery()
|
||||
.like(ObjectUtil.isNotNull(qo.getUsername()), SysUser::getUsername, qo.getUsername())
|
||||
.like(ObjectUtil.isNotNull(qo.getEmail()), SysUser::getEmail, qo.getEmail())
|
||||
.like(ObjectUtil.isNotNull(qo.getPhone()), SysUser::getPhone, qo.getPhone())
|
||||
.like(ObjectUtil.isNotNull(qo.getNickname()), SysUser::getNickname, qo.getNickname())
|
||||
.eq(ObjectUtil.isNotNull(qo.getStatus()), SysUser::getStatus, qo.getStatus())
|
||||
.eq(ObjectUtil.isNotNull(qo.getSex()), SysUser::getSex, qo.getSex())
|
||||
.eq(ObjectUtil.isNotNull(qo.getType()), SysUser::getType, qo.getType());
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.<SysUser>query()
|
||||
.eq(TABLE_ALIAS_PREFIX + "deleted", 0)
|
||||
.like(ObjectUtil.isNotNull(qo.getUsername()), TABLE_ALIAS_PREFIX + "username", qo.getUsername())
|
||||
.like(ObjectUtil.isNotNull(qo.getEmail()), TABLE_ALIAS_PREFIX + "email", qo.getEmail())
|
||||
.like(ObjectUtil.isNotNull(qo.getPhone()), TABLE_ALIAS_PREFIX + "phone", qo.getPhone())
|
||||
.like(ObjectUtil.isNotNull(qo.getNickname()), TABLE_ALIAS_PREFIX + "nickname", qo.getNickname())
|
||||
.eq(ObjectUtil.isNotNull(qo.getStatus()), TABLE_ALIAS_PREFIX + "status", qo.getStatus())
|
||||
.eq(ObjectUtil.isNotNull(qo.getSex()), TABLE_ALIAS_PREFIX + "sex", qo.getSex())
|
||||
.eq(ObjectUtil.isNotNull(qo.getType()), TABLE_ALIAS_PREFIX + "type", qo.getType())
|
||||
.eq(ObjectUtil.isNotNull(qo.getOrganizationId()), TABLE_ALIAS_PREFIX + "organization_id",
|
||||
qo.getOrganizationId());
|
||||
if (StringUtils.isNotBlank(qo.getStartTime()) && StringUtils.isNotBlank(qo.getEndTime())) {
|
||||
wrapper.between(SysUser::getCreateTime, qo.getStartTime(), qo.getEndTime());
|
||||
wrapper.between(TABLE_ALIAS_PREFIX + "create_time", qo.getStartTime(), qo.getEndTime());
|
||||
}
|
||||
|
||||
return baseMapper.selectPage(page, wrapper);
|
||||
return baseMapper.selectPageVo(page, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,35 +2,49 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hccake.ballcat.admin.modules.sys.mapper.SysUserMapper">
|
||||
|
||||
<sql id="Base_Alias_Column_List">
|
||||
su.user_id,
|
||||
su.username,
|
||||
su.nickname,
|
||||
su.avatar,
|
||||
su.sex,
|
||||
su.email,
|
||||
su.phone,
|
||||
su.status,
|
||||
su.type,
|
||||
su.organization_id,
|
||||
su.create_time,
|
||||
su.update_time
|
||||
</sql>
|
||||
|
||||
<select id="selectPageVo" resultType="com.hccake.ballcat.admin.modules.sys.model.vo.SysUserVO">
|
||||
SELECT
|
||||
<include refid="Base_Alias_Column_List"/>
|
||||
, so.name as organization_name
|
||||
FROM sys_user su
|
||||
LEFT JOIN
|
||||
sys_organization so
|
||||
ON su.organization_id = so.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<!-- 通过用户ID查询其关联的角色ID-->
|
||||
<select id="selectUsersByRoleCode" resultType="com.hccake.ballcat.admin.modules.sys.model.entity.SysUser">
|
||||
SELECT
|
||||
u.user_id,
|
||||
u.username,
|
||||
u.nickname,
|
||||
u.password,
|
||||
u.salt,
|
||||
u.avatar,
|
||||
u.sex,
|
||||
u.email,
|
||||
u.phone,
|
||||
u.status,
|
||||
u.create_time,
|
||||
u.update_time
|
||||
<include refid="Base_Alias_Column_List"/>
|
||||
FROM
|
||||
sys_user u
|
||||
sys_user su
|
||||
left join
|
||||
sys_user_role ur
|
||||
on u.user_id = ur.user_id
|
||||
on su.user_id = ur.user_id
|
||||
left join
|
||||
sys_role r
|
||||
on r.id = ur.role_id
|
||||
WHERE r.`code` = #{0}
|
||||
and u.deleted = 0
|
||||
and su.deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getSelectData" resultType="com.hccake.ballcat.common.core.vo.SelectData">
|
||||
<select id="getSelectData" resultType="com.hccake.ballcat.common.core.vo.SelectData">
|
||||
select
|
||||
username as name , user_id as value
|
||||
from
|
||||
|
||||
Reference in New Issue
Block a user