mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
多模块重构 4:system 模块的创建,去除 Sys
This commit is contained in:
parent
117914d92b
commit
ab6ec2f0ed
@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -30,11 +30,11 @@ public class InfConfigExcelVO {
|
||||
private String value;
|
||||
|
||||
@ExcelProperty(value = "参数类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.CONFIG_TYPE)
|
||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty(value = "是否敏感", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.BOOLEAN_STRING)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean sensitive;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiacces
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -26,7 +26,7 @@ public class InfApiAccessLogExcelVO {
|
||||
private Long userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.USER_TYPE)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@ExcelProperty("应用名")
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierror
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.enums.InfDictTypeConstants;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -27,7 +27,7 @@ public class InfApiErrorLogExcelVO {
|
||||
private Integer userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.USER_TYPE)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@ExcelProperty("应用名")
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
@ -46,11 +46,11 @@ public class PayOrderExcelVO {
|
||||
@ExcelProperty("渠道手续费,单位:百分比")
|
||||
private String channelFeeRate;
|
||||
|
||||
@DictFormat(SysDictTypeConstants.PAY_ORDER_STATUS)
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_STATUS)
|
||||
@ExcelProperty(value = "支付状态", converter = DictConvert.class)
|
||||
private Integer status;
|
||||
|
||||
@DictFormat(SysDictTypeConstants.PAY_ORDER_NOTIFY_STATUS)
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_NOTIFY_STATUS)
|
||||
@ExcelProperty(value = "通知商户支付结果的回调状态", converter = DictConvert.class)
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ -75,7 +75,7 @@ public class PayOrderExcelVO {
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@DictFormat(SysDictTypeConstants.PAY_ORDER_REFUND_STATUS)
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_REFUND_STATUS)
|
||||
@ExcelProperty(value = "退款状态", converter = DictConvert.class)
|
||||
private Integer refundStatus;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
@ -43,15 +43,15 @@ public class PayRefundExcelVO {
|
||||
@ExcelProperty("异步通知商户地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@DictFormat(SysDictTypeConstants.PAY_ORDER_NOTIFY_STATUS)
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_NOTIFY_STATUS)
|
||||
@ExcelProperty(value = "商户退款结果回调状态", converter = DictConvert.class)
|
||||
private Integer notifyStatus;
|
||||
|
||||
@DictFormat(SysDictTypeConstants.PAY_REFUND_ORDER_STATUS)
|
||||
@DictFormat(DictTypeConstants.PAY_REFUND_ORDER_STATUS)
|
||||
@ExcelProperty(value = "退款状态", converter = DictConvert.class)
|
||||
private Integer status;
|
||||
|
||||
@DictFormat(SysDictTypeConstants.PAY_REFUND_ORDER_TYPE)
|
||||
@DictFormat(DictTypeConstants.PAY_REFUND_ORDER_TYPE)
|
||||
@ExcelProperty(value = "退款类型", converter = DictConvert.class)
|
||||
private Integer type;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.enums.InfDictTypeConstants;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -24,11 +24,11 @@ public class ToolTestDemoExcelVO {
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty(value = "类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.OPERATE_TYPE)
|
||||
@DictFormat(DictTypeConstants.OPERATE_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty(value = "分类", converter = DictConvert.class)
|
||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.adminserver.BaseRedisIntegrationTest;
|
||||
import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer;
|
||||
import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer;
|
||||
import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage;
|
||||
import cn.iocoder.yudao.module.system.mq.message.sms.SysSmsSendMessage;
|
||||
import cn.iocoder.yudao.framework.mq.core.util.RedisMessageUtils;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl;
|
||||
import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsLogServiceImpl;
|
||||
import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsTemplateServiceImpl;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.impl.SysSmsCoreServiceImpl;
|
||||
import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.sms.config.YudaoSmsAutoConfiguration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.infra.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* System 错误码枚举类
|
||||
*
|
||||
* system 系统,使用 1-006-000-000 段
|
||||
*/
|
||||
public interface SysErrorCodeConstants {
|
||||
|
||||
// ========= 文件相关 1006001000=================
|
||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1006001000, "文件路径已存在");
|
||||
ErrorCode FILE_NOT_EXISTS = new ErrorCode(1006001002, "文件不存在");
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* 占位类,可以无视
|
||||
*/
|
||||
package cn.iocoder.yudao.coreservice.modules.infra.enums;
|
@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.coreservice.modules.infra.enums.SysErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
|
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.logger.SysLoginLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SysLoginLogCoreConvert {
|
||||
|
||||
SysLoginLogCoreConvert INSTANCE = Mappers.getMapper(SysLoginLogCoreConvert.class);
|
||||
|
||||
SysLoginLogDO convert(SysLoginLogCreateReqDTO bean);
|
||||
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* 提供 POJO 类的实体转换
|
||||
*
|
||||
* 目前使用 MapStruct 框架
|
||||
*/
|
||||
package cn.iocoder.yudao.coreservice.modules.system.convert;
|
@ -1 +0,0 @@
|
||||
<http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>
|
@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject;
|
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.dict;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dict.SysDictDataDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Mapper
|
||||
public interface SysDictDataCoreMapper extends BaseMapperX<SysDictDataDO> {
|
||||
|
||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||
return selectOne(new QueryWrapper<SysDictDataDO>().select("id")
|
||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
||||
}
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql;
|
@ -1,13 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysSmsLogCoreMapper extends BaseMapperX<SysSmsLogDO> {
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Mapper
|
||||
public interface SysSmsTemplateCoreMapper extends BaseMapperX<SysSmsTemplateDO> {
|
||||
|
||||
@Select("SELECT id FROM sys_sms_template WHERE update_time > #{maxUpdateTime} LIMIT 1")
|
||||
Long selectExistsByUpdateTimeAfter(Date maxUpdateTime);
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.user;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.dal.redis;
|
||||
|
||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static cn.iocoder.yudao.framework.redis.core.RedisKeyDefine.KeyTypeEnum.STRING;
|
||||
|
||||
/**
|
||||
* System Redis Key 枚举类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysRedisKeyCoreConstants {
|
||||
|
||||
RedisKeyDefine LOGIN_USER = new RedisKeyDefine("登录用户的缓存",
|
||||
"login_user:%s", // 参数为 sessionId
|
||||
STRING, LoginUser.class, RedisKeyDefine.TimeoutTypeEnum.DYNAMIC);
|
||||
|
||||
RedisKeyDefine SOCIAL_AUTH_USER = new RedisKeyDefine("社交登陆的授权用户",
|
||||
"social_auth_user:%d:%s", // 参数为 type,code
|
||||
STRING, AuthUser.class, Duration.ofDays(1));
|
||||
|
||||
RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交登陆的 state",
|
||||
"social_auth_state:%s", // 参数为 state
|
||||
STRING, String.class, Duration.ofHours(24)); // 值为 state
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.coreservice.modules.system.mq.message;
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.coreservice.modules.system.mq.producer;
|
@ -1,41 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.mq.producer.sms;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage;
|
||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sms 短信相关消息的 Core Producer
|
||||
*
|
||||
* @author zzf
|
||||
* @date 2021/3/9 16:35
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysSmsCoreProducer {
|
||||
|
||||
@Resource
|
||||
private RedisMQTemplate redisMQTemplate;
|
||||
|
||||
/**
|
||||
* 发送 {@link SysSmsSendMessage} 消息
|
||||
*
|
||||
* @param logId 短信日志编号
|
||||
* @param mobile 手机号
|
||||
* @param channelId 渠道编号
|
||||
* @param apiTemplateId 短信模板编号
|
||||
* @param templateParams 短信模板参数
|
||||
*/
|
||||
public void sendSmsSendMessage(Long logId, String mobile,
|
||||
Long channelId, String apiTemplateId, List<KeyValue<String, Object>> templateParams) {
|
||||
SysSmsSendMessage message = new SysSmsSendMessage().setLogId(logId).setMobile(mobile);
|
||||
message.setChannelId(channelId).setApiTemplateId(apiTemplateId).setTemplateParams(templateParams);
|
||||
redisMQTemplate.send(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
/**
|
||||
* system 包下,我们放通用业务,支撑上层的核心业务。
|
||||
* 例如说:用户、部门、权限、数据字典等等
|
||||
*
|
||||
* 缩写:sys
|
||||
*/
|
||||
package cn.iocoder.yudao.coreservice.modules.system;
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.auth;
|
||||
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
|
||||
/**
|
||||
* 在线用户 Session Core Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysUserSessionCoreService {
|
||||
|
||||
/**
|
||||
* 创建在线用户 Session
|
||||
*
|
||||
* @param loginUser 登录用户
|
||||
* @param userIp 用户 IP
|
||||
* @param userAgent 用户 UA
|
||||
* @return Session 编号
|
||||
*/
|
||||
String createUserSession(LoginUser loginUser, String userIp, String userAgent);
|
||||
|
||||
/**
|
||||
* 刷新在线用户 Session 的更新时间
|
||||
*
|
||||
* @param sessionId Session 编号
|
||||
* @param loginUser 登录用户
|
||||
*/
|
||||
void refreshUserSession(String sessionId, LoginUser loginUser);
|
||||
|
||||
/**
|
||||
* 删除在线用户 Session
|
||||
*
|
||||
* @param sessionId Session 编号
|
||||
*/
|
||||
void deleteUserSession(String sessionId);
|
||||
|
||||
/**
|
||||
* 获得 Session 编号对应的在线用户
|
||||
*
|
||||
* @param sessionId Session 编号
|
||||
* @return 在线用户
|
||||
*/
|
||||
LoginUser getLoginUser(String sessionId);
|
||||
|
||||
/**
|
||||
* 获得 Session 超时时间,单位:毫秒
|
||||
*
|
||||
* @return 超时时间
|
||||
*/
|
||||
Long getSessionTimeoutMillis();
|
||||
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.auth.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.auth.SysUserSessionCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.redis.auth.SysLoginUserCoreRedisDAO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.addTime;
|
||||
|
||||
/**
|
||||
* 在线用户 Session Core Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class SysUserSessionCoreServiceImpl implements SysUserSessionCoreService {
|
||||
|
||||
@Resource
|
||||
private SysUserSessionCoreMapper userSessionCoreMapper;
|
||||
|
||||
@Resource
|
||||
private SysLoginUserCoreRedisDAO loginUserCoreRedisDAO;
|
||||
|
||||
@Resource
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@Override
|
||||
public String createUserSession(LoginUser loginUser, String userIp, String userAgent) {
|
||||
// 生成 Session 编号
|
||||
String sessionId = generateSessionId();
|
||||
// 写入 Redis 缓存
|
||||
loginUser.setUpdateTime(new Date());
|
||||
loginUserCoreRedisDAO.set(sessionId, loginUser);
|
||||
// 写入 DB 中
|
||||
SysUserSessionDO userSession = SysUserSessionDO.builder().id(sessionId)
|
||||
.userId(loginUser.getId()).userType(loginUser.getUserType())
|
||||
.userIp(userIp).userAgent(userAgent).username(loginUser.getUsername())
|
||||
.sessionTimeout(addTime(Duration.ofMillis(getSessionTimeoutMillis())))
|
||||
.build();
|
||||
userSessionCoreMapper.insert(userSession);
|
||||
// 返回 Session 编号
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUserSession(String sessionId, LoginUser loginUser) {
|
||||
// 写入 Redis 缓存
|
||||
loginUser.setUpdateTime(new Date());
|
||||
loginUserCoreRedisDAO.set(sessionId, loginUser);
|
||||
// 更新 DB 中
|
||||
SysUserSessionDO updateObj = SysUserSessionDO.builder().id(sessionId).build();
|
||||
updateObj.setUsername(loginUser.getUsername());
|
||||
updateObj.setUpdateTime(new Date());
|
||||
updateObj.setSessionTimeout(addTime(Duration.ofMillis(getSessionTimeoutMillis())));
|
||||
userSessionCoreMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserSession(String sessionId) {
|
||||
// 删除 Redis 缓存
|
||||
loginUserCoreRedisDAO.delete(sessionId);
|
||||
// 删除 DB 记录
|
||||
userSessionCoreMapper.deleteById(sessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser getLoginUser(String sessionId) {
|
||||
return loginUserCoreRedisDAO.get(sessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSessionTimeoutMillis() {
|
||||
return securityProperties.getSessionTimeout().toMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Session 编号,目前采用 UUID 算法
|
||||
*
|
||||
* @return Session 编号
|
||||
*/
|
||||
private static String generateSessionId() {
|
||||
return IdUtil.fastSimpleUUID();
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dict;
|
||||
|
||||
import cn.iocoder.yudao.framework.dict.core.service.DictDataFrameworkService;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 字典数据 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysDictDataCoreService extends DictDataFrameworkService {
|
||||
|
||||
/**
|
||||
* 初始化字典数据的本地缓存
|
||||
*/
|
||||
void initLocalCache();
|
||||
|
||||
/**
|
||||
* 校验字典数据们是否有效。如下情况,视为无效:
|
||||
* 1. 字典数据不存在
|
||||
* 2. 字典数据被禁用
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param values 字典数据值的数组
|
||||
*/
|
||||
void validDictDatas(String dictType, Collection<String> values);
|
||||
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dict.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.convert.dict.SysDictDataCoreConvert;
|
||||
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;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
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 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysDictDataCoreServiceImpl implements SysDictDataCoreService {
|
||||
|
||||
/**
|
||||
* 定时执行 {@link #schedulePeriodicRefresh()} 的周期
|
||||
* 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高
|
||||
*/
|
||||
private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
|
||||
|
||||
/**
|
||||
* 字典数据缓存,第二个 key 使用 label
|
||||
*
|
||||
* key1:字典类型 dictType
|
||||
* key2:字典标签 label
|
||||
*/
|
||||
private ImmutableTable<String, String, SysDictDataDO> labelDictDataCache;
|
||||
/**
|
||||
* 字典数据缓存,第二个 key 使用 value
|
||||
*
|
||||
* key1:字典类型 dictType
|
||||
* key2:字典值 value
|
||||
*/
|
||||
private ImmutableTable<String, String, SysDictDataDO> valueDictDataCache;
|
||||
/**
|
||||
* 缓存字典数据的最大更新时间,用于后续的增量轮询,判断是否有更新
|
||||
*/
|
||||
private volatile Date maxUpdateTime;
|
||||
|
||||
@Resource
|
||||
private SysDictDataCoreMapper dictDataCoreMapper;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public synchronized void initLocalCache() {
|
||||
// 获取字典数据列表,如果有更新
|
||||
List<SysDictDataDO> dataList = this.loadDictDataIfUpdate(maxUpdateTime);
|
||||
if (CollUtil.isEmpty(dataList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建缓存
|
||||
ImmutableTable.Builder<String, String, SysDictDataDO> labelDictDataBuilder = ImmutableTable.builder();
|
||||
ImmutableTable.Builder<String, String, SysDictDataDO> valueDictDataBuilder = ImmutableTable.builder();
|
||||
dataList.forEach(dictData -> {
|
||||
labelDictDataBuilder.put(dictData.getDictType(), dictData.getLabel(), dictData);
|
||||
valueDictDataBuilder.put(dictData.getDictType(), dictData.getValue(), dictData);
|
||||
});
|
||||
labelDictDataCache = labelDictDataBuilder.build();
|
||||
valueDictDataCache = valueDictDataBuilder.build();
|
||||
assert dataList.size() > 0; // 断言,避免告警
|
||||
maxUpdateTime = dataList.stream().max(Comparator.comparing(BaseDO::getUpdateTime)).get().getUpdateTime();
|
||||
log.info("[initLocalCache][缓存字典数据,数量为:{}]", dataList.size());
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD)
|
||||
public void schedulePeriodicRefresh() {
|
||||
initLocalCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果字典数据发生变化,从数据库中获取最新的全量字典数据。
|
||||
* 如果未发生变化,则返回空
|
||||
*
|
||||
* @param maxUpdateTime 当前字典数据的最大更新时间
|
||||
* @return 字典数据列表
|
||||
*/
|
||||
private List<SysDictDataDO> loadDictDataIfUpdate(Date maxUpdateTime) {
|
||||
// 第一步,判断是否要更新。
|
||||
if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据
|
||||
log.info("[loadDictDataIfUpdate][首次加载全量字典数据]");
|
||||
} else { // 判断数据库中是否有更新的字典数据
|
||||
if (!dictDataCoreMapper.selectExistsByUpdateTimeAfter(maxUpdateTime)) {
|
||||
return null;
|
||||
}
|
||||
log.info("[loadDictDataIfUpdate][增量加载全量字典数据]");
|
||||
}
|
||||
// 第二步,如果有更新,则从数据库加载所有字典数据
|
||||
return dictDataCoreMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDataRespDTO getDictDataFromCache(String type, String value) {
|
||||
return SysDictDataCoreConvert.INSTANCE.convert02(valueDictDataCache.get(type, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDataRespDTO parseDictDataFromCache(String type, String label) {
|
||||
return SysDictDataCoreConvert.INSTANCE.convert02(labelDictDataCache.get(type, label));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDataRespDTO> listDictDatasFromCache(String type) {
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
|
||||
/**
|
||||
* 登录日志 Core Service 接口
|
||||
*/
|
||||
public interface SysLoginLogCoreService {
|
||||
|
||||
/**
|
||||
* 创建登录日志
|
||||
*
|
||||
* @param reqDTO 日志信息
|
||||
*/
|
||||
void createLoginLog(SysLoginLogCreateReqDTO reqDTO);
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.logger.impl;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.convert.logger.SysLoginLogCoreConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.logger.SysLoginLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.logger.SysLoginLogCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 登录日志 Service Core 实现
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class SysLoginLogCoreServiceImpl implements SysLoginLogCoreService {
|
||||
|
||||
@Resource
|
||||
private SysLoginLogCoreMapper loginLogMapper;
|
||||
|
||||
@Override
|
||||
public void createLoginLog(SysLoginLogCreateReqDTO reqDTO) {
|
||||
SysLoginLogDO loginLog = SysLoginLogCoreConvert.INSTANCE.convert(reqDTO);
|
||||
// 插入
|
||||
loginLogMapper.insert(loginLog);
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.sms;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信日志 Core Service 接口
|
||||
*
|
||||
* @author zzf
|
||||
* @date 13:48 2021/3/2
|
||||
*/
|
||||
public interface SysSmsLogCoreService {
|
||||
|
||||
/**
|
||||
* 创建短信日志
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param userId 用户编号
|
||||
* @param userType 用户类型
|
||||
* @param isSend 是否发送
|
||||
* @param template 短信模板
|
||||
* @param templateContent 短信内容
|
||||
* @param templateParams 短信参数
|
||||
* @return 发送日志编号
|
||||
*/
|
||||
Long createSmsLog(String mobile, Long userId, Integer userType, Boolean isSend,
|
||||
SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams);
|
||||
|
||||
/**
|
||||
* 更新日志的发送结果
|
||||
*
|
||||
* @param id 日志编号
|
||||
* @param sendCode 发送结果的编码
|
||||
* @param sendMsg 发送结果的提示
|
||||
* @param apiSendCode 短信 API 发送结果的编码
|
||||
* @param apiSendMsg 短信 API 发送失败的提示
|
||||
* @param apiRequestId 短信 API 发送返回的唯一请求 ID
|
||||
* @param apiSerialNo 短信 API 发送返回的序号
|
||||
*/
|
||||
void updateSmsSendResult(Long id, Integer sendCode, String sendMsg,
|
||||
String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo);
|
||||
|
||||
/**
|
||||
* 更新日志的接收结果
|
||||
*
|
||||
* @param id 日志编号
|
||||
* @param success 是否接收成功
|
||||
* @param receiveTime 用户接收时间
|
||||
* @param apiReceiveCode API 接收结果的编码
|
||||
* @param apiReceiveMsg API 接收结果的说明
|
||||
*/
|
||||
void updateSmsReceiveResult(Long id, Boolean success, Date receiveTime, String apiReceiveCode, String apiReceiveMsg);
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.sms;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信模板 Core Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysSmsTemplateCoreService {
|
||||
|
||||
/**
|
||||
* 初始化短信模板的本地缓存
|
||||
*/
|
||||
void initLocalCache();
|
||||
|
||||
/**
|
||||
* 获得短信模板,从缓存中
|
||||
*
|
||||
* @param code 模板编码
|
||||
* @return 短信模板
|
||||
*/
|
||||
SysSmsTemplateDO getSmsTemplateByCodeFromCache(String code);
|
||||
|
||||
/**
|
||||
* 格式化短信内容
|
||||
*
|
||||
* @param content 短信模板的内容
|
||||
* @param params 内容的参数
|
||||
* @return 格式化后的内容
|
||||
*/
|
||||
String formatSmsTemplateContent(String content, Map<String, Object> params);
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.sms.impl;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsLogCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsReceiveStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsSendStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsLogCoreService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 短信日志 Core Service 实现类
|
||||
*
|
||||
* @author zzf
|
||||
* @date 2021/1/25 9:25
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysSmsLogCoreServiceImpl implements SysSmsLogCoreService {
|
||||
|
||||
@Resource
|
||||
private SysSmsLogCoreMapper smsLogCoreMapper;
|
||||
|
||||
@Override
|
||||
public Long createSmsLog(String mobile, Long userId, Integer userType, Boolean isSend,
|
||||
SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams) {
|
||||
SysSmsLogDO.SysSmsLogDOBuilder logBuilder = SysSmsLogDO.builder();
|
||||
// 根据是否要发送,设置状态
|
||||
logBuilder.sendStatus(Objects.equals(isSend, true) ? SysSmsSendStatusEnum.INIT.getStatus()
|
||||
: SysSmsSendStatusEnum.IGNORE.getStatus());
|
||||
// 设置手机相关字段
|
||||
logBuilder.mobile(mobile).userId(userId).userType(userType);
|
||||
// 设置模板相关字段
|
||||
logBuilder.templateId(template.getId()).templateCode(template.getCode()).templateType(template.getType());
|
||||
logBuilder.templateContent(templateContent).templateParams(templateParams).apiTemplateId(template.getApiTemplateId());
|
||||
// 设置渠道相关字段
|
||||
logBuilder.channelId(template.getChannelId()).channelCode(template.getChannelCode());
|
||||
// 设置接收相关字段
|
||||
logBuilder.receiveStatus(SysSmsReceiveStatusEnum.INIT.getStatus());
|
||||
|
||||
// 插入数据库
|
||||
SysSmsLogDO logDO = logBuilder.build();
|
||||
smsLogCoreMapper.insert(logDO);
|
||||
return logDO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSmsSendResult(Long id, Integer sendCode, String sendMsg,
|
||||
String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo) {
|
||||
SysSmsSendStatusEnum sendStatus = CommonResult.isSuccess(sendCode) ? SysSmsSendStatusEnum.SUCCESS
|
||||
: SysSmsSendStatusEnum.FAILURE;
|
||||
smsLogCoreMapper.updateById(SysSmsLogDO.builder().id(id).sendStatus(sendStatus.getStatus()).sendTime(new Date())
|
||||
.sendCode(sendCode).sendMsg(sendMsg).apiSendCode(apiSendCode).apiSendMsg(apiSendMsg)
|
||||
.apiRequestId(apiRequestId).apiSerialNo(apiSerialNo).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSmsReceiveResult(Long id, Boolean success, Date receiveTime, String apiReceiveCode, String apiReceiveMsg) {
|
||||
SysSmsReceiveStatusEnum receiveStatus = Objects.equals(success, true) ? SysSmsReceiveStatusEnum.SUCCESS
|
||||
: SysSmsReceiveStatusEnum.FAILURE;
|
||||
smsLogCoreMapper.updateById(SysSmsLogDO.builder().id(id).receiveStatus(receiveStatus.getStatus()).receiveTime(receiveTime)
|
||||
.apiReceiveCode(apiReceiveCode).apiReceiveMsg(apiReceiveMsg).build());
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.sms.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsTemplateCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsTemplateCoreService;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
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.Map;
|
||||
|
||||
/**
|
||||
* 短信模板 Core Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysSmsTemplateCoreServiceImpl implements SysSmsTemplateCoreService {
|
||||
|
||||
/**
|
||||
* 定时执行 {@link #schedulePeriodicRefresh()} 的周期
|
||||
* 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高
|
||||
*/
|
||||
private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
|
||||
|
||||
/**
|
||||
* 短信模板缓存
|
||||
* key:短信模板编码 {@link SysSmsTemplateDO#getCode()}
|
||||
*
|
||||
* 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
|
||||
*/
|
||||
private volatile Map<String, SysSmsTemplateDO> smsTemplateCache;
|
||||
/**
|
||||
* 缓存短信模板的最大更新时间,用于后续的增量轮询,判断是否有更新
|
||||
*/
|
||||
private volatile Date maxUpdateTime;
|
||||
|
||||
@Resource
|
||||
private SysSmsTemplateCoreMapper smsTemplateCoreMapper;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void initLocalCache() {
|
||||
// 获取短信模板列表,如果有更新
|
||||
List<SysSmsTemplateDO> smsTemplateList = this.loadSmsTemplateIfUpdate(maxUpdateTime);
|
||||
if (CollUtil.isEmpty(smsTemplateList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 写入缓存
|
||||
ImmutableMap.Builder<String, SysSmsTemplateDO> builder = ImmutableMap.builder();
|
||||
smsTemplateList.forEach(sysSmsTemplateDO -> builder.put(sysSmsTemplateDO.getCode(), sysSmsTemplateDO));
|
||||
smsTemplateCache = builder.build();
|
||||
assert smsTemplateList.size() > 0; // 断言,避免告警
|
||||
maxUpdateTime = smsTemplateList.stream().max(Comparator.comparing(BaseDO::getUpdateTime)).get().getUpdateTime();
|
||||
log.info("[initLocalCache][初始化 SmsTemplate 数量为 {}]", smsTemplateList.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果短信模板发生变化,从数据库中获取最新的全量短信模板。
|
||||
* 如果未发生变化,则返回空
|
||||
*
|
||||
* @param maxUpdateTime 当前短信模板的最大更新时间
|
||||
* @return 短信模板列表
|
||||
*/
|
||||
private List<SysSmsTemplateDO> loadSmsTemplateIfUpdate(Date maxUpdateTime) {
|
||||
// 第一步,判断是否要更新。
|
||||
if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据
|
||||
log.info("[loadSmsTemplateIfUpdate][首次加载全量短信模板]");
|
||||
} else { // 判断数据库中是否有更新的短信模板
|
||||
if (smsTemplateCoreMapper.selectExistsByUpdateTimeAfter(maxUpdateTime) == null) {
|
||||
return null;
|
||||
}
|
||||
log.info("[loadSmsTemplateIfUpdate][增量加载全量短信模板]");
|
||||
}
|
||||
// 第二步,如果有更新,则从数据库加载所有短信模板
|
||||
return smsTemplateCoreMapper.selectList();
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD)
|
||||
public void schedulePeriodicRefresh() {
|
||||
initLocalCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysSmsTemplateDO getSmsTemplateByCodeFromCache(String code) {
|
||||
return smsTemplateCache.get(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatSmsTemplateContent(String content, Map<String, Object> params) {
|
||||
return StrUtil.format(content, params);
|
||||
}
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
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 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysUserCoreService {
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
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,82 +0,0 @@
|
||||
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 实现
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class SysUserCoreServiceImpl implements SysUserCoreService {
|
||||
|
||||
@Resource
|
||||
private SysUserCoreMapper userCoreMapper;
|
||||
|
||||
@Override
|
||||
public SysUserDO getUser(Long id) {
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,7 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.FILE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.FILE_PATH_EXISTS;
|
||||
import static cn.iocoder.yudao.coreservice.modules.infra.enums.SysErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString;
|
||||
|
@ -1,125 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.BaseDbAndRedisUnitTest;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.auth.SysUserSessionCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.redis.auth.SysLoginUserCoreRedisDAO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.auth.impl.SysUserSessionCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.addTime;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@Import({SysUserSessionCoreServiceImpl.class, SysLoginUserCoreRedisDAO.class})
|
||||
public class SysUserSessionCoreServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
@Resource
|
||||
private SysUserSessionCoreServiceImpl userSessionCoreService;
|
||||
|
||||
@Resource
|
||||
private SysUserSessionCoreMapper userSessionCoreMapper;
|
||||
@Resource
|
||||
private SysLoginUserCoreRedisDAO loginUserCoreRedisDAO;
|
||||
|
||||
@MockBean
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@Test
|
||||
public void testCreateUserSession_success() {
|
||||
// 准备参数
|
||||
String userIp = randomString();
|
||||
String userAgent = randomString();
|
||||
LoginUser loginUser = randomPojo(LoginUser.class, o -> {
|
||||
o.setUserType(randomEle(UserTypeEnum.values()).getValue());
|
||||
o.setTenantId(0L); // 租户设置为 0,因为暂未启用多租户组件
|
||||
});
|
||||
// mock 方法
|
||||
when(securityProperties.getSessionTimeout()).thenReturn(Duration.ofDays(1));
|
||||
|
||||
// 调用
|
||||
String sessionId = userSessionCoreService.createUserSession(loginUser, userIp, userAgent);
|
||||
// 校验 SysUserSessionDO 记录
|
||||
SysUserSessionDO userSessionDO = userSessionCoreMapper.selectById(sessionId);
|
||||
assertPojoEquals(loginUser, userSessionDO, "id", "updateTime");
|
||||
assertEquals(sessionId, userSessionDO.getId());
|
||||
assertEquals(userIp, userSessionDO.getUserIp());
|
||||
assertEquals(userAgent, userSessionDO.getUserAgent());
|
||||
// 校验 LoginUser 缓存
|
||||
LoginUser redisLoginUser = loginUserCoreRedisDAO.get(sessionId);
|
||||
assertPojoEquals(loginUser, redisLoginUser, "username", "password");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateRefreshUserSession_success() {
|
||||
// 准备参数
|
||||
String sessionId = randomString();
|
||||
String userIp = randomString();
|
||||
String userAgent = randomString();
|
||||
long timeLong = randomLongId();
|
||||
String userName = randomString();
|
||||
Date date = randomDate();
|
||||
LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setUserType(randomEle(UserTypeEnum.values()).getValue()));
|
||||
// mock 方法
|
||||
when(securityProperties.getSessionTimeout()).thenReturn(Duration.ofDays(1));
|
||||
// mock 数据
|
||||
loginUser.setUpdateTime(date);
|
||||
loginUserCoreRedisDAO.set(sessionId, loginUser);
|
||||
SysUserSessionDO userSession = SysUserSessionDO.builder().id(sessionId)
|
||||
.userId(loginUser.getId()).userType(loginUser.getUserType())
|
||||
.userIp(userIp).userAgent(userAgent).username(userName)
|
||||
.sessionTimeout(addTime(Duration.ofMillis(timeLong)))
|
||||
.build();
|
||||
userSessionCoreMapper.insert(userSession);
|
||||
|
||||
// 调用
|
||||
userSessionCoreService.refreshUserSession(sessionId, loginUser);
|
||||
// 校验 LoginUser 缓存
|
||||
LoginUser redisLoginUser = loginUserCoreRedisDAO.get(sessionId);
|
||||
assertNotEquals(redisLoginUser.getUpdateTime(), date);
|
||||
// 校验 SysUserSessionDO 记录
|
||||
SysUserSessionDO updateDO = userSessionCoreMapper.selectById(sessionId);
|
||||
assertEquals(updateDO.getUsername(), loginUser.getUsername());
|
||||
assertNotEquals(updateDO.getUpdateTime(), userSession.getUpdateTime());
|
||||
assertNotEquals(updateDO.getSessionTimeout(), addTime(Duration.ofMillis(timeLong)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteUserSession_success() {
|
||||
// 准备参数
|
||||
String sessionId = randomString();
|
||||
String userIp = randomString();
|
||||
String userAgent = randomString();
|
||||
Long timeLong = randomLongId();
|
||||
LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setUserType(randomEle(UserTypeEnum.values()).getValue()));
|
||||
// mock 存入 Redis
|
||||
when(securityProperties.getSessionTimeout()).thenReturn(Duration.ofDays(1));
|
||||
// mock 数据
|
||||
loginUserCoreRedisDAO.set(sessionId, loginUser);
|
||||
SysUserSessionDO userSession = SysUserSessionDO.builder().id(sessionId)
|
||||
.userId(loginUser.getId()).userType(loginUser.getUserType())
|
||||
.userIp(userIp).userAgent(userAgent).username(loginUser.getUsername())
|
||||
.sessionTimeout(addTime(Duration.ofMillis(timeLong)))
|
||||
.build();
|
||||
userSessionCoreMapper.insert(userSession);
|
||||
|
||||
// 调用
|
||||
userSessionCoreService.deleteUserSession(sessionId);
|
||||
// 校验数据不存在了
|
||||
assertNull(loginUserCoreRedisDAO.get(sessionId));
|
||||
assertNull(userSessionCoreMapper.selectById(sessionId));
|
||||
}
|
||||
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.dict;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
|
||||
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.impl.SysDictDataCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static cn.hutool.core.bean.BeanUtil.getFieldValue;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomCommonStatus;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* {@link SysDictDataCoreServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(SysDictDataCoreServiceImpl.class)
|
||||
public class SysDictDataCoreServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private SysDictDataCoreServiceImpl dictDataCoreService;
|
||||
|
||||
@Resource
|
||||
private SysDictDataCoreMapper dictDataMapper;
|
||||
|
||||
/**
|
||||
* 测试加载到新的字典数据的情况
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testInitLocalCache() {
|
||||
// mock 数据
|
||||
SysDictDataDO dictData01 = randomDictDataDO();
|
||||
dictDataMapper.insert(dictData01);
|
||||
SysDictDataDO dictData02 = randomDictDataDO();
|
||||
dictDataMapper.insert(dictData02);
|
||||
|
||||
// 调用
|
||||
dictDataCoreService.initLocalCache();
|
||||
// 断言 labelDictDataCache 缓存
|
||||
ImmutableTable<String, String, SysDictDataDO> labelDictDataCache =
|
||||
(ImmutableTable<String, String, SysDictDataDO>) getFieldValue(dictDataCoreService, "labelDictDataCache");
|
||||
assertEquals(2, labelDictDataCache.size());
|
||||
assertPojoEquals(dictData01, labelDictDataCache.get(dictData01.getDictType(), dictData01.getLabel()));
|
||||
assertPojoEquals(dictData02, labelDictDataCache.get(dictData02.getDictType(), dictData02.getLabel()));
|
||||
// 断言 valueDictDataCache 缓存
|
||||
ImmutableTable<String, String, SysDictDataDO> valueDictDataCache =
|
||||
(ImmutableTable<String, String, SysDictDataDO>) getFieldValue(dictDataCoreService, "valueDictDataCache");
|
||||
assertEquals(2, valueDictDataCache.size());
|
||||
assertPojoEquals(dictData01, valueDictDataCache.get(dictData01.getDictType(), dictData01.getValue()));
|
||||
assertPojoEquals(dictData02, valueDictDataCache.get(dictData02.getDictType(), dictData02.getValue()));
|
||||
// 断言 maxUpdateTime 缓存
|
||||
Date maxUpdateTime = (Date) getFieldValue(dictDataCoreService, "maxUpdateTime");
|
||||
assertEquals(ObjectUtils.max(dictData01.getUpdateTime(), dictData02.getUpdateTime()), maxUpdateTime);
|
||||
}
|
||||
|
||||
// ========== 随机对象 ==========
|
||||
|
||||
@SafeVarargs
|
||||
private static SysDictDataDO randomDictDataDO(Consumer<SysDictDataDO>... consumers) {
|
||||
Consumer<SysDictDataDO> consumer = (o) -> {
|
||||
o.setStatus(randomCommonStatus()); // 保证 status 的范围
|
||||
};
|
||||
return randomPojo(SysDictDataDO.class, ArrayUtils.append(consumer, consumers));
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.logger.SysLoginLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.logger.SysLoginLogCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginLogTypeEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.impl.SysLoginLogCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
|
||||
@Import(SysLoginLogCoreServiceImpl.class)
|
||||
public class SysLoginLogServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private SysLoginLogCoreServiceImpl loginLogCoreService;
|
||||
|
||||
@Resource
|
||||
private SysLoginLogCoreMapper loginLogCoreMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateLoginLog() {
|
||||
SysLoginLogCreateReqDTO reqDTO = RandomUtils.randomPojo(SysLoginLogCreateReqDTO.class, vo -> {
|
||||
// 指定随机的范围,避免超出范围入库失败
|
||||
vo.setUserType(randomEle(UserTypeEnum.values()).getValue());
|
||||
vo.setLogType(randomEle(SysLoginLogTypeEnum.values()).getType());
|
||||
vo.setResult(randomEle(SysLoginResultEnum.values()).getResult());
|
||||
vo.setTraceId(TracerUtils.getTraceId());
|
||||
});
|
||||
|
||||
// 调用
|
||||
loginLogCoreService.createLoginLog(reqDTO);
|
||||
// 断言,忽略基本字段
|
||||
SysLoginLogDO sysLoginLogDO = loginLogCoreMapper.selectOne(null);
|
||||
assertPojoEquals(reqDTO, sysLoginLogDO);
|
||||
}
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service;
|
@ -1,149 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.sms;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsLogCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsReceiveStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsSendStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.impl.SysSmsLogCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomBoolean;
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* {@link SysSmsLogCoreServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(SysSmsLogCoreServiceImpl.class)
|
||||
public class SysSmsLogCoreServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private SysSmsLogCoreServiceImpl smsLogCoreService;
|
||||
|
||||
@Resource
|
||||
private SysSmsLogCoreMapper smsLogCoreMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateSmsLog() {
|
||||
// 准备参数
|
||||
String mobile = randomString();
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
Boolean isSend = randomBoolean();
|
||||
SysSmsTemplateDO templateDO = randomPojo(SysSmsTemplateDO.class,
|
||||
o -> o.setType(randomEle(SysSmsTemplateTypeEnum.values()).getType()));
|
||||
String templateContent = randomString();
|
||||
Map<String, Object> templateParams = randomTemplateParams();
|
||||
// mock 方法
|
||||
|
||||
// 调用
|
||||
Long logId = smsLogCoreService.createSmsLog(mobile, userId, userType, isSend,
|
||||
templateDO, templateContent, templateParams);
|
||||
// 断言
|
||||
SysSmsLogDO logDO = smsLogCoreMapper.selectById(logId);
|
||||
assertEquals(isSend ? SysSmsSendStatusEnum.INIT.getStatus() : SysSmsSendStatusEnum.IGNORE.getStatus(),
|
||||
logDO.getSendStatus());
|
||||
assertEquals(mobile, logDO.getMobile());
|
||||
assertEquals(userType, logDO.getUserType());
|
||||
assertEquals(userId, logDO.getUserId());
|
||||
assertEquals(templateDO.getId(), logDO.getTemplateId());
|
||||
assertEquals(templateDO.getCode(), logDO.getTemplateCode());
|
||||
assertEquals(templateDO.getType(), logDO.getTemplateType());
|
||||
assertEquals(templateDO.getChannelId(), logDO.getChannelId());
|
||||
assertEquals(templateDO.getChannelCode(), logDO.getChannelCode());
|
||||
assertEquals(templateContent, logDO.getTemplateContent());
|
||||
assertEquals(templateParams, logDO.getTemplateParams());
|
||||
assertEquals(SysSmsReceiveStatusEnum.INIT.getStatus(), logDO.getReceiveStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSmsSendResult() {
|
||||
// mock 数据
|
||||
SysSmsLogDO dbSmsLog = randomSmsLogDO(
|
||||
o -> o.setSendStatus(SysSmsSendStatusEnum.IGNORE.getStatus()));
|
||||
smsLogCoreMapper.insert(dbSmsLog);
|
||||
// 准备参数
|
||||
Long id = dbSmsLog.getId();
|
||||
Integer sendCode = randomInteger();
|
||||
String sendMsg = randomString();
|
||||
String apiSendCode = randomString();
|
||||
String apiSendMsg = randomString();
|
||||
String apiRequestId = randomString();
|
||||
String apiSerialNo = randomString();
|
||||
|
||||
// 调用
|
||||
smsLogCoreService.updateSmsSendResult(id, sendCode, sendMsg,
|
||||
apiSendCode, apiSendMsg, apiRequestId, apiSerialNo);
|
||||
// 断言
|
||||
dbSmsLog = smsLogCoreMapper.selectById(id);
|
||||
assertEquals(CommonResult.isSuccess(sendCode) ? SysSmsSendStatusEnum.SUCCESS.getStatus()
|
||||
: SysSmsSendStatusEnum.FAILURE.getStatus(), dbSmsLog.getSendStatus());
|
||||
assertNotNull(dbSmsLog.getSendTime());
|
||||
assertEquals(sendMsg, dbSmsLog.getSendMsg());
|
||||
assertEquals(apiSendCode, dbSmsLog.getApiSendCode());
|
||||
assertEquals(apiSendMsg, dbSmsLog.getApiSendMsg());
|
||||
assertEquals(apiRequestId, dbSmsLog.getApiRequestId());
|
||||
assertEquals(apiSerialNo, dbSmsLog.getApiSerialNo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSmsReceiveResult() {
|
||||
// mock 数据
|
||||
SysSmsLogDO dbSmsLog = randomSmsLogDO(
|
||||
o -> o.setReceiveStatus(SysSmsReceiveStatusEnum.INIT.getStatus()));
|
||||
smsLogCoreMapper.insert(dbSmsLog);
|
||||
// 准备参数
|
||||
Long id = dbSmsLog.getId();
|
||||
Boolean success = randomBoolean();
|
||||
Date receiveTime = randomDate();
|
||||
String apiReceiveCode = randomString();
|
||||
String apiReceiveMsg = randomString();
|
||||
|
||||
// 调用
|
||||
smsLogCoreService.updateSmsReceiveResult(id, success, receiveTime, apiReceiveCode, apiReceiveMsg);
|
||||
// 断言
|
||||
dbSmsLog = smsLogCoreMapper.selectById(id);
|
||||
assertEquals(success ? SysSmsReceiveStatusEnum.SUCCESS.getStatus()
|
||||
: SysSmsReceiveStatusEnum.FAILURE.getStatus(), dbSmsLog.getReceiveStatus());
|
||||
assertEquals(receiveTime, dbSmsLog.getReceiveTime());
|
||||
assertEquals(apiReceiveCode, dbSmsLog.getApiReceiveCode());
|
||||
assertEquals(apiReceiveMsg, dbSmsLog.getApiReceiveMsg());
|
||||
}
|
||||
|
||||
// ========== 随机对象 ==========
|
||||
|
||||
@SafeVarargs
|
||||
private static SysSmsLogDO randomSmsLogDO(Consumer<SysSmsLogDO>... consumers) {
|
||||
Consumer<SysSmsLogDO> consumer = (o) -> {
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
o.setTemplateType(randomEle(SysSmsTemplateTypeEnum.values()).getType()); // 保证 templateType 的范围
|
||||
o.setUserType(randomEle(UserTypeEnum.values()).getValue()); // 保证 userType 的范围
|
||||
o.setSendStatus(randomEle(SysSmsSendStatusEnum.values()).getStatus()); // 保证 sendStatus 的范围
|
||||
o.setReceiveStatus(randomEle(SysSmsReceiveStatusEnum.values()).getStatus()); // 保证 receiveStatus 的范围
|
||||
};
|
||||
return randomPojo(SysSmsLogDO.class, ArrayUtils.append(consumer, consumers));
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, Object> randomTemplateParams() {
|
||||
return MapUtil.<String, Object>builder().put(randomString(), randomString())
|
||||
.put(randomString(), randomString()).build();
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.service.sms;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsTemplateCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.impl.SysSmsTemplateCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static cn.hutool.core.bean.BeanUtil.getFieldValue;
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.max;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* {@link SysSmsTemplateCoreServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(SysSmsTemplateCoreServiceImpl.class)
|
||||
public class SysSmsTemplateServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private SysSmsTemplateCoreServiceImpl smsTemplateCoreService;
|
||||
|
||||
@Resource
|
||||
private SysSmsTemplateCoreMapper smsTemplateCoreMapper;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void testInitLocalCache() {
|
||||
// mock 数据
|
||||
SysSmsTemplateDO smsTemplate01 = randomSmsTemplateDO();
|
||||
smsTemplateCoreMapper.insert(smsTemplate01);
|
||||
SysSmsTemplateDO smsTemplate02 = randomSmsTemplateDO();
|
||||
smsTemplateCoreMapper.insert(smsTemplate02);
|
||||
|
||||
// 调用
|
||||
smsTemplateCoreService.initLocalCache();
|
||||
// 断言 deptCache 缓存
|
||||
Map<String, SysSmsTemplateDO> smsTemplateCache = (Map<String, SysSmsTemplateDO>) getFieldValue(smsTemplateCoreService, "smsTemplateCache");
|
||||
assertEquals(2, smsTemplateCache.size());
|
||||
assertPojoEquals(smsTemplate01, smsTemplateCache.get(smsTemplate01.getCode()));
|
||||
assertPojoEquals(smsTemplate02, smsTemplateCache.get(smsTemplate02.getCode()));
|
||||
// 断言 maxUpdateTime 缓存
|
||||
Date maxUpdateTime = (Date) getFieldValue(smsTemplateCoreService, "maxUpdateTime");
|
||||
assertEquals(max(smsTemplate01.getUpdateTime(), smsTemplate02.getUpdateTime()), maxUpdateTime);
|
||||
}
|
||||
|
||||
// ========== 随机对象 ==========
|
||||
|
||||
@SafeVarargs
|
||||
private static SysSmsTemplateDO randomSmsTemplateDO(Consumer<SysSmsTemplateDO>... consumers) {
|
||||
Consumer<SysSmsTemplateDO> consumer = (o) -> {
|
||||
o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围
|
||||
o.setType(randomEle(SysSmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围
|
||||
};
|
||||
return randomPojo(SysSmsTemplateDO.class, ArrayUtils.append(consumer, consumers));
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.message;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import org.activiti.api.task.model.Task;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.mapstruct.Mapper;
|
||||
|
@ -5,8 +5,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmP
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
|
@ -4,8 +4,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskD
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskTodoPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.enums.message;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -7,9 +7,9 @@ import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.identity
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.listener.BpmTackActivitiEventListener;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import org.activiti.api.runtime.shared.identity.UserGroupManager;
|
||||
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
@ -3,9 +3,9 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavio
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Setter;
|
||||
|
@ -9,11 +9,11 @@ import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.Setter;
|
||||
|
@ -2,17 +2,16 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavio
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
/**
|
||||
|
@ -14,12 +14,12 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelServi
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysPostCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dict.SysDictDataCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysRoleCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysPostCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.dict.DictDataCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.SysRoleCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
@ -64,7 +64,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
||||
@Resource
|
||||
private BpmUserGroupServiceApi userGroupServiceApi;
|
||||
@Resource
|
||||
private SysDictDataCoreService dictDataCoreService;
|
||||
private DictDataCoreService dictDataCoreService;
|
||||
|
||||
@Override
|
||||
public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
|
||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.message.BpmMessageServic
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SysSmsCoreService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -18,10 +18,10 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.message.BpmMessageServic
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -12,10 +12,10 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.message.BpmMessageServic
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
|
@ -8,11 +8,11 @@ import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi;
|
||||
import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.impl;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
|
@ -24,6 +24,12 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-system-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
|
@ -1,11 +1,9 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.app.auth.vo.*;
|
||||
import cn.iocoder.yudao.module.member.service.auth.AuthService;
|
||||
import cn.iocoder.yudao.module.member.service.sms.SysSmsCodeService;
|
||||
@ -15,7 +13,6 @@ import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.auth.vo;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.auth.vo;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -22,7 +22,7 @@ import javax.validation.constraints.Pattern;
|
||||
public class AppAuthSocialLogin2ReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.auth.vo;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -20,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
public class AppAuthSocialLoginReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.auth.vo;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -20,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
public class AppAuthSocialUnbindReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -2,13 +2,13 @@ package cn.iocoder.yudao.module.member.service.auth;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.social.SysSocialUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginLogTypeEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SysSocialUserDO;
|
||||
import cn.iocoder.yudao.module.system.enums.logger.SysLoginLogTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.logger.SysLoginResultEnum;
|
||||
import cn.iocoder.yudao.module.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.logger.SysLoginLogCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.logger.dto.SysLoginLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||
@ -29,7 +29,6 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.service.sms;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SysSmsCoreService;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.sms.SysSmsCodeDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.UserDO;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.member.service.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.logger.SysLoginLogCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.enums;
|
||||
package cn.iocoder.yudao.module.system.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
@ -14,10 +14,6 @@ public interface SysErrorCodeConstants {
|
||||
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1006000001, "模板参数({})缺失");
|
||||
ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1006000000, "短信模板不存在");
|
||||
|
||||
// ========= 文件相关 1006001000=================
|
||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1006001000, "文件路径已存在");
|
||||
ErrorCode FILE_NOT_EXISTS = new ErrorCode(1006001002, "文件不存在");
|
||||
|
||||
// ========== 社交模块 1006002000 ==========
|
||||
ErrorCode SOCIAL_AUTH_FAILURE = new ErrorCode(1006002000, "社交授权失败,原因是:{}");
|
||||
ErrorCode SOCIAL_UNBIND_NOT_SELF = new ErrorCode(1006002001, "社交解绑失败,非当前用户绑定");
|
||||
@ -34,10 +30,6 @@ public interface SysErrorCodeConstants {
|
||||
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, "岗位({}) 不处于开启状态,不允许选择");
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.system.enums.social;
|
||||
package cn.iocoder.yudao.module.system.enums.social;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
@ -16,7 +16,7 @@ import java.util.List;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SysSocialTypeEnum implements IntArrayValuable {
|
||||
public enum SocialTypeEnum implements IntArrayValuable {
|
||||
|
||||
/**
|
||||
* Gitee
|
||||
@ -51,7 +51,7 @@ public enum SysSocialTypeEnum implements IntArrayValuable {
|
||||
WECHAT_MINI_PROGRAM(33, "WECHAT_MINI_PROGRAM"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SysSocialTypeEnum::getType).toArray();
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SocialTypeEnum::getType).toArray();
|
||||
|
||||
public static final List<Integer> WECHAT_ALL = ListUtil.toList(WECHAT_ENTERPRISE.type, WECHAT_MP.type, WECHAT_OPEN.type,
|
||||
WECHAT_MINI_PROGRAM.type);
|
||||
@ -70,7 +70,7 @@ public enum SysSocialTypeEnum implements IntArrayValuable {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static SysSocialTypeEnum valueOfType(Integer type) {
|
||||
public static SocialTypeEnum valueOfType(Integer type) {
|
||||
return ArrayUtil.firstMatch(o -> o.getType().equals(type), values());
|
||||
}
|
||||
|
@ -3,19 +3,19 @@ package cn.iocoder.yudao.module.system.controller.admin.auth;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth.*;
|
||||
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.module.system.enums.permission.MenuTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.service.auth.AuthService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.UserDO;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.service.user.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -45,14 +45,15 @@ public class AuthController {
|
||||
@Autowired
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // AuthService 存在重名
|
||||
private AuthService authService;
|
||||
@Resource
|
||||
private SysUserCoreService userCoreService;
|
||||
@Autowired
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // UserService 存在重名
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
@Resource
|
||||
private SysSocialCoreService socialCoreService;
|
||||
private SocialUserService socialCoreService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("使用账号密码登录")
|
||||
@ -67,7 +68,7 @@ public class AuthController {
|
||||
@ApiOperation("获取登录用户的权限信息")
|
||||
public CommonResult<AuthPermissionInfoRespVO> getPermissionInfo() {
|
||||
// 获得用户信息
|
||||
SysUserDO user = userCoreService.getUser(getLoginUserId());
|
||||
UserDO user = userService.getUser(getLoginUserId());
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -3,19 +3,19 @@ package cn.iocoder.yudao.module.system.controller.admin.auth;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.session.UserSessionPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.session.UserSessionPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.convert.auth.UserSessionConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.auth.UserSessionService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.auth.SysUserSessionDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.UserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.system.service.user.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -35,10 +35,9 @@ public class UserSessionController {
|
||||
|
||||
@Resource
|
||||
private UserSessionService userSessionService;
|
||||
@Resource
|
||||
private SysUserSessionCoreService userSessionCoreService;
|
||||
@Resource
|
||||
private SysUserCoreService userCoreService;
|
||||
@Autowired
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // UserService 存在重名
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private SysDeptCoreService deptCoreService;
|
||||
@ -51,10 +50,10 @@ public class UserSessionController {
|
||||
PageResult<SysUserSessionDO> pageResult = userSessionService.getUserSessionPage(reqVO);
|
||||
|
||||
// 获得拼接需要的数据
|
||||
Map<Long, SysUserDO> userMap = userCoreService.getUserMap(
|
||||
Map<Long, UserDO> userMap = userService.getUserMap(
|
||||
convertList(pageResult.getList(), SysUserSessionDO::getUserId));
|
||||
Map<Long, SysDeptDO> deptMap = deptCoreService.getDeptMap(
|
||||
convertList(userMap.values(), SysUserDO::getDeptId));
|
||||
convertList(userMap.values(), UserDO::getDeptId));
|
||||
// 拼接结果返回
|
||||
List<UserSessionPageItemRespVO> sessionList = new ArrayList<>(pageResult.getList().size());
|
||||
pageResult.getList().forEach(session -> {
|
||||
@ -76,7 +75,7 @@ public class UserSessionController {
|
||||
example = "fe50b9f6-d177-44b1-8da9-72ea34f63db7")
|
||||
@PreAuthorize("@ss.hasPermission('system:user-session:delete')")
|
||||
public CommonResult<Boolean> deleteUserSession(@RequestParam("id") String id) {
|
||||
userSessionCoreService.deleteUserSession(id);
|
||||
userSessionService.deleteUserSession(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
public class AuthSocialBindReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -22,7 +22,7 @@ import javax.validation.constraints.Pattern;
|
||||
public class AuthSocialLogin2ReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -20,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
public class AuthSocialLoginReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -20,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
public class AuthSocialUnbindReqVO {
|
||||
|
||||
@ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值")
|
||||
@InEnum(SysSocialTypeEnum.class)
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dept;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.*;
|
||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.*;
|
||||
import cn.iocoder.yudao.module.system.convert.dept.PostConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.PostService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -25,7 +25,7 @@ public class PostExcelVO {
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dict.SysDictDataDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.SysDictDataDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -28,7 +28,7 @@ public class DictDataExcelVO {
|
||||
private String dictType;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.dict.vo.type;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -22,7 +22,7 @@ public class DictTypeExcelVO {
|
||||
private String type;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.logger.SysLoginLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.logger.SysLoginLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
@ -7,16 +7,17 @@ import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.Oper
|
||||
import cn.iocoder.yudao.module.system.convert.logger.OperateLogConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
|
||||
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.UserDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.service.user.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -43,8 +44,9 @@ public class OperateLogController {
|
||||
|
||||
@Resource
|
||||
private OperateLogService operateLogService;
|
||||
@Resource
|
||||
private SysUserCoreService userCoreService;
|
||||
@Autowired
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // UserService 存在重名
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("查看操作日志分页列表")
|
||||
@ -54,7 +56,7 @@ public class OperateLogController {
|
||||
|
||||
// 获得拼接需要的数据
|
||||
Collection<Long> userIds = CollectionUtils.convertList(pageResult.getList(), OperateLogDO::getUserId);
|
||||
Map<Long, SysUserDO> userMap = userCoreService.getUserMap(userIds);
|
||||
Map<Long, UserDO> userMap = userService.getUserMap(userIds);
|
||||
// 拼接数据
|
||||
List<OperateLogRespVO> list = new ArrayList<>(pageResult.getList().size());
|
||||
pageResult.getList().forEach(operateLog -> {
|
||||
@ -75,7 +77,7 @@ public class OperateLogController {
|
||||
|
||||
// 获得拼接需要的数据
|
||||
Collection<Long> userIds = CollectionUtils.convertList(list, OperateLogDO::getUserId);
|
||||
Map<Long, SysUserDO> userMap = userCoreService.getUserMap(userIds);
|
||||
Map<Long, UserDO> userMap = userService.getUserMap(userIds);
|
||||
// 拼接数据
|
||||
List<OperateLogExcelVO> excelDataList = OperateLogConvert.INSTANCE.convertList(list, userMap);
|
||||
// 输出
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -21,11 +21,11 @@ public class LoginLogExcelVO {
|
||||
private String username;
|
||||
|
||||
@ExcelProperty(value = "日志类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.LOGIN_TYPE)
|
||||
@DictFormat(DictTypeConstants.LOGIN_TYPE)
|
||||
private Integer logType;
|
||||
|
||||
@ExcelProperty(value = "登录结果", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.LOGIN_RESULT)
|
||||
@DictFormat(DictTypeConstants.LOGIN_RESULT)
|
||||
private Integer result;
|
||||
|
||||
@ExcelProperty("登录 IP")
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -24,7 +24,7 @@ public class OperateLogExcelVO {
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "操作类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.OPERATE_TYPE)
|
||||
@DictFormat(DictTypeConstants.OPERATE_TYPE)
|
||||
private String type;
|
||||
|
||||
@ExcelProperty("操作人")
|
||||
|
@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.*;
|
||||
import cn.iocoder.yudao.module.system.convert.permission.RoleConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.permission.vo.role;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -28,7 +28,7 @@ public class RoleExcelVO {
|
||||
private Integer dataScope;
|
||||
|
||||
@ExcelProperty(value = "角色状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.sms;
|
||||
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SysSmsSendService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum;
|
||||
@ -25,7 +25,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
public class SmsCallbackController {
|
||||
|
||||
@Resource
|
||||
private SysSmsCoreService smsCoreService;
|
||||
private SysSmsSendService smsCoreService;
|
||||
|
||||
@PostMapping("/sms/yunpian")
|
||||
@ApiOperation(value = "云片短信的回调", notes = "参见 https://www.yunpian.com/official/document/sms/zh_cn/domestic_push_report 文档")
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.sms;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.*;
|
||||
import cn.iocoder.yudao.module.system.convert.sms.SmsChannelConvert;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SmsChannelService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SysSmsChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqV
|
||||
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SysSmsLogRespVO;
|
||||
import cn.iocoder.yudao.module.system.convert.sms.SmsLogConvert;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SmsLogService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SysSmsLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.system.controller.admin.sms;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.*;
|
||||
import cn.iocoder.yudao.module.system.convert.sms.SmsTemplateConvert;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.service.sms.SysSmsSendService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
@ -32,7 +32,7 @@ public class SmsTemplateController {
|
||||
@Resource
|
||||
private SmsTemplateService smsTemplateService;
|
||||
@Resource
|
||||
private SysSmsCoreService smsCoreService;
|
||||
private SysSmsSendService smsCoreService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建短信模板")
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.sms.vo.log;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.JsonConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -34,7 +34,7 @@ public class SmsLogExcelVO {
|
||||
private String templateCode;
|
||||
|
||||
@ExcelProperty(value = "短信类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.SMS_TEMPLATE_TYPE)
|
||||
@DictFormat(DictTypeConstants.SMS_TEMPLATE_TYPE)
|
||||
private Integer templateType;
|
||||
|
||||
@ExcelProperty("短信内容")
|
||||
@ -53,11 +53,11 @@ public class SmsLogExcelVO {
|
||||
private Long userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.USER_TYPE)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@ExcelProperty(value = "发送状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.SMS_SEND_STATUS)
|
||||
@DictFormat(DictTypeConstants.SMS_SEND_STATUS)
|
||||
private Integer sendStatus;
|
||||
|
||||
@ExcelProperty("发送时间")
|
||||
@ -82,7 +82,7 @@ public class SmsLogExcelVO {
|
||||
private String apiSerialNo;
|
||||
|
||||
@ExcelProperty(value = "接收状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.SMS_RECEIVE_STATUS)
|
||||
@DictFormat(DictTypeConstants.SMS_RECEIVE_STATUS)
|
||||
private Integer receiveStatus;
|
||||
|
||||
@ExcelProperty("接收时间")
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -20,11 +20,11 @@ public class SmsTemplateExcelVO {
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty(value = "短信签名", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.SMS_TEMPLATE_TYPE)
|
||||
@DictFormat(DictTypeConstants.SMS_TEMPLATE_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty(value = "开启状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("模板编码")
|
||||
@ -46,7 +46,7 @@ public class SmsTemplateExcelVO {
|
||||
private Long channelId;
|
||||
|
||||
@ExcelProperty(value = "短信渠道编码", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.SMS_CHANNEL_CODE)
|
||||
@DictFormat(DictTypeConstants.SMS_CHANNEL_CODE)
|
||||
private String channelCode;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.tenant;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.*;
|
||||
import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert;
|
||||
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.tenant.SysTenantDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.SysTenantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
@ -3,12 +3,11 @@ package cn.iocoder.yudao.module.system.controller.admin.user;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
|
||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.user.UserService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.common.SysSexEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.UserDO;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SysSexEnum;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -19,6 +18,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -41,11 +41,10 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E
|
||||
@Validated
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // UserService 存在重名
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private SysUserCoreService userCoreService;
|
||||
@Resource
|
||||
private SysDeptCoreService deptCoreService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ -94,13 +93,13 @@ public class UserController {
|
||||
@PreAuthorize("@ss.hasPermission('system:user:list')")
|
||||
public CommonResult<PageResult<UserPageItemRespVO>> getUserPage(@Valid UserPageReqVO reqVO) {
|
||||
// 获得用户分页列表
|
||||
PageResult<SysUserDO> pageResult = userService.getUserPage(reqVO);
|
||||
PageResult<UserDO> pageResult = userService.getUserPage(reqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal())); // 返回空
|
||||
}
|
||||
|
||||
// 获得拼接需要的数据
|
||||
Collection<Long> deptIds = convertList(pageResult.getList(), SysUserDO::getDeptId);
|
||||
Collection<Long> deptIds = convertList(pageResult.getList(), UserDO::getDeptId);
|
||||
Map<Long, SysDeptDO> deptMap = deptCoreService.getDeptMap(deptIds);
|
||||
// 拼接结果返回
|
||||
List<UserPageItemRespVO> userList = new ArrayList<>(pageResult.getList().size());
|
||||
@ -116,7 +115,7 @@ public class UserController {
|
||||
@ApiOperation(value = "获取用户精简信息列表", notes = "只包含被开启的用户,主要用于前端的下拉选项")
|
||||
public CommonResult<List<UserSimpleRespVO>> getSimpleUsers() {
|
||||
// 获用户门列表,只要开启状态的
|
||||
List<SysUserDO> list = userService.getUsersByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
List<UserDO> list = userService.getUsersByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
// 排序后,返回给前端
|
||||
return success(UserConvert.INSTANCE.convertList04(list));
|
||||
}
|
||||
@ -126,7 +125,7 @@ public class UserController {
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('system:user:query')")
|
||||
public CommonResult<UserRespVO> getInfo(@RequestParam("id") Long id) {
|
||||
return success(UserConvert.INSTANCE.convert(userCoreService.getUser(id)));
|
||||
return success(UserConvert.INSTANCE.convert(userService.getUser(id)));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@ -136,12 +135,13 @@ public class UserController {
|
||||
public void exportUsers(@Validated UserExportReqVO reqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
// 获得用户列表
|
||||
List<SysUserDO> users = userService.getUsers(reqVO);
|
||||
List<UserDO> users = userService.getUsers(reqVO);
|
||||
|
||||
// 获得拼接需要的数据
|
||||
Collection<Long> deptIds = convertList(users, SysUserDO::getDeptId);
|
||||
Collection<Long> deptIds = convertList(users, UserDO::getDeptId);
|
||||
Map<Long, SysDeptDO> deptMap = deptCoreService.getDeptMap(deptIds);
|
||||
Map<Long, SysUserDO> deptLeaderUserMap = userCoreService.getUserMap(convertSet(deptMap.values(), SysDeptDO::getLeaderUserId));
|
||||
Map<Long, UserDO> deptLeaderUserMap = userService.getUserMap(
|
||||
convertSet(deptMap.values(), SysDeptDO::getLeaderUserId));
|
||||
// 拼接数据
|
||||
List<UserExcelVO> excelUsers = new ArrayList<>(users.size());
|
||||
users.forEach(user -> {
|
||||
|
@ -9,20 +9,20 @@ import cn.iocoder.yudao.module.system.service.dept.PostService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.user.UserService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.social.SysSocialUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialCoreService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SysSocialUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.UserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -43,11 +43,10 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
|
||||
@Slf4j
|
||||
public class UserProfileController {
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // UserService 存在重名
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private SysUserCoreService userCoreService;
|
||||
@Resource
|
||||
private SysDeptCoreService deptCoreService;
|
||||
|
||||
@Resource
|
||||
@ -57,13 +56,13 @@ public class UserProfileController {
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private SysSocialCoreService socialService;
|
||||
private SocialUserService socialService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得登录用户信息")
|
||||
public CommonResult<UserProfileRespVO> profile() {
|
||||
// 获得用户基本信息
|
||||
SysUserDO user = userCoreService.getUser(getLoginUserId());
|
||||
UserDO user = userService.getUser(getLoginUserId());
|
||||
UserProfileRespVO resp = UserConvert.INSTANCE.convert03(user);
|
||||
// 获得用户角色
|
||||
List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.getUserRoleIdListByUserId(user.getId()));
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.user.vo.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -30,11 +30,11 @@ public class UserExcelVO {
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty(value = "用户性别", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.USER_SEX)
|
||||
@DictFormat(DictTypeConstants.USER_SEX)
|
||||
private Integer sex;
|
||||
|
||||
@ExcelProperty(value = "帐号状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("最后登录IP")
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.user.vo.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -36,11 +36,11 @@ public class UserImportExcelVO {
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty(value = "用户性别", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.USER_SEX)
|
||||
@DictFormat(DictTypeConstants.USER_SEX)
|
||||
private Integer sex;
|
||||
|
||||
@ExcelProperty(value = "账号状态", converter = DictConvert.class)
|
||||
@DictFormat(SysDictTypeConstants.COMMON_STATUS)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user