mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	update 优化代码与注释
This commit is contained in:
		@@ -32,7 +32,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 | 
			
		||||
 | 
			
		||||
    public static 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"};
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
@@ -124,8 +124,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 | 
			
		||||
    /**
 | 
			
		||||
     * 计算相差天数
 | 
			
		||||
     */
 | 
			
		||||
    public static int differentDaysByMillisecond(Date date1, Date date2)
 | 
			
		||||
    {
 | 
			
		||||
    public static int differentDaysByMillisecond(Date date1, Date date2) {
 | 
			
		||||
        return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,10 +18,10 @@ import java.awt.*;
 | 
			
		||||
@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);
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 圆圈干扰验证码
 | 
			
		||||
@@ -29,9 +29,9 @@ public class CaptchaConfig {
 | 
			
		||||
    @Lazy
 | 
			
		||||
    @Bean
 | 
			
		||||
    public CircleCaptcha circleCaptcha() {
 | 
			
		||||
        CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(width, height);
 | 
			
		||||
        captcha.setBackground(background);
 | 
			
		||||
        captcha.setFont(font);
 | 
			
		||||
        CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(WIDTH, HEIGHT);
 | 
			
		||||
        captcha.setBackground(BACKGROUND);
 | 
			
		||||
        captcha.setFont(FONT);
 | 
			
		||||
        return captcha;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -41,9 +41,9 @@ public class CaptchaConfig {
 | 
			
		||||
    @Lazy
 | 
			
		||||
    @Bean
 | 
			
		||||
    public LineCaptcha lineCaptcha() {
 | 
			
		||||
        LineCaptcha captcha = CaptchaUtil.createLineCaptcha(width, height);
 | 
			
		||||
        captcha.setBackground(background);
 | 
			
		||||
        captcha.setFont(font);
 | 
			
		||||
        LineCaptcha captcha = CaptchaUtil.createLineCaptcha(WIDTH, HEIGHT);
 | 
			
		||||
        captcha.setBackground(BACKGROUND);
 | 
			
		||||
        captcha.setFont(FONT);
 | 
			
		||||
        return captcha;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -53,9 +53,9 @@ public class CaptchaConfig {
 | 
			
		||||
    @Lazy
 | 
			
		||||
    @Bean
 | 
			
		||||
    public ShearCaptcha shearCaptcha() {
 | 
			
		||||
        ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(width, height);
 | 
			
		||||
        captcha.setBackground(background);
 | 
			
		||||
        captcha.setFont(font);
 | 
			
		||||
        ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(WIDTH, HEIGHT);
 | 
			
		||||
        captcha.setBackground(BACKGROUND);
 | 
			
		||||
        captcha.setFont(FONT);
 | 
			
		||||
        return captcha;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@ import com.ruoyi.common.utils.StringUtils;
 | 
			
		||||
import com.ruoyi.generator.config.GenConfig;
 | 
			
		||||
import com.ruoyi.generator.domain.GenTable;
 | 
			
		||||
import com.ruoyi.generator.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 {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package com.ruoyi.generator.util;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.constant.Constants;
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import org.apache.velocity.app.Velocity;
 | 
			
		||||
 | 
			
		||||
import java.util.Properties;
 | 
			
		||||
@@ -10,6 +12,7 @@ import java.util.Properties;
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
 | 
			
		||||
public class VelocityInitializer {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,8 @@ import com.ruoyi.common.utils.JsonUtils;
 | 
			
		||||
import com.ruoyi.common.utils.StringUtils;
 | 
			
		||||
import com.ruoyi.generator.domain.GenTable;
 | 
			
		||||
import com.ruoyi.generator.domain.GenTableColumn;
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import org.apache.velocity.VelocityContext;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
@@ -20,6 +22,7 @@ import java.util.*;
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
 | 
			
		||||
public class VelocityUtils {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -12,11 +12,14 @@ import java.io.InputStream;
 | 
			
		||||
 */
 | 
			
		||||
public interface IOssStrategy {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建存储桶
 | 
			
		||||
     */
 | 
			
		||||
    void createBucket();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取服务商类型
 | 
			
		||||
     * @return
 | 
			
		||||
     * @return 对象存储服务商枚举
 | 
			
		||||
     */
 | 
			
		||||
    OssEnumd getServiceType();
 | 
			
		||||
 | 
			
		||||
@@ -25,6 +28,7 @@ public interface IOssStrategy {
 | 
			
		||||
     *
 | 
			
		||||
     * @param data 文件字节数组
 | 
			
		||||
     * @param path 文件路径,包含文件名
 | 
			
		||||
     * @param contentType 文件类型
 | 
			
		||||
     * @return 返回http地址
 | 
			
		||||
     */
 | 
			
		||||
    UploadResult upload(byte[] data, String path, String contentType);
 | 
			
		||||
@@ -41,6 +45,7 @@ public interface IOssStrategy {
 | 
			
		||||
     *
 | 
			
		||||
     * @param data   文件字节数组
 | 
			
		||||
     * @param suffix 后缀
 | 
			
		||||
     * @param contentType 文件类型
 | 
			
		||||
     * @return 返回http地址
 | 
			
		||||
     */
 | 
			
		||||
    UploadResult uploadSuffix(byte[] data, String suffix, String contentType);
 | 
			
		||||
@@ -50,6 +55,7 @@ public interface IOssStrategy {
 | 
			
		||||
     *
 | 
			
		||||
     * @param inputStream 字节流
 | 
			
		||||
     * @param path        文件路径,包含文件名
 | 
			
		||||
     * @param contentType 文件类型
 | 
			
		||||
     * @return 返回http地址
 | 
			
		||||
     */
 | 
			
		||||
    UploadResult upload(InputStream inputStream, String path, String contentType);
 | 
			
		||||
@@ -59,6 +65,7 @@ public interface IOssStrategy {
 | 
			
		||||
     *
 | 
			
		||||
     * @param inputStream 字节流
 | 
			
		||||
     * @param suffix      后缀
 | 
			
		||||
     * @param contentType 文件类型
 | 
			
		||||
     * @return 返回http地址
 | 
			
		||||
     */
 | 
			
		||||
    UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType);
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user