mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-15 12:53:42 +00:00
修改字典功能 和模板生成id 太长19位 改为1,2,3
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.ruoyi.generator.controller;
|
package org.ruoyi.generator.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.net.URLDecoder;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.ruoyi.common.core.domain.R;
|
import org.ruoyi.common.core.domain.R;
|
||||||
@@ -8,10 +9,11 @@ import org.ruoyi.generator.service.IGenTableService;
|
|||||||
import org.ruoyi.generator.service.SchemaFieldService;
|
import org.ruoyi.generator.service.SchemaFieldService;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成 操作处理
|
* 代码生成 操作处理
|
||||||
*
|
*
|
||||||
@@ -46,4 +48,18 @@ public class GenController extends BaseController {
|
|||||||
genTableService.generateCodeToClasspathByTableNames(tableNameStr);
|
genTableService.generateCodeToClasspathByTableNames(tableNameStr);
|
||||||
return R.ok("代码生成成功");
|
return R.ok("代码生成成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成前端代码
|
||||||
|
*
|
||||||
|
* @param workPath 执行命令路径
|
||||||
|
* @param previewCode 执行生成前端文件命令
|
||||||
|
*/
|
||||||
|
@GetMapping("/batchGenFrontendCode")
|
||||||
|
public R<String> batchGenFrontendCode(@NotNull(message = "路径不能为空") String workPath, @NotNull(message = "指令不能为空") String previewCode) {
|
||||||
|
String decodedWorkPath = URLDecoder.decode(workPath, StandardCharsets.UTF_8);
|
||||||
|
String decodedPreviewCode = URLDecoder.decode(previewCode, StandardCharsets.UTF_8);
|
||||||
|
genTableService.generateFrontendTemplateFiles(decodedWorkPath, decodedPreviewCode);
|
||||||
|
return R.ok("代码生成成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class SchemaGroupController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取数据模型分组选择列表
|
* 获取数据模型分组选择列表
|
||||||
*/
|
*/
|
||||||
|
@SaCheckPermission("dev:schemaGroup:select")
|
||||||
@GetMapping("/select")
|
@GetMapping("/select")
|
||||||
public R<List<SchemaGroupVo>> select() {
|
public R<List<SchemaGroupVo>> select() {
|
||||||
SchemaGroupBo bo = new SchemaGroupBo();
|
SchemaGroupBo bo = new SchemaGroupBo();
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package org.ruoyi.generator.domain;
|
package org.ruoyi.generator.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型对象 dev_schema
|
* 数据模型对象 dev_schema
|
||||||
@@ -16,12 +17,9 @@ import java.io.Serial;
|
|||||||
* @date 2024-01-01
|
* @date 2024-01-01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("dev_schema")
|
@TableName("dev_schema")
|
||||||
public class Schema extends BaseEntity {
|
public class Schema implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -49,41 +47,6 @@ public class Schema extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 表注释
|
|
||||||
*/
|
|
||||||
private String comment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储引擎
|
|
||||||
*/
|
|
||||||
private String engine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表字段
|
|
||||||
*/
|
|
||||||
private String listKeys;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索表单字段
|
|
||||||
*/
|
|
||||||
private String searchFormKeys;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单设计
|
|
||||||
*/
|
|
||||||
private String designer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@@ -96,8 +59,33 @@ public class Schema extends BaseEntity {
|
|||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户编号
|
* 创建部门
|
||||||
*/
|
*/
|
||||||
private String tenantId;
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package org.ruoyi.generator.domain;
|
package org.ruoyi.generator.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型字段对象 dev_schema_field
|
* 数据模型字段对象 dev_schema_field
|
||||||
@@ -16,12 +17,8 @@ import java.io.Serial;
|
|||||||
* @date 2024-01-01
|
* @date 2024-01-01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("dev_schema_field")
|
@TableName("dev_schema_field")
|
||||||
public class SchemaField extends BaseEntity {
|
public class SchemaField implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -129,15 +126,6 @@ public class SchemaField extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展JSON
|
|
||||||
*/
|
|
||||||
private String extendJson;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
@@ -151,8 +139,33 @@ public class SchemaField extends BaseEntity {
|
|||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户编号
|
* 创建部门
|
||||||
*/
|
*/
|
||||||
private String tenantId;
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package org.ruoyi.generator.domain;
|
package org.ruoyi.generator.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型分组对象 dev_schema_group
|
* 数据模型分组对象 dev_schema_group
|
||||||
@@ -16,12 +17,8 @@ import java.io.Serial;
|
|||||||
* @date 2024-01-01
|
* @date 2024-01-01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("dev_schema_group")
|
@TableName("dev_schema_group")
|
||||||
public class SchemaGroup extends BaseEntity {
|
public class SchemaGroup implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -44,16 +41,6 @@ public class SchemaGroup extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@@ -66,8 +53,32 @@ public class SchemaGroup extends BaseEntity {
|
|||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户编号
|
* 创建部门
|
||||||
*/
|
*/
|
||||||
private String tenantId;
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,12 @@ import io.github.linpeilie.annotations.AutoMapper;
|
|||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.ruoyi.common.core.validate.AddGroup;
|
import org.ruoyi.common.core.validate.AddGroup;
|
||||||
import org.ruoyi.common.core.validate.EditGroup;
|
import org.ruoyi.common.core.validate.EditGroup;
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
import org.ruoyi.generator.domain.Schema;
|
import org.ruoyi.generator.domain.Schema;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型业务对象 SchemaBo
|
* 数据模型业务对象 SchemaBo
|
||||||
*
|
*
|
||||||
@@ -17,9 +17,8 @@ import org.ruoyi.generator.domain.Schema;
|
|||||||
* @date 2024-01-01
|
* @date 2024-01-01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@AutoMapper(target = Schema.class, reverseConvertGenerate = false)
|
@AutoMapper(target = Schema.class, reverseConvertGenerate = false)
|
||||||
public class SchemaBo extends BaseEntity {
|
public class SchemaBo implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -38,52 +37,12 @@ public class SchemaBo extends BaseEntity {
|
|||||||
@NotBlank(message = "模型名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
@NotBlank(message = "模型名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
|
||||||
* 模型编码
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "模型编码不能为空", groups = {AddGroup.class, EditGroup.class})
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表名
|
* 表名
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "表名不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 表注释
|
|
||||||
*/
|
|
||||||
private String comment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储引擎
|
|
||||||
*/
|
|
||||||
private String engine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表字段
|
|
||||||
*/
|
|
||||||
private String listKeys;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索表单字段
|
|
||||||
*/
|
|
||||||
private String searchFormKeys;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单设计
|
|
||||||
*/
|
|
||||||
private String designer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import io.github.linpeilie.annotations.AutoMapper;
|
|||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.ruoyi.common.core.validate.AddGroup;
|
import org.ruoyi.common.core.validate.AddGroup;
|
||||||
import org.ruoyi.common.core.validate.EditGroup;
|
import org.ruoyi.common.core.validate.EditGroup;
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
import org.ruoyi.generator.domain.SchemaField;
|
import org.ruoyi.generator.domain.SchemaField;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型字段业务对象 SchemaFieldBo
|
* 数据模型字段业务对象 SchemaFieldBo
|
||||||
*
|
*
|
||||||
@@ -17,9 +17,8 @@ import org.ruoyi.generator.domain.SchemaField;
|
|||||||
* @date 2024-01-01
|
* @date 2024-01-01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@AutoMapper(target = SchemaField.class, reverseConvertGenerate = false)
|
@AutoMapper(target = SchemaField.class, reverseConvertGenerate = false)
|
||||||
public class SchemaFieldBo extends BaseEntity {
|
public class SchemaFieldBo implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -36,7 +35,7 @@ public class SchemaFieldBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 模型名称
|
* 模型名称
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "模型名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
// @NotNull(message = "模型名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String schemaName;
|
private String schemaName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,16 +130,6 @@ public class SchemaFieldBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展JSON
|
|
||||||
*/
|
|
||||||
private String extendJson;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import io.github.linpeilie.annotations.AutoMapper;
|
|||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.ruoyi.common.core.validate.AddGroup;
|
import org.ruoyi.common.core.validate.AddGroup;
|
||||||
import org.ruoyi.common.core.validate.EditGroup;
|
import org.ruoyi.common.core.validate.EditGroup;
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
import org.ruoyi.generator.domain.SchemaGroup;
|
import org.ruoyi.generator.domain.SchemaGroup;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型分组业务对象 SchemaGroupBo
|
* 数据模型分组业务对象 SchemaGroupBo
|
||||||
*
|
*
|
||||||
@@ -17,9 +17,8 @@ import org.ruoyi.generator.domain.SchemaGroup;
|
|||||||
* @date 2024-01-01
|
* @date 2024-01-01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@AutoMapper(target = SchemaGroup.class, reverseConvertGenerate = false)
|
@AutoMapper(target = SchemaGroup.class, reverseConvertGenerate = false)
|
||||||
public class SchemaGroupBo extends BaseEntity {
|
public class SchemaGroupBo implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
@@ -44,16 +43,6 @@ public class SchemaGroupBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.ruoyi.generator.domain.SchemaField;
|
import org.ruoyi.generator.domain.SchemaField;
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型字段视图对象 SchemaFieldVo
|
* 数据模型字段视图对象 SchemaFieldVo
|
||||||
@@ -20,9 +18,6 @@ import java.util.Date;
|
|||||||
@AutoMapper(target = SchemaField.class)
|
@AutoMapper(target = SchemaField.class)
|
||||||
public class SchemaFieldVo implements Serializable {
|
public class SchemaFieldVo implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@@ -136,25 +131,8 @@ public class SchemaFieldVo implements Serializable {
|
|||||||
@Schema(description = "字典类型")
|
@Schema(description = "字典类型")
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
@Schema(description = "状态")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展JSON
|
|
||||||
*/
|
|
||||||
private String extendJson;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ import io.github.linpeilie.annotations.AutoMapper;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.ruoyi.generator.domain.SchemaGroup;
|
import org.ruoyi.generator.domain.SchemaGroup;
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -18,9 +17,6 @@ import java.util.Date;
|
|||||||
@AutoMapper(target = SchemaGroup.class)
|
@AutoMapper(target = SchemaGroup.class)
|
||||||
public class SchemaGroupVo implements Serializable {
|
public class SchemaGroupVo implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@@ -46,11 +42,6 @@ public class SchemaGroupVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ import java.util.Date;
|
|||||||
@AutoMapper(target = Schema.class)
|
@AutoMapper(target = Schema.class)
|
||||||
public class SchemaVo implements Serializable {
|
public class SchemaVo implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@@ -46,6 +43,11 @@ public class SchemaVo implements Serializable {
|
|||||||
* 表名
|
* 表名
|
||||||
*/
|
*/
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
/**
|
||||||
|
* 字典
|
||||||
|
*/
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表注释
|
* 表注释
|
||||||
|
|||||||
@@ -11,26 +11,19 @@ import org.apache.velocity.app.Velocity;
|
|||||||
import org.ruoyi.common.core.constant.Constants;
|
import org.ruoyi.common.core.constant.Constants;
|
||||||
import org.ruoyi.generator.config.GenConfig;
|
import org.ruoyi.generator.config.GenConfig;
|
||||||
import org.ruoyi.generator.domain.vo.SchemaFieldVo;
|
import org.ruoyi.generator.domain.vo.SchemaFieldVo;
|
||||||
|
import org.ruoyi.generator.domain.vo.SchemaGroupVo;
|
||||||
import org.ruoyi.generator.domain.vo.SchemaVo;
|
import org.ruoyi.generator.domain.vo.SchemaVo;
|
||||||
import org.ruoyi.generator.service.IGenTableService;
|
import org.ruoyi.generator.service.IGenTableService;
|
||||||
import org.ruoyi.generator.service.SchemaFieldService;
|
import org.ruoyi.generator.service.SchemaFieldService;
|
||||||
|
import org.ruoyi.generator.service.SchemaGroupService;
|
||||||
import org.ruoyi.generator.service.SchemaService;
|
import org.ruoyi.generator.service.SchemaService;
|
||||||
import org.ruoyi.generator.util.VelocityInitializer;
|
import org.ruoyi.generator.util.VelocityInitializer;
|
||||||
import org.ruoyi.generator.util.VelocityUtils;
|
import org.ruoyi.generator.util.VelocityUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 服务层实现
|
* 业务 服务层实现
|
||||||
@@ -44,6 +37,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
|
|
||||||
private final SchemaService schemaService;
|
private final SchemaService schemaService;
|
||||||
private final SchemaFieldService schemaFieldService;
|
private final SchemaFieldService schemaFieldService;
|
||||||
|
private final SchemaGroupService schemaGroupService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于表名称批量生成代码到classpath路径
|
* 基于表名称批量生成代码到classpath路径
|
||||||
@@ -59,6 +53,41 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateFrontendTemplateFiles(String workPath, String previewCode) {
|
||||||
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
|
||||||
|
ProcessBuilder builder;
|
||||||
|
if (os.contains("win")) {
|
||||||
|
// Windows下用 cmd /c 执行 previewCode
|
||||||
|
builder = new ProcessBuilder("cmd.exe", "/c", previewCode);
|
||||||
|
} else {
|
||||||
|
// macOS/Linux 用 bash -c 执行 previewCode
|
||||||
|
builder = new ProcessBuilder("bash", "-c", previewCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置工作目录
|
||||||
|
builder.directory(new File(workPath));
|
||||||
|
builder.redirectErrorStream(true);
|
||||||
|
|
||||||
|
try (BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader(
|
||||||
|
builder.start().getInputStream(),
|
||||||
|
StandardCharsets.UTF_8
|
||||||
|
)
|
||||||
|
)) {
|
||||||
|
String line;
|
||||||
|
log.info("执行结果:");
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
log.info(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("生成前端代码出错", e);
|
||||||
|
throw new RuntimeException("生成前端代码失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据表名称生成代码到classpath
|
* 根据表名称生成代码到classpath
|
||||||
*/
|
*/
|
||||||
@@ -69,6 +98,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
log.warn("Schema不存在,表名: {}", tableName);
|
log.warn("Schema不存在,表名: {}", tableName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询Schema字段信息
|
// 查询Schema字段信息
|
||||||
List<SchemaFieldVo> fields = schemaFieldService.queryListByTableName(tableName);
|
List<SchemaFieldVo> fields = schemaFieldService.queryListByTableName(tableName);
|
||||||
if (CollUtil.isEmpty(fields)) {
|
if (CollUtil.isEmpty(fields)) {
|
||||||
@@ -128,17 +158,19 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
*/
|
*/
|
||||||
private VelocityContext prepareSchemaContext(SchemaVo schema, List<SchemaFieldVo> fields) {
|
private VelocityContext prepareSchemaContext(SchemaVo schema, List<SchemaFieldVo> fields) {
|
||||||
VelocityContext context = new VelocityContext();
|
VelocityContext context = new VelocityContext();
|
||||||
|
|
||||||
// 从配置文件读取基本配置
|
// 从配置文件读取基本配置
|
||||||
String packageName = GenConfig.getPackageName();
|
String packageName = GenConfig.getPackageName();
|
||||||
String author = GenConfig.getAuthor();
|
String author = GenConfig.getAuthor();
|
||||||
String tablePrefix = GenConfig.getTablePrefix();
|
String tablePrefix = GenConfig.getTablePrefix();
|
||||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||||
|
|
||||||
// 处理表名和类名
|
// 处理表名和类名
|
||||||
|
Long schemaGroupId = schema.getSchemaGroupId();
|
||||||
|
SchemaGroupVo schemaGroupVo = schemaGroupService.queryById(schemaGroupId);
|
||||||
String tableName = schema.getTableName();
|
String tableName = schema.getTableName();
|
||||||
String baseClassName = schema.getTableName();
|
String baseClassName = schema.getTableName();
|
||||||
|
|
||||||
// 自动去除表前缀
|
// 自动去除表前缀
|
||||||
if (autoRemovePre && StrUtil.isNotBlank(tablePrefix)) {
|
if (autoRemovePre && StrUtil.isNotBlank(tablePrefix)) {
|
||||||
String[] prefixes = tablePrefix.split(",");
|
String[] prefixes = tablePrefix.split(",");
|
||||||
@@ -149,12 +181,12 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String className = toCamelCase(baseClassName, true); // 首字母大写的类名,如:SysRole
|
String className = toCamelCase(baseClassName, true); // 首字母大写的类名,如:SysRole
|
||||||
String classname = toCamelCase(baseClassName, false); // 首字母小写的类名,如:sysRole
|
String classname = toCamelCase(baseClassName, false); // 首字母小写的类名,如:sysRole
|
||||||
String businessName = toCamelCase(baseClassName, false);
|
String businessName = toCamelCase(baseClassName, false);
|
||||||
String moduleName = getModuleName(packageName);
|
String moduleName = schemaGroupVo.getCode();
|
||||||
|
|
||||||
// 基本信息
|
// 基本信息
|
||||||
context.put("tableName", tableName);
|
context.put("tableName", tableName);
|
||||||
context.put("tableComment", schema.getComment());
|
context.put("tableComment", schema.getComment());
|
||||||
@@ -168,18 +200,18 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
context.put("packageName", packageName);
|
context.put("packageName", packageName);
|
||||||
context.put("moduleName", moduleName);
|
context.put("moduleName", moduleName);
|
||||||
context.put("businessName", businessName);
|
context.put("businessName", businessName);
|
||||||
|
|
||||||
// 权限相关
|
// 权限相关
|
||||||
context.put("permissionPrefix", moduleName + ":" + businessName);
|
context.put("permissionPrefix", moduleName + ":" + businessName);
|
||||||
context.put("parentMenuId", "2000"); // 默认父菜单ID,可配置
|
context.put("parentMenuId", "2000"); // 默认父菜单ID,可配置
|
||||||
|
|
||||||
// 生成菜单ID
|
// 生成菜单ID
|
||||||
List<Long> menuIds = new ArrayList<>();
|
List<Long> menuIds = new ArrayList<>();
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
menuIds.add(IdUtil.getSnowflakeNextId());
|
menuIds.add(IdUtil.getSnowflakeNextId());
|
||||||
}
|
}
|
||||||
context.put("menuIds", menuIds);
|
context.put("menuIds", menuIds);
|
||||||
|
|
||||||
// 创建table对象,包含menuIds等信息和方法
|
// 创建table对象,包含menuIds等信息和方法
|
||||||
Map<String, Object> table = new HashMap<>();
|
Map<String, Object> table = new HashMap<>();
|
||||||
table.put("menuIds", menuIds);
|
table.put("menuIds", menuIds);
|
||||||
@@ -188,29 +220,19 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
table.put("className", className);
|
table.put("className", className);
|
||||||
table.put("classname", classname);
|
table.put("classname", classname);
|
||||||
table.put("functionName", schema.getName());
|
table.put("functionName", schema.getName());
|
||||||
|
|
||||||
// 添加表类型属性(默认为crud类型)
|
// 添加表类型属性(默认为crud类型)
|
||||||
table.put("crud", true);
|
table.put("crud", true);
|
||||||
table.put("sub", false);
|
table.put("sub", false);
|
||||||
table.put("tree", false);
|
table.put("tree", false);
|
||||||
|
|
||||||
// 添加isSuperColumn方法
|
|
||||||
table.put("isSuperColumn", new Object() {
|
|
||||||
public boolean isSuperColumn(String javaField) {
|
|
||||||
// 定义超类字段(BaseEntity中的字段)
|
|
||||||
return "createBy".equals(javaField) || "createTime".equals(javaField)
|
|
||||||
|| "updateBy".equals(javaField) || "updateTime".equals(javaField)
|
|
||||||
|| "remark".equals(javaField) || "tenantId".equals(javaField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
context.put("table", table);
|
context.put("table", table);
|
||||||
|
|
||||||
// 处理字段信息
|
// 处理字段信息
|
||||||
List<Map<String, Object>> columns = new ArrayList<>();
|
List<Map<String, Object>> columns = new ArrayList<>();
|
||||||
Map<String, Object> pkColumn = null;
|
Map<String, Object> pkColumn = null;
|
||||||
Set<String> importList = new HashSet<>();
|
Set<String> importList = new HashSet<>();
|
||||||
|
|
||||||
// 添加基础导入
|
// 添加基础导入
|
||||||
importList.add("java.io.Serializable");
|
importList.add("java.io.Serializable");
|
||||||
|
|
||||||
@@ -218,7 +240,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
Map<String, Object> column = new HashMap<>();
|
Map<String, Object> column = new HashMap<>();
|
||||||
String javaType = getJavaType(field.getType());
|
String javaType = getJavaType(field.getType());
|
||||||
String javaField = StrUtil.toCamelCase(field.getCode());
|
String javaField = StrUtil.toCamelCase(field.getCode());
|
||||||
|
|
||||||
column.put("columnName", field.getCode());
|
column.put("columnName", field.getCode());
|
||||||
column.put("columnComment", field.getName());
|
column.put("columnComment", field.getName());
|
||||||
column.put("comment", field.getName()); // 添加comment别名
|
column.put("comment", field.getName()); // 添加comment别名
|
||||||
@@ -226,15 +248,15 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
column.put("javaType", javaType);
|
column.put("javaType", javaType);
|
||||||
column.put("javaField", javaField);
|
column.put("javaField", javaField);
|
||||||
column.put("capJavaField", toCamelCase(field.getCode(), true));
|
column.put("capJavaField", toCamelCase(field.getCode(), true));
|
||||||
|
|
||||||
// 布尔值属性(兼容两种格式)
|
// 布尔值dictType属性(兼容两种格式)
|
||||||
boolean isPk = "1".equals(field.getIsPk());
|
boolean isPk = "1".equals(field.getIsPk());
|
||||||
boolean isRequired = "1".equals(field.getIsRequired());
|
boolean isRequired = "1".equals(field.getIsRequired());
|
||||||
boolean isInsert = "1".equals(field.getIsInsert());
|
boolean isInsert = "1".equals(field.getIsInsert());
|
||||||
boolean isEdit = "1".equals(field.getIsEdit());
|
boolean isEdit = "1".equals(field.getIsEdit());
|
||||||
boolean isList = "1".equals(field.getIsList());
|
boolean isList = "1".equals(field.getIsList());
|
||||||
boolean isQuery = "1".equals(field.getIsQuery());
|
boolean isQuery = "1".equals(field.getIsQuery());
|
||||||
|
|
||||||
column.put("isPk", isPk ? 1 : 0);
|
column.put("isPk", isPk ? 1 : 0);
|
||||||
column.put("pk", isPk); // 添加pk别名
|
column.put("pk", isPk); // 添加pk别名
|
||||||
column.put("isRequired", isRequired);
|
column.put("isRequired", isRequired);
|
||||||
@@ -247,27 +269,27 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
column.put("list", isList); // 添加list别名
|
column.put("list", isList); // 添加list别名
|
||||||
column.put("isQuery", isQuery);
|
column.put("isQuery", isQuery);
|
||||||
column.put("query", isQuery); // 添加query别名
|
column.put("query", isQuery); // 添加query别名
|
||||||
|
|
||||||
column.put("queryType", field.getQueryType());
|
column.put("queryType", field.getQueryType());
|
||||||
column.put("htmlType", field.getHtmlType());
|
column.put("htmlType", field.getHtmlType());
|
||||||
column.put("dictType", field.getDictType());
|
column.put("dictType", field.getDictType());
|
||||||
column.put("sort", field.getSort());
|
column.put("sort", field.getSort());
|
||||||
|
|
||||||
// 添加readConverterExp方法
|
// 添加readConverterExp方法
|
||||||
column.put("readConverterExp", new Object() {
|
column.put("readConverterExp", new Object() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// 根据Java类型添加相应的导入
|
// 根据Java类型添加相应的导入
|
||||||
addImportForJavaType(javaType, importList);
|
addImportForJavaType(javaType, importList);
|
||||||
|
|
||||||
columns.add(column);
|
columns.add(column);
|
||||||
|
|
||||||
// 设置主键列
|
// 设置主键列
|
||||||
if (isPk) {
|
if (isPk) {
|
||||||
pkColumn = column;
|
pkColumn = column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有主键,使用第一个字段作为主键
|
// 如果没有主键,使用第一个字段作为主键
|
||||||
if (pkColumn == null && !columns.isEmpty()) {
|
if (pkColumn == null && !columns.isEmpty()) {
|
||||||
pkColumn = columns.get(0);
|
pkColumn = columns.get(0);
|
||||||
@@ -275,27 +297,28 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
pkColumn.put("isPk", 1);
|
pkColumn.put("isPk", 1);
|
||||||
pkColumn.put("pk", true);
|
pkColumn.put("pk", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.put("columns", columns);
|
context.put("columns", columns);
|
||||||
context.put("pkColumn", pkColumn);
|
context.put("pkColumn", pkColumn);
|
||||||
context.put("importList", new ArrayList<>(importList));
|
context.put("importList", new ArrayList<>(importList));
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据Java类型添加相应的导入
|
* 根据Java类型添加相应的导入
|
||||||
*/
|
*/
|
||||||
private void addImportForJavaType(String javaType, Set<String> importList) {
|
private void addImportForJavaType(String javaType, Set<String> importList) {
|
||||||
switch (javaType) {
|
switch (javaType) {
|
||||||
case "BigDecimal" -> importList.add("java.math.BigDecimal");
|
case "BigDecimal" -> importList.add("java.math.BigDecimal");
|
||||||
case "Date" -> importList.add("java.util.Date");
|
case "Date" -> importList.add("java.util.Date");
|
||||||
case "LocalDateTime" -> importList.add("java.time.LocalDateTime");
|
case "LocalDateTime" -> importList.add("java.time.LocalDateTime");
|
||||||
case "LocalDate" -> importList.add("java.time.LocalDate");
|
case "LocalDate" -> importList.add("java.time.LocalDate");
|
||||||
case "LocalTime" -> importList.add("java.time.LocalTime");
|
case "LocalTime" -> importList.add("java.time.LocalTime");
|
||||||
default -> {}
|
default -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从包名中提取模块名
|
* 从包名中提取模块名
|
||||||
@@ -319,10 +342,10 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
String packageName = GenConfig.getPackageName();
|
String packageName = GenConfig.getPackageName();
|
||||||
String tablePrefix = GenConfig.getTablePrefix();
|
String tablePrefix = GenConfig.getTablePrefix();
|
||||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||||
|
|
||||||
// 处理类名
|
// 处理类名
|
||||||
String baseClassName = schema.getTableName();
|
String baseClassName = schema.getTableName();
|
||||||
|
|
||||||
// 自动去除表前缀
|
// 自动去除表前缀
|
||||||
if (autoRemovePre && StrUtil.isNotBlank(tablePrefix)) {
|
if (autoRemovePre && StrUtil.isNotBlank(tablePrefix)) {
|
||||||
String[] prefixes = tablePrefix.split(",");
|
String[] prefixes = tablePrefix.split(",");
|
||||||
@@ -333,13 +356,13 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String className = toCamelCase(baseClassName, true); // 首字母大写,如:SysRole
|
String className = toCamelCase(baseClassName, true); // 首字母大写,如:SysRole
|
||||||
// 首字母小写,如:sysRole
|
// 首字母小写,如:sysRole
|
||||||
String moduleName = getModuleName(packageName);
|
String moduleName = getModuleName(packageName);
|
||||||
String javaPath = "src/main/java/";
|
String javaPath = "src/main/java/";
|
||||||
String mybatisPath = "src/main/resources/mapper/";
|
String mybatisPath = "src/main/resources/mapper/";
|
||||||
|
|
||||||
if (template.contains("domain.java.vm")) {
|
if (template.contains("domain.java.vm")) {
|
||||||
return javaPath + packageName.replace(".", "/") + "/domain/" + className + ".java";
|
return javaPath + packageName.replace(".", "/") + "/domain/" + className + ".java";
|
||||||
} else if (template.contains("mapper.java.vm")) {
|
} else if (template.contains("mapper.java.vm")) {
|
||||||
@@ -412,16 +435,17 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
return "String";
|
return "String";
|
||||||
}
|
}
|
||||||
String type = dbType.toLowerCase();
|
String type = dbType.toLowerCase();
|
||||||
if (Objects.equals(type,"int") || type.contains("tinyint") || type.contains("smallint")) {
|
if (StrUtil.equalsAny(type, "int", "tinyint")) {
|
||||||
return "Integer";
|
return "Integer";
|
||||||
} else if (type.contains("bigint")) {
|
} else if (StrUtil.equalsAny(type, "bigint")) {
|
||||||
return "Long";
|
return "Long";
|
||||||
} else if (type.contains("decimal") || type.contains("numeric") || type.contains("float") || type.contains(
|
} else if (StrUtil.equalsAny(type, "decimal", "numeric", "float", "double")) {
|
||||||
"double")) {
|
|
||||||
return "BigDecimal";
|
return "BigDecimal";
|
||||||
} else if (type.contains("date") || type.contains("time")) {
|
} else if (StrUtil.equalsAny(type, "date")) {
|
||||||
return "Date";
|
return "LocalDate";
|
||||||
} else if (type.contains("bit") || type.contains("boolean")) {
|
} else if (StrUtil.equalsAny(type, "datetime", "timestamp")) {
|
||||||
|
return "LocalDateTime";
|
||||||
|
} else if (StrUtil.equalsAny(type, "bit", "boolean")) {
|
||||||
return "Boolean";
|
return "Boolean";
|
||||||
} else {
|
} else {
|
||||||
return "String";
|
return "String";
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
lqw.eq(StringUtils.isNotBlank(bo.getQueryType()), SchemaField::getQueryType, bo.getQueryType());
|
lqw.eq(StringUtils.isNotBlank(bo.getQueryType()), SchemaField::getQueryType, bo.getQueryType());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getHtmlType()), SchemaField::getHtmlType, bo.getHtmlType());
|
lqw.eq(StringUtils.isNotBlank(bo.getHtmlType()), SchemaField::getHtmlType, bo.getHtmlType());
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getDictType()), SchemaField::getDictType, bo.getDictType());
|
lqw.like(StringUtils.isNotBlank(bo.getDictType()), SchemaField::getDictType, bo.getDictType());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SchemaField::getStatus, bo.getStatus());
|
|
||||||
lqw.orderByAsc(SchemaField::getSort);
|
lqw.orderByAsc(SchemaField::getSort);
|
||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
@@ -150,7 +149,6 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
public List<SchemaFieldVo> queryListBySchemaId(Long schemaId) {
|
public List<SchemaFieldVo> queryListBySchemaId(Long schemaId) {
|
||||||
LambdaQueryWrapper<SchemaField> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<SchemaField> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(SchemaField::getSchemaId, schemaId);
|
lqw.eq(SchemaField::getSchemaId, schemaId);
|
||||||
lqw.eq(SchemaField::getStatus, "0"); // 只查询正常状态的字段
|
|
||||||
lqw.orderByAsc(SchemaField::getSort);
|
lqw.orderByAsc(SchemaField::getSort);
|
||||||
return baseMapper.selectVoList(lqw);
|
return baseMapper.selectVoList(lqw);
|
||||||
}
|
}
|
||||||
@@ -209,9 +207,9 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("schemaGroupCode", schemaGroupVo.getCode());
|
result.put("schemaGroupCode", schemaGroupVo.getCode());
|
||||||
result.put("tableName", schema.getTableName());
|
result.put("tableName", schema.getTableName());
|
||||||
|
result.put("dictType",schema.getDictType());
|
||||||
result.put("tableComment", schema.getComment());
|
result.put("tableComment", schema.getComment());
|
||||||
result.put("className", toCamelCase(schema.getTableName(), true));
|
result.put("className", toCamelCase(schema.getTableName(), true));
|
||||||
// result.put("className", StrUtil.toCamelCase(schema.getTableName()));
|
|
||||||
result.put("tableCamelName", StrUtil.toCamelCase(schema.getTableName()));
|
result.put("tableCamelName", StrUtil.toCamelCase(schema.getTableName()));
|
||||||
result.put("functionName", schema.getName());
|
result.put("functionName", schema.getName());
|
||||||
result.put("schemaName", schema.getName());
|
result.put("schemaName", schema.getName());
|
||||||
@@ -225,6 +223,8 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
if (pkField != null) {
|
if (pkField != null) {
|
||||||
Map<String, Object> pkColumn = new HashMap<>();
|
Map<String, Object> pkColumn = new HashMap<>();
|
||||||
pkColumn.put("columnName", pkField.getCode());
|
pkColumn.put("columnName", pkField.getCode());
|
||||||
|
pkColumn.put("dictType", pkField.getDictType());
|
||||||
|
|
||||||
pkColumn.put("columnComment", pkField.getName());
|
pkColumn.put("columnComment", pkField.getName());
|
||||||
pkColumn.put("javaField", StrUtil.toCamelCase(pkField.getCode()));
|
pkColumn.put("javaField", StrUtil.toCamelCase(pkField.getCode()));
|
||||||
pkColumn.put("javaType", getJavaType(pkField.getType()));
|
pkColumn.put("javaType", getJavaType(pkField.getType()));
|
||||||
@@ -236,6 +236,7 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
for (SchemaFieldVo field : fields) {
|
for (SchemaFieldVo field : fields) {
|
||||||
Map<String, Object> column = new HashMap<>();
|
Map<String, Object> column = new HashMap<>();
|
||||||
column.put("columnName", field.getCode());
|
column.put("columnName", field.getCode());
|
||||||
|
column.put("dictType", field.getDictType());
|
||||||
column.put("columnComment", field.getName());
|
column.put("columnComment", field.getName());
|
||||||
column.put("javaField", StrUtil.toCamelCase(field.getCode()));
|
column.put("javaField", StrUtil.toCamelCase(field.getCode()));
|
||||||
column.put("javaType", getJavaType(field.getType()));
|
column.put("javaType", getJavaType(field.getType()));
|
||||||
@@ -265,8 +266,7 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<SchemaField> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<SchemaField> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(SchemaField::getSchemaName, tableName);
|
lqw.eq(SchemaField::getSchemaId, schemaId);
|
||||||
lqw.eq(SchemaField::getStatus, "0");
|
|
||||||
// 检查是否已存在字段数据
|
// 检查是否已存在字段数据
|
||||||
List<SchemaFieldVo> existingFields = baseMapper.selectVoList(lqw);
|
List<SchemaFieldVo> existingFields = baseMapper.selectVoList(lqw);
|
||||||
if (CollUtil.isNotEmpty(existingFields)) {
|
if (CollUtil.isNotEmpty(existingFields)) {
|
||||||
@@ -280,20 +280,27 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
SchemaField field = new SchemaField();
|
SchemaField field = new SchemaField();
|
||||||
field.setSchemaId(schemaId);
|
field.setSchemaId(schemaId);
|
||||||
field.setSchemaName(tableName);
|
field.setSchemaName(tableName);
|
||||||
|
field.setDefaultValue((String) columnInfo.get("columnDefault"));
|
||||||
|
field.setComment((String) columnInfo.get("columnComment"));
|
||||||
field.setName((String) columnInfo.get("columnComment"));
|
field.setName((String) columnInfo.get("columnComment"));
|
||||||
|
field.setDictType(StrUtil.toCamelCase((String) columnInfo.get("dictType")));
|
||||||
field.setCode(StrUtil.toCamelCase((String) columnInfo.get("columnName")));
|
field.setCode(StrUtil.toCamelCase((String) columnInfo.get("columnName")));
|
||||||
field.setType((String) columnInfo.get("dataType"));
|
field.setType((String) columnInfo.get("dataType"));
|
||||||
field.setLength(Integer.valueOf(String.valueOf(columnInfo.get("columnSize"))));
|
field.setLength(Integer.valueOf(String.valueOf(columnInfo.get("columnSize"))));
|
||||||
field.setIsPk((Boolean) columnInfo.get("isPrimaryKey") ? "1" : "0");
|
field.setIsPk((Boolean) columnInfo.get("isPrimaryKey") ? "1" : "0");
|
||||||
field.setIsRequired(!(Boolean) columnInfo.get("isNullable") ? "1" : "0");
|
field.setIsRequired(!(Boolean) columnInfo.get("isNullable") ? "1" : "0");
|
||||||
field.setIsInsert("1");
|
if ("1".equals(field.getIsPk())) {
|
||||||
field.setIsEdit("1");
|
field.setIsInsert("0");
|
||||||
|
field.setIsEdit("0");
|
||||||
|
}else {
|
||||||
|
field.setIsInsert("1");
|
||||||
|
field.setIsEdit("1");
|
||||||
|
}
|
||||||
field.setIsList("1");
|
field.setIsList("1");
|
||||||
field.setIsQuery("1");
|
field.setIsQuery("1");
|
||||||
field.setQueryType("EQ");
|
field.setQueryType("EQ");
|
||||||
field.setHtmlType(getDefaultHtmlType((String) columnInfo.get("dataType")));
|
field.setHtmlType(getDefaultHtmlType((String) columnInfo.get("dataType")));
|
||||||
field.setSort(sort++);
|
field.setSort(sort++);
|
||||||
field.setStatus("0");
|
|
||||||
// 如果字段名为空,使用字段代码作为名称
|
// 如果字段名为空,使用字段代码作为名称
|
||||||
if (StringUtils.isBlank(field.getName())) {
|
if (StringUtils.isBlank(field.getName())) {
|
||||||
field.setName(field.getCode());
|
field.setName(field.getCode());
|
||||||
@@ -363,16 +370,15 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String type = dbType.toLowerCase();
|
String type = dbType.toLowerCase();
|
||||||
if (Objects.equals(type,"int")|| type.contains("tinyint") || type.contains("smallint")) {
|
if (StrUtil.equalsAny(type, "int", "tinyint", "smallint")) {
|
||||||
return "Integer";
|
return "Integer";
|
||||||
} else if (type.contains("bigint")) {
|
} else if (StrUtil.equalsAny(type, "bigint")) {
|
||||||
return "Long";
|
return "Long";
|
||||||
} else if (type.contains("decimal") || type.contains("numeric") || type.contains("float") || type.contains(
|
} else if (StrUtil.equalsAny(type, "decimal", "numeric", "float", "double")) {
|
||||||
"double")) {
|
|
||||||
return "BigDecimal";
|
return "BigDecimal";
|
||||||
} else if (type.contains("date") || type.contains("time")) {
|
} else if (StrUtil.equalsAny(type, "date", "datetime","timestamp")) {
|
||||||
return "Date";
|
return "Date";
|
||||||
} else if (type.contains("bit") || type.contains("boolean")) {
|
} else if (StrUtil.equalsAny(type, "bit", "boolean")) {
|
||||||
return "Boolean";
|
return "Boolean";
|
||||||
} else {
|
} else {
|
||||||
return "String";
|
return "String";
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ public class SchemaGroupServiceImpl implements SchemaGroupService {
|
|||||||
LambdaQueryWrapper<SchemaGroup> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<SchemaGroup> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getName()), SchemaGroup::getName, bo.getName());
|
lqw.like(StringUtils.isNotBlank(bo.getName()), SchemaGroup::getName, bo.getName());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), SchemaGroup::getCode, bo.getCode());
|
lqw.eq(StringUtils.isNotBlank(bo.getCode()), SchemaGroup::getCode, bo.getCode());
|
||||||
lqw.eq(bo.getSort() != null, SchemaGroup::getSort, bo.getSort());
|
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SchemaGroup::getStatus, bo.getStatus());
|
|
||||||
lqw.orderByAsc(SchemaGroup::getSort);
|
|
||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,9 +99,6 @@ public class SchemaGroupServiceImpl implements SchemaGroupService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if (isValid) {
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
|
||||||
}
|
|
||||||
return baseMapper.deleteBatchIds(ids) > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,10 @@ import org.ruoyi.common.core.utils.MapstructUtils;
|
|||||||
import org.ruoyi.common.core.utils.StringUtils;
|
import org.ruoyi.common.core.utils.StringUtils;
|
||||||
import org.ruoyi.core.page.PageQuery;
|
import org.ruoyi.core.page.PageQuery;
|
||||||
import org.ruoyi.core.page.TableDataInfo;
|
import org.ruoyi.core.page.TableDataInfo;
|
||||||
|
import org.ruoyi.generator.domain.SchemaGroup;
|
||||||
|
import org.ruoyi.generator.domain.vo.SchemaGroupVo;
|
||||||
import org.ruoyi.generator.event.SchemaDeletedEvent;
|
import org.ruoyi.generator.event.SchemaDeletedEvent;
|
||||||
|
import org.ruoyi.generator.service.SchemaGroupService;
|
||||||
import org.ruoyi.generator.service.SchemaService;
|
import org.ruoyi.generator.service.SchemaService;
|
||||||
import org.ruoyi.generator.domain.Schema;
|
import org.ruoyi.generator.domain.Schema;
|
||||||
import org.ruoyi.generator.domain.bo.SchemaBo;
|
import org.ruoyi.generator.domain.bo.SchemaBo;
|
||||||
@@ -20,6 +23,8 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型Service业务层处理
|
* 数据模型Service业务层处理
|
||||||
@@ -31,6 +36,7 @@ import java.util.List;
|
|||||||
public class SchemaServiceImpl implements SchemaService {
|
public class SchemaServiceImpl implements SchemaService {
|
||||||
|
|
||||||
private final SchemaMapper baseMapper;
|
private final SchemaMapper baseMapper;
|
||||||
|
private final SchemaGroupService schemaGroupService;
|
||||||
private final ApplicationEventPublisher eventPublisher;
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,10 +70,7 @@ public class SchemaServiceImpl implements SchemaService {
|
|||||||
LambdaQueryWrapper<Schema> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<Schema> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(bo.getSchemaGroupId() != null, Schema::getSchemaGroupId, bo.getSchemaGroupId());
|
lqw.eq(bo.getSchemaGroupId() != null, Schema::getSchemaGroupId, bo.getSchemaGroupId());
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getName()), Schema::getName, bo.getName());
|
lqw.like(StringUtils.isNotBlank(bo.getName()), Schema::getName, bo.getName());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), Schema::getCode, bo.getCode());
|
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getTableName()), Schema::getTableName, bo.getTableName());
|
lqw.eq(StringUtils.isNotBlank(bo.getTableName()), Schema::getTableName, bo.getTableName());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), Schema::getStatus, bo.getStatus());
|
|
||||||
lqw.orderByAsc(Schema::getSort);
|
|
||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,15 +79,18 @@ public class SchemaServiceImpl implements SchemaService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(SchemaBo bo) {
|
public Boolean insertByBo(SchemaBo bo) {
|
||||||
Schema add = MapstructUtils.convert(bo, Schema.class);
|
Schema schema = MapstructUtils.convert(bo, Schema.class);
|
||||||
validEntityBeforeSave(add);
|
Long schemaGroupId = bo.getSchemaGroupId();
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
SchemaGroupVo schemaGroupVo = schemaGroupService.queryById(schemaGroupId);
|
||||||
|
if (Objects.nonNull(schemaGroupVo)) {
|
||||||
|
schema.setCode(schemaGroupVo.getCode());
|
||||||
|
}
|
||||||
|
boolean flag = baseMapper.insert(schema) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(schema.getId());
|
||||||
|
|
||||||
// 发布数据模型添加事件,由事件监听器处理字段插入
|
// 发布数据模型添加事件,由事件监听器处理字段插入
|
||||||
if (StringUtils.isNotBlank(bo.getTableName())) {
|
if (StringUtils.isNotBlank(bo.getTableName())) {
|
||||||
eventPublisher.publishEvent(new SchemaAddedEvent(this, add.getId(), bo.getTableName()));
|
eventPublisher.publishEvent(new SchemaAddedEvent(this, schema.getId(), bo.getTableName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
@@ -96,17 +102,9 @@ public class SchemaServiceImpl implements SchemaService {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean updateByBo(SchemaBo bo) {
|
public Boolean updateByBo(SchemaBo bo) {
|
||||||
Schema update = MapstructUtils.convert(bo, Schema.class);
|
Schema update = MapstructUtils.convert(bo, Schema.class);
|
||||||
validEntityBeforeSave(update);
|
|
||||||
return baseMapper.updateById(update) > 0;
|
return baseMapper.updateById(update) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存前的数据校验
|
|
||||||
*/
|
|
||||||
private void validEntityBeforeSave(Schema entity) {
|
|
||||||
//TODO 做一些数据校验,如唯一约束
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除数据模型
|
* 批量删除数据模型
|
||||||
*/
|
*/
|
||||||
@@ -127,8 +125,6 @@ public class SchemaServiceImpl implements SchemaService {
|
|||||||
public SchemaVo queryByTableName(String tableName) {
|
public SchemaVo queryByTableName(String tableName) {
|
||||||
LambdaQueryWrapper<Schema> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<Schema> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(Schema::getTableName, tableName);
|
lqw.eq(Schema::getTableName, tableName);
|
||||||
// 只查询正常状态的模型
|
|
||||||
lqw.eq(Schema::getStatus, "0");
|
|
||||||
return baseMapper.selectVoOne(lqw);
|
return baseMapper.selectVoOne(lqw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,4 +13,12 @@ public interface IGenTableService {
|
|||||||
* @param tableName 表名称数组
|
* @param tableName 表名称数组
|
||||||
*/
|
*/
|
||||||
void generateCodeToClasspathByTableNames(String tableName);
|
void generateCodeToClasspathByTableNames(String tableName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成前端文件
|
||||||
|
*
|
||||||
|
* @param workPath 执行命令路径
|
||||||
|
* @param previewCode 执行生成前端文件命令
|
||||||
|
*/
|
||||||
|
void generateFrontendTemplateFiles(String workPath, String previewCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,26 +25,28 @@ import org.ruoyi.common.core.validate.EditGroup;
|
|||||||
public class ${ClassName}Bo implements Serializable {
|
public class ${ClassName}Bo implements Serializable {
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField) && ($column.isPk || $column.query || $column.insert || $column.edit))
|
#if($column.isPk)
|
||||||
/**
|
|
||||||
* $column.columnComment
|
|
||||||
*/
|
|
||||||
#if($column.insert && $column.edit)
|
|
||||||
#set($Group="AddGroup.class, EditGroup.class")
|
|
||||||
#elseif($column.insert)
|
|
||||||
#set($Group="AddGroup.class")
|
|
||||||
#elseif($column.edit)
|
|
||||||
#set($Group="EditGroup.class")
|
|
||||||
#end
|
|
||||||
#if($column.required)
|
|
||||||
#if($column.javaType == 'String')
|
|
||||||
@NotBlank(message = "$column.columnComment不能为空", groups = { $Group })
|
|
||||||
#else
|
|
||||||
@NotNull(message = "$column.columnComment不能为空", groups = { $Group })
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
private $column.javaType $column.javaField;
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#elseif($column.insert || $column.edit)
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
#if($column.insert && $column.edit)
|
||||||
|
#set($Group="AddGroup.class, EditGroup.class")
|
||||||
|
#elseif($column.insert)
|
||||||
|
#set($Group="AddGroup.class")
|
||||||
|
#elseif($column.edit)
|
||||||
|
#set($Group="EditGroup.class")
|
||||||
|
#end
|
||||||
|
#if($column.required)
|
||||||
|
#if($column.javaType == 'String')
|
||||||
|
@NotBlank(message = "$column.columnComment不能为空", groups = { $Group })
|
||||||
|
#else
|
||||||
|
@NotNull(message = "$column.columnComment不能为空", groups = { $Group })
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,10 @@
|
|||||||
package ${packageName}.domain;
|
package ${packageName}.domain;
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.javaField=='tenantId')
|
|
||||||
#set($IsTenant=1)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($IsTenant==1)
|
|
||||||
import core.tenant.common.org.ruoyi.TenantEntity;
|
|
||||||
#else
|
|
||||||
#end
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
#foreach ($import in $importList)
|
||||||
#foreach ($import in $importList)
|
import ${import};
|
||||||
import ${import};
|
#end
|
||||||
#end
|
|
||||||
|
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}对象 ${tableName}
|
* ${functionName}对象 ${tableName}
|
||||||
@@ -24,15 +12,9 @@ import org.ruoyi.core.domain.BaseEntity;
|
|||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
#if($IsTenant==1)
|
|
||||||
#set($Entity="TenantEntity")
|
|
||||||
#else
|
|
||||||
#set($Entity="BaseEntity")
|
|
||||||
#end
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("${tableName}")
|
@TableName("${tableName}")
|
||||||
public class ${ClassName} extends ${Entity} {
|
public class ${ClassName} implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
@@ -47,7 +29,7 @@ public class ${ClassName} extends ${Entity} {
|
|||||||
@Version
|
@Version
|
||||||
#end
|
#end
|
||||||
#if($column.isPk==1)
|
#if($column.isPk==1)
|
||||||
@TableId(value = "$column.columnName")
|
@TableId(value = "${column.columnName}", type = IdType.AUTO)
|
||||||
#end
|
#end
|
||||||
private $column.javaType $column.javaField;
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
|||||||
@@ -23,29 +23,30 @@ import java.util.Date;
|
|||||||
@AutoMapper(target = ${ClassName}.class)
|
@AutoMapper(target = ${ClassName}.class)
|
||||||
public class ${ClassName}Vo implements Serializable {
|
public class ${ClassName}Vo implements Serializable {
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.list)
|
#if($column.isPk)
|
||||||
/**
|
private $column.javaType $column.javaField;
|
||||||
* $column.columnComment
|
#elseif($column.list)
|
||||||
*/
|
/**
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
* $column.columnComment
|
||||||
#if($parentheseIndex != -1)
|
*/
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
#else
|
#if($parentheseIndex != -1)
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
#end
|
#else
|
||||||
#if(${column.dictType} && ${column.dictType} != '')
|
#set($comment=$column.columnComment)
|
||||||
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(dictType = "${column.dictType}")
|
|
||||||
#elseif($parentheseIndex != -1)
|
|
||||||
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(readConverterExp = "$column.readConverterExp()")
|
|
||||||
#else
|
|
||||||
@ExcelProperty(value = "${comment}")
|
|
||||||
#end
|
|
||||||
private $column.javaType $column.javaField;
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
|
#if(${column.dictType} && ${column.dictType} != '')
|
||||||
|
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "${column.dictType}")
|
||||||
|
#elseif($parentheseIndex != -1)
|
||||||
|
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "$column.readConverterExp()")
|
||||||
|
#else
|
||||||
|
@ExcelProperty(value = "${comment}")
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user