From d902d44880e8437aad548beed049326ae4f27522 Mon Sep 17 00:00:00 2001 From: vamsikrishnagv Date: Sun, 25 May 2025 10:16:48 -0700 Subject: [PATCH] phase 2 translation --- .../java/me/zhengjie/base/BaseEntity.java | 16 +- .../me/zhengjie/utils/BigDecimalUtils.java | 74 +- .../java/me/zhengjie/domain/vo/TableInfo.java | 12 +- .../repository/ColumnInfoRepository.java | 6 +- .../repository/GenConfigRepository.java | 4 +- .../me/zhengjie/rest/GeneratorController.java | 24 +- .../service/impl/GeneratorServiceImpl.java | 26 +- .../main/java/me/zhengjie/utils/GenUtil.java | 164 ++--- .../resources/template/admin/Controller.ftl | 18 +- .../src/main/resources/template/admin/Dto.ftl | 2 +- .../resources/template/admin/Repository.ftl | 2 +- .../main/resources/template/admin/Service.ftl | 24 +- .../resources/template/admin/ServiceImpl.ftl | 2 +- .../main/resources/template/front/index.ftl | 28 +- .../zhengjie/service/dto/SysLogErrorDto.java | 16 +- .../service/dto/SysLogQueryCriteria.java | 10 +- .../service/impl/SysLogServiceImpl.java | 44 +- .../system/service/impl/DeptServiceImpl.java | 6 +- .../system/service/impl/DictServiceImpl.java | 20 +- .../system/service/impl/RoleServiceImpl.java | 10 +- .../system/service/impl/UserServiceImpl.java | 15 +- .../java/me/zhengjie/domain/AlipayConfig.java | 22 +- .../java/me/zhengjie/domain/EmailConfig.java | 12 +- .../domain/enums/AliPayStatusEnum.java | 10 +- .../java/me/zhengjie/domain/vo/TradeVo.java | 18 +- .../repository/QiNiuConfigRepository.java | 2 +- .../repository/QiniuContentRepository.java | 4 +- .../me/zhengjie/rest/AliPayController.java | 44 +- .../me/zhengjie/rest/QiniuController.java | 32 +- .../me/zhengjie/service/AliPayService.java | 22 +- .../me/zhengjie/service/EmailService.java | 14 +- .../zhengjie/service/LocalStorageService.java | 28 +- .../me/zhengjie/service/QiNiuService.java | 54 +- .../zhengjie/service/dto/LocalStorageDto.java | 10 +- .../dto/LocalStorageQueryCriteria.java | 4 +- .../service/dto/QiniuQueryCriteria.java | 4 +- .../service/impl/AliPayServiceImpl.java | 4 +- .../service/impl/LocalStorageServiceImpl.java | 14 +- .../service/impl/QiNiuServiceImpl.java | 43 +- .../java/me/zhengjie/utils/AlipayUtils.java | 10 +- .../java/me/zhengjie/utils/QiNiuUtil.java | 20 +- sport/pom.xml | 2 +- sport/src/main/java/com/srr/domain/Event.java | 20 +- .../java/com/srr/rest/ClubController.java | 18 +- .../java/com/srr/rest/CourtController.java | 18 +- .../java/com/srr/rest/EventController.java | 18 +- .../java/com/srr/rest/PlayerController.java | 18 +- .../java/com/srr/rest/SportController.java | 18 +- .../java/com/srr/service/ClubService.java | 6 +- .../java/com/srr/service/CourtService.java | 24 +- .../java/com/srr/service/EventService.java | 24 +- .../java/com/srr/service/PlayerService.java | 24 +- .../java/com/srr/service/SportService.java | 24 +- sql/eladmin.sql | 674 +++++++++--------- 54 files changed, 891 insertions(+), 891 deletions(-) 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/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-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/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/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/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-->