Merge branch 'master' into feature_user-session-timeout
# Conflicts: # sql/ruoyi-vue-pro.sql
This commit is contained in:
@@ -12,6 +12,7 @@ import cn.iocoder.dashboard.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
import cn.iocoder.dashboard.modules.infra.enums.config.InfConfigTypeEnum;
|
||||
import cn.iocoder.dashboard.modules.infra.mq.producer.config.InfConfigProducer;
|
||||
import cn.iocoder.dashboard.modules.infra.service.config.InfConfigService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -99,7 +100,8 @@ public class InfConfigServiceImpl implements InfConfigService {
|
||||
checkConfigKeyUnique(id, key);
|
||||
}
|
||||
|
||||
private InfConfigDO checkConfigExists(Long id) {
|
||||
@VisibleForTesting
|
||||
public InfConfigDO checkConfigExists(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -110,7 +112,8 @@ public class InfConfigServiceImpl implements InfConfigService {
|
||||
return config;
|
||||
}
|
||||
|
||||
private void checkConfigKeyUnique(Long id, String key) {
|
||||
@VisibleForTesting
|
||||
public void checkConfigKeyUnique(Long id, String key) {
|
||||
InfConfigDO config = configMapper.selectByKey(key);
|
||||
if (config == null) {
|
||||
return;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SysDeptBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024")
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "负责人", example = "芋道")
|
||||
private String leader;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SysPostBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024")
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SysPostExcelVO {
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("岗位排序")
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(SYS_COMMON_STATUS)
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SysMenuBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024")
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "父菜单 ID", required = true, example = "1024")
|
||||
@NotNull(message = "父菜单 ID 不能为空")
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SysRoleBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024")
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 SysRoleTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SysDeptDO extends BaseDO {
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SysPostDO extends BaseDO {
|
||||
/**
|
||||
* 岗位排序
|
||||
*/
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SysMenuDO extends BaseDO {
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private String sort;
|
||||
private Integer sort;
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
|
||||
@@ -15,13 +15,13 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface SysDictDataMapper extends BaseMapperX<SysDictDataDO> {
|
||||
|
||||
default SysDictDataDO selectByDictTypeAndLabel(String dictType, String label) {
|
||||
default SysDictDataDO selectByDictTypeAndValue(String dictType, String value) {
|
||||
return selectOne(new QueryWrapper<SysDictDataDO>().eq("dict_type", dictType)
|
||||
.eq("label", label));
|
||||
.eq("value", value));
|
||||
}
|
||||
|
||||
default int selectCountByDictType(String dictType) {
|
||||
return selectCount(new QueryWrapper<SysDictDataDO>().eq("dict_type", dictType));
|
||||
return selectCount("dict_type", dictType);
|
||||
}
|
||||
|
||||
default PageResult<SysDictDataDO> selectPage(SysDictDataPageReqVO reqVO) {
|
||||
|
||||
@@ -160,7 +160,26 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
|
||||
@Override
|
||||
public void logout(String token) {
|
||||
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, "退出成功")); TODO 需要搞一搞
|
||||
// 查询用户信息
|
||||
LoginUser loginUser = userSessionService.getLoginUser(token);
|
||||
if (loginUser == null) {
|
||||
return;
|
||||
}
|
||||
// 删除 session
|
||||
userSessionService.deleteUserSession(token);
|
||||
// 记录登出日子和
|
||||
this.createLogoutLog(loginUser.getUsername());
|
||||
}
|
||||
|
||||
private void createLogoutLog(String username) {
|
||||
SysLoginLogCreateReqVO reqVO = new SysLoginLogCreateReqVO();
|
||||
reqVO.setLogType(SysLoginLogTypeEnum.LOGOUT_SELF.getType());
|
||||
reqVO.setTraceId(TracerUtils.getTraceId());
|
||||
reqVO.setUsername(username);
|
||||
reqVO.setUserAgent(ServletUtils.getUserAgent());
|
||||
reqVO.setUserIp(ServletUtils.getClientIP());
|
||||
reqVO.setResult(SysLoginResultEnum.SUCCESS.getResult());
|
||||
loginLogService.createLoginLog(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package cn.iocoder.dashboard.modules.system.service.dict.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.data.SysDictDataCreateReqVO;
|
||||
@@ -10,12 +9,13 @@ import cn.iocoder.dashboard.modules.system.controller.dict.vo.data.SysDictDataEx
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.data.SysDictDataPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.data.SysDictDataUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.dict.SysDictDataConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dict.SysDictDataMapper;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.dict.SysDictDataDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.dict.SysDictTypeDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dict.SysDictDataMapper;
|
||||
import cn.iocoder.dashboard.modules.system.mq.producer.dict.SysDictDataProducer;
|
||||
import cn.iocoder.dashboard.modules.system.service.dict.SysDictDataService;
|
||||
import cn.iocoder.dashboard.modules.system.service.dict.SysDictTypeService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@@ -28,6 +28,7 @@ import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@@ -156,7 +157,7 @@ public class SysDictDataServiceImpl implements SysDictDataService {
|
||||
@Override
|
||||
public Long createDictData(SysDictDataCreateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
this.checkCreateOrUpdate(null, reqVO.getLabel(), reqVO.getDictType());
|
||||
this.checkCreateOrUpdate(null, reqVO.getValue(), reqVO.getDictType());
|
||||
// 插入字典类型
|
||||
SysDictDataDO dictData = SysDictDataConvert.INSTANCE.convert(reqVO);
|
||||
dictDataMapper.insert(dictData);
|
||||
@@ -168,7 +169,7 @@ public class SysDictDataServiceImpl implements SysDictDataService {
|
||||
@Override
|
||||
public void updateDictData(SysDictDataUpdateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
this.checkCreateOrUpdate(reqVO.getId(), reqVO.getLabel(), reqVO.getDictType());
|
||||
this.checkCreateOrUpdate(reqVO.getId(), reqVO.getValue(), reqVO.getDictType());
|
||||
// 更新字典类型
|
||||
SysDictDataDO updateObj = SysDictDataConvert.INSTANCE.convert(reqVO);
|
||||
dictDataMapper.updateById(updateObj);
|
||||
@@ -191,46 +192,49 @@ public class SysDictDataServiceImpl implements SysDictDataService {
|
||||
return dictDataMapper.selectCountByDictType(dictType);
|
||||
}
|
||||
|
||||
private void checkCreateOrUpdate(Long id, String label, String dictType) {
|
||||
private void checkCreateOrUpdate(Long id, String value, String dictType) {
|
||||
// 校验自己存在
|
||||
checkDictDataExists(id);
|
||||
// 校验字典类型有效
|
||||
checkDictTypeValid(dictType);
|
||||
// 校验字典数据的值的唯一性
|
||||
checkDictDataValueUnique(id, dictType, label);
|
||||
checkDictDataValueUnique(id, dictType, value);
|
||||
}
|
||||
|
||||
private void checkDictDataValueUnique(Long id, String dictType, String label) {
|
||||
SysDictDataDO dictData = dictDataMapper.selectByDictTypeAndLabel(dictType, label);
|
||||
@VisibleForTesting
|
||||
public void checkDictDataValueUnique(Long id, String dictType, String value) {
|
||||
SysDictDataDO dictData = dictDataMapper.selectByDictTypeAndValue(dictType, value);
|
||||
if (dictData == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的字典数据
|
||||
if (id == null) {
|
||||
throw ServiceExceptionUtil.exception(DICT_DATA_VALUE_DUPLICATE);
|
||||
throw exception(DICT_DATA_VALUE_DUPLICATE);
|
||||
}
|
||||
if (!dictData.getId().equals(id)) {
|
||||
throw ServiceExceptionUtil.exception(DICT_DATA_VALUE_DUPLICATE);
|
||||
throw exception(DICT_DATA_VALUE_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDictDataExists(Long id) {
|
||||
@VisibleForTesting
|
||||
public void checkDictDataExists(Long id) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
SysDictDataDO dictData = dictDataMapper.selectById(id);
|
||||
if (dictData == null) {
|
||||
throw ServiceExceptionUtil.exception(DICT_DATA_NOT_EXISTS);
|
||||
throw exception(DICT_DATA_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDictTypeValid(String type) {
|
||||
@VisibleForTesting
|
||||
public void checkDictTypeValid(String type) {
|
||||
SysDictTypeDO dictType = dictTypeService.getDictType(type);
|
||||
if (dictType == null) {
|
||||
throw ServiceExceptionUtil.exception(DICT_TYPE_NOT_EXISTS);
|
||||
throw exception(DICT_TYPE_NOT_EXISTS);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(dictType.getStatus())) {
|
||||
throw ServiceExceptionUtil.exception(DICT_TYPE_NOT_ENABLE);
|
||||
throw exception(DICT_TYPE_NOT_ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.iocoder.dashboard.modules.system.dal.dataobject.dict.SysDictTypeDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dict.SysDictTypeMapper;
|
||||
import cn.iocoder.dashboard.modules.system.service.dict.SysDictDataService;
|
||||
import cn.iocoder.dashboard.modules.system.service.dict.SysDictTypeService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -97,8 +98,9 @@ public class SysDictTypeServiceImpl implements SysDictTypeService {
|
||||
checkDictTypeUnique(id, type);
|
||||
}
|
||||
|
||||
private void checkDictTypeNameUnique(Long id, String type) {
|
||||
SysDictTypeDO dictType = dictTypeMapper.selectByName(type);
|
||||
@VisibleForTesting
|
||||
public void checkDictTypeNameUnique(Long id, String name) {
|
||||
SysDictTypeDO dictType = dictTypeMapper.selectByName(name);
|
||||
if (dictType == null) {
|
||||
return;
|
||||
}
|
||||
@@ -111,7 +113,8 @@ public class SysDictTypeServiceImpl implements SysDictTypeService {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDictTypeUnique(Long id, String type) {
|
||||
@VisibleForTesting
|
||||
public void checkDictTypeUnique(Long id, String type) {
|
||||
SysDictTypeDO dictType = dictTypeMapper.selectByType(type);
|
||||
if (dictType == null) {
|
||||
return;
|
||||
@@ -125,7 +128,8 @@ public class SysDictTypeServiceImpl implements SysDictTypeService {
|
||||
}
|
||||
}
|
||||
|
||||
private SysDictTypeDO checkDictTypeExists(Long id) {
|
||||
@VisibleForTesting
|
||||
public SysDictTypeDO checkDictTypeExists(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user