review code.

This commit is contained in:
lijiahang
2023-07-16 22:58:49 +08:00
parent 462cd81865
commit 90b9dba7ed
38 changed files with 431 additions and 165 deletions

View File

@@ -12,6 +12,11 @@ public class Const implements com.orion.lang.constant.Const {
private Const() {
}
/**
* 同 ${orion.version} 迭代时候需要手动更改
*/
public static String VERSION = "1.0.0";
public static final Integer NOT_DELETE = 0;
public static final Integer IS_DELETED = 1;

View File

@@ -3,6 +3,7 @@ package com.orion.ops.framework.common.constant;
import com.orion.lang.define.wrapper.CodeInfo;
import com.orion.lang.define.wrapper.HttpWrapper;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Strings;
/**
* 错误码
@@ -36,39 +37,43 @@ public enum ErrorCode implements CodeInfo {
INTERNAL_SERVER_ERROR(500, "系统异常"),
// -------------------- 自定义 --------------------
// -------------------- 自定义 - 业务 --------------------
NETWORK_FLUCTUATION(700, "当前环境网路波动"),
OTHER_DEVICE_LOGIN(700, "该账号于 {} 已在其他设备登陆 {}({})"),
HTTP_API(701, "api 调用异常"),
// -------------------- 自定义 - 通用 --------------------
IO_EXCEPTION(702, "网络异常"),
NETWORK_FLUCTUATION(900, "当前环境网路波动"),
SQL_EXCEPTION(703, "数据异常"),
HTTP_API(901, "api 调用异常"),
SFTP_EXCEPTION(704, "操作失败"),
IO_EXCEPTION(902, "网络异常"),
EXCEL_PASSWORD_ERROR(705, "文档密码错误"),
SQL_EXCEPTION(903, "数据异常"),
PASER_FAILED(706, "解析失败"),
SFTP_EXCEPTION(904, "操作失败"),
ENCRYPT_ERROR(707, "数据加密异常"),
EXCEL_PASSWORD_ERROR(905, "文档密码错误"),
DECRYPT_ERROR(708, "数据解密异常"),
PASER_FAILED(906, "解析失败"),
EXPRESSION_ERROR(709, "表达式错误"),
ENCRYPT_ERROR(907, "数据加密异常"),
TASK_EXECUTE_ERROR(710, "任务执行异常"),
DECRYPT_ERROR(908, "数据解密异常"),
CONNECT_ERROR(711, "建立连接失败"),
EXPRESSION_ERROR(909, "表达式错误"),
INTERRUPT_ERROR(712, "操作中断"),
TASK_EXECUTE_ERROR(910, "任务执行异常"),
UNSAFE_OPERATOR(713, "不安全的操作"),
CONNECT_ERROR(911, "建立连接失败"),
VCS_OPETATOR_ERROR(714, "仓库操作执行失败"),
INTERRUPT_ERROR(912, "操作中断"),
DIABLED_ERROR(715, "数据已被禁用"),
UNSAFE_OPERATOR(913, "不安全的操作"),
VCS_OPETATOR_ERROR(914, "仓库操作执行失败"),
DIABLED_ERROR(915, "数据已被禁用"),
;
@@ -135,4 +140,12 @@ public enum ErrorCode implements CodeInfo {
return Exceptions.httpWrapper(this);
}
/**
* @param params 错误信息参数
* @return 获取异常
*/
public RuntimeException exception(Object... params) {
return Exceptions.httpWrapper(this.toHttpWrapper().msg(Strings.format(this.message, params)));
}
}

View File

@@ -39,10 +39,10 @@ public class CodeGenerator {
@NotNull
String author = Const.ORION_AUTHOR;
@NotEmpty
String[] tables = {"system_role", "system_user_role", "system_menu", "system_role_menu"};
String[] tables = {"system_user", "system_role", "system_user_role", "system_menu", "system_role_menu"};
// 表业务注释 需要和表一一对应 null则为表注释
@NotEmpty
String[] comment = {"角色", "用户角色关联", "菜单", "角色菜单关联"};
String[] comment = {"用户", "角色", "用户角色关联", "菜单", "角色菜单关联"};
// 模块
@NotNull
String module = "infra";

View File

@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.generator.config.builder.CustomFile;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
import com.orion.lang.utils.Strings;
import com.orion.ops.framework.common.constant.Const;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
@@ -135,6 +136,8 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
// http 注释标识
objectMap.put("httpComment", "###");
// 版本
objectMap.put("since", Const.VERSION);
// 实体名称
String domainName = tableInfo.getEntityName();

View File

@@ -24,7 +24,7 @@ import java.util.List;
* $!{table.comment} api
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Tag(name = "${package.ModuleName} - $!{table.comment}服务")

View File

@@ -12,7 +12,7 @@ import java.util.List;
* $!{table.comment} 暴露服务转换器
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Mapper

View File

@@ -12,7 +12,7 @@ import java.util.List;
* $!{table.comment} 内部对象转换器
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Mapper

View File

@@ -11,7 +11,7 @@ import java.util.*;
* $!{table.comment} 实体对象
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Data

View File

@@ -10,7 +10,7 @@ import java.util.*;
* $!{table.comment} 业务对象
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Data

View File

@@ -16,7 +16,7 @@ import java.util.*;
* $!{table.comment} 创建请求对象
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Data

View File

@@ -11,7 +11,7 @@ import java.util.*;
* $!{table.comment} 查询请求对象
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Data

View File

@@ -16,7 +16,7 @@ import java.util.*;
* $!{table.comment} 更新请求对象
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Data

View File

@@ -10,7 +10,7 @@ import java.util.*;
* $!{table.comment} 视图响应对象
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Data

View File

@@ -1,5 +1,6 @@
package ${package.Mapper};
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import ${package.Entity}.${entity};
import ${superMapperClassPackage};
#if(${mapperAnnotationClass})
@@ -10,7 +11,7 @@ import ${mapperAnnotationClass.name};
* $!{table.comment} Mapper 接口
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
#if(${mapperAnnotationClass})
@@ -18,4 +19,17 @@ import ${mapperAnnotationClass.name};
#end
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
/**
* 获取全部条件
*
* @param entity entity
* @return 全部条件
*/
default LambdaQueryWrapper<${entity}> condition(${entity} entity) {
return this.wrapper()
#foreach($field in ${table.fields})
.eq(${type}DO::get${field.capitalName}, entity.get${field.capitalName}())#if(!$foreach.hasNext);#end
#end
}
}

View File

@@ -22,7 +22,7 @@ import java.util.List;
* $!{table.comment} 服务实现类
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
@Slf4j
@@ -37,24 +37,27 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
// 转换
${type}DO record = ${type}Convert.MAPPER.to(request);
record.setId(null);
// 查询是否存在
// 查询数据是否冲突
this.check${type}Present(record);
// 插入
int effect = ${typeLower}DAO.insert(record);
log.info("${type}Service-create${type} effect: {}, domain: {}", effect, JSON.toJSONString(record));
log.info("${type}Service-create${type} effect: {}, record: {}", effect, JSON.toJSONString(record));
return record.getId();
}
@Override
public Integer update${type}(${type}UpdateRequest request) {
// 查询
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
${type}DO record = ${typeLower}DAO.selectById(id);
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
// 转换
${type}DO record = ${type}Convert.MAPPER.to(request);
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
// 查询是否存在
this.check${type}Present(record);
${type}DO updateRecord = ${type}Convert.MAPPER.to(request);
// 查询数据是否冲突
this.check${type}Present(updateRecord);
// 更新
int effect = ${typeLower}DAO.updateById(record);
log.info("${type}Service-update${type} effect: {}, domain: {}", effect, JSON.toJSONString(record));
int effect = ${typeLower}DAO.updateById(updateRecord);
log.info("${type}Service-update${type} effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
return effect;
}
@@ -83,8 +86,9 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
// 构造条件
LambdaQueryWrapper<${type}DO> wrapper = ${typeLower}DAO.wrapper()
#foreach($field in ${table.fields})
.eq(${type}DO::get${field.capitalName}, request.get${field.capitalName}())#if(!$foreach.hasNext);#end
.eq(${type}DO::get${field.capitalName}, request.get${field.capitalName}())
#end
.orderByDesc(${type}DO::getId);
// 查询
return ${typeLower}DAO.of()
.wrapper(wrapper)

View File

@@ -11,7 +11,7 @@ import java.util.List;
* $!{table.comment} 服务类
*
* @author ${author}
* @version 1.0.0
* @version ${since}
* @since ${date}
*/
public interface ${table.serviceName} {

View File

@@ -43,7 +43,7 @@ public class SystemUserDTO implements Serializable {
@Schema(description = "邮箱")
private String email;
@Schema(description = "用户状态 0正常 1用 2锁定")
@Schema(description = "用户状态 0停用 1用 2锁定")
private Integer status;
@Schema(description = "最后登录时间")

View File

@@ -1,5 +1,6 @@
package com.orion.ops.module.infra.dao;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.module.infra.entity.domain.SystemMenuDO;
import org.apache.ibatis.annotations.Mapper;
@@ -9,9 +10,31 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:31
*/
@Mapper
public interface SystemMenuDAO extends IMapper<SystemMenuDO> {
/**
* 获取全部条件
*
* @param entity entity
* @return 全部条件
*/
default LambdaQueryWrapper<SystemMenuDO> condition(SystemMenuDO entity) {
return this.wrapper()
.eq(SystemMenuDO::getId, entity.getId())
.eq(SystemMenuDO::getParentId, entity.getParentId())
.eq(SystemMenuDO::getName, entity.getName())
.eq(SystemMenuDO::getPermission, entity.getPermission())
.eq(SystemMenuDO::getType, entity.getType())
.eq(SystemMenuDO::getSort, entity.getSort())
.eq(SystemMenuDO::getStatus, entity.getStatus())
.eq(SystemMenuDO::getCache, entity.getCache())
.eq(SystemMenuDO::getIcon, entity.getIcon())
.eq(SystemMenuDO::getPath, entity.getPath())
.eq(SystemMenuDO::getComponentName, entity.getComponentName())
.eq(SystemMenuDO::getComponent, entity.getComponent());
}
}

View File

@@ -1,7 +1,8 @@
package com.orion.ops.module.infra.dao;
import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import org.apache.ibatis.annotations.Mapper;
/**
@@ -9,9 +10,23 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:31
*/
@Mapper
public interface SystemRoleDAO extends IMapper<SystemRoleDO> {
/**
* 获取全部条件
*
* @param entity entity
* @return 全部条件
*/
default LambdaQueryWrapper<SystemRoleDO> condition(SystemRoleDO entity) {
return this.wrapper()
.eq(SystemRoleDO::getId, entity.getId())
.eq(SystemRoleDO::getName, entity.getName())
.eq(SystemRoleDO::getCode, entity.getCode())
.eq(SystemRoleDO::getStatus, entity.getStatus());
}
}

View File

@@ -1,7 +1,8 @@
package com.orion.ops.module.infra.dao;
import com.orion.ops.module.infra.entity.domain.SystemRoleMenuDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.module.infra.entity.domain.SystemRoleMenuDO;
import org.apache.ibatis.annotations.Mapper;
/**
@@ -9,9 +10,22 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:31
*/
@Mapper
public interface SystemRoleMenuDAO extends IMapper<SystemRoleMenuDO> {
/**
* 获取全部条件
*
* @param entity entity
* @return 全部条件
*/
default LambdaQueryWrapper<SystemRoleMenuDO> condition(SystemRoleMenuDO entity) {
return this.wrapper()
.eq(SystemRoleMenuDO::getId, entity.getId())
.eq(SystemRoleMenuDO::getRoleId, entity.getRoleId())
.eq(SystemRoleMenuDO::getMenuId, entity.getMenuId());
}
}

View File

@@ -1,7 +1,8 @@
package com.orion.ops.module.infra.dao;
import com.orion.ops.module.infra.entity.domain.SystemUserDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.module.infra.entity.domain.SystemUserDO;
import org.apache.ibatis.annotations.Mapper;
/**
@@ -9,9 +10,28 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-13 18:42
* @since 2023-7-16 22:31
*/
@Mapper
public interface SystemUserDAO extends IMapper<SystemUserDO> {
/**
* 获取全部条件
*
* @param entity entity
* @return 全部条件
*/
default LambdaQueryWrapper<SystemUserDO> condition(SystemUserDO entity) {
return this.wrapper()
.eq(SystemUserDO::getId, entity.getId())
.eq(SystemUserDO::getUsername, entity.getUsername())
.eq(SystemUserDO::getPassword, entity.getPassword())
.eq(SystemUserDO::getNickname, entity.getNickname())
.eq(SystemUserDO::getAvatar, entity.getAvatar())
.eq(SystemUserDO::getMobile, entity.getMobile())
.eq(SystemUserDO::getEmail, entity.getEmail())
.eq(SystemUserDO::getStatus, entity.getStatus())
.eq(SystemUserDO::getLastLoginTime, entity.getLastLoginTime());
}
}

View File

@@ -1,17 +1,49 @@
package com.orion.ops.module.infra.dao;
import com.orion.ops.module.infra.entity.domain.SystemUserRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.module.infra.entity.domain.SystemUserRoleDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户角色关联 Mapper 接口
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:31
*/
@Mapper
public interface SystemUserRoleDAO extends IMapper<SystemUserRoleDO> {
/**
* 获取全部条件
*
* @param entity entity
* @return 全部条件
*/
default LambdaQueryWrapper<SystemUserRoleDO> condition(SystemUserRoleDO entity) {
return this.wrapper()
.eq(SystemUserRoleDO::getId, entity.getId())
.eq(SystemUserRoleDO::getUserId, entity.getUserId())
.eq(SystemUserRoleDO::getRoleId, entity.getRoleId());
}
/**
* 查询用户的全部角色id
*
* @param userId userId
* @return roleId
*/
default List<Long> selectRoleByUserId(Long userId) {
LambdaQueryWrapper<SystemUserRoleDO> wrapper = this.wrapper()
.select(SystemUserRoleDO::getRoleId)
.eq(SystemUserRoleDO::getUserId, userId);
return this.selectList(wrapper).stream()
.map(SystemUserRoleDO::getRoleId)
.collect(Collectors.toList());
}
}

View File

@@ -56,7 +56,7 @@ public class SystemUserDO extends BaseDO {
@TableField("email")
private String email;
@Schema(description = "用户状态 0正常 1用 2锁定")
@Schema(description = "用户状态 0停用 1用 2锁定")
@TableField("status")
private Integer status;

View File

@@ -30,6 +30,11 @@ public class LoginTokenDTO {
*/
private Integer tokenStatus;
/**
* 已续签次数
*/
private Integer refreshCount;
/**
* 登陆时间/其他设备登陆时间
*/

View File

@@ -7,10 +7,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.*;
/**
* 角色 创建请求对象
@@ -36,8 +34,4 @@ public class SystemRoleCreateRequest implements Serializable {
@Schema(description = "角色编码")
private String code;
@NotNull
@Schema(description = "状态 0停用 1启用")
private Integer status;
}

View File

@@ -10,7 +10,6 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.*;
/**
* 角色 更新请求对象
@@ -35,13 +34,4 @@ public class SystemRoleUpdateRequest implements Serializable {
@Schema(description = "角色名称")
private String name;
@Size(max = 32)
@NotBlank
@Schema(description = "角色编码")
private String code;
@NotNull
@Schema(description = "状态 0停用 1启用")
private Integer status;
}

View File

@@ -57,7 +57,7 @@ public class SystemUserCreateRequest implements Serializable {
private String email;
@NotNull
@Schema(description = "用户状态 0正常 1用 2锁定")
@Schema(description = "用户状态 0停用 1用 2锁定")
private Integer status;
@NotNull

View File

@@ -49,7 +49,7 @@ public class SystemUserQueryRequest extends PageRequest {
@Schema(description = "邮箱")
private String email;
@Schema(description = "用户状态 0正常 1用 2锁定")
@Schema(description = "用户状态 0停用 1用 2锁定")
private Integer status;
@Schema(description = "最后登录时间")

View File

@@ -61,7 +61,7 @@ public class SystemUserUpdateRequest implements Serializable {
private String email;
@NotNull
@Schema(description = "用户状态 0正常 1用 2锁定")
@Schema(description = "用户状态 0停用 1用 2锁定")
private Integer status;
@NotNull

View File

@@ -46,7 +46,7 @@ public class SystemUserVO implements Serializable {
@Schema(description = "邮箱")
private String email;
@Schema(description = "用户状态 0正常 1用 2锁定")
@Schema(description = "用户状态 0停用 1用 2锁定")
private Integer status;
@Schema(description = "最后登录时间")

View File

@@ -15,14 +15,14 @@ import lombok.Getter;
public enum UserStatusEnum {
/**
* 0 正常
* 0 停用
*/
NORMAL(0),
DISABLED(0),
/**
* 1
* 1
*/
DISABLED(1),
ENABLED(1),
/**
* 2 锁定

View File

@@ -18,13 +18,16 @@ import com.orion.ops.framework.common.utils.Kits;
import com.orion.ops.framework.redis.core.utils.RedisUtils;
import com.orion.ops.module.infra.convert.SystemUserConvert;
import com.orion.ops.module.infra.dao.SystemUserDAO;
import com.orion.ops.module.infra.dao.SystemUserRoleDAO;
import com.orion.ops.module.infra.define.UserCacheKeyDefine;
import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import com.orion.ops.module.infra.entity.domain.SystemUserDO;
import com.orion.ops.module.infra.entity.dto.LoginTokenDTO;
import com.orion.ops.module.infra.entity.request.UserLoginRequest;
import com.orion.ops.module.infra.enums.LoginTokenStatusEnum;
import com.orion.ops.module.infra.enums.UserStatusEnum;
import com.orion.ops.module.infra.service.AuthenticationService;
import com.orion.ops.module.infra.service.PermissionService;
import com.orion.web.servlet.web.Servlets;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -35,6 +38,7 @@ import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
@@ -53,7 +57,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
// 允许凭证续签
private final boolean allowRefresh = true;
// 凭证续签最大次数
private final int maxRefreshCount = 5;
private final int maxRefreshCount = 3;
// 失败锁定次数
private final int maxFailedLoginCount = 5;
@@ -63,6 +67,12 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Resource
private SystemUserDAO systemUserDAO;
@Resource
private SystemUserRoleDAO systemUserRoleDAO;
@Resource
private PermissionService permissionService;
@Resource
private RedisTemplate<String, String> redisTemplate;
@@ -81,8 +91,8 @@ public class AuthenticationServiceImpl implements AuthenticationService {
this.checkUserStatus(user.getStatus());
// 设置上次登录时间
this.setLastLoginTime(user.getId());
// 设置缓存
this.setUserCache(user);
// 检查用户缓存
this.setUserCacheIfPresent(() -> user);
// 删除登陆失败次数缓存
redisTemplate.delete(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(request.getUsername()));
// 获取登陆 ip
@@ -90,7 +100,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
String location = IpUtils.getLocation(remoteAddr);
long current = System.currentTimeMillis();
// 不允许多端登陆
if (!false) {
if (!allowMultiDevice) {
// 无效化其他缓存
this.invalidOtherDeviceToken(user.getId(), current, remoteAddr, location);
}
@@ -105,6 +115,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
if (loginToken == null) {
return;
}
// 获取 token 信息
Pair<Long, Long> pair = this.getLoginTokenPair(loginToken);
if (pair == null) {
return;
@@ -118,7 +129,61 @@ public class AuthenticationServiceImpl implements AuthenticationService {
}
@Override
public Pair<Long, Long> getLoginTokenPair(String loginToken) {
public LoginUser getLoginUser(Long userId) {
// 获取用户缓存信息
return this.setUserCacheIfPresent(() -> systemUserDAO.selectById(userId));
}
@Override
public LoginTokenDTO getLoginTokenInfo(String loginToken, boolean checkRefresh) {
// 获取登陆 key pair
Pair<Long, Long> pair = this.getLoginTokenPair(loginToken);
if (pair == null) {
return null;
}
// 获取登陆 key value
String loginKey = UserCacheKeyDefine.LOGIN_TOKEN.format(pair.getKey(), pair.getValue());
String loginCache = redisTemplate.opsForValue().get(loginKey);
if (loginCache != null) {
return JSON.parseObject(loginCache, LoginTokenDTO.class);
}
// loginToken 不存在 需要查询 refreshToken
if (!checkRefresh || !allowRefresh) {
return null;
}
String refreshKey = UserCacheKeyDefine.LOGIN_REFRESH.format(pair.getKey(), pair.getValue());
String refreshCache = redisTemplate.opsForValue().get(refreshKey);
// 未查询到刷新key直接返回
if (refreshCache == null) {
return null;
}
// 执行续签操作
LoginTokenDTO refresh = JSON.parseObject(refreshCache, LoginTokenDTO.class);
int refreshCount = refresh.getRefreshCount() + 1;
refresh.setRefreshCount(refreshCount);
// 设置登陆缓存
redisTemplate.opsForValue().set(loginKey, JSON.toJSONString(refresh),
UserCacheKeyDefine.LOGIN_TOKEN.getTimeout(),
UserCacheKeyDefine.LOGIN_TOKEN.getUnit());
if (refreshCount < maxRefreshCount) {
// 小于续签最大次数 则再次设置 refreshToken
redisTemplate.opsForValue().set(refreshKey, JSON.toJSONString(refresh),
UserCacheKeyDefine.LOGIN_REFRESH.getTimeout(),
UserCacheKeyDefine.LOGIN_REFRESH.getUnit());
} else {
// 大于等于续签最大次数 则删除
redisTemplate.delete(refreshKey);
}
return refresh;
}
/**
* 获取 token pair
*
* @param loginToken loginToken
* @return pair
*/
private Pair<Long, Long> getLoginTokenPair(String loginToken) {
if (loginToken == null) {
return null;
}
@@ -162,7 +227,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
return true;
}
// 刷新登陆失败缓存
String failedCountKey = UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(user.getUsername());
String failedCountKey = UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(request.getUsername());
Long failedLoginCount = redisTemplate.opsForValue().increment(failedCountKey);
// 用户不存在
if (user == null) {
@@ -222,21 +287,33 @@ public class AuthenticationServiceImpl implements AuthenticationService {
/**
* 设置用户缓存
*
* @param user user
* @param supplier supplier
* @return 用户缓存
*/
private void setUserCache(SystemUserDO user) {
String userInfoKey = UserCacheKeyDefine.USER_INFO.format(user.getId());
private LoginUser setUserCacheIfPresent(Supplier<SystemUserDO> supplier) {
SystemUserDO user = supplier.get();
Long id = user.getId();
String userInfoKey = UserCacheKeyDefine.USER_INFO.format(id);
String userInfoCache = redisTemplate.opsForValue().get(userInfoKey);
// 缓存存在
if (userInfoCache != null) {
return;
return JSON.parseObject(userInfoCache, LoginUser.class);
}
// 设置缓存
LoginUser loginUser = SystemUserConvert.MAPPER.toLoginUser(user);
// TODO 查询角色
// 查询用户角色
List<Long> roleIds = systemUserRoleDAO.selectRoleByUserId(id);
List<String> roleCodeList = permissionService.getRoleCache()
.values()
.stream()
.filter(s -> roleIds.contains(s.getId()))
.map(SystemRoleDO::getCode)
.collect(Collectors.toList());
loginUser.setRoles(roleCodeList);
redisTemplate.opsForValue().set(userInfoKey, JSON.toJSONString(loginUser),
UserCacheKeyDefine.USER_INFO.getTimeout(),
UserCacheKeyDefine.USER_INFO.getUnit());
return loginUser;
}
/**
@@ -258,12 +335,12 @@ public class AuthenticationServiceImpl implements AuthenticationService {
.stream()
.filter(Objects::nonNull)
.map(s -> JSON.parseObject(s, LoginTokenDTO.class))
.filter(s -> LoginTokenStatusEnum.OK.getStatus().equals(s.getStatus()))
.filter(s -> LoginTokenStatusEnum.OK.getStatus().equals(s.getTokenStatus()))
.collect(Collectors.toList());
// 修改登陆信息
for (LoginTokenDTO loginTokenInfo : loginTokenInfoList) {
String deviceLoginKey = UserCacheKeyDefine.LOGIN_TOKEN.format(id, loginTokenInfo.getLoginTime());
loginTokenInfo.setStatus(LoginTokenStatusEnum.OTHER_DEVICE.getStatus());
loginTokenInfo.setTokenStatus(LoginTokenStatusEnum.OTHER_DEVICE.getStatus());
loginTokenInfo.setLoginTime(loginTime);
loginTokenInfo.setIp(remoteAddr);
loginTokenInfo.setLocation(location);
@@ -297,7 +374,9 @@ public class AuthenticationServiceImpl implements AuthenticationService {
// 生成 loginToken
String loginKey = UserCacheKeyDefine.LOGIN_TOKEN.format(id, loginTime);
LoginTokenDTO loginValue = LoginTokenDTO.builder()
.status(LoginTokenStatusEnum.OK.getStatus())
.id(id)
.tokenStatus(LoginTokenStatusEnum.OK.getStatus())
.refreshCount(0)
.ip(remoteAddr)
.loginTime(loginTime)
.location(location)
@@ -308,7 +387,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
// 生成 refreshToken
if (allowRefresh) {
String refreshKey = UserCacheKeyDefine.LOGIN_REFRESH.format(id, loginTime);
redisTemplate.opsForValue().set(refreshKey, "1",
redisTemplate.opsForValue().set(refreshKey, JSON.toJSONString(loginValue),
UserCacheKeyDefine.LOGIN_REFRESH.getTimeout(),
UserCacheKeyDefine.LOGIN_REFRESH.getUnit());
}

View File

@@ -13,6 +13,7 @@ import com.orion.ops.module.infra.entity.dto.SystemMenuCacheDTO;
import com.orion.ops.module.infra.enums.MenuStatusEnum;
import com.orion.ops.module.infra.enums.RoleStatusEnum;
import com.orion.ops.module.infra.service.PermissionService;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -24,6 +25,8 @@ import java.util.stream.Collectors;
/**
* 权限服务
* <p>
* TODO 分布式缓存解决方案?
*
* @author Jiahang Li
* @version 1.0.0
@@ -36,6 +39,7 @@ public class PermissionServiceImpl implements PermissionService {
/**
* 菜单缓存
*/
@Getter
private final Map<String, SystemRoleDO> roleCache = new HashMap<>();
/**
@@ -43,11 +47,13 @@ public class PermissionServiceImpl implements PermissionService {
*
* @see #roleMenuCache
*/
@Getter
private final List<SystemMenuCacheDTO> menuCache = new ArrayList<>();
/**
* 角色菜单关联
*/
@Getter
private final Map<String, List<SystemMenuCacheDTO>> roleMenuCache = new HashMap<>();
@Resource
@@ -64,7 +70,6 @@ public class PermissionServiceImpl implements PermissionService {
*/
@PostConstruct
public void initRoleMenuCache() {
// TODO 分布式解决方案?
long start = System.currentTimeMillis();
log.info("initRoleMenuCache-start");
// 加载所有角色
@@ -102,6 +107,13 @@ public class PermissionServiceImpl implements PermissionService {
@Override
public boolean rolesHasRole(List<String> roles, String role) {
// 检查是否为超级管理员
for (String r : roles) {
// 是否为超级管理员
if (RoleDefine.isAdmin(r) && this.checkRoleEnabled(r)) {
return true;
}
}
// 检查是否包含
if (!roles.contains(role)) {
return false;
@@ -113,20 +125,16 @@ public class PermissionServiceImpl implements PermissionService {
@Override
public boolean rolesHasPermission(List<String> roles, String permission) {
// 检查是否为超级管理员
for (String role : roles) {
// 角色是否启用
if (this.checkRoleEnabled(role)) {
continue;
}
for (String r : roles) {
// 是否为超级管理员
if (RoleDefine.isAdmin(role)) {
if (RoleDefine.isAdmin(r) && this.checkRoleEnabled(r)) {
return true;
}
}
// 检查普通角色是否有此权限
for (String role : roles) {
// 角色是否启用
if (this.checkRoleEnabled(role)) {
if (!this.checkRoleEnabled(role)) {
continue;
}
// 获取角色权限列表

View File

@@ -6,13 +6,12 @@ import com.orion.lang.define.wrapper.DataGrid;
import com.orion.lang.utils.Valid;
import com.orion.lang.utils.collect.Lists;
import com.orion.ops.framework.common.constant.ErrorMessage;
import com.orion.ops.module.infra.convert.SystemMenuConvert;
import com.orion.ops.module.infra.dao.SystemMenuDAO;
import com.orion.ops.module.infra.entity.vo.*;
import com.orion.ops.module.infra.entity.dto.*;
import com.orion.ops.module.infra.entity.request.*;
import com.orion.ops.module.infra.convert.*;
import com.orion.ops.module.infra.entity.domain.SystemMenuDO;
import com.orion.ops.module.infra.entity.request.SystemMenuCreateRequest;
import com.orion.ops.module.infra.entity.request.SystemMenuQueryRequest;
import com.orion.ops.module.infra.entity.request.SystemMenuUpdateRequest;
import com.orion.ops.module.infra.entity.vo.SystemMenuVO;
import com.orion.ops.module.infra.dao.SystemMenuDAO;
import com.orion.ops.module.infra.service.SystemMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -25,7 +24,7 @@ import java.util.List;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:46
*/
@Slf4j
@Service
@@ -39,24 +38,27 @@ public class SystemMenuServiceImpl implements SystemMenuService {
// 转换
SystemMenuDO record = SystemMenuConvert.MAPPER.to(request);
record.setId(null);
// 查询是否存在
// 查询数据是否冲突
this.checkSystemMenuPresent(record);
// 插入
int effect = systemMenuDAO.insert(record);
log.info("SystemMenuService-createSystemMenu effect: {}, domain: {}", effect, JSON.toJSONString(record));
log.info("SystemMenuService-createSystemMenu effect: {}, record: {}", effect, JSON.toJSONString(record));
return record.getId();
}
@Override
public Integer updateSystemMenu(SystemMenuUpdateRequest request) {
// 查询
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
SystemMenuDO record = systemMenuDAO.selectById(id);
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
// 转换
SystemMenuDO record = SystemMenuConvert.MAPPER.to(request);
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
// 查询是否存在
this.checkSystemMenuPresent(record);
SystemMenuDO updateRecord = SystemMenuConvert.MAPPER.to(request);
// 查询数据是否冲突
this.checkSystemMenuPresent(updateRecord);
// 更新
int effect = systemMenuDAO.updateById(record);
log.info("SystemMenuService-updateSystemMenu effect: {}, domain: {}", effect, JSON.toJSONString(record));
int effect = systemMenuDAO.updateById(updateRecord);
log.info("SystemMenuService-updateSystemMenu effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
return effect;
}
@@ -95,7 +97,8 @@ public class SystemMenuServiceImpl implements SystemMenuService {
.eq(SystemMenuDO::getIcon, request.getIcon())
.eq(SystemMenuDO::getPath, request.getPath())
.eq(SystemMenuDO::getComponentName, request.getComponentName())
.eq(SystemMenuDO::getComponent, request.getComponent());
.eq(SystemMenuDO::getComponent, request.getComponent())
.orderByDesc(SystemMenuDO::getId);
// 查询
return systemMenuDAO.of()
.wrapper(wrapper)

View File

@@ -24,7 +24,7 @@ import java.util.List;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:46
*/
@Slf4j
@Service
@@ -38,24 +38,27 @@ public class SystemRoleMenuServiceImpl implements SystemRoleMenuService {
// 转换
SystemRoleMenuDO record = SystemRoleMenuConvert.MAPPER.to(request);
record.setId(null);
// 查询是否存在
// 查询数据是否冲突
this.checkSystemRoleMenuPresent(record);
// 插入
int effect = systemRoleMenuDAO.insert(record);
log.info("SystemRoleMenuService-createSystemRoleMenu effect: {}, domain: {}", effect, JSON.toJSONString(record));
log.info("SystemRoleMenuService-createSystemRoleMenu effect: {}, record: {}", effect, JSON.toJSONString(record));
return record.getId();
}
@Override
public Integer updateSystemRoleMenu(SystemRoleMenuUpdateRequest request) {
// 查询
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
SystemRoleMenuDO record = systemRoleMenuDAO.selectById(id);
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
// 转换
SystemRoleMenuDO record = SystemRoleMenuConvert.MAPPER.to(request);
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
// 查询是否存在
this.checkSystemRoleMenuPresent(record);
SystemRoleMenuDO updateRecord = SystemRoleMenuConvert.MAPPER.to(request);
// 查询数据是否冲突
this.checkSystemRoleMenuPresent(updateRecord);
// 更新
int effect = systemRoleMenuDAO.updateById(record);
log.info("SystemRoleMenuService-updateSystemRoleMenu effect: {}, domain: {}", effect, JSON.toJSONString(record));
int effect = systemRoleMenuDAO.updateById(updateRecord);
log.info("SystemRoleMenuService-updateSystemRoleMenu effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
return effect;
}
@@ -85,7 +88,8 @@ public class SystemRoleMenuServiceImpl implements SystemRoleMenuService {
LambdaQueryWrapper<SystemRoleMenuDO> wrapper = systemRoleMenuDAO.wrapper()
.eq(SystemRoleMenuDO::getId, request.getId())
.eq(SystemRoleMenuDO::getRoleId, request.getRoleId())
.eq(SystemRoleMenuDO::getMenuId, request.getMenuId());
.eq(SystemRoleMenuDO::getMenuId, request.getMenuId())
.orderByDesc(SystemRoleMenuDO::getId);
// 查询
return systemRoleMenuDAO.of()
.wrapper(wrapper)

View File

@@ -6,12 +6,14 @@ import com.orion.lang.define.wrapper.DataGrid;
import com.orion.lang.utils.Valid;
import com.orion.lang.utils.collect.Lists;
import com.orion.ops.framework.common.constant.ErrorMessage;
import com.orion.ops.module.infra.entity.vo.*;
import com.orion.ops.module.infra.entity.dto.*;
import com.orion.ops.module.infra.entity.request.*;
import com.orion.ops.module.infra.convert.*;
import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import com.orion.ops.module.infra.convert.SystemRoleConvert;
import com.orion.ops.module.infra.dao.SystemRoleDAO;
import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import com.orion.ops.module.infra.entity.request.SystemRoleCreateRequest;
import com.orion.ops.module.infra.entity.request.SystemRoleQueryRequest;
import com.orion.ops.module.infra.entity.request.SystemRoleUpdateRequest;
import com.orion.ops.module.infra.entity.vo.SystemRoleVO;
import com.orion.ops.module.infra.service.PermissionService;
import com.orion.ops.module.infra.service.SystemRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -33,29 +35,45 @@ public class SystemRoleServiceImpl implements SystemRoleService {
@Resource
private SystemRoleDAO systemRoleDAO;
@Resource
private PermissionService permissionService;
@Override
public Long createSystemRole(SystemRoleCreateRequest request) {
// 转换
SystemRoleDO record = SystemRoleConvert.MAPPER.to(request);
record.setId(null);
// 查询是否存在
this.checkSystemRolePresent(record);
// 查询名称是否存在
this.checkNamePresent(record);
// 查询编码是否存在
this.checkCodePresent(record);
// 插入
int effect = systemRoleDAO.insert(record);
log.info("SystemRoleService-createSystemRole effect: {}, domain: {}", effect, JSON.toJSONString(record));
// 设置到缓存
permissionService.getRoleCache().put(record.getCode(), record);
return record.getId();
}
@Override
public Integer updateSystemRole(SystemRoleUpdateRequest request) {
// 查询
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
SystemRoleDO record = systemRoleDAO.selectById(id);
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
// 转换
SystemRoleDO record = SystemRoleConvert.MAPPER.to(request);
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
// 查询是否存在
this.checkSystemRolePresent(record);
SystemRoleDO updateRecord = SystemRoleConvert.MAPPER.to(request);
// 查询数据是否冲突
// 查询名称是否存在
this.checkNamePresent(updateRecord);
// 查询编码是否存在
this.checkCodePresent(updateRecord);
// 更新
int effect = systemRoleDAO.updateById(record);
log.info("SystemRoleService-updateSystemRole effect: {}, domain: {}", effect, JSON.toJSONString(record));
int effect = systemRoleDAO.updateById(updateRecord);
log.info("SystemRoleService-updateSystemRole effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
// 设置到缓存
SystemRoleDO roleCache = permissionService.getRoleCache().get(record.getCode());
roleCache.setName(updateRecord.getName());
return effect;
}
@@ -86,7 +104,8 @@ public class SystemRoleServiceImpl implements SystemRoleService {
.eq(SystemRoleDO::getId, request.getId())
.eq(SystemRoleDO::getName, request.getName())
.eq(SystemRoleDO::getCode, request.getCode())
.eq(SystemRoleDO::getStatus, request.getStatus());
.eq(SystemRoleDO::getStatus, request.getStatus())
.orderByDesc(SystemRoleDO::getId);
// 查询
return systemRoleDAO.of()
.wrapper(wrapper)
@@ -109,22 +128,35 @@ public class SystemRoleServiceImpl implements SystemRoleService {
}
/**
* 检测对象是否存在
* 检测名称是否存在
*
* @param domain domain
*/
private void checkSystemRolePresent(SystemRoleDO domain) {
private void checkNamePresent(SystemRoleDO domain) {
// 构造条件
LambdaQueryWrapper<SystemRoleDO> wrapper = systemRoleDAO.wrapper()
// 更新时忽略当前记录
.ne(SystemRoleDO::getId, domain.getId())
// 用其他字段做重复校验
.eq(SystemRoleDO::getName, domain.getName())
.eq(SystemRoleDO::getCode, domain.getCode())
.eq(SystemRoleDO::getStatus, domain.getStatus());
.eq(SystemRoleDO::getName, domain.getName());
// 检查是否存在
boolean present = systemRoleDAO.of().wrapper(wrapper).present();
Valid.isFalse(present, ErrorMessage.DATA_PRESENT);
Valid.isFalse(present, ErrorMessage.NAME_PRESENT);
}
/**
* 检测编码是否存在
*
* @param domain domain
*/
private void checkCodePresent(SystemRoleDO domain) {
// 构造条件
LambdaQueryWrapper<SystemRoleDO> wrapper = systemRoleDAO.wrapper()
// 更新时忽略当前记录
.ne(SystemRoleDO::getId, domain.getId())
.eq(SystemRoleDO::getCode, domain.getCode());
// 检查是否存在
boolean present = systemRoleDAO.of().wrapper(wrapper).present();
Valid.isFalse(present, ErrorMessage.CODE_PRESENT);
}
}

View File

@@ -24,7 +24,7 @@ import java.util.List;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-16 01:19
* @since 2023-7-16 22:46
*/
@Slf4j
@Service
@@ -38,24 +38,27 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
// 转换
SystemUserRoleDO record = SystemUserRoleConvert.MAPPER.to(request);
record.setId(null);
// 查询是否存在
// 查询数据是否冲突
this.checkSystemUserRolePresent(record);
// 插入
int effect = systemUserRoleDAO.insert(record);
log.info("SystemUserRoleService-createSystemUserRole effect: {}, domain: {}", effect, JSON.toJSONString(record));
log.info("SystemUserRoleService-createSystemUserRole effect: {}, record: {}", effect, JSON.toJSONString(record));
return record.getId();
}
@Override
public Integer updateSystemUserRole(SystemUserRoleUpdateRequest request) {
// 查询
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
SystemUserRoleDO record = systemUserRoleDAO.selectById(id);
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
// 转换
SystemUserRoleDO record = SystemUserRoleConvert.MAPPER.to(request);
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
// 查询是否存在
this.checkSystemUserRolePresent(record);
SystemUserRoleDO updateRecord = SystemUserRoleConvert.MAPPER.to(request);
// 查询数据是否冲突
this.checkSystemUserRolePresent(updateRecord);
// 更新
int effect = systemUserRoleDAO.updateById(record);
log.info("SystemUserRoleService-updateSystemUserRole effect: {}, domain: {}", effect, JSON.toJSONString(record));
int effect = systemUserRoleDAO.updateById(updateRecord);
log.info("SystemUserRoleService-updateSystemUserRole effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
return effect;
}
@@ -85,7 +88,8 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
LambdaQueryWrapper<SystemUserRoleDO> wrapper = systemUserRoleDAO.wrapper()
.eq(SystemUserRoleDO::getId, request.getId())
.eq(SystemUserRoleDO::getUserId, request.getUserId())
.eq(SystemUserRoleDO::getRoleId, request.getRoleId());
.eq(SystemUserRoleDO::getRoleId, request.getRoleId())
.orderByDesc(SystemUserRoleDO::getId);
// 查询
return systemUserRoleDAO.of()
.wrapper(wrapper)

View File

@@ -24,7 +24,7 @@ import java.util.List;
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023-7-14 10:16
* @since 2023-7-16 22:46
*/
@Slf4j
@Service
@@ -38,24 +38,27 @@ public class SystemUserServiceImpl implements SystemUserService {
// 转换
SystemUserDO record = SystemUserConvert.MAPPER.to(request);
record.setId(null);
// 查询是否存在
// 查询数据是否冲突
this.checkSystemUserPresent(record);
// 插入
int effect = systemUserDAO.insert(record);
log.info("SystemUserService-createSystemUser effect: {}, domain: {}", effect, JSON.toJSONString(record));
log.info("SystemUserService-createSystemUser effect: {}, record: {}", effect, JSON.toJSONString(record));
return record.getId();
}
@Override
public Integer updateSystemUser(SystemUserUpdateRequest request) {
// 查询
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
SystemUserDO record = systemUserDAO.selectById(id);
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
// 转换
SystemUserDO record = SystemUserConvert.MAPPER.to(request);
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
// 查询是否存在
this.checkSystemUserPresent(record);
SystemUserDO updateRecord = SystemUserConvert.MAPPER.to(request);
// 查询数据是否冲突
this.checkSystemUserPresent(updateRecord);
// 更新
int effect = systemUserDAO.updateById(record);
log.info("SystemUserService-updateSystemUser effect: {}, domain: {}", effect, JSON.toJSONString(record));
int effect = systemUserDAO.updateById(updateRecord);
log.info("SystemUserService-updateSystemUser effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
return effect;
}
@@ -91,7 +94,8 @@ public class SystemUserServiceImpl implements SystemUserService {
.eq(SystemUserDO::getMobile, request.getMobile())
.eq(SystemUserDO::getEmail, request.getEmail())
.eq(SystemUserDO::getStatus, request.getStatus())
.eq(SystemUserDO::getLastLoginTime, request.getLastLoginTime());
.eq(SystemUserDO::getLastLoginTime, request.getLastLoginTime())
.orderByDesc(SystemUserDO::getId);
// 查询
return systemUserDAO.of()
.wrapper(wrapper)