mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-13 20:53:42 +08:00
feat: fix代码生成类型问题
This commit is contained in:
@@ -27,10 +27,18 @@ import org.ruoyi.service.IKnowledgeAttachService;
|
||||
import org.ruoyi.service.IKnowledgeFragmentService;
|
||||
import org.ruoyi.service.IKnowledgeInfoService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 知识库管理
|
||||
@@ -60,7 +68,9 @@ public class KnowledgeController extends BaseController {
|
||||
if (!StpUtil.isLogin()) {
|
||||
throw new SecurityException("请先去登录!");
|
||||
}
|
||||
bo.setUid(LoginHelper.getUserId());
|
||||
if (!Objects.equals(LoginHelper.getUserId(), 1L)) {
|
||||
bo.setUid(LoginHelper.getUserId());
|
||||
}
|
||||
return knowledgeInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@@ -72,13 +82,15 @@ public class KnowledgeController extends BaseController {
|
||||
if (!StpUtil.isLogin()) {
|
||||
throw new SecurityException("请先去登录!");
|
||||
}
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
|
||||
// 管理员跳过权限
|
||||
if (loginUser.getUserId().equals(1L) || !knowledgeRoleConfig.getEnable()) {
|
||||
if (Objects.equals(LoginHelper.getUserId(), 1L)) {
|
||||
return knowledgeInfoService.queryPageList(bo, pageQuery);
|
||||
} else if (!knowledgeRoleConfig.getEnable()) {
|
||||
bo.setUid(LoginHelper.getUserId());
|
||||
return knowledgeInfoService.queryPageList(bo, pageQuery);
|
||||
} else {
|
||||
// TODO 自己创建的知识库+角色分配的知识库
|
||||
return knowledgeInfoService.queryPageListByRole(pageQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class SchemaGroupController extends BaseController {
|
||||
/**
|
||||
* 获取数据模型分组选择列表
|
||||
*/
|
||||
@SaCheckPermission("dev:schemaGroup:select")
|
||||
@GetMapping("/select")
|
||||
public R<List<SchemaGroupVo>> select() {
|
||||
SchemaGroupBo bo = new SchemaGroupBo();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
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.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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
|
||||
@@ -16,12 +17,9 @@ import java.io.Serial;
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@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 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 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;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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
|
||||
@@ -16,12 +17,8 @@ import java.io.Serial;
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("dev_schema_field")
|
||||
public class SchemaField extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class SchemaField implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
@@ -129,15 +126,6 @@ public class SchemaField extends BaseEntity {
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 扩展JSON
|
||||
*/
|
||||
private String extendJson;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
@@ -151,8 +139,33 @@ public class SchemaField extends BaseEntity {
|
||||
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;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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
|
||||
@@ -16,12 +17,8 @@ import java.io.Serial;
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("dev_schema_group")
|
||||
public class SchemaGroup extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class SchemaGroup implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
@@ -44,16 +41,6 @@ public class SchemaGroup extends BaseEntity {
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@@ -66,8 +53,32 @@ public class SchemaGroup extends BaseEntity {
|
||||
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.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
import org.ruoyi.generator.domain.Schema;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据模型业务对象 SchemaBo
|
||||
*
|
||||
@@ -17,9 +17,8 @@ import org.ruoyi.generator.domain.Schema;
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@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})
|
||||
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 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.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
import org.ruoyi.generator.domain.SchemaField;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据模型字段业务对象 SchemaFieldBo
|
||||
*
|
||||
@@ -17,9 +17,8 @@ import org.ruoyi.generator.domain.SchemaField;
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@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;
|
||||
|
||||
/**
|
||||
@@ -131,16 +130,6 @@ public class SchemaFieldBo extends BaseEntity {
|
||||
*/
|
||||
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.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
import org.ruoyi.generator.domain.SchemaGroup;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据模型分组业务对象 SchemaGroupBo
|
||||
*
|
||||
@@ -17,9 +17,8 @@ import org.ruoyi.generator.domain.SchemaGroup;
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@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 Integer sort;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -6,9 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.ruoyi.generator.domain.SchemaField;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据模型字段视图对象 SchemaFieldVo
|
||||
@@ -20,9 +18,6 @@ import java.util.Date;
|
||||
@AutoMapper(target = SchemaField.class)
|
||||
public class SchemaFieldVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@@ -136,25 +131,8 @@ public class SchemaFieldVo implements Serializable {
|
||||
@Schema(description = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 扩展JSON
|
||||
*/
|
||||
private String extendJson;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.ruoyi.generator.domain.SchemaGroup;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -18,9 +17,6 @@ import java.util.Date;
|
||||
@AutoMapper(target = SchemaGroup.class)
|
||||
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 String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -19,9 +19,6 @@ import java.util.Date;
|
||||
@AutoMapper(target = Schema.class)
|
||||
public class SchemaVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
||||
@@ -11,9 +11,11 @@ import org.apache.velocity.app.Velocity;
|
||||
import org.ruoyi.common.core.constant.Constants;
|
||||
import org.ruoyi.generator.config.GenConfig;
|
||||
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.service.IGenTableService;
|
||||
import org.ruoyi.generator.service.SchemaFieldService;
|
||||
import org.ruoyi.generator.service.SchemaGroupService;
|
||||
import org.ruoyi.generator.service.SchemaService;
|
||||
import org.ruoyi.generator.util.VelocityInitializer;
|
||||
import org.ruoyi.generator.util.VelocityUtils;
|
||||
@@ -44,6 +46,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
|
||||
private final SchemaService schemaService;
|
||||
private final SchemaFieldService schemaFieldService;
|
||||
private final SchemaGroupService schemaGroupService;
|
||||
|
||||
/**
|
||||
* 基于表名称批量生成代码到classpath路径
|
||||
@@ -137,6 +140,8 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||
|
||||
// 处理表名和类名
|
||||
Long schemaGroupId = schema.getSchemaGroupId();
|
||||
SchemaGroupVo schemaGroupVo = schemaGroupService.queryById(schemaGroupId);
|
||||
String tableName = schema.getTableName();
|
||||
String baseClassName = schema.getTableName();
|
||||
|
||||
@@ -154,7 +159,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
String className = toCamelCase(baseClassName, true); // 首字母大写的类名,如:SysRole
|
||||
String classname = toCamelCase(baseClassName, false); // 首字母小写的类名,如:sysRole
|
||||
String businessName = toCamelCase(baseClassName, false);
|
||||
String moduleName = getModuleName(packageName);
|
||||
String moduleName = schemaGroupVo.getCode();
|
||||
|
||||
// 基本信息
|
||||
context.put("tableName", tableName);
|
||||
|
||||
@@ -79,7 +79,6 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getQueryType()), SchemaField::getQueryType, bo.getQueryType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getHtmlType()), SchemaField::getHtmlType, bo.getHtmlType());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDictType()), SchemaField::getDictType, bo.getDictType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SchemaField::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(SchemaField::getSort);
|
||||
return lqw;
|
||||
}
|
||||
@@ -150,7 +149,6 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
||||
public List<SchemaFieldVo> queryListBySchemaId(Long schemaId) {
|
||||
LambdaQueryWrapper<SchemaField> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SchemaField::getSchemaId, schemaId);
|
||||
lqw.eq(SchemaField::getStatus, "0"); // 只查询正常状态的字段
|
||||
lqw.orderByAsc(SchemaField::getSort);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
@@ -264,8 +262,7 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
||||
return false;
|
||||
}
|
||||
LambdaQueryWrapper<SchemaField> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SchemaField::getSchemaName, tableName);
|
||||
lqw.eq(SchemaField::getStatus, "0");
|
||||
lqw.eq(SchemaField::getSchemaId, schemaId);
|
||||
// 检查是否已存在字段数据
|
||||
List<SchemaFieldVo> existingFields = baseMapper.selectVoList(lqw);
|
||||
if (CollUtil.isNotEmpty(existingFields)) {
|
||||
@@ -279,20 +276,26 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
||||
SchemaField field = new SchemaField();
|
||||
field.setSchemaId(schemaId);
|
||||
field.setSchemaName(tableName);
|
||||
field.setDefaultValue((String) columnInfo.get("columnDefault"));
|
||||
field.setComment((String) columnInfo.get("columnComment"));
|
||||
field.setName((String) columnInfo.get("columnComment"));
|
||||
field.setCode(StrUtil.toCamelCase((String) columnInfo.get("columnName")));
|
||||
field.setType((String) columnInfo.get("dataType"));
|
||||
field.setLength(Integer.valueOf(String.valueOf(columnInfo.get("columnSize"))));
|
||||
field.setIsPk((Boolean) columnInfo.get("isPrimaryKey") ? "1" : "0");
|
||||
field.setIsRequired(!(Boolean) columnInfo.get("isNullable") ? "1" : "0");
|
||||
field.setIsInsert("1");
|
||||
field.setIsEdit("1");
|
||||
if ("1".equals(field.getIsPk())) {
|
||||
field.setIsInsert("0");
|
||||
field.setIsEdit("0");
|
||||
}else {
|
||||
field.setIsInsert("1");
|
||||
field.setIsEdit("1");
|
||||
}
|
||||
field.setIsList("1");
|
||||
field.setIsQuery("1");
|
||||
field.setQueryType("EQ");
|
||||
field.setHtmlType(getDefaultHtmlType((String) columnInfo.get("dataType")));
|
||||
field.setSort(sort++);
|
||||
field.setStatus("0");
|
||||
// 如果字段名为空,使用字段代码作为名称
|
||||
if (StringUtils.isBlank(field.getName())) {
|
||||
field.setName(field.getCode());
|
||||
|
||||
@@ -60,9 +60,6 @@ public class SchemaGroupServiceImpl implements SchemaGroupService {
|
||||
LambdaQueryWrapper<SchemaGroup> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), SchemaGroup::getName, bo.getName());
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -102,9 +99,6 @@ public class SchemaGroupServiceImpl implements SchemaGroupService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,10 @@ import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
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.service.SchemaGroupService;
|
||||
import org.ruoyi.generator.service.SchemaService;
|
||||
import org.ruoyi.generator.domain.Schema;
|
||||
import org.ruoyi.generator.domain.bo.SchemaBo;
|
||||
@@ -20,6 +23,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 数据模型Service业务层处理
|
||||
@@ -31,6 +36,7 @@ import java.util.List;
|
||||
public class SchemaServiceImpl implements SchemaService {
|
||||
|
||||
private final SchemaMapper baseMapper;
|
||||
private final SchemaGroupService schemaGroupService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
/**
|
||||
@@ -64,10 +70,7 @@ public class SchemaServiceImpl implements SchemaService {
|
||||
LambdaQueryWrapper<Schema> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getSchemaGroupId() != null, Schema::getSchemaGroupId, bo.getSchemaGroupId());
|
||||
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.getStatus()), Schema::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(Schema::getSort);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@@ -76,15 +79,18 @@ public class SchemaServiceImpl implements SchemaService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(SchemaBo bo) {
|
||||
Schema add = MapstructUtils.convert(bo, Schema.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Schema schema = MapstructUtils.convert(bo, Schema.class);
|
||||
Long schemaGroupId = bo.getSchemaGroupId();
|
||||
SchemaGroupVo schemaGroupVo = schemaGroupService.queryById(schemaGroupId);
|
||||
if (Objects.nonNull(schemaGroupVo)) {
|
||||
schema.setCode(schemaGroupVo.getCode());
|
||||
}
|
||||
boolean flag = baseMapper.insert(schema) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
|
||||
bo.setId(schema.getId());
|
||||
// 发布数据模型添加事件,由事件监听器处理字段插入
|
||||
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;
|
||||
@@ -96,17 +102,9 @@ public class SchemaServiceImpl implements SchemaService {
|
||||
@Override
|
||||
public Boolean updateByBo(SchemaBo bo) {
|
||||
Schema update = MapstructUtils.convert(bo, Schema.class);
|
||||
validEntityBeforeSave(update);
|
||||
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) {
|
||||
LambdaQueryWrapper<Schema> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(Schema::getTableName, tableName);
|
||||
// 只查询正常状态的模型
|
||||
lqw.eq(Schema::getStatus, "0");
|
||||
return baseMapper.selectVoOne(lqw);
|
||||
}
|
||||
}
|
||||
@@ -25,26 +25,28 @@ import org.ruoyi.common.core.validate.EditGroup;
|
||||
public class ${ClassName}Bo implements Serializable {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isPk || $column.query || $column.insert || $column.edit|| $column.required)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#if(($column.insert && $column.edit) || $column.required)
|
||||
#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
|
||||
#if($column.isPk)
|
||||
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
|
||||
|
||||
|
||||
@@ -2496,11 +2496,56 @@ CREATE TABLE prompt_template
|
||||
ROW_FORMAT = Dynamic;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `dev_schema_group`;
|
||||
create table dev_schema_group
|
||||
(
|
||||
id bigint auto_increment comment '主键' primary key,
|
||||
name varchar(100) null comment '分组名称',
|
||||
code varchar(100) null comment '分组编码',
|
||||
icon varchar(100) null comment '图标',
|
||||
remark varchar(500) null comment '备注',
|
||||
del_flag char default '0' null comment '删除标志(0代表存在 2代表删除)',
|
||||
create_dept bigint null comment '创建部门',
|
||||
create_by bigint null comment '创建者',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_by bigint null comment '更新者',
|
||||
update_time datetime null comment '更新时间'
|
||||
) ENGINE = InnoDB
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT = '数据模型分组表';
|
||||
|
||||
INSERT INTO dev_schema_group (id, name, code, icon, remark, del_flag, create_dept, create_by, create_time, update_by, update_time) VALUES
|
||||
(1944240213530648567, '系统管理', 'system', 'eos-icons:system-group', '系统默认分组', '0', null, null, '2025-07-13 11:37:28', 1, '2025-07-13 18:42:48');
|
||||
INSERT INTO dev_schema_group (id, name, code, icon, remark, del_flag, create_dept, create_by, create_time, update_by, update_time) VALUES
|
||||
(1944240213530648577, '运营管理', 'operator', 'icon-park-outline:appointment', '运营管理', '0', null, null, '2025-07-13 11:39:24', 1, '2025-07-13 18:42:31');
|
||||
INSERT INTO dev_schema_group (id, name, code, icon, remark, del_flag, create_dept, create_by, create_time, update_by, update_time) VALUES
|
||||
(1944346023254429697, '在线开发', 'dev', 'carbon:development', '在线开发', '0', null, null, '2025-07-13 18:39:51', 1, '2025-07-13 18:42:07');
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `dev_schema`;
|
||||
create table dev_schema
|
||||
(
|
||||
id bigint auto_increment comment '主键' primary key,
|
||||
schema_group_id bigint null comment '分组ID',
|
||||
name varchar(100) null comment '模型名称',
|
||||
code varchar(100) null comment '模型编码',
|
||||
table_name varchar(100) null comment '表名',
|
||||
remark varchar(500) null comment '备注',
|
||||
del_flag char default '0' null comment '删除标志(0代表存在 2代表删除)',
|
||||
create_dept bigint null comment '创建部门',
|
||||
create_by bigint null comment '创建者',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_by bigint null comment '更新者',
|
||||
update_time datetime null comment '更新时间'
|
||||
) ENGINE = InnoDB
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT = '数据模型表';
|
||||
|
||||
DROP TABLE IF EXISTS `dev_schema_field`;
|
||||
create table dev_schema_field
|
||||
(
|
||||
id bigint auto_increment comment '主键'
|
||||
primary key,
|
||||
id bigint auto_increment comment '主键' primary key,
|
||||
schema_id bigint null comment '模型ID',
|
||||
schema_name varchar(64) null comment '模型名称',
|
||||
name varchar(100) null comment '字段名称',
|
||||
@@ -2513,17 +2558,6 @@ create table dev_schema_field
|
||||
default_value varchar(200) null comment '默认值',
|
||||
length int null comment '字段长度',
|
||||
scale int null comment '小数位数',
|
||||
sort int null comment '排序',
|
||||
status char default '0' null comment '状态(0正常 1停用)',
|
||||
extend_json text null comment '扩展配置',
|
||||
remark varchar(500) null comment '备注',
|
||||
del_flag char default '0' null comment '删除标志(0代表存在 2代表删除)',
|
||||
tenant_id varchar(20) default '000000' null comment '租户编号',
|
||||
create_dept bigint null comment '创建部门',
|
||||
create_by bigint null comment '创建者',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_by bigint null comment '更新者',
|
||||
update_time datetime null comment '更新时间',
|
||||
is_list char default '1' null comment '是否列表显示(0否 1是)',
|
||||
is_query char default '1' null comment '是否查询字段(0否 1是)',
|
||||
is_insert char default '1' null comment '是否插入字段(0否 1是)',
|
||||
@@ -2531,125 +2565,23 @@ create table dev_schema_field
|
||||
query_type varchar(200) default null comment '查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围)',
|
||||
html_type varchar(200) default 'input' null comment '显示类型(input输入框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传、upload文件上传、editor富文本编辑器)',
|
||||
dict_type varchar(200) default '' null comment '字典类型',
|
||||
constraint fk_schema_field_schema
|
||||
foreign key (schema_id) references dev_schema (id)
|
||||
on delete cascade
|
||||
) comment '数据模型字段表';
|
||||
|
||||
create index idx_html_type
|
||||
on dev_schema_field (html_type);
|
||||
|
||||
create index idx_is_list
|
||||
on dev_schema_field (is_list);
|
||||
|
||||
create index idx_is_query
|
||||
on dev_schema_field (is_query);
|
||||
|
||||
create index idx_query_type
|
||||
on dev_schema_field (query_type);
|
||||
|
||||
create index idx_schema_field_code
|
||||
on dev_schema_field (code);
|
||||
|
||||
create index idx_schema_field_schema_id
|
||||
on dev_schema_field (schema_id);
|
||||
|
||||
create index idx_schema_field_status
|
||||
on dev_schema_field (status);
|
||||
|
||||
create index idx_schema_field_tenant
|
||||
on dev_schema_field (tenant_id);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `dev_schema`;
|
||||
create table dev_schema
|
||||
(
|
||||
id bigint auto_increment comment '主键'
|
||||
primary key,
|
||||
schema_group_id bigint null comment '分组ID',
|
||||
name varchar(100) null comment '模型名称',
|
||||
code varchar(100) null comment '模型编码',
|
||||
table_name varchar(100) null comment '表名',
|
||||
comment varchar(500) null comment '表注释',
|
||||
engine varchar(50) default 'InnoDB' null comment '存储引擎',
|
||||
list_keys text null comment '列表字段',
|
||||
search_form_keys text null comment '搜索表单字段',
|
||||
designer longtext null comment '表单设计',
|
||||
status char default '0' null comment '状态(0正常 1停用)',
|
||||
sort int null comment '排序',
|
||||
remark varchar(500) null comment '备注',
|
||||
del_flag char default '0' null comment '删除标志(0代表存在 2代表删除)',
|
||||
tenant_id varchar(20) default '000000' null comment '租户编号',
|
||||
create_dept bigint null comment '创建部门',
|
||||
create_by bigint null comment '创建者',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_by bigint null comment '更新者',
|
||||
update_time datetime null comment '更新时间',
|
||||
constraint fk_schema_group
|
||||
foreign key (schema_group_id) references dev_schema_group (id)
|
||||
on delete set null
|
||||
)
|
||||
comment '数据模型表';
|
||||
|
||||
create index idx_schema_code
|
||||
on dev_schema (code);
|
||||
|
||||
create index idx_schema_group_id
|
||||
on dev_schema (schema_group_id);
|
||||
|
||||
create index idx_schema_status
|
||||
on dev_schema (status);
|
||||
|
||||
create index idx_schema_table_name
|
||||
on dev_schema (table_name);
|
||||
|
||||
create index idx_schema_tenant
|
||||
on dev_schema (tenant_id);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `dev_schema_group`;
|
||||
create table dev_schema_group
|
||||
(
|
||||
id bigint auto_increment comment '主键'
|
||||
primary key,
|
||||
name varchar(100) null comment '分组名称',
|
||||
code varchar(100) null comment '分组编码',
|
||||
icon varchar(100) null comment '图标',
|
||||
sort int null comment '排序',
|
||||
status char default '0' null comment '状态(0正常 1停用)',
|
||||
remark varchar(500) null comment '备注',
|
||||
del_flag char default '0' null comment '删除标志(0代表存在 2代表删除)',
|
||||
tenant_id varchar(20) default '000000' null comment '租户编号',
|
||||
create_dept bigint null comment '创建部门',
|
||||
create_by bigint null comment '创建者',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_by bigint null comment '更新者',
|
||||
update_time datetime null comment '更新时间'
|
||||
)
|
||||
comment '数据模型分组表';
|
||||
|
||||
create index idx_schema_group_code
|
||||
on dev_schema_group (code);
|
||||
|
||||
create index idx_schema_group_status
|
||||
on dev_schema_group (status);
|
||||
|
||||
create index idx_schema_group_tenant
|
||||
on dev_schema_group (tenant_id);
|
||||
|
||||
|
||||
INSERT INTO dev_schema_group (id, name, code, icon, sort, status, remark, del_flag, tenant_id, create_dept, create_by, create_time, update_by, update_time) VALUES (1944240213530648567, '系统管理', 'system', 'eos-icons:system-group', 2, '0', '系统默认分组', '0', '000000', null, null, '2025-07-13 11:37:28', 1, '2025-07-13 18:42:48');
|
||||
INSERT INTO dev_schema_group (id, name, code, icon, sort, status, remark, del_flag, tenant_id, create_dept, create_by, create_time, update_by, update_time) VALUES (1944240213530648577, '运营管理', 'operator', 'icon-park-outline:appointment', 1, '0', null, '0', '000000', null, null, '2025-07-13 11:39:24', 1, '2025-07-13 18:42:31');
|
||||
INSERT INTO dev_schema_group (id, name, code, icon, sort, status, remark, del_flag, tenant_id, create_dept, create_by, create_time, update_by, update_time) VALUES (1944346023254429697, '在线开发', 'dev', 'carbon:development', 3, '0', null, '0', '000000', null, null, '2025-07-13 18:39:51', 1, '2025-07-13 18:42:07');
|
||||
|
||||
|
||||
|
||||
sort int null comment '排序',
|
||||
del_flag char default '0' null comment '删除标志(0代表存在 2代表删除)',
|
||||
create_dept bigint null comment '创建部门',
|
||||
create_by bigint null comment '创建者',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_by bigint null comment '更新者',
|
||||
update_time datetime null comment '更新时间',
|
||||
remark varchar(500) null comment '备注'
|
||||
) ENGINE = InnoDB
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT = '数据模型字段表';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `knowledge_role`;
|
||||
-- ----------------------------
|
||||
-- Table structure for knowledge_role
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `knowledge_role`;
|
||||
CREATE TABLE `knowledge_role` (
|
||||
`id` bigint NOT NULL COMMENT '知识库角色id',
|
||||
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '知识库角色name',
|
||||
@@ -2664,10 +2596,10 @@ CREATE TABLE `knowledge_role` (
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '知识库角色表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
DROP TABLE IF EXISTS `knowledge_role_group`;
|
||||
-- ----------------------------
|
||||
-- Table structure for knowledge_role_group
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `knowledge_role_group`;
|
||||
CREATE TABLE `knowledge_role_group` (
|
||||
`id` bigint NOT NULL COMMENT '知识库角色组id',
|
||||
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '知识库角色组name',
|
||||
|
||||
Reference in New Issue
Block a user