mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-08 07:01:37 +08:00
refactor: 移除 Lombok 私有构造注解使用
修复 Sonarqube 扫描问题
This commit is contained in:
@@ -18,8 +18,6 @@ package top.charles7c.continew.starter.auth.satoken.autoconfigure;
|
||||
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.client.RedisClient;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
@@ -37,7 +35,6 @@ import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoC
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
abstract class SaTokenDaoConfiguration {
|
||||
|
||||
/**
|
||||
|
@@ -17,9 +17,7 @@
|
||||
package top.charles7c.continew.starter.cache.redisson.util;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.redisson.api.*;
|
||||
import org.redisson.config.Config;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
@@ -36,11 +34,13 @@ import java.util.stream.Stream;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class RedisUtils {
|
||||
|
||||
private static final RedissonClient CLIENT = SpringUtil.getBean(RedissonClient.class);
|
||||
|
||||
private RedisUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存
|
||||
*
|
||||
|
@@ -21,8 +21,6 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.anji.captcha.service.CaptchaCacheService;
|
||||
import com.anji.captcha.service.impl.CaptchaServiceFactory;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.client.RedisClient;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
@@ -42,7 +40,6 @@ import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
abstract class BehaviorCaptchaCacheConfiguration {
|
||||
|
||||
/**
|
||||
|
@@ -16,18 +16,17 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.constant;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 配置属性相关常量
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.1.1
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class PropertiesConstants {
|
||||
|
||||
private PropertiesConstants() {
|
||||
}
|
||||
|
||||
/**
|
||||
* ContiNew Starter
|
||||
*/
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package top.charles7c.continew.starter.core.constant;
|
||||
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 字符串相关常量
|
||||
@@ -26,9 +24,11 @@ import lombok.NoArgsConstructor;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class StringConstants implements StrPool {
|
||||
|
||||
private StringConstants() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 空字符串
|
||||
*/
|
||||
|
@@ -16,17 +16,17 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.exception;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 自定义验证异常-错误请求
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class BadRequestException extends BaseException {
|
||||
|
||||
public BadRequestException() {
|
||||
}
|
||||
|
||||
public BadRequestException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
@@ -16,17 +16,17 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.exception;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 自定义异常基类
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class BaseException extends RuntimeException {
|
||||
|
||||
public BaseException() {
|
||||
}
|
||||
|
||||
public BaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
@@ -16,17 +16,17 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.exception;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class BusinessException extends BaseException {
|
||||
|
||||
public BusinessException() {
|
||||
}
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.util;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
|
||||
@@ -33,9 +31,11 @@ import java.util.function.Consumer;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ExceptionUtils {
|
||||
|
||||
private ExceptionUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印线程异常信息
|
||||
*
|
||||
|
@@ -21,8 +21,6 @@ import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||
import net.dreamlu.mica.ip2region.core.IpInfo;
|
||||
@@ -37,9 +35,11 @@ import java.util.Set;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class IpUtils {
|
||||
|
||||
private IpUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 IP 归属地(本地库解析)
|
||||
*
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package top.charles7c.continew.starter.core.util;
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -32,9 +30,11 @@ import java.util.stream.Collectors;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ReflectUtils {
|
||||
|
||||
private ReflectUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个类中所有非静态字段名列表,包括其父类中的字段<br>
|
||||
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。
|
||||
|
@@ -20,8 +20,6 @@ import cn.hutool.extra.template.Template;
|
||||
import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
import cn.hutool.extra.template.TemplateUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,11 +29,13 @@ import java.util.Map;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TemplateUtils {
|
||||
|
||||
private static final String DEFAULT_TEMPLATE_PARENT_PATH = "templates";
|
||||
|
||||
private TemplateUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板
|
||||
*
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package top.charles7c.continew.starter.core.util;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* URL(Uniform Resource Locator)统一资源定位符相关工具类
|
||||
@@ -26,9 +24,11 @@ import lombok.NoArgsConstructor;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class URLUtils {
|
||||
|
||||
private URLUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供的 URL 是否为 HTTP URL(协议包括:"http","https")
|
||||
*
|
||||
|
@@ -22,8 +22,6 @@ import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import cn.hutool.db.meta.Column;
|
||||
import cn.hutool.db.meta.MetaUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
@@ -37,9 +35,11 @@ import java.util.List;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MetaUtils {
|
||||
|
||||
private MetaUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有表信息
|
||||
*
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package top.charles7c.continew.starter.core.util.validate;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
import top.charles7c.continew.starter.core.exception.BusinessException;
|
||||
@@ -33,11 +31,13 @@ import java.util.function.BooleanSupplier;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class CheckUtils extends Validator {
|
||||
|
||||
private static final Class<BusinessException> EXCEPTION_TYPE = BusinessException.class;
|
||||
|
||||
private CheckUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果不存在,抛出异常
|
||||
*
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package top.charles7c.continew.starter.core.util.validate;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
||||
|
||||
@@ -32,11 +30,13 @@ import java.util.function.BooleanSupplier;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ValidationUtils extends Validator {
|
||||
|
||||
private static final Class<BadRequestException> EXCEPTION_TYPE = BadRequestException.class;
|
||||
|
||||
private ValidationUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果为空,抛出异常
|
||||
*
|
||||
|
@@ -19,8 +19,6 @@ package top.charles7c.continew.starter.core.util.validate;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -32,9 +30,11 @@ import java.util.function.BooleanSupplier;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
public class Validator {
|
||||
|
||||
protected Validator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果为空,抛出异常
|
||||
*
|
||||
|
@@ -21,8 +21,6 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
||||
import top.charles7c.continew.starter.core.util.ReflectUtils;
|
||||
@@ -42,9 +40,11 @@ import java.util.function.Consumer;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class QueryWrapperHelper {
|
||||
|
||||
private QueryWrapperHelper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 QueryWrapper
|
||||
*
|
||||
|
@@ -23,7 +23,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -48,7 +47,6 @@ import java.util.List;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q, C extends BaseReq> {
|
||||
|
||||
@Autowired
|
||||
|
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
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.time.LocalDateTime;
|
||||
@@ -45,7 +45,7 @@ public class BaseDetailResp extends BaseResp {
|
||||
* 修改人
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Assemble(container = ContainerConstants.USER_NICKNAME, props = @Mapping(ref = "updateUserString"))
|
||||
@Assemble(container = ContainerPool.USER_NICKNAME, props = @Mapping(ref = "updateUserString"))
|
||||
private Long updateUser;
|
||||
|
||||
/**
|
||||
|
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
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.time.LocalDateTime;
|
||||
@@ -50,7 +50,7 @@ public class BaseResp implements Serializable {
|
||||
* 创建人
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Assemble(container = ContainerConstants.USER_NICKNAME, props = @Mapping(ref = "createUserString"))
|
||||
@Assemble(container = ContainerPool.USER_NICKNAME, props = @Mapping(ref = "createUserString"))
|
||||
private Long createUser;
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.extension.crud.base;
|
||||
|
||||
import cn.crane4j.annotation.ContainerMethod;
|
||||
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
|
||||
* @return 昵称
|
||||
*/
|
||||
@ContainerMethod(namespace = ContainerConstants.USER_NICKNAME, type = MappingType.NONE)
|
||||
@ContainerMethod(namespace = ContainerPool.USER_NICKNAME, type = MappingType.NONE)
|
||||
String getNicknameById(Long id);
|
||||
}
|
||||
|
@@ -22,10 +22,10 @@ package top.charles7c.continew.starter.extension.crud.constant;
|
||||
* @author Charles7c
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public interface ContainerConstants {
|
||||
public class ContainerPool {
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
String USER_NICKNAME = "UserNickname";
|
||||
public static final String USER_NICKNAME = "UserNickname";
|
||||
}
|
@@ -24,7 +24,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -39,7 +38,6 @@ import java.io.Serial;
|
||||
*/
|
||||
@Data
|
||||
@ParameterObject
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "分页查询条件")
|
||||
public class PageQuery extends SortQuery {
|
||||
|
||||
@@ -68,6 +66,9 @@ public class PageQuery extends SortQuery {
|
||||
@Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max})")
|
||||
private Integer size = DEFAULT_SIZE;
|
||||
|
||||
public PageQuery() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于分页查询条件转换为 MyBatis Plus 分页条件
|
||||
*
|
||||
|
@@ -22,8 +22,6 @@ import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import cn.hutool.core.lang.tree.parser.NodeParser;
|
||||
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.extension.crud.annotation.TreeField;
|
||||
|
||||
@@ -36,9 +34,11 @@ import java.util.List;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TreeUtils {
|
||||
|
||||
private TreeUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认字段配置对象(根据前端树结构灵活调整名称)
|
||||
*/
|
||||
|
@@ -22,8 +22,6 @@ import cn.hutool.core.util.URLUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.charles7c.continew.starter.core.exception.BaseException;
|
||||
import top.charles7c.continew.starter.file.excel.converter.ExcelBigNumberConverter;
|
||||
@@ -38,9 +36,11 @@ import java.util.List;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ExcelUtils {
|
||||
|
||||
private ExcelUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
|
@@ -23,9 +23,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
@@ -43,11 +41,13 @@ import java.util.List;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MailUtils {
|
||||
|
||||
private static final JavaMailSender MAIL_SENDER = SpringUtil.getBean(JavaMailSender.class);
|
||||
|
||||
private MailUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送文本邮件给单个人
|
||||
*
|
||||
@@ -162,12 +162,10 @@ public class MailUtils {
|
||||
MimeMessage mimeMessage = MAIL_SENDER.createMimeMessage();
|
||||
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8
|
||||
.displayName());
|
||||
|
||||
// 设置基本信息
|
||||
messageHelper.setFrom(SpringUtil.getProperty("spring.mail.username"));
|
||||
messageHelper.setSubject(subject);
|
||||
messageHelper.setText(content, isHtml);
|
||||
|
||||
// 设置收信人
|
||||
// 抄送人
|
||||
if (CollUtil.isNotEmpty(ccs)) {
|
||||
@@ -179,14 +177,12 @@ public class MailUtils {
|
||||
}
|
||||
// 收件人
|
||||
messageHelper.setTo(tos.toArray(String[]::new));
|
||||
|
||||
// 设置附件
|
||||
if (ArrayUtil.isNotEmpty(files)) {
|
||||
for (File file : files) {
|
||||
messageHelper.addAttachment(file.getName(), file);
|
||||
}
|
||||
}
|
||||
|
||||
// 发送邮件
|
||||
MAIL_SENDER.send(mimeMessage);
|
||||
}
|
||||
@@ -201,7 +197,6 @@ public class MailUtils {
|
||||
if (StrUtil.isBlank(addresses)) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
List<String> result;
|
||||
if (StrUtil.contains(addresses, StringConstants.COMMA)) {
|
||||
result = StrUtil.splitTrim(addresses, StringConstants.COMMA);
|
||||
|
@@ -18,9 +18,7 @@ package top.charles7c.continew.starter.web.model;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -33,7 +31,6 @@ import java.io.Serializable;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Schema(description = "响应信息")
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
@@ -73,6 +70,9 @@ public class R<T> implements Serializable {
|
||||
@Schema(description = "时间戳", example = "1691453288")
|
||||
private long timestamp = DateUtil.currentSeconds();
|
||||
|
||||
private R() {
|
||||
}
|
||||
|
||||
private R(boolean success, int code, String msg, T data) {
|
||||
this.success = success;
|
||||
this.code = code;
|
||||
|
@@ -20,8 +20,6 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -36,9 +34,11 @@ import java.time.LocalDateTime;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class FileUploadUtils {
|
||||
|
||||
private FileUploadUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
|
@@ -21,8 +21,6 @@ import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
@@ -35,9 +33,11 @@ import java.util.*;
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ServletUtils {
|
||||
|
||||
private ServletUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求对象
|
||||
*
|
||||
|
@@ -20,8 +20,6 @@ import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
@@ -38,9 +36,11 @@ import java.util.Map;
|
||||
* @author Charles7c
|
||||
* @since 1.1.1
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class SpringWebUtils {
|
||||
|
||||
private SpringWebUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消注册静态资源映射
|
||||
*
|
||||
|
Reference in New Issue
Block a user