diff --git a/doc/代码生成.drawio b/doc/代码生成.drawio index 9ede539..c892fbe 100644 --- a/doc/代码生成.drawio +++ b/doc/代码生成.drawio @@ -1,86 +1,310 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index fafbbfe..696de5f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,6 @@ 3.1.1 3.4.2 1.2.24 - 4.3.1 1.1 1.21 3.0.0 @@ -108,13 +107,6 @@ ${druid.version} - - - com.baomidou - dynamic-datasource-spring-boot-starter - ${dynamic.version} - - javax.transaction jta diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 9344d69..df8184c 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -52,12 +52,6 @@ jackson-datatype-jsr310 - - - com.alibaba.fastjson2 diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java index 99e7de9..07ea3ef 100644 --- a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java @@ -2,7 +2,6 @@ package com.ruoyi.generator.controller; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,8 +31,11 @@ import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.sql.SqlUtil; +import com.ruoyi.generator.domain.GenJoinTable; import com.ruoyi.generator.domain.GenTable; import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.domain.vo.GenTableVo; +import com.ruoyi.generator.service.IGenJoinTableService; import com.ruoyi.generator.service.IGenTableColumnService; import com.ruoyi.generator.service.IGenTableService; @@ -53,6 +55,9 @@ public class GenController extends BaseController { @Autowired private IGenTableColumnService genTableColumnService; + @Autowired + private IGenJoinTableService genJoinTableService; + /** * 查询代码生成列表 */ @@ -71,13 +76,27 @@ public class GenController extends BaseController { @GetMapping(value = "/{tableId}") public AjaxResult getInfo(@PathVariable(name = "tableId") Long tableId) { GenTable table = genTableService.selectGenTableById(tableId); - List tables = genTableService.selectGenTableAll(); - List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); - Map map = new HashMap(); - map.put("info", table); - map.put("rows", list); - map.put("tables", tables); - return success(map); + GenTableVo genTableVo = new GenTableVo(); + genTableVo.setTable(table); + genTableVo.setColumns(table.getColumns()); + GenJoinTable genJoinTable = new GenJoinTable(); + genJoinTable.setTableId(tableId); + List selectGenJoinTableList = genJoinTableService.selectGenJoinTableList(genJoinTable); + genTableVo.setJoins(selectGenJoinTableList); + List joinTables = new ArrayList<>(); + selectGenJoinTableList.forEach(i -> { + GenTable joinTable = genTableService.selectGenTableById(i.getJoinTableId()); + joinTables.add(joinTable); + }); + genTableVo.setJoinTables(joinTables); + // List tables = genTableService.selectGenTableAll(); + // List list = + // genTableColumnService.selectGenTableColumnListByTableId(tableId); + // Map map = new HashMap(); + // map.put("info", table); + // map.put("rows", list); + // map.put("tables", tables); + return success(genTableVo); } /** @@ -118,54 +137,51 @@ public class GenController extends BaseController { return success(); } - /** + /** * 创建表结构(保存) */ @PreAuthorize("@ss.hasRole('admin')") @Log(title = "创建表", businessType = BusinessType.OTHER) @PostMapping("/createTable") - public AjaxResult createTableSave(String sql) - { - try - { + public AjaxResult createTableSave(String sql) { + try { SqlUtil.filterKeyword(sql); List sqlStatements = SQLUtils.parseStatements(sql, DbType.mysql); List tableNames = new ArrayList<>(); - for (SQLStatement sqlStatement : sqlStatements) - { - if (sqlStatement instanceof MySqlCreateTableStatement) - { + for (SQLStatement sqlStatement : sqlStatements) { + if (sqlStatement instanceof MySqlCreateTableStatement) { MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement) sqlStatement; - if (genTableService.createTable(createTableStatement.toString())) - { + if (genTableService.createTable(createTableStatement.toString())) { String tableName = createTableStatement.getTableName().replaceAll("`", ""); tableNames.add(tableName); } } } - List tableList = genTableService.selectDbTableListByNames(tableNames.toArray(new String[tableNames.size()])); + List tableList = genTableService + .selectDbTableListByNames(tableNames.toArray(new String[tableNames.size()])); String operName = SecurityUtils.getUsername(); genTableService.importGenTable(tableList, operName); return AjaxResult.success(); - } - catch (Exception e) - { + } catch (Exception e) { logger.error(e.getMessage(), e); return AjaxResult.error("创建表结构异常"); } } - - /** * 修改保存代码生成业务 */ @PreAuthorize("@ss.hasPermi('tool:gen:edit')") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult editSave(@Validated @RequestBody GenTable genTable) { + public AjaxResult editSave(@Validated @RequestBody GenTableVo genTableVo) { + GenTable genTable = genTableVo.getTable(); genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); + genJoinTableService.deleteGenJoinTableByTableId(genTable.getTableId()); + genTableVo.getJoins().forEach(i -> { + genJoinTableService.insertGenJoinTable(i); + }); return success(); } diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenJoinTable.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenJoinTable.java new file mode 100644 index 0000000..6a92486 --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenJoinTable.java @@ -0,0 +1,32 @@ +package com.ruoyi.generator.domain; + +import com.ruoyi.common.core.domain.BaseEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GenJoinTable extends BaseEntity { + + /** 表编号 */ + private Long tableId; + + private Long mainTableId; + + /** 关联表编号 */ + private Long joinTableId; + + /** 主表别名 */ + private String mainTableAlias; + + /** 关联表别名 */ + private String joinTableAlias; + + /** 主表外键 */ + private String mainTableFk; + + /** 关联表外键 */ + private String joinTableFk; + +} diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenJoinTableColumn.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenJoinTableColumn.java new file mode 100644 index 0000000..92e5c0f --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenJoinTableColumn.java @@ -0,0 +1,24 @@ +package com.ruoyi.generator.domain; + +import com.ruoyi.common.core.domain.BaseEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GenJoinTableColumn extends BaseEntity { + + /** 归属表编号 */ + private Long tableId; + + /** 关联表编号 */ + private Long joinTableId; + + /** 编号 */ + private Long columnId; + + /** 关联表别名 */ + private String joinTableAlias; + +} diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java index f13c715..f11ec5c 100644 --- a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java @@ -10,12 +10,16 @@ import com.ruoyi.generator.constant.GenConstants; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import lombok.EqualsAndHashCode; /** * 业务表 gen_table * * @author ruoyi */ +@Data +@EqualsAndHashCode(callSuper = true) public class GenTable extends BaseEntity { private static final long serialVersionUID = 1L; @@ -26,6 +30,9 @@ public class GenTable extends BaseEntity { @NotBlank(message = "表名称不能为空") private String tableName; + /** 表别名 */ + private String tableAlias; + /** 表描述 */ @NotBlank(message = "表描述不能为空") private String tableComment; @@ -100,210 +107,9 @@ public class GenTable extends BaseEntity { /** 上级菜单名称字段 */ private String parentMenuName; - /** 是否含有关联字段 */ private String haveSubColumn; - public String getHaveSubColumn() { - return haveSubColumn; - } - - public void setHaveSubColumn(String haveSubColumn) { - this.haveSubColumn = haveSubColumn; - } - - public Long getTableId() { - return tableId; - } - - public void setTableId(Long tableId) { - this.tableId = tableId; - } - - public String getTableName() { - return tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public String getTableComment() { - return tableComment; - } - - public void setTableComment(String tableComment) { - this.tableComment = tableComment; - } - - public String getSubTableName() { - return subTableName; - } - - public void setSubTableName(String subTableName) { - this.subTableName = subTableName; - } - - public String getSubTableFkName() { - return subTableFkName; - } - - public void setSubTableFkName(String subTableFkName) { - this.subTableFkName = subTableFkName; - } - - public String getClassName() { - return className; - } - - public void setClassName(String className) { - this.className = className; - } - - public String getTplCategory() { - return tplCategory; - } - - public void setTplCategory(String tplCategory) { - this.tplCategory = tplCategory; - } - - public String getTplWebType() { - return tplWebType; - } - - public void setTplWebType(String tplWebType) { - this.tplWebType = tplWebType; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - public String getModuleName() { - return moduleName; - } - - public void setModuleName(String moduleName) { - this.moduleName = moduleName; - } - - public String getBusinessName() { - return businessName; - } - - public void setBusinessName(String businessName) { - this.businessName = businessName; - } - - public String getFunctionName() { - return functionName; - } - - public void setFunctionName(String functionName) { - this.functionName = functionName; - } - - public String getFunctionAuthor() { - return functionAuthor; - } - - public void setFunctionAuthor(String functionAuthor) { - this.functionAuthor = functionAuthor; - } - - public String getGenType() { - return genType; - } - - public void setGenType(String genType) { - this.genType = genType; - } - - public String getGenPath() { - return genPath; - } - - public void setGenPath(String genPath) { - this.genPath = genPath; - } - - public GenTableColumn getPkColumn() { - return pkColumn; - } - - public void setPkColumn(GenTableColumn pkColumn) { - this.pkColumn = pkColumn; - } - - public GenTable getSubTable() { - return subTable; - } - - public void setSubTable(GenTable subTable) { - this.subTable = subTable; - } - - public List getColumns() { - return columns; - } - - public void setColumns(List columns) { - this.columns = columns; - } - - public String getOptions() { - return options; - } - - public void setOptions(String options) { - this.options = options; - } - - public String getTreeCode() { - return treeCode; - } - - public void setTreeCode(String treeCode) { - this.treeCode = treeCode; - } - - public String getTreeParentCode() { - return treeParentCode; - } - - public void setTreeParentCode(String treeParentCode) { - this.treeParentCode = treeParentCode; - } - - public String getTreeName() { - return treeName; - } - - public void setTreeName(String treeName) { - this.treeName = treeName; - } - - public String getParentMenuId() { - return parentMenuId; - } - - public void setParentMenuId(String parentMenuId) { - this.parentMenuId = parentMenuId; - } - - public String getParentMenuName() { - return parentMenuName; - } - - public void setParentMenuName(String parentMenuName) { - this.parentMenuName = parentMenuName; - } - public boolean isSub() { return isSub(this.tplCategory); } diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java index b520fdf..0c4cabb 100644 --- a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java @@ -4,14 +4,17 @@ import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.utils.StringUtils; import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import lombok.EqualsAndHashCode; /** * 代码生成业务字段表 gen_table_column * * @author ruoyi */ -public class GenTableColumn extends BaseEntity -{ +@Data +@EqualsAndHashCode(callSuper = true) +public class GenTableColumn extends BaseEntity { private static final long serialVersionUID = 1L; /** 编号 */ @@ -60,7 +63,9 @@ public class GenTableColumn extends BaseEntity /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */ private String queryType; - /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */ + /** + * 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) + */ private String htmlType; /** 字典类型 */ @@ -85,312 +90,67 @@ public class GenTableColumn extends BaseEntity /** 映射字段Java类型 */ private String subColumnJavaType; - public String getSubColumnJavaField() { - return subColumnJavaField; - } - - public void setSubColumnJavaField(String subColumnJavaField) { - this.subColumnJavaField = subColumnJavaField; - } - - public String getSubColumnJavaType() { - return subColumnJavaType; - } - - public void setSubColumnJavaType(String subColumnJavaType) { - this.subColumnJavaType = subColumnJavaType; - } - - public String getSubColumnTableName() { - return subColumnTableName; - } - - public void setSubColumnTableName(String subColumnTableName) { - this.subColumnTableName = subColumnTableName; - } - - public String getSubColumnFkName() { - return subColumnFkName; - } - - public String getSubColumnFkJavaField(){ - return StringUtils.toCamelCase(this.subColumnFkName); - } - - public void setSubColumnFkName(String subColumnFkName) { - this.subColumnFkName = subColumnFkName; - } - - public String getSubColumnName() { - return subColumnName; - } - - public void setSubColumnName(String subColumnName) { - this.subColumnName = subColumnName; - } - - public void setColumnId(Long columnId) - { - this.columnId = columnId; - } - - public Long getColumnId() - { - return columnId; - } - - public void setTableId(Long tableId) - { - this.tableId = tableId; - } - - public Long getTableId() - { - return tableId; - } - - public void setColumnName(String columnName) - { - this.columnName = columnName; - } - - public String getColumnName() - { - return columnName; - } - - public void setColumnComment(String columnComment) - { - this.columnComment = columnComment; - } - - public String getColumnComment() - { - return columnComment; - } - - public void setColumnType(String columnType) - { - this.columnType = columnType; - } - - public String getColumnType() - { - return columnType; - } - - public void setJavaType(String javaType) - { - this.javaType = javaType; - } - - public String getJavaType() - { - return javaType; - } - - public void setJavaField(String javaField) - { - this.javaField = javaField; - } - - public String getJavaField() - { - return javaField; - } - - public String getCapJavaField() - { - return StringUtils.capitalize(javaField); - } - - public void setIsPk(String isPk) - { - this.isPk = isPk; - } - - public String getIsPk() - { - return isPk; - } - - public boolean isPk() - { + public boolean isPk() { return isPk(this.isPk); } - public boolean isPk(String isPk) - { + public boolean isPk(String isPk) { return isPk != null && StringUtils.equals("1", isPk); } - public String getIsIncrement() - { - return isIncrement; - } - - public void setIsIncrement(String isIncrement) - { - this.isIncrement = isIncrement; - } - - public boolean isIncrement() - { + public boolean isIncrement() { return isIncrement(this.isIncrement); } - public boolean isIncrement(String isIncrement) - { + public boolean isIncrement(String isIncrement) { return isIncrement != null && StringUtils.equals("1", isIncrement); } - public void setIsRequired(String isRequired) - { - this.isRequired = isRequired; - } - - public String getIsRequired() - { - return isRequired; - } - - public boolean isRequired() - { + public boolean isRequired() { return isRequired(this.isRequired); } - public boolean isRequired(String isRequired) - { + public boolean isRequired(String isRequired) { return isRequired != null && StringUtils.equals("1", isRequired); } - public void setIsInsert(String isInsert) - { - this.isInsert = isInsert; - } - - public String getIsInsert() - { - return isInsert; - } - - public boolean isInsert() - { + public boolean isInsert() { return isInsert(this.isInsert); } - public boolean isInsert(String isInsert) - { + public boolean isInsert(String isInsert) { return isInsert != null && StringUtils.equals("1", isInsert); } - public void setIsEdit(String isEdit) - { - this.isEdit = isEdit; - } - - public String getIsEdit() - { - return isEdit; - } - - public boolean isEdit() - { + public boolean isEdit() { return isInsert(this.isEdit); } - public boolean isEdit(String isEdit) - { + public boolean isEdit(String isEdit) { return isEdit != null && StringUtils.equals("1", isEdit); } - public void setIsList(String isList) - { - this.isList = isList; - } - - public String getIsList() - { - return isList; - } - - public boolean isList() - { + public boolean isList() { return isList(this.isList); } - public boolean isList(String isList) - { + public boolean isList(String isList) { return isList != null && StringUtils.equals("1", isList); } - public void setIsQuery(String isQuery) - { - this.isQuery = isQuery; - } - - public String getIsQuery() - { - return isQuery; - } - - public boolean isQuery() - { + public boolean isQuery() { return isQuery(this.isQuery); } - public boolean isQuery(String isQuery) - { + public boolean isQuery(String isQuery) { return isQuery != null && StringUtils.equals("1", isQuery); } - public void setQueryType(String queryType) - { - this.queryType = queryType; - } - - public String getQueryType() - { - return queryType; - } - - public String getHtmlType() - { - return htmlType; - } - - public void setHtmlType(String htmlType) - { - this.htmlType = htmlType; - } - - public void setDictType(String dictType) - { - this.dictType = dictType; - } - - public String getDictType() - { - return dictType; - } - - public void setSort(Integer sort) - { - this.sort = sort; - } - - public Integer getSort() - { - return sort; - } - - public boolean isSuperColumn() - { + public boolean isSuperColumn() { return isSuperColumn(this.javaField); } - public static boolean isSuperColumn(String javaField) - { + public static boolean isSuperColumn(String javaField) { return StringUtils.equalsAnyIgnoreCase(javaField, // BaseEntity "createBy", "createTime", "updateBy", "updateTime", "remark", @@ -398,36 +158,28 @@ public class GenTableColumn extends BaseEntity "parentName", "parentId", "orderNum", "ancestors"); } - public boolean isUsableColumn() - { + public boolean isUsableColumn() { return isUsableColumn(javaField); } - public static boolean isUsableColumn(String javaField) - { + public static boolean isUsableColumn(String javaField) { // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单 return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); } - public String readConverterExp() - { + public String readConverterExp() { String remarks = StringUtils.substringBetween(this.columnComment, "(", ")"); StringBuffer sb = new StringBuffer(); - if (StringUtils.isNotEmpty(remarks)) - { - for (String value : remarks.split(" ")) - { - if (StringUtils.isNotEmpty(value)) - { + if (StringUtils.isNotEmpty(remarks)) { + for (String value : remarks.split(" ")) { + if (StringUtils.isNotEmpty(value)) { Object startStr = value.subSequence(0, 1); String endStr = value.substring(1); sb.append("").append(startStr).append("=").append(endStr).append(","); } } return sb.deleteCharAt(sb.length() - 1).toString(); - } - else - { + } else { return this.columnComment; } } diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/vo/GenTableVo.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/vo/GenTableVo.java new file mode 100644 index 0000000..de911eb --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/vo/GenTableVo.java @@ -0,0 +1,38 @@ +package com.ruoyi.generator.domain.vo; + +import java.util.List; + +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.generator.domain.GenJoinTable; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; + +import jakarta.validation.Valid; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Setter; + +/** + * 业务表 gen_table + * + * @author ruoyi + */ +@Data +@Setter +@EqualsAndHashCode(callSuper = true) +public class GenTableVo extends BaseEntity { + private static final long serialVersionUID = 1L; + + private GenTable table; + + private List columns; + + private List joins; + + @Valid + private List joinTables; + + @Valid + private List joinColumns; + +} \ No newline at end of file diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenJoinTableMapper.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenJoinTableMapper.java new file mode 100644 index 0000000..77797ac --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenJoinTableMapper.java @@ -0,0 +1,40 @@ +package com.ruoyi.generator.mapper; + +import java.util.List; + +import com.ruoyi.generator.domain.GenJoinTable; + +/** + * 代码生成关联字段Mapper接口 + * + * @author ruoyi + * @date 2025-02-19 + */ +public interface GenJoinTableMapper { + /** + * 查询代码生成关联字段列表 + * + * @param genJoinTable 代码生成关联字段 + * @return 代码生成关联字段集合 + */ + public List selectGenJoinTableList(GenJoinTable genJoinTable); + + /** + * 新增代码生成关联字段 + * + * @param genJoinTable 代码生成关联字段 + * @return 结果 + */ + public int insertGenJoinTable(GenJoinTable genJoinTable); + + /** + * 修改代码生成关联字段 + * + * @param genJoinTable 代码生成关联字段 + * @return 结果 + */ + public int updateGenJoinTable(GenJoinTable genJoinTable); + + public int deleteGenJoinTableByTableId(Long tableId); + +} diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenJoinTableServiceImpl.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenJoinTableServiceImpl.java new file mode 100644 index 0000000..c9c3039 --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenJoinTableServiceImpl.java @@ -0,0 +1,65 @@ +package com.ruoyi.generator.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.generator.domain.GenJoinTable; +import com.ruoyi.generator.mapper.GenJoinTableMapper; + +/** + * 代码生成关联字段Service业务层处理 + * + * @author ruoyi + * @date 2025-02-19 + */ +@Service +public class GenJoinTableServiceImpl implements IGenJoinTableService { + @Autowired + private GenJoinTableMapper genJoinTableMapper; + + /** + * 查询代码生成关联字段列表 + * + * @param genJoinTable 代码生成关联字段 + * @return 代码生成关联字段 + */ + @Override + public List selectGenJoinTableList(GenJoinTable genJoinTable) { + return genJoinTableMapper.selectGenJoinTableList(genJoinTable); + } + + /** + * 新增代码生成关联字段 + * + * @param genJoinTable 代码生成关联字段 + * @return 结果 + */ + @Override + public int insertGenJoinTable(GenJoinTable genJoinTable) { + genJoinTable.setCreateTime(DateUtils.getNowDate()); + return genJoinTableMapper.insertGenJoinTable(genJoinTable); + } + + /** + * 修改代码生成关联字段 + * + * @param genJoinTable 代码生成关联字段 + * @return 结果 + */ + @Override + public int updateGenJoinTable(GenJoinTable genJoinTable) { + genJoinTable.setUpdateTime(DateUtils.getNowDate()); + return genJoinTableMapper.updateGenJoinTable(genJoinTable); + } + + /** + * 根据tableId删除字段关联 + */ + public int deleteGenJoinTableByTableId(Long tableId){ + return genJoinTableMapper.deleteGenJoinTableByTableId(tableId); + } + +} diff --git a/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenJoinTableService.java b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenJoinTableService.java new file mode 100644 index 0000000..9aa3cfd --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenJoinTableService.java @@ -0,0 +1,42 @@ +package com.ruoyi.generator.service; + +import java.util.List; + +import com.ruoyi.generator.domain.GenJoinTable; + +/** + * 代码生成关联字段Service接口 + * + * @author ruoyi + * @date 2025-02-19 + */ +public interface IGenJoinTableService { + /** + * 查询代码生成关联字段列表 + * + * @param genJoinTable 代码生成关联字段 + * @return 代码生成关联字段集合 + */ + public List selectGenJoinTableList(GenJoinTable genJoinTable); + + /** + * 新增代码生成关联字段 + * + * @param genJoinTable 代码生成关联字段 + * @return 结果 + */ + public int insertGenJoinTable(GenJoinTable genJoinTable); + + /** + * 修改代码生成关联字段 + * + * @param genJoinTable 代码生成关联字段 + * @return 结果 + */ + public int updateGenJoinTable(GenJoinTable genJoinTable); + + /** + * 根据tableId删除字段关联 + */ + public int deleteGenJoinTableByTableId(Long tableId); +} diff --git a/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenJoinTableMapper.xml b/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenJoinTableMapper.xml new file mode 100644 index 0000000..5551915 --- /dev/null +++ b/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenJoinTableMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + select table_id, main_table_id, join_table_id, main_table_alias, join_table_alias, main_table_fk,join_table_fk,create_by, create_time, update_by, update_time from gen_join_table + + + + + + insert into gen_join_table + + table_id, + main_table_id, + join_table_id, + main_table_alias, + join_table_alias, + main_table_fk, + join_table_fk, + create_by, + create_time, + update_by, + update_time, + + + #{tableId}, + #{mainTableId}, + #{joinTableId}, + #{mainTableAlias}, + #{joinTableAlias}, + #{mainTableFk}, + #{joinTableFk}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update gen_join_table + + main_table_id = #{mainTableId}, + join_table_id = #{joinTableId}, + main_table_alias = #{mainTableAlias}, + join_table_alias = #{joinTableAlias}, + main_table_fk = #{mainTableFk}, + join_table_fk = #{joinTableFk}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where gen_join_table.table_id = #{tableId} and gen_join_table.join_table_id = #{joinTableId} + + + + + + delete from gen_join_table where table_id = #{tableId} + + \ No newline at end of file diff --git a/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml index fd8d2cd..39114ab 100644 --- a/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/ruoyi-models/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -61,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, have_sub_column,create_by, create_time, update_by, update_time, remark from gen_table + select table_id, table_name,table_alias, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, have_sub_column,create_by, create_time, update_by, update_time, remark from gen_table select table_name, table_comment, create_time, update_time from information_schema.tables where table_schema = (select database()) - AND table_name NOT LIKE 'qrtz\_%' AND table_name NOT LIKE 'gen\_%' + AND table_name NOT LIKE 'qrtz\_%' AND table_name NOT IN (select table_name from gen_table) AND lower(table_name) like lower(concat('%', #{tableName}, '%')) @@ -104,7 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"