mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-22 14:57:14 +08:00
chore: continew-starter 2.7.2 => 2.7.3
1.CrudApi GET => DETAIL(支持详情权限) 2.适配 CharConstants 3.适配 EnumValue 校验器
This commit is contained in:
@@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.continew.admin.common.constant.SysConstants;
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.service.OptionService;
|
||||
import top.continew.starter.messaging.mail.core.MailConfig;
|
||||
import top.continew.starter.messaging.mail.core.MailConfigurer;
|
||||
@@ -43,7 +44,7 @@ public class MailConfigurerImpl implements MailConfigurer {
|
||||
@Override
|
||||
public MailConfig getMailConfig() {
|
||||
// 查询邮件配置
|
||||
Map<String, String> map = optionService.getByCategory("MAIL");
|
||||
Map<String, String> map = optionService.getByCategory(OptionCategoryEnum.MAIL);
|
||||
// 封装邮件配置
|
||||
MailConfig mailConfig = new MailConfig();
|
||||
mailConfig.setProtocol(MapUtil.getStr(map, "MAIL_PROTOCOL"));
|
||||
|
@@ -168,7 +168,7 @@ public enum PasswordPolicyEnum {
|
||||
/**
|
||||
* 策略类别
|
||||
*/
|
||||
public static final String CATEGORY = "PASSWORD";
|
||||
public static final OptionCategoryEnum CATEGORY = OptionCategoryEnum.PASSWORD;
|
||||
|
||||
/**
|
||||
* 校验取值范围
|
||||
|
@@ -19,6 +19,7 @@ package top.continew.admin.system.model.query;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.starter.core.validation.constraints.EnumValue;
|
||||
import top.continew.starter.data.core.annotation.Query;
|
||||
import top.continew.starter.data.core.enums.QueryType;
|
||||
|
||||
@@ -50,5 +51,6 @@ public class OptionQuery implements Serializable {
|
||||
* 类别
|
||||
*/
|
||||
@Schema(description = "类别", example = "SITE")
|
||||
private OptionCategoryEnum category;
|
||||
@EnumValue(value = OptionCategoryEnum.class, message = "类别非法")
|
||||
private String category;
|
||||
}
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.continew.admin.system.service;
|
||||
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.model.query.OptionQuery;
|
||||
import top.continew.admin.system.model.req.OptionReq;
|
||||
import top.continew.admin.system.model.req.OptionResetValueReq;
|
||||
@@ -47,7 +48,7 @@ public interface OptionService {
|
||||
* @param category 类别
|
||||
* @return 参数信息
|
||||
*/
|
||||
Map<String, String> getByCategory(String category);
|
||||
Map<String, String> getByCategory(OptionCategoryEnum category);
|
||||
|
||||
/**
|
||||
* 修改参数
|
||||
|
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWra
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.continew.admin.common.constant.CacheConstants;
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.enums.PasswordPolicyEnum;
|
||||
import top.continew.admin.system.mapper.OptionMapper;
|
||||
import top.continew.admin.system.model.entity.OptionDO;
|
||||
@@ -64,8 +65,8 @@ public class OptionServiceImpl implements OptionService {
|
||||
|
||||
@Override
|
||||
@Cached(key = "#category", name = CacheConstants.OPTION_KEY_PREFIX + "MAP:")
|
||||
public Map<String, String> getByCategory(String category) {
|
||||
return baseMapper.selectByCategory(category)
|
||||
public Map<String, String> getByCategory(OptionCategoryEnum category) {
|
||||
return baseMapper.selectByCategory(category.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(OptionDO::getCode, o -> StrUtil.emptyIfNull(ObjectUtil.defaultIfNull(o
|
||||
.getValue(), o.getDefaultValue())), (oldVal, newVal) -> oldVal));
|
||||
@@ -87,8 +88,8 @@ public class OptionServiceImpl implements OptionService {
|
||||
}
|
||||
// 校验密码策略参数取值范围
|
||||
Map<String, String> passwordPolicyOptionMap = options.stream()
|
||||
.filter(option -> StrUtil.startWith(option
|
||||
.getCode(), PasswordPolicyEnum.CATEGORY + StringConstants.UNDERLINE))
|
||||
.filter(option -> StrUtil.startWith(option.getCode(), PasswordPolicyEnum.CATEGORY
|
||||
.name() + StringConstants.UNDERLINE))
|
||||
.collect(Collectors.toMap(OptionReq::getCode, OptionReq::getValue, (oldVal, newVal) -> oldVal));
|
||||
for (Map.Entry<String, String> passwordPolicyOptionEntry : passwordPolicyOptionMap.entrySet()) {
|
||||
String code = passwordPolicyOptionEntry.getKey();
|
||||
|
@@ -61,6 +61,7 @@ import top.continew.admin.common.context.UserContextHolder;
|
||||
import top.continew.admin.common.enums.DisEnableStatusEnum;
|
||||
import top.continew.admin.common.enums.GenderEnum;
|
||||
import top.continew.admin.common.util.SecureUtils;
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.mapper.UserMapper;
|
||||
import top.continew.admin.system.model.entity.DeptDO;
|
||||
import top.continew.admin.system.model.entity.RoleDO;
|
||||
@@ -630,7 +631,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
* @return 密码允许重复使用次数
|
||||
*/
|
||||
private int checkPassword(String password, UserDO user) {
|
||||
Map<String, String> passwordPolicy = optionService.getByCategory(CATEGORY);
|
||||
Map<String, String> passwordPolicy = optionService.getByCategory(OptionCategoryEnum.PASSWORD);
|
||||
// 密码最小长度
|
||||
PASSWORD_MIN_LENGTH.validate(password, MapUtil.getInt(passwordPolicy, PASSWORD_MIN_LENGTH.name()), user);
|
||||
// 密码是否必须包含特殊字符
|
||||
|
Reference in New Issue
Block a user