mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	refactor: 优化部分代码
修复 Sonar、Codacy 扫描问题
This commit is contained in:
		@@ -26,9 +26,6 @@ import top.charles7c.continew.starter.core.constant.StringConstants;
 | 
			
		||||
 */
 | 
			
		||||
public class CacheConstants {
 | 
			
		||||
 | 
			
		||||
    private CacheConstants() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 分隔符
 | 
			
		||||
     */
 | 
			
		||||
@@ -73,4 +70,7 @@ public class CacheConstants {
 | 
			
		||||
     * 仪表盘缓存键前缀
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DASHBOARD_KEY_PREFIX = "DASHBOARD" + DELIMITER;
 | 
			
		||||
 | 
			
		||||
    private CacheConstants() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,8 +26,10 @@ import top.charles7c.continew.starter.extension.crud.constant.ContainerPool;
 | 
			
		||||
 */
 | 
			
		||||
public class ContainerConstants extends ContainerPool {
 | 
			
		||||
 | 
			
		||||
    private ContainerConstants() {
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户昵称
 | 
			
		||||
     */
 | 
			
		||||
    public static final String USER_NICKNAME = ContainerPool.USER_NICKNAME;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户角色 ID 列表
 | 
			
		||||
@@ -38,4 +40,7 @@ public class ContainerConstants extends ContainerPool {
 | 
			
		||||
     * 角色部门列表
 | 
			
		||||
     */
 | 
			
		||||
    public static final String ROLE_DEPT_ID_LIST = "RoleDeptIdList";
 | 
			
		||||
 | 
			
		||||
    private ContainerConstants() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,34 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.common.constant;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 文件相关常量
 | 
			
		||||
 *
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 2023/1/2 21:19
 | 
			
		||||
 */
 | 
			
		||||
public class FileConstants {
 | 
			
		||||
 | 
			
		||||
    private FileConstants() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 头像支持的图片类型
 | 
			
		||||
     */
 | 
			
		||||
    public static final String[] AVATAR_SUPPORTED_IMG_TYPES = {"jpg", "png", "gif", "jpeg"};
 | 
			
		||||
}
 | 
			
		||||
@@ -16,18 +16,13 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.common.constant;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 正则相关常量
 | 
			
		||||
 *
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 2023/1/10 20:06
 | 
			
		||||
 */
 | 
			
		||||
public class RegexConstants implements RegexPool {
 | 
			
		||||
 | 
			
		||||
    private RegexConstants() {
 | 
			
		||||
    }
 | 
			
		||||
public class RegexConstants {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户名正则(长度为 4 到 64 位,可以包含字母、数字,下划线,以字母开头)
 | 
			
		||||
@@ -53,4 +48,7 @@ public class RegexConstants implements RegexPool {
 | 
			
		||||
     * 包名正则(可以包含大小写字母、数字、下划线,每一级包名不能以数字开头)
 | 
			
		||||
     */
 | 
			
		||||
    public static final String PACKAGE_NAME = "^(?:[a-zA-Z_][a-zA-Z0-9_]*\\.)*[a-zA-Z_][a-zA-Z0-9_]*$";
 | 
			
		||||
 | 
			
		||||
    private RegexConstants() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,9 +26,6 @@ import top.charles7c.continew.starter.core.constant.StringConstants;
 | 
			
		||||
 */
 | 
			
		||||
public class SysConstants {
 | 
			
		||||
 | 
			
		||||
    private SysConstants() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 管理员角色编码
 | 
			
		||||
     */
 | 
			
		||||
@@ -68,4 +65,7 @@ public class SysConstants {
 | 
			
		||||
     * 描述类字段后缀
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DESCRIPTION_FIELD_SUFFIX = "String";
 | 
			
		||||
 | 
			
		||||
    private SysConstants() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,9 +24,6 @@ package top.charles7c.continew.admin.common.constant;
 | 
			
		||||
 */
 | 
			
		||||
public class UiConstants {
 | 
			
		||||
 | 
			
		||||
    private UiConstants() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 主色(极致蓝)
 | 
			
		||||
     */
 | 
			
		||||
@@ -51,4 +48,7 @@ public class UiConstants {
 | 
			
		||||
     * 默认色(中性灰)
 | 
			
		||||
     */
 | 
			
		||||
    public static final String COLOR_DEFAULT = "gray";
 | 
			
		||||
 | 
			
		||||
    private UiConstants() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -16,19 +16,15 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.auth.model.req;
 | 
			
		||||
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.Pattern;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.validator.constraints.Length;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.RegexConstants;
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 邮箱登录信息
 | 
			
		||||
@@ -48,7 +44,7 @@ public class EmailLoginReq implements Serializable {
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "邮箱", example = "123456789@qq.com")
 | 
			
		||||
    @NotBlank(message = "邮箱不能为空")
 | 
			
		||||
    @Pattern(regexp = RegexConstants.EMAIL, message = "邮箱格式错误")
 | 
			
		||||
    @Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误")
 | 
			
		||||
    private String email;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -16,19 +16,15 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.auth.model.req;
 | 
			
		||||
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.Pattern;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.validator.constraints.Length;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.RegexConstants;
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 手机号登录信息
 | 
			
		||||
@@ -48,7 +44,7 @@ public class PhoneLoginReq implements Serializable {
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "手机号", example = "13811111111")
 | 
			
		||||
    @NotBlank(message = "手机号不能为空")
 | 
			
		||||
    @Pattern(regexp = RegexConstants.MOBILE, message = "手机号格式错误")
 | 
			
		||||
    @Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误")
 | 
			
		||||
    private String phone;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -16,19 +16,15 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.system.model.req;
 | 
			
		||||
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.Pattern;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.validator.constraints.Length;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.RegexConstants;
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用户邮箱修改信息
 | 
			
		||||
@@ -48,7 +44,7 @@ public class UserEmailUpdateRequest implements Serializable {
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "新邮箱", example = "123456789@qq.com")
 | 
			
		||||
    @NotBlank(message = "新邮箱不能为空")
 | 
			
		||||
    @Pattern(regexp = RegexConstants.EMAIL, message = "邮箱格式错误")
 | 
			
		||||
    @Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误")
 | 
			
		||||
    private String newEmail;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -60,9 +56,9 @@ public class UserEmailUpdateRequest implements Serializable {
 | 
			
		||||
    private String captcha;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前密码(加密后)
 | 
			
		||||
     * 当前密码(加密)
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "当前密码(加密后)", example = "SYRLSszQGcMv4kP2Yolou9zf28B9GDakR9u91khxmR7V++i5A384kwnNZxqgvT6bjT4zqpIDuMFLWSt92hQJJA==")
 | 
			
		||||
    @Schema(description = "当前密码(加密)", example = "SYRLSszQGcMv4kP2Yolou9zf28B9GDakR9u91khxmR7V++i5A384kwnNZxqgvT6bjT4zqpIDuMFLWSt92hQJJA==")
 | 
			
		||||
    @NotBlank(message = "当前密码不能为空")
 | 
			
		||||
    private String currentPassword;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,14 +16,12 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.system.model.req;
 | 
			
		||||
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用户密码修改信息
 | 
			
		||||
@@ -39,15 +37,15 @@ public class UserPasswordUpdateReq implements Serializable {
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前密码(加密后)
 | 
			
		||||
     * 当前密码(加密)
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "当前密码(加密后)", example = "E7c72TH+LDxKTwavjM99W1MdI9Lljh79aPKiv3XB9MXcplhm7qJ1BJCj28yaflbdVbfc366klMtjLIWQGqb0qw==")
 | 
			
		||||
    @Schema(description = "当前密码(加密)", example = "E7c72TH+LDxKTwavjM99W1MdI9Lljh79aPKiv3XB9MXcplhm7qJ1BJCj28yaflbdVbfc366klMtjLIWQGqb0qw==")
 | 
			
		||||
    private String oldPassword;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新密码(加密后)
 | 
			
		||||
     * 新密码(加密)
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "新密码(加密后)", example = "Gzc78825P5baH190lRuZFb9KJxRt/psN2jiyOMPoc5WRcCvneCwqDm3Q33BZY56EzyyVy7vQu7jQwYTK4j1+5w==")
 | 
			
		||||
    @Schema(description = "新密码(加密)", example = "Gzc78825P5baH190lRuZFb9KJxRt/psN2jiyOMPoc5WRcCvneCwqDm3Q33BZY56EzyyVy7vQu7jQwYTK4j1+5w==")
 | 
			
		||||
    @NotBlank(message = "新密码不能为空")
 | 
			
		||||
    private String newPassword;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,19 +16,15 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.system.model.req;
 | 
			
		||||
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.Pattern;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.validator.constraints.Length;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.RegexConstants;
 | 
			
		||||
import java.io.Serial;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用户手机号修改信息
 | 
			
		||||
@@ -48,7 +44,7 @@ public class UserPhoneUpdateReq implements Serializable {
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "新手机号", example = "13811111111")
 | 
			
		||||
    @NotBlank(message = "新手机号不能为空")
 | 
			
		||||
    @Pattern(regexp = RegexConstants.MOBILE, message = "手机号格式错误")
 | 
			
		||||
    @Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误")
 | 
			
		||||
    private String newPhone;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -60,9 +56,9 @@ public class UserPhoneUpdateReq implements Serializable {
 | 
			
		||||
    private String captcha;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前密码(加密后)
 | 
			
		||||
     * 当前密码(加密)
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "当前密码(加密后)", example = "SYRLSszQGcMv4kP2Yolou9zf28B9GDakR9u91khxmR7V++i5A384kwnNZxqgvT6bjT4zqpIDuMFLWSt92hQJJA==")
 | 
			
		||||
    @Schema(description = "当前密码(加密)", example = "SYRLSszQGcMv4kP2Yolou9zf28B9GDakR9u91khxmR7V++i5A384kwnNZxqgvT6bjT4zqpIDuMFLWSt92hQJJA==")
 | 
			
		||||
    @NotBlank(message = "当前密码不能为空")
 | 
			
		||||
    private String currentPassword;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.system.model.req;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.NotEmpty;
 | 
			
		||||
@@ -64,7 +65,7 @@ public class UserReq extends BaseReq {
 | 
			
		||||
     * 邮箱
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "邮箱", example = "123456789@qq.com")
 | 
			
		||||
    @Pattern(regexp = "^$|" + RegexConstants.EMAIL, message = "邮箱格式错误")
 | 
			
		||||
    @Pattern(regexp = "^$|" + RegexPool.EMAIL, message = "邮箱格式错误")
 | 
			
		||||
    @Length(max = 255, message = "邮箱长度不能超过 {max} 个字符")
 | 
			
		||||
    private String email;
 | 
			
		||||
 | 
			
		||||
@@ -72,7 +73,7 @@ public class UserReq extends BaseReq {
 | 
			
		||||
     * 手机号码
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "手机号码", example = "13811111111")
 | 
			
		||||
    @Pattern(regexp = "^$|" + RegexConstants.MOBILE, message = "手机号码格式错误")
 | 
			
		||||
    @Pattern(regexp = "^$|" + RegexPool.MOBILE, message = "手机号码格式错误")
 | 
			
		||||
    private String phone;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -27,12 +27,12 @@ import com.alicp.jetcache.anno.Cached;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import org.dromara.x.file.storage.core.FileInfo;
 | 
			
		||||
import org.dromara.x.file.storage.core.FileStorageService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
import org.springframework.security.crypto.password.PasswordEncoder;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.CacheConstants;
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.FileConstants;
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.SysConstants;
 | 
			
		||||
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
 | 
			
		||||
import top.charles7c.continew.admin.common.util.helper.LoginHelper;
 | 
			
		||||
@@ -73,6 +73,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
 | 
			
		||||
    private final FileService fileService;
 | 
			
		||||
    private final FileStorageService fileStorageService;
 | 
			
		||||
    private final PasswordEncoder passwordEncoder;
 | 
			
		||||
    @Value("${avatar.support-suffix}")
 | 
			
		||||
    private String[] avatarSupportSuffix;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Long add(UserDO user) {
 | 
			
		||||
@@ -118,7 +120,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
 | 
			
		||||
        CheckUtils.throwIf(DisEnableStatusEnum.DISABLE.equals(newStatus) && ObjectUtil.equal(id, LoginHelper
 | 
			
		||||
            .getUserId()), "不允许禁用当前用户");
 | 
			
		||||
        UserDO oldUser = super.getById(id);
 | 
			
		||||
        if (oldUser.getIsSystem()) {
 | 
			
		||||
        if (Boolean.TRUE.equals(oldUser.getIsSystem())) {
 | 
			
		||||
            CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, newStatus, "[{}] 是系统内置用户,不允许禁用", oldUser
 | 
			
		||||
                .getNickname());
 | 
			
		||||
            Collection<Long> disjunctionRoleIds = CollUtil.disjunction(req.getRoleIds(), userRoleService
 | 
			
		||||
@@ -164,10 +166,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public String uploadAvatar(MultipartFile avatarFile, Long id) {
 | 
			
		||||
        String avatarImageType = FileNameUtil.extName(avatarFile.getOriginalFilename());
 | 
			
		||||
        String[] avatarSupportImgTypes = FileConstants.AVATAR_SUPPORTED_IMG_TYPES;
 | 
			
		||||
        CheckUtils.throwIf(!StrUtil
 | 
			
		||||
            .equalsAnyIgnoreCase(avatarImageType, avatarSupportImgTypes), "头像仅支持 {} 格式的图片", String
 | 
			
		||||
                .join(StringConstants.CHINESE_COMMA, avatarSupportImgTypes));
 | 
			
		||||
            .equalsAnyIgnoreCase(avatarImageType, avatarSupportSuffix), "头像仅支持 {} 格式的图片", String
 | 
			
		||||
                .join(StringConstants.CHINESE_COMMA, avatarSupportSuffix));
 | 
			
		||||
        // 上传新头像
 | 
			
		||||
        UserDO user = super.getById(id);
 | 
			
		||||
        FileInfo fileInfo = fileService.upload(avatarFile);
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ package top.charles7c.continew.admin.webapi.common;
 | 
			
		||||
 | 
			
		||||
import cn.dev33.satoken.annotation.SaIgnore;
 | 
			
		||||
import cn.hutool.core.lang.Dict;
 | 
			
		||||
import cn.hutool.core.lang.RegexPool;
 | 
			
		||||
import cn.hutool.core.map.MapUtil;
 | 
			
		||||
import cn.hutool.core.util.IdUtil;
 | 
			
		||||
import cn.hutool.core.util.RandomUtil;
 | 
			
		||||
@@ -44,7 +45,6 @@ import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
import top.charles7c.continew.admin.common.config.properties.CaptchaProperties;
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.CacheConstants;
 | 
			
		||||
import top.charles7c.continew.admin.common.constant.RegexConstants;
 | 
			
		||||
import top.charles7c.continew.admin.common.model.resp.CaptchaResp;
 | 
			
		||||
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
 | 
			
		||||
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
 | 
			
		||||
@@ -105,7 +105,7 @@ public class CaptchaController {
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱")
 | 
			
		||||
    @GetMapping("/mail")
 | 
			
		||||
    public R getMailCaptcha(@NotBlank(message = "邮箱不能为空") @Pattern(regexp = RegexConstants.EMAIL, message = "邮箱格式错误") String email) throws MessagingException {
 | 
			
		||||
    public R getMailCaptcha(@NotBlank(message = "邮箱不能为空") @Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误") String email) throws MessagingException {
 | 
			
		||||
        String limitKeyPrefix = CacheConstants.LIMIT_KEY_PREFIX;
 | 
			
		||||
        String captchaKeyPrefix = CacheConstants.CAPTCHA_KEY_PREFIX;
 | 
			
		||||
        String limitCaptchaKey = limitKeyPrefix + captchaKeyPrefix + email;
 | 
			
		||||
@@ -129,7 +129,7 @@ public class CaptchaController {
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "获取短信验证码", description = "发送验证码到指定手机号")
 | 
			
		||||
    @GetMapping("/sms")
 | 
			
		||||
    public R getSmsCaptcha(@NotBlank(message = "手机号不能为空") @Pattern(regexp = RegexConstants.MOBILE, message = "手机号格式错误") String phone,
 | 
			
		||||
    public R getSmsCaptcha(@NotBlank(message = "手机号不能为空") @Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误") String phone,
 | 
			
		||||
                           CaptchaVO captchaReq,
 | 
			
		||||
                           HttpServletRequest request) {
 | 
			
		||||
        // 行为验证码校验
 | 
			
		||||
 
 | 
			
		||||
@@ -256,3 +256,10 @@ spring.servlet:
 | 
			
		||||
    max-file-size: 10MB
 | 
			
		||||
    # 单次总上传文件大小限制
 | 
			
		||||
    max-request-size: 20MB
 | 
			
		||||
## 头像支持格式配置
 | 
			
		||||
avatar:
 | 
			
		||||
  support-suffix:
 | 
			
		||||
    - jpg
 | 
			
		||||
    - jpeg
 | 
			
		||||
    - png
 | 
			
		||||
    - gif
 | 
			
		||||
 
 | 
			
		||||
@@ -256,3 +256,10 @@ spring.servlet:
 | 
			
		||||
    max-file-size: 10MB
 | 
			
		||||
    # 单次总上传文件大小限制
 | 
			
		||||
    max-request-size: 20MB
 | 
			
		||||
## 头像支持格式配置
 | 
			
		||||
avatar:
 | 
			
		||||
  support-suffix:
 | 
			
		||||
    - jpg
 | 
			
		||||
    - jpeg
 | 
			
		||||
    - png
 | 
			
		||||
    - gif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user