diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateUtils.java index 9681bc28..519ce740 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateUtils.java @@ -22,17 +22,17 @@ import java.util.Date; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class DateUtils extends org.apache.commons.lang3.time.DateUtils { - public static String YYYY = "yyyy"; + public static final String YYYY = "yyyy"; - public static String YYYY_MM = "yyyy-MM"; + public static final String YYYY_MM = "yyyy-MM"; - public static String YYYY_MM_DD = "yyyy-MM-dd"; + public static final String YYYY_MM_DD = "yyyy-MM-dd"; - public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; - public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; - private static String[] parsePatterns = { + private static final String[] PARSE_PATTERNS = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; @@ -55,27 +55,27 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { return dateTimeNow(YYYY_MM_DD); } - public static final String getTime() { + public static String getTime() { return dateTimeNow(YYYY_MM_DD_HH_MM_SS); } - public static final String dateTimeNow() { + public static String dateTimeNow() { return dateTimeNow(YYYYMMDDHHMMSS); } - public static final String dateTimeNow(final String format) { + public static String dateTimeNow(final String format) { return parseDateToStr(format, new Date()); } - public static final String dateTime(final Date date) { + public static String dateTime(final Date date) { return parseDateToStr(YYYY_MM_DD, date); } - public static final String parseDateToStr(final String format, final Date date) { + public static String parseDateToStr(final String format, final Date date) { return new SimpleDateFormat(format).format(date); } - public static final Date dateTime(final String format, final String ts) { + public static Date dateTime(final String format, final String ts) { try { return new SimpleDateFormat(format).parse(ts); } catch (ParseException e) { @@ -86,7 +86,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { /** * 日期路径 即年/月/日 如2018/08/08 */ - public static final String datePath() { + public static String datePath() { Date now = new Date(); return DateFormatUtils.format(now, "yyyy/MM/dd"); } @@ -94,7 +94,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { /** * 日期路径 即年/月/日 如20180808 */ - public static final String dateTime() { + public static String dateTime() { Date now = new Date(); return DateFormatUtils.format(now, "yyyyMMdd"); } @@ -107,7 +107,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { return null; } try { - return parseDate(str.toString(), parsePatterns); + return parseDate(str.toString(), PARSE_PATTERNS); } catch (ParseException e) { return null; } diff --git a/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/IOssStrategy.java b/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/IOssStrategy.java index 6e1de5b1..ca7f7629 100644 --- a/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/IOssStrategy.java +++ b/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/IOssStrategy.java @@ -13,11 +13,14 @@ import java.io.InputStream; */ public interface IOssStrategy { + /** + * 创建存储桶 + */ void createBucket(); /** * 获取服务商类型 - * @return + * @return 对象存储服务商枚举 */ OssEnumd getServiceType(); @@ -26,6 +29,7 @@ public interface IOssStrategy { * * @param data 文件字节数组 * @param path 文件路径,包含文件名 + * @param contentType 文件类型 * @return 返回http地址 */ UploadResult upload(byte[] data, String path, String contentType); @@ -42,6 +46,7 @@ public interface IOssStrategy { * * @param data 文件字节数组 * @param suffix 后缀 + * @param contentType 文件类型 * @return 返回http地址 */ UploadResult uploadSuffix(byte[] data, String suffix, String contentType); @@ -51,6 +56,7 @@ public interface IOssStrategy { * * @param inputStream 字节流 * @param path 文件路径,包含文件名 + * @param contentType 文件类型 * @return 返回http地址 */ UploadResult upload(InputStream inputStream, String path, String contentType); @@ -60,6 +66,7 @@ public interface IOssStrategy { * * @param inputStream 字节流 * @param suffix 后缀 + * @param contentType 文件类型 * @return 返回http地址 */ UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); diff --git a/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/abstractd/AbstractOssStrategy.java b/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/abstractd/AbstractOssStrategy.java index d837800b..f1aaa315 100644 --- a/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/abstractd/AbstractOssStrategy.java +++ b/ruoyi-common/ruoyi-common-oss/src/main/java/com/ruoyi/common/oss/service/abstractd/AbstractOssStrategy.java @@ -60,5 +60,10 @@ public abstract class AbstractOssStrategy implements IOssStrategy { @Override public abstract UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); + /** + * 获取域名访问链接 + * + * @return 域名访问链接 + */ public abstract String getEndpointLink(); } diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/CaptchaConfig.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/CaptchaConfig.java index 595e6b23..197a1eb5 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/CaptchaConfig.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/CaptchaConfig.java @@ -1,62 +1,62 @@ -package com.ruoyi.gateway.config; - -import cn.hutool.captcha.CaptchaUtil; -import cn.hutool.captcha.CircleCaptcha; -import cn.hutool.captcha.LineCaptcha; -import cn.hutool.captcha.ShearCaptcha; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; - -import java.awt.*; - -/** - * 验证码配置 - * - * @author Lion Li - */ -@Configuration -public class CaptchaConfig { - - private final int width = 160; - private final int height = 60; - private final Color background = Color.PINK; - private final Font font = new Font("Arial", Font.BOLD, 48); - - /** - * 圆圈干扰验证码 - */ - @Lazy - @Bean - public CircleCaptcha circleCaptcha() { - CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(width, height); - captcha.setBackground(background); - captcha.setFont(font); - return captcha; - } - - /** - * 线段干扰的验证码 - */ - @Lazy - @Bean - public LineCaptcha lineCaptcha() { - LineCaptcha captcha = CaptchaUtil.createLineCaptcha(width, height); - captcha.setBackground(background); - captcha.setFont(font); - return captcha; - } - - /** - * 扭曲干扰验证码 - */ - @Lazy - @Bean - public ShearCaptcha shearCaptcha() { - ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(width, height); - captcha.setBackground(background); - captcha.setFont(font); - return captcha; - } - -} \ No newline at end of file +package com.ruoyi.gateway.config; + +import cn.hutool.captcha.CaptchaUtil; +import cn.hutool.captcha.CircleCaptcha; +import cn.hutool.captcha.LineCaptcha; +import cn.hutool.captcha.ShearCaptcha; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +import java.awt.*; + +/** + * 验证码配置 + * + * @author Lion Li + */ +@Configuration +public class CaptchaConfig { + + private static final int WIDTH = 160; + private static final int HEIGHT = 60; + private static final Color BACKGROUND = Color.PINK; + private static final Font FONT = new Font("Arial", Font.BOLD, 48); + + /** + * 圆圈干扰验证码 + */ + @Lazy + @Bean + public CircleCaptcha circleCaptcha() { + CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(WIDTH, HEIGHT); + captcha.setBackground(BACKGROUND); + captcha.setFont(FONT); + return captcha; + } + + /** + * 线段干扰的验证码 + */ + @Lazy + @Bean + public LineCaptcha lineCaptcha() { + LineCaptcha captcha = CaptchaUtil.createLineCaptcha(WIDTH, HEIGHT); + captcha.setBackground(BACKGROUND); + captcha.setFont(FONT); + return captcha; + } + + /** + * 扭曲干扰验证码 + */ + @Lazy + @Bean + public ShearCaptcha shearCaptcha() { + ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(WIDTH, HEIGHT); + captcha.setBackground(BACKGROUND); + captcha.setFont(FONT); + return captcha; + } + +} diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java index 91da7efe..08a998a3 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java @@ -5,6 +5,8 @@ import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.gen.config.GenConfig; import com.ruoyi.gen.domain.GenTable; import com.ruoyi.gen.domain.GenTableColumn; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.commons.lang3.RegExUtils; import java.util.Arrays; @@ -14,6 +16,7 @@ import java.util.Arrays; * * @author ruoyi */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class GenUtils { /** * 初始化表信息 diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityInitializer.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityInitializer.java index 076814fd..8b92b6fa 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityInitializer.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityInitializer.java @@ -1,30 +1,33 @@ -package com.ruoyi.gen.util; - -import com.ruoyi.common.core.constant.Constants; -import org.apache.velocity.app.Velocity; - -import java.util.Properties; - -/** - * VelocityEngine工厂 - * - * @author ruoyi - */ -public class VelocityInitializer { - /** - * 初始化vm方法 - */ - public static void initVelocity() { - Properties p = new Properties(); - try { - // 加载classpath目录下的vm文件 - p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - // 定义字符集 - p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8); - // 初始化Velocity引擎,指定配置Properties - Velocity.init(p); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} +package com.ruoyi.gen.util; + +import com.ruoyi.common.core.constant.Constants; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.apache.velocity.app.Velocity; + +import java.util.Properties; + +/** + * VelocityEngine工厂 + * + * @author ruoyi + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class VelocityInitializer { + /** + * 初始化vm方法 + */ + public static void initVelocity() { + Properties p = new Properties(); + try { + // 加载classpath目录下的vm文件 + p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + // 定义字符集 + p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8); + // 初始化Velocity引擎,指定配置Properties + Velocity.init(p); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java index 4462780a..8daeb6f4 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java @@ -10,6 +10,8 @@ import com.ruoyi.common.core.utils.JsonUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.gen.domain.GenTable; import com.ruoyi.gen.domain.GenTableColumn; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.velocity.VelocityContext; import java.util.*; @@ -19,6 +21,7 @@ import java.util.*; * * @author ruoyi */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class VelocityUtils { /**