refactor: 移除 Lombok 私有构造注解使用

修复 Sonarqube 扫描问题
This commit is contained in:
2024-01-27 00:30:20 +08:00
parent 91651b0b59
commit 11d0798f92
31 changed files with 80 additions and 93 deletions

View File

@@ -18,8 +18,6 @@ package top.charles7c.continew.starter.auth.satoken.autoconfigure;
import cn.dev33.satoken.dao.SaTokenDao; import cn.dev33.satoken.dao.SaTokenDao;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.redisson.client.RedisClient; import org.redisson.client.RedisClient;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
@@ -37,7 +35,6 @@ import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoC
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
abstract class SaTokenDaoConfiguration { abstract class SaTokenDaoConfiguration {
/** /**

View File

@@ -17,9 +17,7 @@
package top.charles7c.continew.starter.cache.redisson.util; package top.charles7c.continew.starter.cache.redisson.util;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import lombok.AccessLevel;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.redisson.api.*; import org.redisson.api.*;
import org.redisson.config.Config; import org.redisson.config.Config;
import top.charles7c.continew.starter.core.constant.StringConstants; import top.charles7c.continew.starter.core.constant.StringConstants;
@@ -36,11 +34,13 @@ import java.util.stream.Stream;
* @since 1.0.0 * @since 1.0.0
*/ */
@Data @Data
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RedisUtils { public class RedisUtils {
private static final RedissonClient CLIENT = SpringUtil.getBean(RedissonClient.class); private static final RedissonClient CLIENT = SpringUtil.getBean(RedissonClient.class);
private RedisUtils() {
}
/** /**
* 设置缓存 * 设置缓存
* *

View File

@@ -21,8 +21,6 @@ import cn.hutool.extra.spring.SpringUtil;
import com.anji.captcha.service.CaptchaCacheService; import com.anji.captcha.service.CaptchaCacheService;
import com.anji.captcha.service.impl.CaptchaServiceFactory; import com.anji.captcha.service.impl.CaptchaServiceFactory;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.redisson.client.RedisClient; import org.redisson.client.RedisClient;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
@@ -42,7 +40,6 @@ import top.charles7c.continew.starter.core.constant.PropertiesConstants;
* @since 1.1.0 * @since 1.1.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
abstract class BehaviorCaptchaCacheConfiguration { abstract class BehaviorCaptchaCacheConfiguration {
/** /**

View File

@@ -16,18 +16,17 @@
package top.charles7c.continew.starter.core.constant; package top.charles7c.continew.starter.core.constant;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/** /**
* 配置属性相关常量 * 配置属性相关常量
* *
* @author Charles7c * @author Charles7c
* @since 1.1.1 * @since 1.1.1
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PropertiesConstants { public class PropertiesConstants {
private PropertiesConstants() {
}
/** /**
* ContiNew Starter * ContiNew Starter
*/ */

View File

@@ -17,8 +17,6 @@
package top.charles7c.continew.starter.core.constant; package top.charles7c.continew.starter.core.constant;
import cn.hutool.core.text.StrPool; import cn.hutool.core.text.StrPool;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/** /**
* 字符串相关常量 * 字符串相关常量
@@ -26,9 +24,11 @@ import lombok.NoArgsConstructor;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class StringConstants implements StrPool { public class StringConstants implements StrPool {
private StringConstants() {
}
/** /**
* 空字符串 * 空字符串
*/ */

View File

@@ -16,17 +16,17 @@
package top.charles7c.continew.starter.core.exception; package top.charles7c.continew.starter.core.exception;
import lombok.NoArgsConstructor;
/** /**
* 自定义验证异常-错误请求 * 自定义验证异常-错误请求
* *
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor
public class BadRequestException extends BaseException { public class BadRequestException extends BaseException {
public BadRequestException() {
}
public BadRequestException(String message) { public BadRequestException(String message) {
super(message); super(message);
} }

View File

@@ -16,17 +16,17 @@
package top.charles7c.continew.starter.core.exception; package top.charles7c.continew.starter.core.exception;
import lombok.NoArgsConstructor;
/** /**
* 自定义异常基类 * 自定义异常基类
* *
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor
public class BaseException extends RuntimeException { public class BaseException extends RuntimeException {
public BaseException() {
}
public BaseException(String message) { public BaseException(String message) {
super(message); super(message);
} }

View File

@@ -16,17 +16,17 @@
package top.charles7c.continew.starter.core.exception; package top.charles7c.continew.starter.core.exception;
import lombok.NoArgsConstructor;
/** /**
* 业务异常 * 业务异常
* *
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor
public class BusinessException extends BaseException { public class BusinessException extends BaseException {
public BusinessException() {
}
public BusinessException(String message) { public BusinessException(String message) {
super(message); super(message);
} }

View File

@@ -16,8 +16,6 @@
package top.charles7c.continew.starter.core.util; package top.charles7c.continew.starter.core.util;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import top.charles7c.continew.starter.core.constant.StringConstants; import top.charles7c.continew.starter.core.constant.StringConstants;
@@ -33,9 +31,11 @@ import java.util.function.Consumer;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ExceptionUtils { public class ExceptionUtils {
private ExceptionUtils() {
}
/** /**
* 打印线程异常信息 * 打印线程异常信息
* *

View File

@@ -21,8 +21,6 @@ import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.http.HtmlUtil; import cn.hutool.http.HtmlUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher; import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
import net.dreamlu.mica.ip2region.core.IpInfo; import net.dreamlu.mica.ip2region.core.IpInfo;
@@ -37,9 +35,11 @@ import java.util.Set;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class IpUtils { public class IpUtils {
private IpUtils() {
}
/** /**
* 查询 IP 归属地(本地库解析) * 查询 IP 归属地(本地库解析)
* *

View File

@@ -17,8 +17,6 @@
package top.charles7c.continew.starter.core.util; package top.charles7c.continew.starter.core.util;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@@ -32,9 +30,11 @@ import java.util.stream.Collectors;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReflectUtils { public class ReflectUtils {
private ReflectUtils() {
}
/** /**
* 获得一个类中所有非静态字段名列表,包括其父类中的字段<br> * 获得一个类中所有非静态字段名列表,包括其父类中的字段<br>
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。 * 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。

View File

@@ -20,8 +20,6 @@ import cn.hutool.extra.template.Template;
import cn.hutool.extra.template.TemplateConfig; import cn.hutool.extra.template.TemplateConfig;
import cn.hutool.extra.template.TemplateEngine; import cn.hutool.extra.template.TemplateEngine;
import cn.hutool.extra.template.TemplateUtil; import cn.hutool.extra.template.TemplateUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.Map; import java.util.Map;
@@ -31,11 +29,13 @@ import java.util.Map;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TemplateUtils { public class TemplateUtils {
private static final String DEFAULT_TEMPLATE_PARENT_PATH = "templates"; private static final String DEFAULT_TEMPLATE_PARENT_PATH = "templates";
private TemplateUtils() {
}
/** /**
* 渲染模板 * 渲染模板
* *

View File

@@ -17,8 +17,6 @@
package top.charles7c.continew.starter.core.util; package top.charles7c.continew.starter.core.util;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/** /**
* URLUniform Resource Locator统一资源定位符相关工具类 * URLUniform Resource Locator统一资源定位符相关工具类
@@ -26,9 +24,11 @@ import lombok.NoArgsConstructor;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class URLUtils { public class URLUtils {
private URLUtils() {
}
/** /**
* 提供的 URL 是否为 HTTP URL协议包括"http""https" * 提供的 URL 是否为 HTTP URL协议包括"http""https"
* *

View File

@@ -22,8 +22,6 @@ import cn.hutool.db.Db;
import cn.hutool.db.Entity; import cn.hutool.db.Entity;
import cn.hutool.db.meta.Column; import cn.hutool.db.meta.Column;
import cn.hutool.db.meta.MetaUtil; import cn.hutool.db.meta.MetaUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.SQLException; import java.sql.SQLException;
@@ -37,9 +35,11 @@ import java.util.List;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MetaUtils { public class MetaUtils {
private MetaUtils() {
}
/** /**
* 获取所有表信息 * 获取所有表信息
* *

View File

@@ -17,8 +17,6 @@
package top.charles7c.continew.starter.core.util.validate; package top.charles7c.continew.starter.core.util.validate;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import top.charles7c.continew.starter.core.constant.StringConstants; import top.charles7c.continew.starter.core.constant.StringConstants;
import top.charles7c.continew.starter.core.exception.BusinessException; import top.charles7c.continew.starter.core.exception.BusinessException;
@@ -33,11 +31,13 @@ import java.util.function.BooleanSupplier;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CheckUtils extends Validator { public class CheckUtils extends Validator {
private static final Class<BusinessException> EXCEPTION_TYPE = BusinessException.class; private static final Class<BusinessException> EXCEPTION_TYPE = BusinessException.class;
private CheckUtils() {
}
/** /**
* 如果不存在,抛出异常 * 如果不存在,抛出异常
* *

View File

@@ -17,8 +17,6 @@
package top.charles7c.continew.starter.core.util.validate; package top.charles7c.continew.starter.core.util.validate;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import top.charles7c.continew.starter.core.exception.BadRequestException; import top.charles7c.continew.starter.core.exception.BadRequestException;
@@ -32,11 +30,13 @@ import java.util.function.BooleanSupplier;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ValidationUtils extends Validator { public class ValidationUtils extends Validator {
private static final Class<BadRequestException> EXCEPTION_TYPE = BadRequestException.class; private static final Class<BadRequestException> EXCEPTION_TYPE = BadRequestException.class;
private ValidationUtils() {
}
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *

View File

@@ -19,8 +19,6 @@ package top.charles7c.continew.starter.core.util.validate;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.function.BooleanSupplier; import java.util.function.BooleanSupplier;
@@ -32,9 +30,11 @@ import java.util.function.BooleanSupplier;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Validator { public class Validator {
protected Validator() {
}
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *

View File

@@ -21,8 +21,6 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import top.charles7c.continew.starter.core.exception.BadRequestException; import top.charles7c.continew.starter.core.exception.BadRequestException;
import top.charles7c.continew.starter.core.util.ReflectUtils; import top.charles7c.continew.starter.core.util.ReflectUtils;
@@ -42,9 +40,11 @@ import java.util.function.Consumer;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class QueryWrapperHelper { public class QueryWrapperHelper {
private QueryWrapperHelper() {
}
/** /**
* 构建 QueryWrapper * 构建 QueryWrapper
* *

View File

@@ -23,7 +23,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterIn;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -48,7 +47,6 @@ import java.util.List;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor
public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q, C extends BaseReq> { public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q, C extends BaseReq> {
@Autowired @Autowired

View File

@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import top.charles7c.continew.starter.extension.crud.constant.ContainerConstants; import top.charles7c.continew.starter.extension.crud.constant.ContainerPool;
import java.io.Serial; import java.io.Serial;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -45,7 +45,7 @@ public class BaseDetailResp extends BaseResp {
* 修改人 * 修改人
*/ */
@JsonIgnore @JsonIgnore
@Assemble(container = ContainerConstants.USER_NICKNAME, props = @Mapping(ref = "updateUserString")) @Assemble(container = ContainerPool.USER_NICKNAME, props = @Mapping(ref = "updateUserString"))
private Long updateUser; private Long updateUser;
/** /**

View File

@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import top.charles7c.continew.starter.extension.crud.constant.ContainerConstants; import top.charles7c.continew.starter.extension.crud.constant.ContainerPool;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -50,7 +50,7 @@ public class BaseResp implements Serializable {
* 创建人 * 创建人
*/ */
@JsonIgnore @JsonIgnore
@Assemble(container = ContainerConstants.USER_NICKNAME, props = @Mapping(ref = "createUserString")) @Assemble(container = ContainerPool.USER_NICKNAME, props = @Mapping(ref = "createUserString"))
private Long createUser; private Long createUser;
/** /**

View File

@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.extension.crud.base;
import cn.crane4j.annotation.ContainerMethod; import cn.crane4j.annotation.ContainerMethod;
import cn.crane4j.annotation.MappingType; import cn.crane4j.annotation.MappingType;
import top.charles7c.continew.starter.extension.crud.constant.ContainerConstants; import top.charles7c.continew.starter.extension.crud.constant.ContainerPool;
/** /**
* 公共用户业务接口 * 公共用户业务接口
@@ -34,6 +34,6 @@ public interface CommonUserService {
* @param id ID * @param id ID
* @return 昵称 * @return 昵称
*/ */
@ContainerMethod(namespace = ContainerConstants.USER_NICKNAME, type = MappingType.NONE) @ContainerMethod(namespace = ContainerPool.USER_NICKNAME, type = MappingType.NONE)
String getNicknameById(Long id); String getNicknameById(Long id);
} }

View File

@@ -22,10 +22,10 @@ package top.charles7c.continew.starter.extension.crud.constant;
* @author Charles7c * @author Charles7c
* @since 1.2.0 * @since 1.2.0
*/ */
public interface ContainerConstants { public class ContainerPool {
/** /**
* 用户昵称 * 用户昵称
*/ */
String USER_NICKNAME = "UserNickname"; public static final String USER_NICKNAME = "UserNickname";
} }

View File

@@ -24,7 +24,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Min;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.Range;
import org.springdoc.core.annotations.ParameterObject; import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
@@ -39,7 +38,6 @@ import java.io.Serial;
*/ */
@Data @Data
@ParameterObject @ParameterObject
@NoArgsConstructor
@Schema(description = "分页查询条件") @Schema(description = "分页查询条件")
public class PageQuery extends SortQuery { public class PageQuery extends SortQuery {
@@ -68,6 +66,9 @@ public class PageQuery extends SortQuery {
@Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max}") @Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max}")
private Integer size = DEFAULT_SIZE; private Integer size = DEFAULT_SIZE;
public PageQuery() {
}
/** /**
* 基于分页查询条件转换为 MyBatis Plus 分页条件 * 基于分页查询条件转换为 MyBatis Plus 分页条件
* *

View File

@@ -22,8 +22,6 @@ import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.lang.tree.parser.NodeParser; import cn.hutool.core.lang.tree.parser.NodeParser;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import top.charles7c.continew.starter.core.util.validate.CheckUtils; import top.charles7c.continew.starter.core.util.validate.CheckUtils;
import top.charles7c.continew.starter.extension.crud.annotation.TreeField; import top.charles7c.continew.starter.extension.crud.annotation.TreeField;
@@ -36,9 +34,11 @@ import java.util.List;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TreeUtils { public class TreeUtils {
private TreeUtils() {
}
/** /**
* 默认字段配置对象(根据前端树结构灵活调整名称) * 默认字段配置对象(根据前端树结构灵活调整名称)
*/ */

View File

@@ -22,8 +22,6 @@ import cn.hutool.core.util.URLUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import top.charles7c.continew.starter.core.exception.BaseException; import top.charles7c.continew.starter.core.exception.BaseException;
import top.charles7c.continew.starter.file.excel.converter.ExcelBigNumberConverter; import top.charles7c.continew.starter.file.excel.converter.ExcelBigNumberConverter;
@@ -38,9 +36,11 @@ import java.util.List;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ExcelUtils { public class ExcelUtils {
private ExcelUtils() {
}
/** /**
* 导出 * 导出
* *

View File

@@ -23,9 +23,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import jakarta.mail.MessagingException; import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimeMessage;
import lombok.AccessLevel;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.mail.javamail.MimeMessageHelper;
import top.charles7c.continew.starter.core.constant.StringConstants; import top.charles7c.continew.starter.core.constant.StringConstants;
@@ -43,11 +41,13 @@ import java.util.List;
* @since 1.0.0 * @since 1.0.0
*/ */
@Data @Data
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MailUtils { public class MailUtils {
private static final JavaMailSender MAIL_SENDER = SpringUtil.getBean(JavaMailSender.class); private static final JavaMailSender MAIL_SENDER = SpringUtil.getBean(JavaMailSender.class);
private MailUtils() {
}
/** /**
* 发送文本邮件给单个人 * 发送文本邮件给单个人
* *
@@ -162,12 +162,10 @@ public class MailUtils {
MimeMessage mimeMessage = MAIL_SENDER.createMimeMessage(); MimeMessage mimeMessage = MAIL_SENDER.createMimeMessage();
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8 MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8
.displayName()); .displayName());
// 设置基本信息 // 设置基本信息
messageHelper.setFrom(SpringUtil.getProperty("spring.mail.username")); messageHelper.setFrom(SpringUtil.getProperty("spring.mail.username"));
messageHelper.setSubject(subject); messageHelper.setSubject(subject);
messageHelper.setText(content, isHtml); messageHelper.setText(content, isHtml);
// 设置收信人 // 设置收信人
// 抄送人 // 抄送人
if (CollUtil.isNotEmpty(ccs)) { if (CollUtil.isNotEmpty(ccs)) {
@@ -179,14 +177,12 @@ public class MailUtils {
} }
// 收件人 // 收件人
messageHelper.setTo(tos.toArray(String[]::new)); messageHelper.setTo(tos.toArray(String[]::new));
// 设置附件 // 设置附件
if (ArrayUtil.isNotEmpty(files)) { if (ArrayUtil.isNotEmpty(files)) {
for (File file : files) { for (File file : files) {
messageHelper.addAttachment(file.getName(), file); messageHelper.addAttachment(file.getName(), file);
} }
} }
// 发送邮件 // 发送邮件
MAIL_SENDER.send(mimeMessage); MAIL_SENDER.send(mimeMessage);
} }
@@ -201,7 +197,6 @@ public class MailUtils {
if (StrUtil.isBlank(addresses)) { if (StrUtil.isBlank(addresses)) {
return new ArrayList<>(0); return new ArrayList<>(0);
} }
List<String> result; List<String> result;
if (StrUtil.contains(addresses, StringConstants.COMMA)) { if (StrUtil.contains(addresses, StringConstants.COMMA)) {
result = StrUtil.splitTrim(addresses, StringConstants.COMMA); result = StrUtil.splitTrim(addresses, StringConstants.COMMA);

View File

@@ -18,9 +18,7 @@ package top.charles7c.continew.starter.web.model;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import java.io.Serial; import java.io.Serial;
@@ -33,7 +31,6 @@ import java.io.Serializable;
* @since 1.0.0 * @since 1.0.0
*/ */
@Data @Data
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Schema(description = "响应信息") @Schema(description = "响应信息")
public class R<T> implements Serializable { public class R<T> implements Serializable {
@@ -73,6 +70,9 @@ public class R<T> implements Serializable {
@Schema(description = "时间戳", example = "1691453288") @Schema(description = "时间戳", example = "1691453288")
private long timestamp = DateUtil.currentSeconds(); private long timestamp = DateUtil.currentSeconds();
private R() {
}
private R(boolean success, int code, String msg, T data) { private R(boolean success, int code, String msg, T data) {
this.success = success; this.success = success;
this.code = code; this.code = code;

View File

@@ -20,8 +20,6 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.file.FileNameUtil; import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -36,9 +34,11 @@ import java.time.LocalDateTime;
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class FileUploadUtils { public class FileUploadUtils {
private FileUploadUtils() {
}
/** /**
* 上传文件 * 上传文件
* *

View File

@@ -21,8 +21,6 @@ import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil; import cn.hutool.http.useragent.UserAgentUtil;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import top.charles7c.continew.starter.core.constant.StringConstants; import top.charles7c.continew.starter.core.constant.StringConstants;
@@ -35,9 +33,11 @@ import java.util.*;
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ServletUtils { public class ServletUtils {
private ServletUtils() {
}
/** /**
* 获取请求对象 * 获取请求对象
* *

View File

@@ -20,8 +20,6 @@ import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import jakarta.servlet.ServletContext; import jakarta.servlet.ServletContext;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.web.accept.ContentNegotiationManager; import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
@@ -38,9 +36,11 @@ import java.util.Map;
* @author Charles7c * @author Charles7c
* @since 1.1.1 * @since 1.1.1
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SpringWebUtils { public class SpringWebUtils {
private SpringWebUtils() {
}
/** /**
* 取消注册静态资源映射 * 取消注册静态资源映射
* *