update 优化代码与注释

2.X
疯狂的狮子Li 3 years ago
parent 73eb9cc7d7
commit 3e7dd75f6d

@ -22,17 +22,17 @@ import java.util.Date;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DateUtils extends org.apache.commons.lang3.time.DateUtils { 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", "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); return dateTimeNow(YYYY_MM_DD);
} }
public static final String getTime() { public static String getTime() {
return dateTimeNow(YYYY_MM_DD_HH_MM_SS); return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
} }
public static final String dateTimeNow() { public static String dateTimeNow() {
return dateTimeNow(YYYYMMDDHHMMSS); return dateTimeNow(YYYYMMDDHHMMSS);
} }
public static final String dateTimeNow(final String format) { public static String dateTimeNow(final String format) {
return parseDateToStr(format, new Date()); 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); 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); 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 { try {
return new SimpleDateFormat(format).parse(ts); return new SimpleDateFormat(format).parse(ts);
} catch (ParseException e) { } catch (ParseException e) {
@ -86,7 +86,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* // 2018/08/08 * // 2018/08/08
*/ */
public static final String datePath() { public static String datePath() {
Date now = new Date(); Date now = new Date();
return DateFormatUtils.format(now, "yyyy/MM/dd"); return DateFormatUtils.format(now, "yyyy/MM/dd");
} }
@ -94,7 +94,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* // 20180808 * // 20180808
*/ */
public static final String dateTime() { public static String dateTime() {
Date now = new Date(); Date now = new Date();
return DateFormatUtils.format(now, "yyyyMMdd"); return DateFormatUtils.format(now, "yyyyMMdd");
} }
@ -107,7 +107,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return null; return null;
} }
try { try {
return parseDate(str.toString(), parsePatterns); return parseDate(str.toString(), PARSE_PATTERNS);
} catch (ParseException e) { } catch (ParseException e) {
return null; return null;
} }

@ -13,11 +13,14 @@ import java.io.InputStream;
*/ */
public interface IOssStrategy { public interface IOssStrategy {
/**
*
*/
void createBucket(); void createBucket();
/** /**
* *
* @return * @return
*/ */
OssEnumd getServiceType(); OssEnumd getServiceType();
@ -26,6 +29,7 @@ public interface IOssStrategy {
* *
* @param data * @param data
* @param path * @param path
* @param contentType
* @return http * @return http
*/ */
UploadResult upload(byte[] data, String path, String contentType); UploadResult upload(byte[] data, String path, String contentType);
@ -42,6 +46,7 @@ public interface IOssStrategy {
* *
* @param data * @param data
* @param suffix * @param suffix
* @param contentType
* @return http * @return http
*/ */
UploadResult uploadSuffix(byte[] data, String suffix, String contentType); UploadResult uploadSuffix(byte[] data, String suffix, String contentType);
@ -51,6 +56,7 @@ public interface IOssStrategy {
* *
* @param inputStream * @param inputStream
* @param path * @param path
* @param contentType
* @return http * @return http
*/ */
UploadResult upload(InputStream inputStream, String path, String contentType); UploadResult upload(InputStream inputStream, String path, String contentType);
@ -60,6 +66,7 @@ public interface IOssStrategy {
* *
* @param inputStream * @param inputStream
* @param suffix * @param suffix
* @param contentType
* @return http * @return http
*/ */
UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType);

@ -60,5 +60,10 @@ public abstract class AbstractOssStrategy implements IOssStrategy {
@Override @Override
public abstract UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); public abstract UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType);
/**
* 访
*
* @return 访
*/
public abstract String getEndpointLink(); public abstract String getEndpointLink();
} }

@ -18,10 +18,10 @@ import java.awt.*;
@Configuration @Configuration
public class CaptchaConfig { public class CaptchaConfig {
private final int width = 160; private static final int WIDTH = 160;
private final int height = 60; private static final int HEIGHT = 60;
private final Color background = Color.PINK; private static final Color BACKGROUND = Color.PINK;
private final Font font = new Font("Arial", Font.BOLD, 48); private static final Font FONT = new Font("Arial", Font.BOLD, 48);
/** /**
* *
@ -29,9 +29,9 @@ public class CaptchaConfig {
@Lazy @Lazy
@Bean @Bean
public CircleCaptcha circleCaptcha() { public CircleCaptcha circleCaptcha() {
CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(width, height); CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(WIDTH, HEIGHT);
captcha.setBackground(background); captcha.setBackground(BACKGROUND);
captcha.setFont(font); captcha.setFont(FONT);
return captcha; return captcha;
} }
@ -41,9 +41,9 @@ public class CaptchaConfig {
@Lazy @Lazy
@Bean @Bean
public LineCaptcha lineCaptcha() { public LineCaptcha lineCaptcha() {
LineCaptcha captcha = CaptchaUtil.createLineCaptcha(width, height); LineCaptcha captcha = CaptchaUtil.createLineCaptcha(WIDTH, HEIGHT);
captcha.setBackground(background); captcha.setBackground(BACKGROUND);
captcha.setFont(font); captcha.setFont(FONT);
return captcha; return captcha;
} }
@ -53,9 +53,9 @@ public class CaptchaConfig {
@Lazy @Lazy
@Bean @Bean
public ShearCaptcha shearCaptcha() { public ShearCaptcha shearCaptcha() {
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(width, height); ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(WIDTH, HEIGHT);
captcha.setBackground(background); captcha.setBackground(BACKGROUND);
captcha.setFont(font); captcha.setFont(FONT);
return captcha; return captcha;
} }

@ -5,6 +5,8 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.gen.config.GenConfig; import com.ruoyi.gen.config.GenConfig;
import com.ruoyi.gen.domain.GenTable; import com.ruoyi.gen.domain.GenTable;
import com.ruoyi.gen.domain.GenTableColumn; import com.ruoyi.gen.domain.GenTableColumn;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.RegExUtils;
import java.util.Arrays; import java.util.Arrays;
@ -14,6 +16,7 @@ import java.util.Arrays;
* *
* @author ruoyi * @author ruoyi
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class GenUtils { public class GenUtils {
/** /**
* *

@ -1,6 +1,8 @@
package com.ruoyi.gen.util; package com.ruoyi.gen.util;
import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.Constants;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.velocity.app.Velocity; import org.apache.velocity.app.Velocity;
import java.util.Properties; import java.util.Properties;
@ -10,6 +12,7 @@ import java.util.Properties;
* *
* @author ruoyi * @author ruoyi
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class VelocityInitializer { public class VelocityInitializer {
/** /**
* vm * vm

@ -10,6 +10,8 @@ import com.ruoyi.common.core.utils.JsonUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.gen.domain.GenTable; import com.ruoyi.gen.domain.GenTable;
import com.ruoyi.gen.domain.GenTableColumn; import com.ruoyi.gen.domain.GenTableColumn;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.velocity.VelocityContext; import org.apache.velocity.VelocityContext;
import java.util.*; import java.util.*;
@ -19,6 +21,7 @@ import java.util.*;
* *
* @author ruoyi * @author ruoyi
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class VelocityUtils { public class VelocityUtils {
/** /**

Loading…
Cancel
Save