mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-18 04:55:06 +08:00
抽取 activiti 到module-bpm-activiti, 为接入flowable 准备
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 部门表
|
||||
*
|
||||
* @author ruoyi
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("sys_dept")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysDeptDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 父部门ID
|
||||
*
|
||||
* 关联 {@link #id}
|
||||
*/
|
||||
private Long parentId;
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 负责人
|
||||
*
|
||||
* 关联 {@link SysUserDO#getId()}
|
||||
*/
|
||||
private Long leaderUserId;
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 部门状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 岗位表
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@TableName("sys_post")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysPostDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 岗位序号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 岗位名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 岗位编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 岗位排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
|
||||
import cn.iocoder.yudao.framework.security.core.enums.DataScopeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色 DO
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@TableName(value = "sys_role", autoResultMap = true)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysRoleDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 角色标识
|
||||
*
|
||||
* 枚举
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 角色排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 角色状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 角色类型
|
||||
*
|
||||
* 枚举
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 数据范围
|
||||
*
|
||||
* 枚举 {@link DataScopeEnum}
|
||||
*/
|
||||
private Integer dataScope;
|
||||
/**
|
||||
* 数据范围(指定部门数组)
|
||||
*
|
||||
* 适用于 {@link #dataScope} 的值为 {@link DataScopeEnum#DEPT_CUSTOM} 时
|
||||
*/
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> dataScopeDeptIds;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户和角色关联
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@TableName("sys_user_role")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserRoleDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 自增主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 角色 ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.dept;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysDeptCoreMapper extends BaseMapperX<SysDeptDO> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.dept;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysPostCoreMapper extends BaseMapperX<SysPostDO> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.permission;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysRoleCoreMapper extends BaseMapperX<SysRoleDO> {
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.permission;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysUserRoleDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserRoleCoreMapper extends BaseMapperX<SysUserRoleDO> {
|
||||
|
||||
default List<SysUserRoleDO> selectListByRoleIds(Collection<Long> roleIds) {
|
||||
return selectList(SysUserRoleDO::getRoleId, roleIds);
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,13 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserCoreMapper extends BaseMapperX<SysUserDO> {
|
||||
|
||||
default List<SysUserDO> selectListByDeptIds(Collection<Long> deptIds) {
|
||||
return selectList(SysUserDO::getDeptId, deptIds);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.enums;
|
||||
|
||||
/**
|
||||
* System 字典类型的枚举类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysDictTypeConstants {
|
||||
|
||||
String USER_TYPE = "user_type"; // 用户类型
|
||||
String COMMON_STATUS = "sys_common_status"; // 系统状态
|
||||
|
||||
String USER_SEX = "sys_user_sex"; // 用户性别
|
||||
String OPERATE_TYPE = "sys_operate_type"; // 操作类型
|
||||
String LOGIN_TYPE = "sys_login_type"; // 登录日志的类型
|
||||
String LOGIN_RESULT = "sys_login_result"; // 登录结果
|
||||
String CONFIG_TYPE = "sys_config_type"; // 参数配置类型
|
||||
String BOOLEAN_STRING = "sys_boolean_string"; // Boolean 是否类型
|
||||
|
||||
String SMS_CHANNEL_CODE = "sys_sms_channel_code"; // 短信渠道编码
|
||||
String SMS_TEMPLATE_TYPE = "sys_sms_template_type"; // 短信模板类型
|
||||
String SMS_SEND_STATUS = "sys_sms_send_status"; // 短信发送状态
|
||||
String SMS_RECEIVE_STATUS = "sys_sms_receive_status"; // 短信接收状态
|
||||
|
||||
/**
|
||||
* 支付-订单-订单状态
|
||||
*/
|
||||
String PAY_ORDER_STATUS = "pay_order_status";
|
||||
|
||||
/**
|
||||
* 支付-订单-订单回调商户状态
|
||||
*/
|
||||
String PAY_ORDER_NOTIFY_STATUS = "pay_order_notify_status";
|
||||
|
||||
/**
|
||||
* 支付-订单-订单退款状态
|
||||
*/
|
||||
String PAY_ORDER_REFUND_STATUS = "pay_order_refund_status";
|
||||
|
||||
/**
|
||||
* 支付-退款订单-退款状态
|
||||
*/
|
||||
String PAY_REFUND_ORDER_STATUS = "pay_refund_order_status";
|
||||
|
||||
/**
|
||||
* 支付-退款订单-退款类别
|
||||
*/
|
||||
String PAY_REFUND_ORDER_TYPE = "pay_refund_order_type";
|
||||
|
||||
String BPM_TASK_ASSIGN_RULE_TYPE = "bpm_task_assign_rule_type"; // 任务分配规则类型
|
||||
String BPM_TASK_ASSIGN_SCRIPT = "bpm_task_assign_script"; // 任务分配自定义脚本
|
||||
|
||||
}
|
@ -22,4 +22,24 @@ public interface SysErrorCodeConstants {
|
||||
ErrorCode SOCIAL_AUTH_FAILURE = new ErrorCode(1006002000, "社交授权失败,原因是:{}");
|
||||
ErrorCode SOCIAL_UNBIND_NOT_SELF = new ErrorCode(1006002001, "社交解绑失败,非当前用户绑定");
|
||||
|
||||
// ========== 用户模块 1006003000 ==========
|
||||
ErrorCode USER_NOT_EXISTS = new ErrorCode(1006003000, "用户不存在");
|
||||
ErrorCode USER_IS_DISABLE = new ErrorCode(1006003001, "名字为【{}】的用户已被禁用");
|
||||
|
||||
// ========== 部门模块 1006004000 ==========
|
||||
ErrorCode DEPT_NOT_FOUND = new ErrorCode(1006004000, "当前部门不存在");
|
||||
ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1006004001, "部门不处于开启状态,不允许选择");
|
||||
|
||||
// ========== 角色模块 1006005000 ==========
|
||||
ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1006005000, "角色不存在");
|
||||
ErrorCode ROLE_IS_DISABLE = new ErrorCode(1006005001, "名字为【{}】的角色已被禁用");
|
||||
|
||||
// ========== 字典类型 1006006000 ==========
|
||||
ErrorCode DICT_DATA_NOT_EXISTS = new ErrorCode(1006006000, "当前字典数据不存在");
|
||||
ErrorCode DICT_DATA_NOT_ENABLE = new ErrorCode(1006006001, "字典数据({})不处于开启状态,不允许选择");
|
||||
|
||||
// ========== 岗位模块 1006007000 ==========
|
||||
ErrorCode POST_NOT_FOUND = new ErrorCode(1006007000, "当前岗位不存在");
|
||||
ErrorCode POST_NOT_ENABLE = new ErrorCode(1006007001, "岗位({}) 不处于开启状态,不允许选择");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dept;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysDeptCoreService {
|
||||
/**
|
||||
* 获得部门信息数组
|
||||
*
|
||||
* @param ids 部门编号数组
|
||||
* @return 部门信息数组
|
||||
*/
|
||||
List<SysDeptDO> getDepts(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得部门信息
|
||||
*
|
||||
* @param id 部门编号
|
||||
* @return 部门信息
|
||||
*/
|
||||
SysDeptDO getDept(Long id);
|
||||
|
||||
/**
|
||||
* 校验部门们是否有效。如下情况,视为无效:
|
||||
* 1. 部门编号不存在
|
||||
* 2. 部门被禁用
|
||||
*
|
||||
* @param ids 角色编号数组
|
||||
*/
|
||||
void validDepts(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得指定编号的部门列表
|
||||
*
|
||||
* @param ids 部门编号数组
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDeptDO> getSimpleDepts(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得指定编号的部门 Map
|
||||
*
|
||||
* @param ids 部门编号数组
|
||||
* @return 部门 Map
|
||||
*/
|
||||
default Map<Long, SysDeptDO> getDeptMap(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysDeptDO> list = getSimpleDepts(ids);
|
||||
return CollectionUtils.convertMap(list, SysDeptDO::getId);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dept;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 岗位 Core Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysPostCoreService {
|
||||
/**
|
||||
* 校验岗位们是否有效。如下情况,视为无效:
|
||||
* 1. 岗位编号不存在
|
||||
* 2. 岗位被禁用
|
||||
*
|
||||
* @param ids 岗位编号数组
|
||||
*/
|
||||
void validPosts(Collection<Long> ids);
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dept.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.dept.SysDeptCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.DEPT_NOT_ENABLE;
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.DEPT_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 部门 Core Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysDeptCoreServiceImpl implements SysDeptCoreService {
|
||||
|
||||
@Resource
|
||||
private SysDeptCoreMapper deptCoreMapper;
|
||||
|
||||
@Override
|
||||
public List<SysDeptDO> getDepts(Collection<Long> ids) {
|
||||
return deptCoreMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDeptDO getDept(Long id) {
|
||||
return deptCoreMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validDepts(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 获得科室信息
|
||||
List<SysDeptDO> depts = deptCoreMapper.selectBatchIds(ids);
|
||||
Map<Long, SysDeptDO> deptMap = CollectionUtils.convertMap(depts, SysDeptDO::getId);
|
||||
// 校验
|
||||
ids.forEach(id -> {
|
||||
SysDeptDO dept = deptMap.get(id);
|
||||
if (dept == null) {
|
||||
throw exception(DEPT_NOT_FOUND);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(dept.getStatus())) {
|
||||
throw exception(DEPT_NOT_ENABLE, dept.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDeptDO> getSimpleDepts(Collection<Long> ids) {
|
||||
return deptCoreMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dept.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.dept.SysPostCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysPostCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.POST_NOT_ENABLE;
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.POST_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 岗位 Core Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class SysPostCoreServiceImpl implements SysPostCoreService {
|
||||
|
||||
@Resource
|
||||
private SysPostCoreMapper sysPostCoreMapper;
|
||||
|
||||
@Override
|
||||
public void validPosts(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 获得岗位信息
|
||||
List<SysPostDO> posts = sysPostCoreMapper.selectBatchIds(ids);
|
||||
Map<Long, SysPostDO> postMap = CollectionUtils.convertMap(posts, SysPostDO::getId);
|
||||
// 校验
|
||||
ids.forEach(id -> {
|
||||
SysPostDO post = postMap.get(id);
|
||||
if (post == null) {
|
||||
throw exception(POST_NOT_FOUND);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(post.getStatus())) {
|
||||
throw exception(POST_NOT_ENABLE, post.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.coreservice.modules.system.service.dict;
|
||||
|
||||
import cn.iocoder.yudao.framework.dict.core.service.DictDataFrameworkService;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 字典数据 Service 接口
|
||||
*
|
||||
@ -14,4 +16,14 @@ public interface SysDictDataCoreService extends DictDataFrameworkService {
|
||||
*/
|
||||
void initLocalCache();
|
||||
|
||||
/**
|
||||
* 校验字典数据们是否有效。如下情况,视为无效:
|
||||
* 1. 字典数据不存在
|
||||
* 2. 字典数据被禁用
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param values 字典数据值的数组
|
||||
*/
|
||||
void validDictDatas(String dictType, Collection<String> values);
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,11 @@ import cn.iocoder.yudao.coreservice.modules.system.convert.dict.SysDictDataCoreC
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dict.SysDictDataDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.dict.SysDictDataCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dict.SysDictDataCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@ -14,9 +17,11 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.DICT_DATA_NOT_ENABLE;
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.DICT_DATA_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 字典数据 Service 实现类
|
||||
@ -119,4 +124,22 @@ public class SysDictDataCoreServiceImpl implements SysDictDataCoreService {
|
||||
return SysDictDataCoreConvert.INSTANCE.convertList03(labelDictDataCache.row(type).values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validDictDatas(String dictType, Collection<String> values) {
|
||||
if (CollUtil.isEmpty(values)) {
|
||||
return;
|
||||
}
|
||||
ImmutableMap<String, SysDictDataDO> dictDataMap = valueDictDataCache.row(dictType);
|
||||
// 校验
|
||||
values.forEach(value -> {
|
||||
SysDictDataDO dictData = dictDataMap.get(value);
|
||||
if (dictData == null) {
|
||||
throw exception(DICT_DATA_NOT_EXISTS);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(dictData.getStatus())) {
|
||||
throw exception(DICT_DATA_NOT_ENABLE, dictData.getLabel());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.permission;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* 权限 Core Service 接口
|
||||
*
|
||||
* 提供用户-角色、角色-菜单、角色-部门的关联权限处理
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysPermissionCoreService {
|
||||
/**
|
||||
* 获得拥有多个角色的用户编号集合
|
||||
*
|
||||
* @param roleIds 角色编号集合
|
||||
* @return 用户编号集合
|
||||
*/
|
||||
Set<Long> getUserRoleIdListByRoleIds(Collection<Long> roleIds);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.permission;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 角色 Core Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysRoleCoreService {
|
||||
/**
|
||||
* 校验角色们是否有效。如下情况,视为无效:
|
||||
* 1. 角色编号不存在
|
||||
* 2. 角色被禁用
|
||||
*
|
||||
* @param ids 角色编号数组
|
||||
*/
|
||||
void validRoles(Collection<Long> ids);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.permission.impl;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysUserRoleDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.permission.SysUserRoleCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* 权限 Core Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class SysPermissionCoreServiceImpl implements SysPermissionCoreService {
|
||||
|
||||
@Resource
|
||||
private SysUserRoleCoreMapper userRoleCoreMapper;
|
||||
|
||||
@Override
|
||||
public Set<Long> getUserRoleIdListByRoleIds(Collection<Long> roleIds) {
|
||||
return CollectionUtils.convertSet(userRoleCoreMapper.selectListByRoleIds(roleIds),
|
||||
SysUserRoleDO::getRoleId);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.permission.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.permission.SysRoleCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysRoleCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.ROLE_IS_DISABLE;
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.ROLE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 角色 Core Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleCoreServiceImpl implements SysRoleCoreService {
|
||||
|
||||
@Resource
|
||||
private SysRoleCoreMapper sysRoleCoreMapper;
|
||||
|
||||
@Override
|
||||
public void validRoles(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 获得角色信息
|
||||
List<SysRoleDO> roles = sysRoleCoreMapper.selectBatchIds(ids);
|
||||
Map<Long, SysRoleDO> roleMap = CollectionUtils.convertMap(roles, SysRoleDO::getId);
|
||||
// 校验
|
||||
ids.forEach(id -> {
|
||||
SysRoleDO role = roleMap.get(id);
|
||||
if (role == null) {
|
||||
throw exception(ROLE_NOT_EXISTS);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())) {
|
||||
throw exception(ROLE_IS_DISABLE, role.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 后台用户 Service Core 接口
|
||||
@ -17,4 +21,50 @@ public interface SysUserCoreService {
|
||||
*/
|
||||
SysUserDO getUser(Long id);
|
||||
|
||||
/**
|
||||
* 获得指定部门的用户数组
|
||||
*
|
||||
* @param deptIds 部门数组
|
||||
* @return 用户数组
|
||||
*/
|
||||
List<SysUserDO> getUsersByDeptIds(Collection<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 获得指定岗位的用户数组
|
||||
*
|
||||
* @param postIds 岗位数组
|
||||
* @return 用户数组
|
||||
*/
|
||||
List<SysUserDO> getUsersByPostIds(Collection<Long> postIds);
|
||||
|
||||
/**
|
||||
* 获得用户列表
|
||||
*
|
||||
* @param ids 用户编号数组
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<SysUserDO> getUsers(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 校验用户们是否有效。如下情况,视为无效:
|
||||
* 1. 用户编号不存在
|
||||
* 2. 用户被禁用
|
||||
*
|
||||
* @param ids 用户编号数组
|
||||
*/
|
||||
void validUsers(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得用户 Map
|
||||
*
|
||||
* @param ids 用户编号数组
|
||||
* @return 用户 Map
|
||||
*/
|
||||
default Map<Long, SysUserDO> getUserMap(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
return CollectionUtils.convertMap(getUsers(ids), SysUserDO::getId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,19 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.user.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.user.SysUserCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.USER_IS_DISABLE;
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.USER_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 后台用户 Service Core 实现
|
||||
@ -23,4 +31,52 @@ public class SysUserCoreServiceImpl implements SysUserCoreService {
|
||||
return userCoreMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserDO> getUsersByDeptIds(Collection<Long> deptIds) {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return userCoreMapper.selectListByDeptIds(deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserDO> getUsersByPostIds(Collection<Long> postIds) {
|
||||
if (CollUtil.isEmpty(postIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 过滤不符合条件的
|
||||
// TODO 芋艿:暂时只能内存过滤。解决方案:1、新建一个关联表;2、基于 where + 函数;3、json 字段,适合 mysql 8+ 版本
|
||||
List<SysUserDO> users = userCoreMapper.selectList();
|
||||
users.removeIf(user -> !CollUtil.containsAny(user.getPostIds(), postIds));
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserDO> getUsers(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return userCoreMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validUsers(Set<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 获得岗位信息
|
||||
List<SysUserDO> users = userCoreMapper.selectBatchIds(ids);
|
||||
Map<Long, SysUserDO> userMap = CollectionUtils.convertMap(users, SysUserDO::getId);
|
||||
// 校验
|
||||
ids.forEach(id -> {
|
||||
SysUserDO user = userMap.get(id);
|
||||
if (user == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus())) {
|
||||
throw exception(USER_IS_DISABLE, user.getNickname());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user