@@ -11,7 +11,6 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
@@ -24,7 +23,6 @@ import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_config")
|
||||
@ExcelIgnoreUnannotated
|
||||
@ApiModel("参数配置业务对象")
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@@ -24,7 +23,6 @@ import java.util.Map;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_logininfor")
|
||||
@ExcelIgnoreUnannotated
|
||||
@ApiModel("系统访问记录业务对象")
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.ruoyi.common.xss.Xss;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
@@ -20,7 +19,6 @@ import javax.validation.constraints.Size;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_notice")
|
||||
public class SysNotice extends BaseEntity {
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@@ -24,7 +23,6 @@ import java.util.Map;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_oper_log")
|
||||
@ExcelIgnoreUnannotated
|
||||
@ApiModel("操作日志记录业务对象")
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* OSS对象存储对象
|
||||
@@ -15,7 +14,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_oss")
|
||||
public class SysOss extends BaseEntity {
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_oss_config")
|
||||
public class SysOssConfig extends BaseEntity {
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
@@ -25,7 +24,6 @@ import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_post")
|
||||
@ExcelIgnoreUnannotated
|
||||
@ApiModel("岗位信息业务对象")
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 角色和部门关联 sys_role_dept
|
||||
@@ -15,7 +14,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_role_dept")
|
||||
@ApiModel("角色和部门关联")
|
||||
public class SysRoleDept {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联 sys_role_menu
|
||||
@@ -15,7 +14,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_role_menu")
|
||||
@ApiModel("角色和菜单关联")
|
||||
public class SysRoleMenu {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.ruoyi.system.domain;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 当前在线会话
|
||||
@@ -12,7 +11,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("当前在线会话业务对象")
|
||||
public class SysUserOnline {
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 用户和岗位关联 sys_user_post
|
||||
@@ -15,7 +14,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_user_post")
|
||||
@ApiModel("用户和岗位关联")
|
||||
public class SysUserPost {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 用户和角色关联 sys_user_role
|
||||
@@ -15,7 +14,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_user_role")
|
||||
@ApiModel("用户和角色关联")
|
||||
public class SysUserRole {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.ruoyi.common.utils.StringUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 路由显示信息
|
||||
@@ -13,7 +12,6 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("路由显示信息")
|
||||
public class MetaVo {
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +13,6 @@ import java.util.List;
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
@ApiModel("路由配置信息")
|
||||
public class RouterVo {
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@@ -18,7 +17,6 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SysUserExportVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.ruoyi.system.listener;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.excel.ExcelListener;
|
||||
import com.ruoyi.common.excel.ExcelResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.ValidatorUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
||||
@@ -45,7 +45,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
||||
this.userService = SpringUtils.getBean(ISysUserService.class);
|
||||
this.password = SecurityUtils.encryptPassword(initPassword);
|
||||
this.isUpdateSupport = isUpdateSupport;
|
||||
this.operName = LoginUtils.getUsername();
|
||||
this.operName = LoginHelper.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +53,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
||||
SysUser user = this.userService.selectUserByUserName(userVo.getUserName());
|
||||
try {
|
||||
// 验证是否存在这个用户
|
||||
if (StringUtils.isNull(user)) {
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
user = BeanUtil.toBean(userVo, SysUser.class);
|
||||
ValidatorUtils.validate(user);
|
||||
user.setPassword(password);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
@@ -15,9 +16,9 @@ public interface SysDictDataMapper extends BaseMapperPlus<SysDictDataMapper, Sys
|
||||
|
||||
default List<SysDictData> selectDictDataByType(String dictType) {
|
||||
return selectList(
|
||||
new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getStatus, "0")
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getStatus, UserConstants.DICT_NORMAL)
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.ruoyi.system.service.ISysDictTypeService;
|
||||
import com.ruoyi.system.service.ISysOssConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -17,7 +16,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
public class SystemApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@@ -30,7 +29,7 @@ public class SystemApplicationRunner implements ApplicationRunner {
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
ossConfigService.init();
|
||||
log.info("初始化OSS配置成功");
|
||||
if (ruoyiConfig.isCacheLazy()){
|
||||
if (ruoyiConfig.isCacheLazy()) {
|
||||
return;
|
||||
}
|
||||
configService.loadingConfigCache();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
/**
|
||||
* 通用 数据权限 服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysDataScopeService {
|
||||
|
||||
/**
|
||||
* 获取角色自定义权限
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @return 部门id组
|
||||
*/
|
||||
String getRoleCustom(Long roleId);
|
||||
|
||||
/**
|
||||
* 获取部门及以下权限
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 部门id组
|
||||
*/
|
||||
String getDeptAndChild(Long deptId);
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public interface ISysDeptService {
|
||||
SysDept selectDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
* 根据ID查询所有子部门数(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.ruoyi.system.service;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.UserService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysUserService extends UserService {
|
||||
public interface ISysUserService {
|
||||
|
||||
|
||||
TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery);
|
||||
@@ -47,7 +46,6 @@ public interface ISysUserService extends UserService {
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
@@ -56,7 +54,6 @@ public interface ISysUserService extends UserService {
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.dto.RoleDTO;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.service.LogininforService;
|
||||
import com.ruoyi.common.enums.DeviceType;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.exception.user.UserException;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -60,17 +66,8 @@ public class SysLoginService {
|
||||
throw new UserException("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME);
|
||||
}
|
||||
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
log.info("登录用户:{} 已被删除.", username);
|
||||
throw new UserException("user.password.delete", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
SysUser user = loadUserByUsername(username);
|
||||
|
||||
if (!SecurityUtils.matchesPassword(password, user.getPassword())) {
|
||||
// 是否第一次
|
||||
errorNumber = ObjectUtil.isNull(errorNumber) ? 1 : errorNumber + 1;
|
||||
@@ -92,15 +89,10 @@ public class SysLoginService {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
||||
recordLoginInfo(user.getUserId(), username);
|
||||
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setDeptId(user.getDeptId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
loginUser.setMenuPermission(permissionService.getMenuPermission(user));
|
||||
loginUser.setRolePermission(permissionService.getRolePermission(user));
|
||||
LoginUser loginUser = buildLoginUser(user);
|
||||
|
||||
// 生成token
|
||||
LoginUtils.loginByDevice(loginUser, UserType.SYS_USER, DeviceType.PC);
|
||||
LoginHelper.loginByDevice(loginUser, DeviceType.PC);
|
||||
return StpUtil.getTokenValue();
|
||||
}
|
||||
|
||||
@@ -125,6 +117,39 @@ public class SysLoginService {
|
||||
}
|
||||
}
|
||||
|
||||
private SysUser loadUserByUsername(String username) {
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
log.info("登录用户:{} 已被删除.", username);
|
||||
throw new UserException("user.password.delete", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建登录用户
|
||||
*/
|
||||
private LoginUser buildLoginUser(SysUser user) {
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setDeptId(user.getDeptId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
loginUser.setNickName(user.getNickName());
|
||||
loginUser.setUserType(user.getUserType());
|
||||
loginUser.setMenuPermission(permissionService.getMenuPermission(user));
|
||||
loginUser.setRolePermission(permissionService.getRolePermission(user));
|
||||
loginUser.setDeptName(user.getDept().getDeptName());
|
||||
List<RoleDTO> roles = BeanUtil.copyToList(user.getRoles(), RoleDTO.class);
|
||||
loginUser.setRoles(roles);
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
|
||||
@@ -5,16 +5,19 @@ import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||
import com.ruoyi.common.core.service.LogininforService;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.exception.user.UserException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 注册校验方法
|
||||
*
|
||||
@@ -31,41 +34,32 @@ public class SysRegisterService {
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public String register(RegisterBody registerBody) {
|
||||
String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
|
||||
public void register(RegisterBody registerBody) {
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
String username = registerBody.getUsername();
|
||||
String password = registerBody.getPassword();
|
||||
// 校验用户类型是否存在
|
||||
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
||||
|
||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||
// 验证码开关
|
||||
if (captchaOnOff) {
|
||||
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
|
||||
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid(), request);
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
msg = "用户名不能为空";
|
||||
} else if (StringUtils.isEmpty(password)) {
|
||||
msg = "用户密码不能为空";
|
||||
} else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
msg = "账户长度必须在2到20个字符之间";
|
||||
} else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
msg = "密码长度必须在5到20个字符之间";
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
|
||||
msg = "保存用户'" + username + "'失败,注册账号已存在";
|
||||
} else {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||
boolean regFlag = userService.registerUser(sysUser);
|
||||
if (!regFlag) {
|
||||
msg = "注册失败,请联系系统管理人员";
|
||||
} else {
|
||||
asyncService.recordLogininfor(username, Constants.REGISTER,
|
||||
MessageUtils.message("user.register.success"), ServletUtils.getRequest());
|
||||
}
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
return msg;
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
sysUser.setUserType(userType);
|
||||
boolean regFlag = userService.registerUser(sysUser);
|
||||
if (!regFlag) {
|
||||
throw new UserException("user.register.error");
|
||||
}
|
||||
asyncService.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success"), request);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,14 +70,16 @@ public class SysRegisterService {
|
||||
* @param uuid 唯一标识
|
||||
* @return 结果
|
||||
*/
|
||||
public void validateCaptcha(String username, String code, String uuid) {
|
||||
public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) {
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
asyncService.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.jcaptcha.expire"), request);
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
asyncService.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.jcaptcha.error"), request);
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -73,7 +74,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
}
|
||||
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
||||
.eq(SysConfig::getConfigKey, configKey));
|
||||
if (StringUtils.isNotNull(retConfig)) {
|
||||
if (ObjectUtil.isNotNull(retConfig)) {
|
||||
RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
||||
return retConfig.getConfigValue();
|
||||
}
|
||||
@@ -197,9 +198,9 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
*/
|
||||
@Override
|
||||
public String checkConfigKeyUnique(SysConfig config) {
|
||||
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
||||
Long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
||||
SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey()));
|
||||
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
|
||||
if (ObjectUtil.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.system.domain.SysRoleDept;
|
||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleDeptMapper;
|
||||
import com.ruoyi.system.service.SysDataScopeService;
|
||||
import com.ruoyi.system.service.ISysDataScopeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service("sdss")
|
||||
public class SysDataScopeServiceImpl implements SysDataScopeService {
|
||||
public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
||||
|
||||
private final SysRoleDeptMapper roleDeptMapper;
|
||||
private final SysDeptMapper deptMapper;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
@@ -10,7 +11,7 @@ import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.TreeBuildUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@@ -45,8 +46,6 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysDept> selectDeptList(SysDept dept) {
|
||||
// return baseMapper.selectList();
|
||||
// return baseMapper.selectList(new LambdaQueryWrapper<>());
|
||||
return baseMapper.selectDeptList(dept);
|
||||
}
|
||||
|
||||
@@ -93,7 +92,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
* 根据ID查询所有子部门数(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
@@ -101,7 +100,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
@Override
|
||||
public long selectNormalChildrenDeptById(Long deptId) {
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getStatus, 0)
|
||||
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
||||
.apply("find_in_set({0}, ancestors)", deptId));
|
||||
}
|
||||
|
||||
@@ -137,12 +136,11 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
*/
|
||||
@Override
|
||||
public String checkDeptNameUnique(SysDept dept) {
|
||||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getDeptName, dept.getDeptName())
|
||||
.eq(SysDept::getParentId, dept.getParentId())
|
||||
.ne(SysDept::getDeptId, deptId));
|
||||
if (count) {
|
||||
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -155,11 +153,11 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
*/
|
||||
@Override
|
||||
public void checkDeptDataScope(Long deptId) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginHelper.getUserId())) {
|
||||
SysDept dept = new SysDept();
|
||||
dept.setDeptId(deptId);
|
||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
if (StringUtils.isEmpty(depts)) {
|
||||
if (CollUtil.isEmpty(depts)) {
|
||||
throw new ServiceException("没有权限访问部门数据!");
|
||||
}
|
||||
}
|
||||
@@ -192,7 +190,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
public int updateDept(SysDept dept) {
|
||||
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
|
||||
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
||||
if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
@@ -200,7 +198,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
}
|
||||
int result = baseMapper.updateById(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals("0", dept.getAncestors())) {
|
||||
&& !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
|
||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
updateParentDeptStatusNormal(dept);
|
||||
}
|
||||
@@ -216,7 +214,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
String ancestors = dept.getAncestors();
|
||||
Long[] deptIds = Convert.toLongArray(ancestors);
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
|
||||
.set(SysDept::getStatus, "0")
|
||||
.set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
||||
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
@Override
|
||||
public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysDictData> lqw = new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||
.orderByAsc(SysDictData::getDictSort);
|
||||
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||
.orderByAsc(SysDictData::getDictSort);
|
||||
Page<SysDictData> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
@@ -46,10 +46,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataList(SysDictData dictData) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
.select(SysDictData::getDictLabel)
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.eq(SysDictData::getDictValue, dictValue))
|
||||
.getDictLabel();
|
||||
.getDictLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -21,10 +22,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
@@ -87,7 +86,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||
List<SysDictData> dictDatas = RedisUtils.getCacheObject(getCacheKey(dictType));
|
||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
if (CollUtil.isNotEmpty(dictDatas)) {
|
||||
return dictDatas;
|
||||
}
|
||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
@@ -130,8 +129,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
public void deleteDictTypeByIds(Long[] dictIds) {
|
||||
for (Long dictId : dictIds) {
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
if (dictDataMapper.selectCount(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, dictType.getDictType())) > 0) {
|
||||
if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, dictType.getDictType()))) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
RedisUtils.deleteObject(getCacheKey(dictType.getDictType()));
|
||||
@@ -144,11 +143,16 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
*/
|
||||
@Override
|
||||
public void loadingDictCache() {
|
||||
List<SysDictType> dictTypeList = baseMapper.selectList();
|
||||
for (SysDictType dictType : dictTypeList) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
|
||||
RedisUtils.setCacheObject(getCacheKey(dictType.getDictType()), dictDatas);
|
||||
}
|
||||
List<SysDictData> dictDataList = dictDataMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getStatus, UserConstants.DICT_NORMAL));
|
||||
Map<String, List<SysDictData>> dictDataMap = dictDataList.stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
dictDataMap.forEach((k,v) -> {
|
||||
String dictKey = getCacheKey(k);
|
||||
List<SysDictData> dictList = v.stream()
|
||||
.sorted(Comparator.comparing(SysDictData::getDictSort))
|
||||
.collect(Collectors.toList());
|
||||
RedisUtils.setCacheObject(dictKey, dictList);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,11 +217,10 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
*/
|
||||
@Override
|
||||
public String checkDictTypeUnique(SysDictType dict) {
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
long count = baseMapper.selectCount(new LambdaQueryWrapper<SysDictType>()
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>()
|
||||
.eq(SysDictType::getDictType, dict.getDictType())
|
||||
.ne(SysDictType::getDictId, dictId));
|
||||
if (count > 0) {
|
||||
.ne(ObjectUtil.isNotNull(dict.getDictId()), SysDictType::getDictId, dict.getDictId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
|
||||
@@ -99,8 +99,9 @@ public class SysLogininforServiceImpl implements ISysLogininforService, Logininf
|
||||
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"));
|
||||
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("info_id").setIsAsc("desc");
|
||||
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("info_id");
|
||||
pageQuery.setIsAsc("desc");
|
||||
}
|
||||
Page<SysLogininfor> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
@@ -262,12 +263,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public String checkMenuNameUnique(SysMenu menu) {
|
||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenu::getParentId, menu.getParentId())
|
||||
.ne(SysMenu::getMenuId, menuId));
|
||||
if (count) {
|
||||
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
|
||||
@@ -28,9 +28,9 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
@Override
|
||||
public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = new LambdaQueryWrapper<SysNotice>()
|
||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
|
||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
|
||||
Page<SysNotice> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
@@ -55,9 +55,9 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
@Override
|
||||
public List<SysNotice> selectNoticeList(SysNotice notice) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysNotice>()
|
||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
|
||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,8 +64,9 @@ public class SysOperLogServiceImpl implements ISysOperLogService, OperLogService
|
||||
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"));
|
||||
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("oper_id").setIsAsc("desc");
|
||||
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("oper_id");
|
||||
pageQuery.setIsAsc("desc");
|
||||
}
|
||||
Page<SysOperLog> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -106,7 +107,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
*/
|
||||
private void validEntityBeforeSave(SysOssConfig entity) {
|
||||
if (StringUtils.isNotEmpty(entity.getConfigKey())
|
||||
&& UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) {
|
||||
&& UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) {
|
||||
throw new ServiceException("操作配置'" + entity.getConfigKey() + "'失败, 配置key已存在!");
|
||||
}
|
||||
}
|
||||
@@ -136,11 +137,11 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
* 判断configKey是否唯一
|
||||
*/
|
||||
private String checkConfigKeyUnique(SysOssConfig sysOssConfig) {
|
||||
long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
|
||||
long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
|
||||
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
|
||||
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
||||
if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
|
||||
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
||||
if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -154,7 +155,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
public int updateOssConfigStatus(SysOssConfigBo bo) {
|
||||
SysOssConfig sysOssConfig = BeanUtil.toBean(bo, SysOssConfig.class);
|
||||
int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>()
|
||||
.set(SysOssConfig::getStatus, "1"));
|
||||
.set(SysOssConfig::getStatus, "1"));
|
||||
row += baseMapper.updateById(sysOssConfig);
|
||||
if (row > 0) {
|
||||
RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey());
|
||||
@@ -182,8 +183,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
private boolean setConfigCache(boolean flag, SysOssConfig config) {
|
||||
if (flag) {
|
||||
RedisUtils.setCacheObject(
|
||||
getCacheKey(config.getConfigKey()),
|
||||
JsonUtils.toJsonString(config));
|
||||
getCacheKey(config.getConfigKey()),
|
||||
JsonUtils.toJsonString(config));
|
||||
RedisUtils.publish(OssConstant.CACHE_CONFIG_KEY, config.getConfigKey(), msg -> {
|
||||
log.info("发布刷新OSS配置 => " + msg);
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
|
||||
return lqw;
|
||||
@@ -73,12 +73,12 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
// 保存文件信息
|
||||
SysOss oss = new SysOss()
|
||||
.setUrl(uploadResult.getUrl())
|
||||
.setFileSuffix(suffix)
|
||||
.setFileName(uploadResult.getFilename())
|
||||
.setOriginalName(originalfileName)
|
||||
.setService(storage.getServiceType());
|
||||
SysOss oss = new SysOss();
|
||||
oss.setUrl(uploadResult.getUrl());
|
||||
oss.setFileSuffix(suffix);
|
||||
oss.setFileName(uploadResult.getFilename());
|
||||
oss.setOriginalName(originalfileName);
|
||||
oss.setService(storage.getServiceType().getValue());
|
||||
baseMapper.insert(oss);
|
||||
return oss;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
@@ -33,9 +34,9 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||
@Override
|
||||
public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysPost> lqw = new LambdaQueryWrapper<SysPost>()
|
||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName());
|
||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName());
|
||||
Page<SysPost> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
@@ -49,9 +50,9 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||
@Override
|
||||
public List<SysPost> selectPostList(SysPost post) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysPost>()
|
||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()));
|
||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,11 +95,10 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||
*/
|
||||
@Override
|
||||
public String checkPostNameUnique(SysPost post) {
|
||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostName, post.getPostName())
|
||||
.ne(SysPost::getPostId, postId));
|
||||
if (count) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostName, post.getPostName())
|
||||
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -112,11 +112,10 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||
*/
|
||||
@Override
|
||||
public String checkPostCodeUnique(SysPost post) {
|
||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostCode, post.getPostCode())
|
||||
.ne(SysPost::getPostId, postId));
|
||||
if (count) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostCode, post.getPostCode())
|
||||
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
@@ -8,8 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.domain.SysRoleDept;
|
||||
import com.ruoyi.system.domain.SysRoleMenu;
|
||||
@@ -88,7 +89,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
List<SysRole> perms = baseMapper.selectRolePermissionByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (SysRole perm : perms) {
|
||||
if (StringUtils.isNotNull(perm)) {
|
||||
if (ObjectUtil.isNotNull(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
||||
}
|
||||
}
|
||||
@@ -135,11 +136,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
*/
|
||||
@Override
|
||||
public String checkRoleNameUnique(SysRole role) {
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleName, role.getRoleName())
|
||||
.ne(SysRole::getRoleId, roleId));
|
||||
if (count) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleName, role.getRoleName())
|
||||
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -153,11 +153,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
*/
|
||||
@Override
|
||||
public String checkRoleKeyUnique(SysRole role) {
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleKey, role.getRoleKey())
|
||||
.ne(SysRole::getRoleId, roleId));
|
||||
if (count) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleKey, role.getRoleKey())
|
||||
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -170,7 +169,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleAllowed(SysRole role) {
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) {
|
||||
if (ObjectUtil.isNotNull(role.getRoleId()) && role.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员角色");
|
||||
}
|
||||
}
|
||||
@@ -182,11 +181,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(Long roleId) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginHelper.getUserId())) {
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
if (StringUtils.isEmpty(roles)) {
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
}
|
||||
}
|
||||
@@ -330,6 +329,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
public int deleteRoleByIds(Long[] roleIds) {
|
||||
for (Long roleId : roleIds) {
|
||||
checkRoleAllowed(new SysRole(roleId));
|
||||
checkRoleDataScope(roleId);
|
||||
SysRole role = selectRoleById(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
@@ -352,8 +352,8 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
@Override
|
||||
public int deleteAuthUser(SysUserRole userRole) {
|
||||
return userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getRoleId, userRole.getRoleId())
|
||||
.eq(SysUserRole::getUserId, userRole.getUserId()));
|
||||
.eq(SysUserRole::getRoleId, userRole.getRoleId())
|
||||
.eq(SysUserRole::getUserId, userRole.getUserId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,8 +366,8 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
@Override
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds) {
|
||||
return userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getRoleId, roleId)
|
||||
.in(SysUserRole::getUserId, Arrays.asList(userIds)));
|
||||
.eq(SysUserRole::getRoleId, roleId)
|
||||
.in(SysUserRole::getUserId, Arrays.asList(userIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.SensitiveService;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SysSensitiveServiceImpl implements SensitiveService {
|
||||
*/
|
||||
@Override
|
||||
public boolean isSensitive() {
|
||||
return SecurityUtils.isAdmin(LoginUtils.getUserId());
|
||||
return SecurityUtils.isAdmin(LoginHelper.getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -9,10 +10,8 @@ import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.UserService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
@@ -38,7 +37,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
public class SysUserServiceImpl implements ISysUserService {
|
||||
|
||||
private final SysUserMapper baseMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
@@ -147,8 +146,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public String checkUserNameUnique(String userName) {
|
||||
long count = baseMapper.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
||||
if (count > 0) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -162,11 +161,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public String checkPhoneUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getPhonenumber, user.getPhonenumber())
|
||||
.ne(SysUser::getUserId, userId));
|
||||
if (count) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getPhonenumber, user.getPhonenumber())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -180,11 +178,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public String checkEmailUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getEmail, user.getEmail())
|
||||
.ne(SysUser::getUserId, userId));
|
||||
if (count) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getEmail, user.getEmail())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
if (exist) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -197,7 +194,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user) {
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||
if (ObjectUtil.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
@@ -209,11 +206,11 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginHelper.getUserId())) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
if (StringUtils.isEmpty(users)) {
|
||||
if (CollUtil.isEmpty(users)) {
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
@@ -245,6 +242,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUser user) {
|
||||
user.setCreateBy(user.getUserName());
|
||||
user.setUpdateBy(user.getUserName());
|
||||
return baseMapper.insert(user) > 0;
|
||||
}
|
||||
|
||||
@@ -279,7 +278,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void insertUserAuth(Long userId, Long[] roleIds) {
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getUserId, userId));
|
||||
.eq(SysUserRole::getUserId, userId));
|
||||
insertUserRole(userId, roleIds);
|
||||
}
|
||||
|
||||
@@ -315,9 +314,9 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userName, String avatar) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getAvatar, avatar)
|
||||
.eq(SysUser::getUserName, userName)) > 0;
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getAvatar, avatar)
|
||||
.eq(SysUser::getUserName, userName)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,9 +340,9 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@Override
|
||||
public int resetUserPwd(String userName, String password) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getPassword, password)
|
||||
.eq(SysUser::getUserName, userName));
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getPassword, password)
|
||||
.eq(SysUser::getUserName, userName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +352,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
public void insertUserRole(SysUser user) {
|
||||
Long[] roles = user.getRoleIds();
|
||||
if (StringUtils.isNotNull(roles)) {
|
||||
if (ObjectUtil.isNotNull(roles)) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
for (Long roleId : roles) {
|
||||
@@ -375,7 +374,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
public void insertUserPost(SysUser user) {
|
||||
Long[] posts = user.getPostIds();
|
||||
if (StringUtils.isNotNull(posts)) {
|
||||
if (ObjectUtil.isNotNull(posts)) {
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = new ArrayList<SysUserPost>();
|
||||
for (Long postId : posts) {
|
||||
@@ -397,7 +396,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
public void insertUserRole(Long userId, Long[] roleIds) {
|
||||
if (StringUtils.isNotNull(roleIds)) {
|
||||
if (ObjectUtil.isNotNull(roleIds)) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
for (Long roleId : roleIds) {
|
||||
@@ -439,6 +438,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
public int deleteUserByIds(Long[] userIds) {
|
||||
for (Long userId : userIds) {
|
||||
checkUserAllowed(new SysUser(userId));
|
||||
checkUserDataScope(userId);
|
||||
}
|
||||
List<Long> ids = Arrays.asList(userIds);
|
||||
// 删除用户与角色关联
|
||||
|
||||
Reference in New Issue
Block a user