diff --git a/eladmin-common/pom.xml b/eladmin-common/pom.xml index e1510a7a..7ee9eefa 100644 --- a/eladmin-common/pom.xml +++ b/eladmin-common/pom.xml @@ -11,10 +11,10 @@ eladmin-common - 公共模块 + Common Module - + cn.hutool hutool-all diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java b/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java index 18bc4c4a..744d2b40 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java @@ -28,60 +28,60 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) public @interface Query { - // Dong ZhaoYang 2017/8/7 基本对象的属性名 + // Dong ZhaoYang 2017/8/7 Property name of the basic object String propName() default ""; - // Dong ZhaoYang 2017/8/7 查询方式 + // Dong ZhaoYang 2017/8/7 Query type Type type() default Type.EQUAL; /** - * 连接查询的属性名,如User类中的dept + * Property name for join query, e.g., dept in User class */ String joinName() default ""; /** - * 默认左连接 + * Default left join */ Join join() default Join.LEFT; /** - * 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username") + * Multi-field fuzzy search, only supports String type fields, separated by commas, e.g., @Query(blurry = "email,username") */ String blurry() default ""; enum Type { - // jie 2019/6/4 相等 + // jie 2019/6/4 Equal EQUAL - // Dong ZhaoYang 2017/8/7 大于等于 + // Dong ZhaoYang 2017/8/7 Greater than or equal to , GREATER_THAN - // Dong ZhaoYang 2017/8/7 小于等于 + // Dong ZhaoYang 2017/8/7 Less than or equal to , LESS_THAN - // Dong ZhaoYang 2017/8/7 中模糊查询 + // Dong ZhaoYang 2017/8/7 Inner fuzzy query , INNER_LIKE - // Dong ZhaoYang 2017/8/7 左模糊查询 + // Dong ZhaoYang 2017/8/7 Left fuzzy query , LEFT_LIKE - // Dong ZhaoYang 2017/8/7 右模糊查询 + // Dong ZhaoYang 2017/8/7 Right fuzzy query , RIGHT_LIKE - // Dong ZhaoYang 2017/8/7 小于 + // Dong ZhaoYang 2017/8/7 Less than , LESS_THAN_NQ - // jie 2019/6/4 包含 + // jie 2019/6/4 Contains , IN - // 不包含 + // Not contains , NOT_IN - // 不等于 + // Not equal ,NOT_EQUAL // between ,BETWEEN - // 不为空 + // Not null ,NOT_NULL - // 为空 + // Is null ,IS_NULL, - // Aborn Jiang 2022/06/01, 对应SQL: SELECT * FROM table WHERE FIND_IN_SET('querytag', table.tags); + // Aborn Jiang 2022/06/01, Corresponds to SQL: SELECT * FROM table WHERE FIND_IN_SET('querytag', table.tags); FIND_IN_SET } /** * @author Zheng Jie - * 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询 + * Suitable for simple join queries. For complex cases, please customize this annotation or use SQL queries. */ enum Join { /** jie 2019-6-4 13:18:30 */ @@ -89,4 +89,3 @@ public @interface Query { } } - diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPatchMapping.java b/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPatchMapping.java index 67d941c0..c6db87de 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPatchMapping.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPatchMapping.java @@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RequestMethod; /** * Annotation for mapping HTTP {@code PATCH} requests onto specific handler * methods. - * * 支持匿名访问 PatchMapping + * * Supports anonymous access PatchMapping * * @author liaojinlong * @see AnonymousGetMapping diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPutMapping.java b/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPutMapping.java index bb2d890e..e014ce7e 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPutMapping.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/rest/AnonymousPutMapping.java @@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RequestMethod; /** * Annotation for mapping HTTP {@code PUT} requests onto specific handler * methods. - * * 支持匿名访问 PutMapping + * * Supports anonymous access PutMapping * * @author liaojinlong * @see AnonymousGetMapping diff --git a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java index 5cc3c6df..08b5351b 100644 --- a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java +++ b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java @@ -75,15 +75,15 @@ public class LimitAspect { RedisScript redisScript = new DefaultRedisScript<>(luaScript, Long.class); Long count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period()); if (ObjUtil.isNotNull(count) && count.intValue() <= limit.count()) { - logger.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name()); + logger.info("The {}th access to the key {}, description [{}] interface", count, keys, limit.name()); return joinPoint.proceed(); } else { - throw new BadRequestException("访问次数受限制"); + throw new BadRequestException("Access count is restricted"); } } /** - * 限流脚本 + * Rate limiting script */ private String buildLuaScript() { return "local c" + diff --git a/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java b/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java index 84dad94d..162b43cc 100644 --- a/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java +++ b/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java @@ -11,23 +11,23 @@ import java.sql.Timestamp; /** * @author Zheng Jie - * @date 2019年10月24日20:48:53 + * @date 2019-10-24 20:48:53 */ @Getter @Setter public class BaseDTO implements Serializable { - @ApiModelProperty(value = "创建人") + @ApiModelProperty(value = "Creator") private String createBy; - @ApiModelProperty(value = "修改人") + @ApiModelProperty(value = "Updater") private String updateBy; - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @ApiModelProperty(value = "Creation Time: yyyy-MM-dd HH:mm:ss", hidden = true) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private Timestamp createTime; - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @ApiModelProperty(value = "Update Time: yyyy-MM-dd HH:mm:ss", hidden = true) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private Timestamp updateTime; diff --git a/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java b/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java index 7f5a0d9f..08a2e715 100644 --- a/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java +++ b/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java @@ -33,9 +33,9 @@ import java.lang.reflect.Field; import java.sql.Timestamp; /** - * 通用字段, is_del 根据需求自行添加 + * Common fields, add is_del as needed * @author Zheng Jie - * @date 2019年10月24日20:46:32 + * @date 2019-10-24 20:46:32 */ @Getter @Setter @@ -45,30 +45,30 @@ public class BaseEntity implements Serializable { @CreatedBy @Column(name = "create_by", updatable = false) - @ApiModelProperty(value = "创建人", hidden = true) + @ApiModelProperty(value = "Creator", hidden = true) private String createBy; @LastModifiedBy @Column(name = "update_by") - @ApiModelProperty(value = "更新人", hidden = true) + @ApiModelProperty(value = "Updater", hidden = true) private String updateBy; @CreationTimestamp @Column(name = "create_time", updatable = false) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @ApiModelProperty(value = "Creation time: yyyy-MM-dd HH:mm:ss", hidden = true) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private Timestamp createTime; @UpdateTimestamp @Column(name = "update_time") - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @ApiModelProperty(value = "Update time: yyyy-MM-dd HH:mm:ss", hidden = true) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private Timestamp updateTime; - /* 分组校验 */ + /* Group validation */ public @interface Create {} - /* 分组校验 */ + /* Group validation */ public @interface Update {} @Override diff --git a/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java b/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java index 6f69b138..4065df05 100644 --- a/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java +++ b/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java @@ -24,28 +24,28 @@ import java.util.List; public interface BaseMapper { /** - * DTO转Entity + * DTO to Entity * @param dto / * @return / */ E toEntity(D dto); /** - * Entity转DTO + * Entity to DTO * @param entity / * @return / */ D toDto(E entity); /** - * DTO集合转Entity集合 + * DTO List to Entity List * @param dtoList / * @return / */ List toEntity(List dtoList); /** - * Entity集合转DTO集合 + * Entity List to DTO List * @param entityList / * @return / */ diff --git a/eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java index d693c58a..2214f1d5 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; import java.util.Optional; /** - * @description : 设置审计 + * @description : Set audit * @author : Dong ZhaoYang * @date : 2019/10/28 */ @@ -29,17 +29,17 @@ import java.util.Optional; public class AuditorConfig implements AuditorAware { /** - * 返回操作员标志信息 + * Return operator identification information * * @return / */ @Override public Optional getCurrentAuditor() { try { - // 这里应根据实际业务情况获取具体信息 + // Here you should obtain specific information according to actual business situation return Optional.of(SecurityUtils.getCurrentUsername()); }catch (Exception ignored){} - // 用户定时任务,或者无Token调用的情况 + // For scheduled tasks or cases where Token is not used return Optional.of("System"); } } diff --git a/eladmin-common/src/main/java/me/zhengjie/config/RemoveDruidAdConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/RemoveDruidAdConfig.java index 8757ead1..b61682e3 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/RemoveDruidAdConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/RemoveDruidAdConfig.java @@ -29,23 +29,23 @@ import java.io.IOException; public class RemoveDruidAdConfig { /** - * 方法名: removeDruidAdFilterRegistrationBean - * 方法描述 除去页面底部的广告 + * Method name: removeDruidAdFilterRegistrationBean + * Method description: Remove the advertisement at the bottom of the page * @param properties com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties * @return org.springframework.boot.web.servlet.FilterRegistrationBean */ @Bean public FilterRegistrationBean removeDruidAdFilterRegistrationBean(DruidStatProperties properties) { - // 获取web监控页面的参数 + // Get the parameters of the web monitoring page DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); - // 提取common.js的配置路径 + // Extract the configuration path of common.js String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); final String filePath = "support/http/resources/js/common.js"; - //创建filter进行过滤 + // Create filter for filtering Filter filter = new Filter() { @Override public void init(FilterConfig filterConfig) throws ServletException {} @@ -55,9 +55,9 @@ public class RemoveDruidAdConfig { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (httpRequest.getRequestURI().endsWith("js/common.js")) { - // 获取common.js + // Get common.js String text = Utils.readFromResource(filePath); - // 正则替换banner, 除去底部的广告信息 + // Use regex to replace banner, remove advertisement information at the bottom text = text.replaceAll("
", ""); text = text.replaceAll("powered by.*?shrek.wang", ""); httpResponse.setContentType("application/javascript"); diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/BigDecimalUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/BigDecimalUtils.java index ff3d81fa..a29fab5f 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/BigDecimalUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/BigDecimalUtils.java @@ -20,15 +20,15 @@ import java.math.RoundingMode; /** * @author Zheng Jie - * @description 计算类 + * @description Calculation class * @date 2024-12-27 **/ public class BigDecimalUtils { /** - * 将对象转换为 BigDecimal - * @param obj 输入对象 - * @return 转换后的 BigDecimal + * Convert object to BigDecimal + * @param obj Input object + * @return Converted BigDecimal */ private static BigDecimal toBigDecimal(Object obj) { if (obj instanceof BigDecimal) { @@ -45,10 +45,10 @@ public class BigDecimalUtils { } /** - * 加法 - * @param a 加数 - * @param b 加数 - * @return 两个加数的和,保留两位小数 + * Addition + * @param a Addend + * @param b Addend + * @return Sum of two addends, rounded to two decimal places */ public static BigDecimal add(Object a, Object b) { BigDecimal bdA = toBigDecimal(a); @@ -57,10 +57,10 @@ public class BigDecimalUtils { } /** - * 减法 - * @param a 被减数 - * @param b 减数 - * @return 两数的差,保留两位小数 + * Subtraction + * @param a Minuend + * @param b Subtrahend + * @return Difference of two numbers, rounded to two decimal places */ public static BigDecimal subtract(Object a, Object b) { BigDecimal bdA = toBigDecimal(a); @@ -69,10 +69,10 @@ public class BigDecimalUtils { } /** - * 乘法 - * @param a 乘数 - * @param b 乘数 - * @return 两个乘数的积,保留两位小数 + * Multiplication + * @param a Multiplier + * @param b Multiplier + * @return Product of two multipliers, rounded to two decimal places */ public static BigDecimal multiply(Object a, Object b) { BigDecimal bdA = toBigDecimal(a); @@ -81,10 +81,10 @@ public class BigDecimalUtils { } /** - * 除法 - * @param a 被除数 - * @param b 除数 - * @return 两数的商,保留两位小数 + * Division + * @param a Dividend + * @param b Divisor + * @return Quotient of two numbers, rounded to two decimal places */ public static BigDecimal divide(Object a, Object b) { BigDecimal bdA = toBigDecimal(a); @@ -93,11 +93,11 @@ public class BigDecimalUtils { } /** - * 除法 - * @param a 被除数 - * @param b 除数 - * @param scale 保留小数位数 - * @return 两数的商,保留两位小数 + * Division + * @param a Dividend + * @param b Divisor + * @param scale Number of decimal places to keep + * @return Quotient of two numbers, rounded to two decimal places */ public static BigDecimal divide(Object a, Object b, int scale) { BigDecimal bdA = toBigDecimal(a); @@ -106,9 +106,9 @@ public class BigDecimalUtils { } /** - * 分转元 - * @param obj 分的金额 - * @return 转换后的元,保留两位小数 + * Cents to Yuan + * @param obj Amount in cents + * @return Converted yuan, rounded to two decimal places */ public static BigDecimal centsToYuan(Object obj) { BigDecimal cents = toBigDecimal(obj); @@ -116,9 +116,9 @@ public class BigDecimalUtils { } /** - * 元转分 - * @param obj 元的金额 - * @return 转换后的分 + * Yuan to Cents + * @param obj Amount in yuan + * @return Converted cents */ public static Long yuanToCents(Object obj) { BigDecimal yuan = toBigDecimal(obj); @@ -129,15 +129,15 @@ public class BigDecimalUtils { BigDecimal num1 = new BigDecimal("10.123"); BigDecimal num2 = new BigDecimal("2.456"); - System.out.println("加法结果: " + add(num1, num2)); - System.out.println("减法结果: " + subtract(num1, num2)); - System.out.println("乘法结果: " + multiply(num1, num2)); - System.out.println("除法结果: " + divide(num1, num2)); + System.out.println("Addition result: " + add(num1, num2)); + System.out.println("Subtraction result: " + subtract(num1, num2)); + System.out.println("Multiplication result: " + multiply(num1, num2)); + System.out.println("Division result: " + divide(num1, num2)); Long cents = 12345L; - System.out.println("分转元结果: " + centsToYuan(cents)); + System.out.println("Cents to Yuan result: " + centsToYuan(cents)); BigDecimal yuan = new BigDecimal("123.45"); - System.out.println("元转分结果: " + yuanToCents(yuan)); + System.out.println("Yuan to Cents result: " + yuanToCents(yuan)); } } diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java index 83bf918f..05564ed1 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java @@ -23,7 +23,7 @@ import javax.crypto.spec.IvParameterSpec; import java.nio.charset.StandardCharsets; /** - * 加密 + * Encryption * @author Zheng Jie * @date 2018-11-23 */ @@ -41,7 +41,7 @@ public class EncryptUtils { } /** - * 对称加密 + * Symmetric encryption */ public static String desEncrypt(String source) throws Exception { Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); @@ -53,7 +53,7 @@ public class EncryptUtils { } /** - * 对称解密 + * Symmetric decryption */ public static String desDecrypt(String source) throws Exception { Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); @@ -83,7 +83,7 @@ public class EncryptUtils { private static byte[] hex2byte(byte[] b) { int size = 2; if ((b.length % size) != 0) { - throw new IllegalArgumentException("长度不是偶数"); + throw new IllegalArgumentException("Length is not even"); } byte[] b2 = new byte[b.length / 2]; for (int n = 0; n < b.length; n += size) { diff --git a/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java b/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java index 3ec73752..85d7fb7c 100644 --- a/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java +++ b/eladmin-common/src/test/java/me/zhengjie/utils/EncryptUtilsTest.java @@ -8,7 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class EncryptUtilsTest { /** - * 对称加密 + * Symmetric encryption */ @Test public void testDesEncrypt() { @@ -20,7 +20,7 @@ public class EncryptUtilsTest { } /** - * 对称解密 + * Symmetric decryption */ @Test public void testDesDecrypt() { diff --git a/eladmin-generator/pom.xml b/eladmin-generator/pom.xml index 46b8e757..c4a8f455 100644 --- a/eladmin-generator/pom.xml +++ b/eladmin-generator/pom.xml @@ -8,7 +8,7 @@ 4.0.0 eladmin-generator - 代码生成模块 + Code Generation Module 1.10 @@ -21,7 +21,7 @@ 2.7
- + org.springframework.boot spring-boot-starter-freemarker diff --git a/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java b/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java index fddc1993..992ee998 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java +++ b/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java @@ -24,7 +24,7 @@ import javax.persistence.*; import java.io.Serializable; /** - * 列的数据信息 + * Column Data Information * @author Zheng Jie * @date 2019-01-02 */ @@ -41,43 +41,43 @@ public class ColumnInfo implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @ApiModelProperty(value = "表名") + @ApiModelProperty(value = "Table Name") private String tableName; - @ApiModelProperty(value = "数据库字段名称") + @ApiModelProperty(value = "Database Column Name") private String columnName; - @ApiModelProperty(value = "数据库字段类型") + @ApiModelProperty(value = "Database Column Type") private String columnType; - @ApiModelProperty(value = "数据库字段键类型") + @ApiModelProperty(value = "Database Column Key Type") private String keyType; - @ApiModelProperty(value = "字段额外的参数") + @ApiModelProperty(value = "Extra Parameters for Column") private String extra; - @ApiModelProperty(value = "数据库字段描述") + @ApiModelProperty(value = "Database Column Description") private String remark; - @ApiModelProperty(value = "是否必填") + @ApiModelProperty(value = "Required") private Boolean notNull; - @ApiModelProperty(value = "是否在列表显示") + @ApiModelProperty(value = "Show in List") private Boolean listShow; - @ApiModelProperty(value = "是否表单显示") + @ApiModelProperty(value = "Show in Form") private Boolean formShow; - @ApiModelProperty(value = "表单类型") + @ApiModelProperty(value = "Form Type") private String formType; - @ApiModelProperty(value = "查询 1:模糊 2:精确") + @ApiModelProperty(value = "Query Type 1:Fuzzy 2:Exact") private String queryType; - @ApiModelProperty(value = "字典名称") + @ApiModelProperty(value = "Dictionary Name") private String dictName; - @ApiModelProperty(value = "日期注解") + @ApiModelProperty(value = "Date Annotation") private String dateAnnotation; public ColumnInfo(String tableName, String columnName, Boolean notNull, String columnType, String remark, String keyType, String extra) { diff --git a/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java b/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java index 47e87d31..6daca39a 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java +++ b/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java @@ -24,7 +24,7 @@ import javax.validation.constraints.NotBlank; import java.io.Serializable; /** - * 代码生成配置 + * Code Generation Configuration * @author Zheng Jie * @date 2019-01-03 */ @@ -46,33 +46,33 @@ public class GenConfig implements Serializable { private Long id; @NotBlank - @ApiModelProperty(value = "表名") + @ApiModelProperty(value = "Table Name") private String tableName; - @ApiModelProperty(value = "接口名称") + @ApiModelProperty(value = "API Alias") private String apiAlias; @NotBlank - @ApiModelProperty(value = "包路径") + @ApiModelProperty(value = "Package Path") private String pack; @NotBlank - @ApiModelProperty(value = "模块名") + @ApiModelProperty(value = "Module Name") private String moduleName; @NotBlank - @ApiModelProperty(value = "前端文件路径") + @ApiModelProperty(value = "Frontend File Path") private String path; - @ApiModelProperty(value = "前端文件路径") + @ApiModelProperty(value = "Frontend API Path") private String apiPath; - @ApiModelProperty(value = "作者") + @ApiModelProperty(value = "Author") private String author; - @ApiModelProperty(value = "表前缀") + @ApiModelProperty(value = "Table Prefix") private String prefix; - @ApiModelProperty(value = "是否覆盖") + @ApiModelProperty(value = "Overwrite") private Boolean cover = false; } diff --git a/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java b/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java index c900a654..117f0699 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java +++ b/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java @@ -22,7 +22,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * 表的数据信息 + * Table data information * @author Zheng Jie * @date 2019-01-02 */ @@ -31,19 +31,19 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class TableInfo { - @ApiModelProperty(value = "表名称") + @ApiModelProperty(value = "Table name") private Object tableName; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "创建日期:yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "Creation date: yyyy-MM-dd HH:mm:ss") private Object createTime; - @ApiModelProperty(value = "数据库引擎") + @ApiModelProperty(value = "Database engine") private Object engine; - @ApiModelProperty(value = "编码集") + @ApiModelProperty(value = "Character set") private Object coding; - @ApiModelProperty(value = "备注") + @ApiModelProperty(value = "Remarks") private Object remark; } diff --git a/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java b/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java index 7a174d2d..6848fbcd 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java +++ b/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java @@ -26,9 +26,9 @@ import java.util.List; public interface ColumnInfoRepository extends JpaRepository { /** - * 查询表信息 - * @param tableName 表格名 - * @return 表信息 + * Query table information + * @param tableName table name + * @return table information */ List findByTableNameOrderByIdAsc(String tableName); } diff --git a/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java b/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java index 1513c810..a7e7f8a5 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java +++ b/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java @@ -25,8 +25,8 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface GenConfigRepository extends JpaRepository { /** - * 查询表配置 - * @param tableName 表名 + * Query table configuration + * @param tableName table name * @return / */ GenConfig findByTableName(String tableName); diff --git a/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java b/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java index 85a2a4bb..c4de71f1 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java +++ b/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java @@ -32,19 +32,19 @@ import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @RequestMapping("/api/genConfig") -@Api(tags = "系统:代码生成器配置管理") +@Api(tags = "System: Code Generator Configuration Management") public class GenConfigController { private final GenConfigService genConfigService; - @ApiOperation("查询") + @ApiOperation("Query") @GetMapping(value = "/{tableName}") public ResponseEntity queryGenConfig(@PathVariable String tableName){ return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK); } @PutMapping - @ApiOperation("修改") + @ApiOperation("Update") public ResponseEntity updateGenConfig(@Validated @RequestBody GenConfig genConfig){ return new ResponseEntity<>(genConfigService.update(genConfig.getTableName(), genConfig),HttpStatus.OK); } diff --git a/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java b/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java index 68148b94..b57020cf 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java +++ b/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java @@ -40,7 +40,7 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/api/generator") -@Api(tags = "系统:代码生成管理") +@Api(tags = "System: Code Generation Management") public class GeneratorController { private final GeneratorService generatorService; @@ -49,13 +49,13 @@ public class GeneratorController { @Value("${generator.enabled}") private Boolean generatorEnabled; - @ApiOperation("查询数据库数据") + @ApiOperation("Query database data") @GetMapping(value = "/tables/all") public ResponseEntity queryAllTables(){ return new ResponseEntity<>(generatorService.getTables(), HttpStatus.OK); } - @ApiOperation("查询数据库数据") + @ApiOperation("Query database data") @GetMapping(value = "/tables") public ResponseEntity> queryTables(@RequestParam(defaultValue = "") String name, @RequestParam(defaultValue = "0")Integer page, @@ -64,21 +64,21 @@ public class GeneratorController { return new ResponseEntity<>(generatorService.getTables(name,startEnd), HttpStatus.OK); } - @ApiOperation("查询字段数据") + @ApiOperation("Query column data") @GetMapping(value = "/columns") public ResponseEntity> queryColumns(@RequestParam String tableName){ List columnInfos = generatorService.getColumns(tableName); return new ResponseEntity<>(PageUtil.toPage(columnInfos,columnInfos.size()), HttpStatus.OK); } - @ApiOperation("保存字段数据") + @ApiOperation("Save column data") @PutMapping public ResponseEntity saveColumn(@RequestBody List columnInfos){ generatorService.save(columnInfos); return new ResponseEntity<>(HttpStatus.OK); } - @ApiOperation("同步字段数据") + @ApiOperation("Sync column data") @PostMapping(value = "sync") public ResponseEntity syncColumn(@RequestBody List tables){ for (String table : tables) { @@ -87,22 +87,22 @@ public class GeneratorController { return new ResponseEntity<>(HttpStatus.OK); } - @ApiOperation("生成代码") + @ApiOperation("Generate code") @PostMapping(value = "/{tableName}/{type}") public ResponseEntity generatorCode(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){ if(!generatorEnabled && type == 0){ - throw new BadRequestException("此环境不允许生成代码,请选择预览或者下载查看!"); + throw new BadRequestException("Code generation is not allowed in this environment, please choose preview or download to view!"); } switch (type){ - // 生成代码 + // Generate code case 0: generatorService.generator(genConfigService.find(tableName), generatorService.getColumns(tableName)); break; - // 预览 + // Preview case 1: return generatorService.preview(genConfigService.find(tableName), generatorService.getColumns(tableName)); - // 打包 + // Package case 2: generatorService.download(genConfigService.find(tableName), generatorService.getColumns(tableName), request, response); break; - default: throw new BadRequestException("没有这个选项"); + default: throw new BadRequestException("No such option"); } return new ResponseEntity<>(HttpStatus.OK); } diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java b/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java index 175439ab..85d77ef7 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java @@ -24,17 +24,17 @@ import me.zhengjie.domain.GenConfig; public interface GenConfigService { /** - * 查询表配置 - * @param tableName 表名 - * @return 表配置 + * Query table configuration + * @param tableName Table name + * @return Table configuration */ GenConfig find(String tableName); /** - * 更新表配置 - * @param tableName 表名 - * @param genConfig 表配置 - * @return 表配置 + * Update table configuration + * @param tableName Table name + * @param genConfig Table configuration + * @return Table configuration */ GenConfig update(String tableName, GenConfig genConfig); } diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java b/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java index 6e59160a..e34d61cc 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java @@ -31,66 +31,66 @@ import java.util.List; public interface GeneratorService { /** - * 查询数据库元数据 - * @param name 表名 - * @param startEnd 分页参数 + * Query database metadata + * @param name Table name + * @param startEnd Pagination parameters * @return / */ PageResult getTables(String name, int[] startEnd); /** - * 得到数据表的元数据 - * @param name 表名 + * Get table metadata + * @param name Table name * @return / */ List getColumns(String name); /** - * 同步表数据 - * @param columnInfos / - * @param columnInfoList / + * Synchronize table data + * @param columnInfos + * @param columnInfoList */ void sync(List columnInfos, List columnInfoList); /** - * 保持数据 - * @param columnInfos / + * Save data + * @param columnInfos */ void save(List columnInfos); /** - * 获取所有table + * Get all tables * @return / */ Object getTables(); /** - * 代码生成 - * @param genConfig 配置信息 - * @param columns 字段信息 + * Code generation + * @param genConfig Configuration information + * @param columns Field information */ void generator(GenConfig genConfig, List columns); /** - * 预览 - * @param genConfig 配置信息 - * @param columns 字段信息 + * Preview + * @param genConfig Configuration information + * @param columns Field information * @return / */ ResponseEntity preview(GenConfig genConfig, List columns); /** - * 打包下载 - * @param genConfig 配置信息 - * @param columns 字段信息 - * @param request / - * @param response / + * Download as package + * @param genConfig Configuration information + * @param columns Field information + * @param request + * @param response */ void download(GenConfig genConfig, List columns, HttpServletRequest request, HttpServletResponse response); /** - * 查询数据库的表字段数据数据 - * @param table / + * Query database table field data + * @param table * @return / */ List query(String table); diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java index fdd0a0ae..768fe4f5 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java @@ -58,10 +58,10 @@ public class GeneratorServiceImpl implements GeneratorService { private final ColumnInfoRepository columnInfoRepository; - private final String CONFIG_MESSAGE = "请先配置生成器"; + private final String CONFIG_MESSAGE = "Please configure the generator first"; @Override public Object getTables() { - // 使用预编译防止sql注入 + // Use precompilation to prevent SQL injection String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " + "where table_schema = (select database()) " + "order by create_time desc"; @@ -71,7 +71,7 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public PageResult getTables(String name, int[] startEnd) { - // 使用预编译防止sql注入 + // Use precompilation to prevent SQL injection String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " + "where table_schema = (select database()) " + "and table_name like :table order by create_time desc"; @@ -106,7 +106,7 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public List query(String tableName) { - // 使用预编译防止sql注入 + // Use precompilation to prevent SQL injection String sql = "select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns " + "where table_name = ? and table_schema = (select database()) order by ordinal_position"; Query query = em.createNativeQuery(sql); @@ -131,11 +131,11 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public void sync(List columnInfos, List columnInfoList) { - // 第一种情况,数据库类字段改变或者新增字段 + // First case: database class field changes or new fields for (ColumnInfo columnInfo : columnInfoList) { - // 根据字段名称查找 + // Find by field name List columns = columnInfos.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()); - // 如果能找到,就修改部分可能被字段 + // If found, modify fields that may have been changed if (CollectionUtil.isNotEmpty(columns)) { ColumnInfo column = columns.get(0); column.setColumnType(columnInfo.getColumnType()); @@ -146,15 +146,15 @@ public class GeneratorServiceImpl implements GeneratorService { } columnInfoRepository.save(column); } else { - // 如果找不到,则保存新字段信息 + // If not found, save new field information columnInfoRepository.save(columnInfo); } } - // 第二种情况,数据库字段删除了 + // Second case: database fields have been deleted for (ColumnInfo columnInfo : columnInfos) { - // 根据字段名称查找 + // Find by field name List columns = columnInfoList.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()); - // 如果找不到,就代表字段被删除了,则需要删除该字段 + // If not found, it means the field has been deleted, so the field needs to be deleted if (CollectionUtil.isEmpty(columns)) { columnInfoRepository.delete(columnInfo); } @@ -175,7 +175,7 @@ public class GeneratorServiceImpl implements GeneratorService { GenUtil.generatorCode(columns, genConfig); } catch (IOException e) { log.error(e.getMessage(), e); - throw new BadRequestException("生成失败,请手动处理已生成的文件"); + throw new BadRequestException("Generation failed, please manually process the generated files"); } } @@ -199,7 +199,7 @@ public class GeneratorServiceImpl implements GeneratorService { ZipUtil.zip(file.getPath(), zipPath); FileUtil.downloadFile(request, response, new File(zipPath), true); } catch (IOException e) { - throw new BadRequestException("打包失败"); + throw new BadRequestException("Package failed"); } } } diff --git a/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java b/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java index cee76364..4eb888cb 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java +++ b/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java @@ -20,7 +20,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * sql字段转java + * Convert SQL fields to Java * * @author Zheng Jie * @date 2019-01-03 @@ -29,9 +29,9 @@ public class ColUtil { private static final Logger log = LoggerFactory.getLogger(ColUtil.class); /** - * 转换mysql数据类型为java数据类型 + * Convert MySQL data type to Java data type * - * @param type 数据库字段类型 + * @param type Database column type * @return String */ static String cloToJava(String type) { @@ -41,7 +41,7 @@ public class ColUtil { } /** - * 获取配置信息 + * Get configuration information */ public static PropertiesConfiguration getConfig() { try { diff --git a/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java b/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java index bb5a85e4..fcdf3286 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java +++ b/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java @@ -32,7 +32,7 @@ import java.util.*; import static me.zhengjie.utils.FileUtil.SYS_TEM_DIR; /** - * 代码生成 + * Code generation * * @author Zheng Jie * @date 2019-01-02 @@ -50,7 +50,7 @@ public class GenUtil { public static final String EXTRA = "auto_increment"; /** - * 获取后端代码模板名称 + * Get backend code template name * * @return List */ @@ -68,7 +68,7 @@ public class GenUtil { } /** - * 获取前端代码模板名称 + * Get frontend code template name * * @return List */ @@ -82,7 +82,7 @@ public class GenUtil { public static List> preview(List columns, GenConfig genConfig) { Map genMap = getGenMap(columns, genConfig); List> genList = new ArrayList<>(); - // 获取后端模版 + // Get backend template List templates = getAdminTemplateNames(); TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); for (String templateName : templates) { @@ -92,7 +92,7 @@ public class GenUtil { map.put("name", templateName); genList.add(map); } - // 获取前端模版 + // Get frontend template templates = getFrontTemplateNames(); for (String templateName : templates) { Map map = new HashMap<>(1); @@ -106,26 +106,26 @@ public class GenUtil { } public static String download(List columns, GenConfig genConfig) throws IOException { - // 拼接的路径:/tmpeladmin-gen-temp/,这个路径在Linux下需要root用户才有权限创建,非root用户会权限错误而失败,更改为: /tmp/eladmin-gen-temp/ + // Concatenated path: /tmpeladmin-gen-temp/. This path requires root privileges to create on Linux, non-root users will encounter permission errors and fail. Change to: /tmp/eladmin-gen-temp/ // String tempPath =SYS_TEM_DIR + "eladmin-gen-temp" + File.separator + genConfig.getTableName() + File.separator; String tempPath = SYS_TEM_DIR + "eladmin-gen-temp" + File.separator + genConfig.getTableName() + File.separator; Map genMap = getGenMap(columns, genConfig); TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); - // 生成后端代码 + // Generate backend code List templates = getAdminTemplateNames(); for (String templateName : templates) { Template template = engine.getTemplate("admin/" + templateName + ".ftl"); String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), tempPath + "eladmin" + File.separator); assert filePath != null; File file = new File(filePath); - // 如果非覆盖生成 + // If not overwriting if (!genConfig.getCover() && FileUtil.exist(file)) { continue; } - // 生成代码 + // Generate code genFile(file, template, genMap); } - // 生成前端代码 + // Generate frontend code templates = getFrontTemplateNames(); for (String templateName : templates) { Template template = engine.getTemplate("front/" + templateName + ".ftl"); @@ -135,11 +135,11 @@ public class GenUtil { String filePath = getFrontFilePath(templateName, apiPath, srcPath, genMap.get("changeClassName").toString()); assert filePath != null; File file = new File(filePath); - // 如果非覆盖生成 + // If not overwriting if (!genConfig.getCover() && FileUtil.exist(file)) { continue; } - // 生成代码 + // Generate code genFile(file, template, genMap); } return tempPath; @@ -148,7 +148,7 @@ public class GenUtil { public static void generatorCode(List columnInfos, GenConfig genConfig) throws IOException { Map genMap = getGenMap(columnInfos, genConfig); TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); - // 生成后端代码 + // Generate backend code List templates = getAdminTemplateNames(); for (String templateName : templates) { Template template = engine.getTemplate("admin/" + templateName + ".ftl"); @@ -158,15 +158,15 @@ public class GenUtil { assert filePath != null; File file = new File(filePath); - // 如果非覆盖生成 + // If not overwriting if (!genConfig.getCover() && FileUtil.exist(file)) { continue; } - // 生成代码 + // Generate code genFile(file, template, genMap); } - // 生成前端代码 + // Generate frontend code templates = getFrontTemplateNames(); for (String templateName : templates) { Template template = engine.getTemplate("front/" + templateName + ".ftl"); @@ -175,177 +175,177 @@ public class GenUtil { assert filePath != null; File file = new File(filePath); - // 如果非覆盖生成 + // If not overwriting if (!genConfig.getCover() && FileUtil.exist(file)) { continue; } - // 生成代码 + // Generate code genFile(file, template, genMap); } } - // 获取模版数据 + // Get template data private static Map getGenMap(List columnInfos, GenConfig genConfig) { - // 存储模版字段数据 + // Store template field data Map genMap = new HashMap<>(16); - // 接口别名 + // Interface alias genMap.put("apiAlias", genConfig.getApiAlias()); - // 包名称 + // Package name genMap.put("package", genConfig.getPack()); - // 模块名称 + // Module name genMap.put("moduleName", genConfig.getModuleName()); - // 作者 + // Author genMap.put("author", genConfig.getAuthor()); - // 创建日期 + // Creation date genMap.put("date", LocalDate.now().toString()); - // 表名 + // Table name genMap.put("tableName", genConfig.getTableName()); - // 大写开头的类名 + // Class name starting with uppercase String className = StringUtils.toCapitalizeCamelCase(genConfig.getTableName()); - // 小写开头的类名 + // Class name starting with lowercase String changeClassName = StringUtils.toCamelCase(genConfig.getTableName()); - // 判断是否去除表前缀 + // Determine whether to remove table prefix if (StringUtils.isNotEmpty(genConfig.getPrefix())) { className = StringUtils.toCapitalizeCamelCase(StrUtil.removePrefix(genConfig.getTableName(), genConfig.getPrefix())); changeClassName = StringUtils.toCamelCase(StrUtil.removePrefix(genConfig.getTableName(), genConfig.getPrefix())); changeClassName = StringUtils.uncapitalize(changeClassName); } - // 保存类名 + // Save class name genMap.put("className", className); - // 保存小写开头的类名 + // Save lowercase class name genMap.put("changeClassName", changeClassName); - // 存在 Timestamp 字段 + // Timestamp field exists genMap.put("hasTimestamp", false); - // 查询类中存在 Timestamp 字段 + // Timestamp field exists in query class genMap.put("queryHasTimestamp", false); - // 存在 BigDecimal 字段 + // BigDecimal field exists genMap.put("hasBigDecimal", false); - // 查询类中存在 BigDecimal 字段 + // BigDecimal field exists in query class genMap.put("queryHasBigDecimal", false); - // 是否需要创建查询 + // Whether to create query genMap.put("hasQuery", false); - // 自增主键 + // Auto increment primary key genMap.put("auto", false); - // 存在字典 + // Dictionary exists genMap.put("hasDict", false); - // 存在日期注解 + // Date annotation exists genMap.put("hasDateAnnotation", false); - // 保存字段信息 + // Save field information List> columns = new ArrayList<>(); - // 保存查询字段的信息 + // Save query field information List> queryColumns = new ArrayList<>(); - // 存储字典信息 + // Store dictionary information List dicts = new ArrayList<>(); - // 存储 between 信息 + // Store between information List> betweens = new ArrayList<>(); - // 存储不为空的字段信息 + // Store non-empty field information List> isNotNullColumns = new ArrayList<>(); for (ColumnInfo column : columnInfos) { Map listMap = new HashMap<>(16); - // 字段描述 + // Field description listMap.put("remark", column.getRemark()); - // 字段类型 + // Field type listMap.put("columnKey", column.getKeyType()); - // 主键类型 + // Primary key type String colType = ColUtil.cloToJava(column.getColumnType()); - // 小写开头的字段名 + // Lowercase field name String changeColumnName = StringUtils.toCamelCase(column.getColumnName()); - // 大写开头的字段名 + // Uppercase field name String capitalColumnName = StringUtils.toCapitalizeCamelCase(column.getColumnName()); if (PK.equals(column.getKeyType())) { - // 存储主键类型 + // Store primary key type genMap.put("pkColumnType", colType); - // 存储小写开头的字段名 + // Store lowercase field name genMap.put("pkChangeColName", changeColumnName); - // 存储大写开头的字段名 + // Store uppercase field name genMap.put("pkCapitalColName", capitalColumnName); } - // 是否存在 Timestamp 类型的字段 + // Whether Timestamp type field exists if (TIMESTAMP.equals(colType)) { genMap.put("hasTimestamp", true); } - // 是否存在 BigDecimal 类型的字段 + // Whether BigDecimal type field exists if (BIGDECIMAL.equals(colType)) { genMap.put("hasBigDecimal", true); } - // 主键是否自增 + // Primary key is auto increment if (EXTRA.equals(column.getExtra())) { genMap.put("auto", true); } - // 主键存在字典 + // Primary key exists in dictionary if (StringUtils.isNotBlank(column.getDictName())) { genMap.put("hasDict", true); if(!dicts.contains(column.getDictName())) dicts.add(column.getDictName()); } - // 存储字段类型 + // Store field type listMap.put("columnType", colType); - // 存储字原始段名称 + // Store original field name listMap.put("columnName", column.getColumnName()); - // 不为空 + // Not empty listMap.put("istNotNull", column.getNotNull()); - // 字段列表显示 + // Field list display listMap.put("columnShow", column.getListShow()); - // 表单显示 + // Form display listMap.put("formShow", column.getFormShow()); - // 表单组件类型 + // Form component type listMap.put("formType", StringUtils.isNotBlank(column.getFormType()) ? column.getFormType() : "Input"); - // 小写开头的字段名称 + // Lowercase field name listMap.put("changeColumnName", changeColumnName); - //大写开头的字段名称 + // Uppercase field name listMap.put("capitalColumnName", capitalColumnName); - // 字典名称 + // Dictionary name listMap.put("dictName", column.getDictName()); - // 日期注解 + // Date annotation listMap.put("dateAnnotation", column.getDateAnnotation()); if (StringUtils.isNotBlank(column.getDateAnnotation())) { genMap.put("hasDateAnnotation", true); } - // 添加非空字段信息 + // Add non-empty field information if (column.getNotNull()) { isNotNullColumns.add(listMap); } - // 判断是否有查询,如有则把查询的字段set进columnQuery + // Determine whether query exists, if so, set query fields in columnQuery if (!StringUtils.isBlank(column.getQueryType())) { - // 查询类型 + // Query type listMap.put("queryType", column.getQueryType()); - // 是否存在查询 + // Whether query exists genMap.put("hasQuery", true); if (TIMESTAMP.equals(colType)) { - // 查询中存储 Timestamp 类型 + // Query stores Timestamp type genMap.put("queryHasTimestamp", true); } if (BIGDECIMAL.equals(colType)) { - // 查询中存储 BigDecimal 类型 + // Query stores BigDecimal type genMap.put("queryHasBigDecimal", true); } if ("between".equalsIgnoreCase(column.getQueryType())) { betweens.add(listMap); } else { - // 添加到查询列表中 + // Add to query list queryColumns.add(listMap); } } - // 添加到字段列表中 + // Add to field list columns.add(listMap); } - // 保存字段列表 + // Save field list genMap.put("columns", columns); - // 保存查询列表 + // Save query list genMap.put("queryColumns", queryColumns); - // 保存字段列表 + // Save field list genMap.put("dicts", dicts); - // 保存查询列表 + // Save query list genMap.put("betweens", betweens); - // 保存非空字段信息 + // Save non-empty field information genMap.put("isNotNullColumns", isNotNullColumns); return genMap; } /** - * 定义后端文件路径以及名称 + * Define backend file path and name */ private static String getAdminFilePath(String templateName, GenConfig genConfig, String className, String rootPath) { String projectPath = rootPath + File.separator + genConfig.getModuleName(); @@ -390,7 +390,7 @@ public class GenUtil { } /** - * 定义前端文件路径以及名称 + * Define frontend file path and name */ private static String getFrontFilePath(String templateName, String apiPath, String path, String apiName) { @@ -406,7 +406,7 @@ public class GenUtil { } private static void genFile(File file, Template template, Map map) throws IOException { - // 生成目标文件 + // Generate target file Writer writer = null; try { FileUtil.touch(file); diff --git a/eladmin-generator/src/main/resources/template/admin/Controller.ftl b/eladmin-generator/src/main/resources/template/admin/Controller.ftl index 215fc953..717e36d1 100644 --- a/eladmin-generator/src/main/resources/template/admin/Controller.ftl +++ b/eladmin-generator/src/main/resources/template/admin/Controller.ftl @@ -45,7 +45,7 @@ public class ${className}Controller { private final ${className}Service ${changeClassName}Service; - @ApiOperation("导出数据") + @ApiOperation("Export Data") @GetMapping(value = "/download") @PreAuthorize("@el.check('${changeClassName}:list')") public void export${className}(HttpServletResponse response, ${className}QueryCriteria criteria) throws IOException { @@ -53,15 +53,15 @@ public class ${className}Controller { } @GetMapping - @ApiOperation("查询${apiAlias}") + @ApiOperation("Query ${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:list')") public ResponseEntity> query${className}(${className}QueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK); } @PostMapping - @Log("新增${apiAlias}") - @ApiOperation("新增${apiAlias}") + @Log("Add ${apiAlias}") + @ApiOperation("Add ${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:add')") public ResponseEntity create${className}(@Validated @RequestBody ${className} resources){ ${changeClassName}Service.create(resources); @@ -69,8 +69,8 @@ public class ${className}Controller { } @PutMapping - @Log("修改${apiAlias}") - @ApiOperation("修改${apiAlias}") + @Log("Edit ${apiAlias}") + @ApiOperation("Edit ${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:edit')") public ResponseEntity update${className}(@Validated @RequestBody ${className} resources){ ${changeClassName}Service.update(resources); @@ -78,10 +78,10 @@ public class ${className}Controller { } @DeleteMapping - @Log("删除${apiAlias}") - @ApiOperation("删除${apiAlias}") + @Log("Delete ${apiAlias}") + @ApiOperation("Delete ${apiAlias}") @PreAuthorize("@el.check('${changeClassName}:del')") - public ResponseEntity delete${className}(@ApiParam(value = "传ID数组[]") @RequestBody ${pkColumnType}[] ids) { + public ResponseEntity delete${className}(@ApiParam(value = "Pass ID array[]") @RequestBody ${pkColumnType}[] ids) { ${changeClassName}Service.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/eladmin-generator/src/main/resources/template/admin/Dto.ftl b/eladmin-generator/src/main/resources/template/admin/Dto.ftl index cc0f8f06..234db111 100644 --- a/eladmin-generator/src/main/resources/template/admin/Dto.ftl +++ b/eladmin-generator/src/main/resources/template/admin/Dto.ftl @@ -47,7 +47,7 @@ public class ${className}Dto implements Serializable { <#if column.columnKey = 'PRI'> <#if !auto && pkColumnType = 'Long'> - /** 防止精度丢失 */ + /** Prevent precision loss */ @JSONField(serializeUsing = ToStringSerializer.class) diff --git a/eladmin-generator/src/main/resources/template/admin/Repository.ftl b/eladmin-generator/src/main/resources/template/admin/Repository.ftl index 42688716..d7ed1ee2 100644 --- a/eladmin-generator/src/main/resources/template/admin/Repository.ftl +++ b/eladmin-generator/src/main/resources/template/admin/Repository.ftl @@ -29,7 +29,7 @@ public interface ${className}Repository extends JpaRepository<${className}, ${pk <#list columns as column> <#if column.columnKey = 'UNI'> /** - * 根据 ${column.capitalColumnName} 查询 + * Query by ${column.capitalColumnName} * @param ${column.columnName} / * @return / */ diff --git a/eladmin-generator/src/main/resources/template/admin/Service.ftl b/eladmin-generator/src/main/resources/template/admin/Service.ftl index 17f5ece9..4e5578bf 100644 --- a/eladmin-generator/src/main/resources/template/admin/Service.ftl +++ b/eladmin-generator/src/main/resources/template/admin/Service.ftl @@ -27,55 +27,55 @@ import me.zhengjie.utils.PageResult; /** * @website https://eladmin.vip -* @description 服务接口 +* @description Service Interface * @author ${author} * @date ${date} **/ public interface ${className}Service { /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 + * Query data with pagination + * @param criteria criteria + * @param pageable pagination parameters * @return Map */ PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable); /** - * 查询所有数据不分页 - * @param criteria 条件参数 + * Query all data without pagination + * @param criteria criteria parameters * @return List<${className}Dto> */ List<${className}Dto> queryAll(${className}QueryCriteria criteria); /** - * 根据ID查询 + * Query by ID * @param ${pkChangeColName} ID * @return ${className}Dto */ ${className}Dto findById(${pkColumnType} ${pkChangeColName}); /** - * 创建 + * Create * @param resources / */ void create(${className} resources); /** - * 编辑 + * Edit * @param resources / */ void update(${className} resources); /** - * 多选删除 + * Multi-select delete * @param ids / */ void deleteAll(${pkColumnType}[] ids); /** - * 导出数据 - * @param all 待导出的数据 + * Export data + * @param all data to be exported * @param response / * @throws IOException / */ diff --git a/eladmin-generator/src/main/resources/template/admin/ServiceImpl.ftl b/eladmin-generator/src/main/resources/template/admin/ServiceImpl.ftl index 784edd6b..a354caa5 100644 --- a/eladmin-generator/src/main/resources/template/admin/ServiceImpl.ftl +++ b/eladmin-generator/src/main/resources/template/admin/ServiceImpl.ftl @@ -56,7 +56,7 @@ import me.zhengjie.utils.PageResult; /** * @website https://eladmin.vip -* @description 服务实现 +* @description Service Implementation * @author ${author} * @date ${date} **/ diff --git a/eladmin-generator/src/main/resources/template/front/index.ftl b/eladmin-generator/src/main/resources/template/front/index.ftl index 4b9111a9..cddb764c 100644 --- a/eladmin-generator/src/main/resources/template/front/index.ftl +++ b/eladmin-generator/src/main/resources/template/front/index.ftl @@ -1,11 +1,11 @@ <#--noinspection ALL-->