mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、token、套餐产品id预设;2、登录/请求部门校验修复;
This commit is contained in:
+6
@@ -111,4 +111,10 @@ public class OAuth2AccessTokenDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String grayDefaultVersion;
|
private String grayDefaultVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品id
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Long productId;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -51,4 +51,9 @@ public class TenantPackageDO extends BaseDO {
|
|||||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||||
private Set<Long> menuIds;
|
private Set<Long> menuIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品id
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Long productId;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -130,4 +130,10 @@ public class AdminUserDO extends OrganBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private UserTypeEnum userType;
|
private UserTypeEnum userType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品id
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Long productId;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.cf.imes.module.system.framework.product;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2025/9/23 9:14
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "chenfeng.product-id")
|
||||||
|
@Data
|
||||||
|
public class ProductProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* imes生产系统
|
||||||
|
*/
|
||||||
|
private Long imesProduct;
|
||||||
|
|
||||||
|
}
|
||||||
+9
-2
@@ -1,6 +1,5 @@
|
|||||||
package com.cf.imes.module.system.service.auth;
|
package com.cf.imes.module.system.service.auth;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.anji.captcha.model.common.ResponseModel;
|
import com.anji.captcha.model.common.ResponseModel;
|
||||||
import com.anji.captcha.model.vo.CaptchaVO;
|
import com.anji.captcha.model.vo.CaptchaVO;
|
||||||
import com.anji.captcha.service.CaptchaService;
|
import com.anji.captcha.service.CaptchaService;
|
||||||
@@ -34,6 +33,8 @@ import com.cf.imes.module.system.enums.logger.LoginLogTypeEnum;
|
|||||||
import com.cf.imes.module.system.enums.logger.LoginResultEnum;
|
import com.cf.imes.module.system.enums.logger.LoginResultEnum;
|
||||||
import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants;
|
import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants;
|
||||||
import com.cf.imes.module.system.enums.sms.SmsSceneEnum;
|
import com.cf.imes.module.system.enums.sms.SmsSceneEnum;
|
||||||
|
import com.cf.imes.module.system.framework.product.ProductProperties;
|
||||||
|
import com.cf.imes.module.system.service.dept.DeptService;
|
||||||
import com.cf.imes.module.system.service.logger.LoginLogService;
|
import com.cf.imes.module.system.service.logger.LoginLogService;
|
||||||
import com.cf.imes.module.system.service.member.MemberService;
|
import com.cf.imes.module.system.service.member.MemberService;
|
||||||
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
|
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
|
||||||
@@ -103,6 +104,12 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SecurityFrameworkService securityFrameworkService;
|
private SecurityFrameworkService securityFrameworkService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeptService deptService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductProperties productProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码的开关,默认为 true
|
* 验证码的开关,默认为 true
|
||||||
*/
|
*/
|
||||||
@@ -132,7 +139,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
organFrameworkService.validOrgan(organId);
|
organFrameworkService.validOrgan(organId);
|
||||||
// 校验部门有效性
|
// 校验部门有效性
|
||||||
OrganContextHolder.setOrganId(organId);
|
OrganContextHolder.setOrganId(organId);
|
||||||
organFrameworkService.validDept(user.getDeptId());
|
deptService.validUserLoginDept(user.getDeptId());
|
||||||
// 校验密码
|
// 校验密码
|
||||||
if (!userService.isPasswordMatch(password, user.getPassword())) {
|
if (!userService.isPasswordMatch(password, user.getPassword())) {
|
||||||
createLoginLog(user.getId(), username, null, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
createLoginLog(user.getId(), username, null, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
||||||
|
|||||||
+7
@@ -84,6 +84,13 @@ public interface DeptService {
|
|||||||
*/
|
*/
|
||||||
void validDept(Long deptId);
|
void validDept(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登陆时部门校验
|
||||||
|
*
|
||||||
|
* @param deptId
|
||||||
|
*/
|
||||||
|
void validUserLoginDept(Long deptId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除没有归属(上级)的部门
|
* 移除没有归属(上级)的部门
|
||||||
*
|
*
|
||||||
|
|||||||
+18
@@ -275,6 +275,24 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
validParentDept(deptDO);
|
validParentDept(deptDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登陆时部门校验,部门不存在时也可以进行登录
|
||||||
|
*
|
||||||
|
* @param deptId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void validUserLoginDept(Long deptId) {
|
||||||
|
DeptDO deptDO = deptMapper.selectById(deptId);
|
||||||
|
if (deptDO == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!CommonStatusEnum.ENABLE.getStatus().equals(deptDO.getStatus())) {
|
||||||
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.DEPT_NOT_ALLOWED_LOGIN, deptDO.getName());
|
||||||
|
}
|
||||||
|
// 递归校验上级部门
|
||||||
|
validParentDept(deptDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归校验上级部门
|
* 递归校验上级部门
|
||||||
|
|||||||
+2
-1
@@ -224,7 +224,8 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
|||||||
.setNickname(user.getNickname())
|
.setNickname(user.getNickname())
|
||||||
.setDeptId(user.getDeptId())
|
.setDeptId(user.getDeptId())
|
||||||
.setGrayVersion(user.getGrayVersion())
|
.setGrayVersion(user.getGrayVersion())
|
||||||
.setGrayDefaultVersion(user.getGrayDefaultVersion());
|
.setGrayDefaultVersion(user.getGrayDefaultVersion())
|
||||||
|
.setProductId(user.getProductId());
|
||||||
if (organId != null) {
|
if (organId != null) {
|
||||||
OrganContextHolder.setOrganId(organId);
|
OrganContextHolder.setOrganId(organId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user