瀏覽代碼

Merge branch 'master' of http://192.168.101.10:13000/boman/boman-framwork

sr 4 年之前
父節點
當前提交
b78fe403fd
共有 46 個文件被更改,包括 1202 次插入115 次删除
  1. 33 0
      boman-api/boman-api-gen/src/main/java/com/boman/gen/api/RemoteGenTableColumnService.java
  2. 9 2
      boman-api/boman-api-gen/src/main/java/com/boman/gen/api/RemoteGenTableService.java
  3. 25 0
      boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteDeptService.java
  4. 15 0
      boman-api/boman-api-system/src/main/java/com/boman/system/api/model/LoginUser.java
  5. 20 0
      boman-api/boman-domain/src/main/java/com.boman.domain/UserEnvConstant.java
  6. 5 0
      boman-common/boman-common-core/src/main/java/com/boman/common/core/constant/UserConstants.java
  7. 4 0
      boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/obj/ObjectUtils.java
  8. 2 0
      boman-common/boman-common-security/pom.xml
  9. 0 0
      boman-common/boman-common-security/src/main/java/com/boman/common/security/service/TokenService.java
  10. 55 0
      boman-jflows/pom.xml
  11. 13 0
      boman-jflows/src/main/java/com/boman/jflow/BomanJflowApplication.java
  12. 1 0
      boman-jflows/src/main/resources/application.properties
  13. 13 0
      boman-jflows/src/test/java/com/boman/jflow/BomanJflowApplicationTests.java
  14. 15 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/controller/GenController.java
  15. 9 1
      boman-modules/boman-gen/src/main/java/com/boman/gen/controller/GenTableColumnController.java
  16. 1 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/controller/MyController.java
  17. 63 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/controller/TableSqlController.java
  18. 20 6
      boman-modules/boman-gen/src/main/java/com/boman/gen/domain/GenTable.java
  19. 64 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/domain/GenTableColumn.java
  20. 51 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/domain/GenTableRelation.java
  21. 66 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/domain/TableSql.java
  22. 8 1
      boman-modules/boman-gen/src/main/java/com/boman/gen/mapper/GenTableColumnMapper.java
  23. 20 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/mapper/TableSqlMapper.java
  24. 40 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/service/GenTableColumnServiceImpl.java
  25. 40 2
      boman-modules/boman-gen/src/main/java/com/boman/gen/service/GenTableServiceImpl.java
  26. 8 1
      boman-modules/boman-gen/src/main/java/com/boman/gen/service/IGenTableColumnService.java
  27. 28 18
      boman-modules/boman-gen/src/main/java/com/boman/gen/service/IGenTableService.java
  28. 40 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/service/ITableSqlService.java
  29. 151 0
      boman-modules/boman-gen/src/main/java/com/boman/gen/service/TableSqlServiceImpl.java
  30. 31 6
      boman-modules/boman-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml
  31. 8 4
      boman-modules/boman-gen/src/main/resources/mapper/generator/GenTableMapper.xml
  32. 24 7
      boman-modules/boman-gen/src/main/resources/mapper/generator/GenTableRelationMapper.xml
  33. 61 0
      boman-modules/boman-gen/src/main/resources/mapper/generator/TableSqlMapper.xml
  34. 10 0
      boman-modules/boman-system/src/main/java/com/boman/system/controller/SysDeptController.java
  35. 9 0
      boman-web-core/src/main/java/com/boman/web/core/constant/MaskConstant.java
  36. 16 0
      boman-web-core/src/main/java/com/boman/web/core/controller/TableController.java
  37. 14 10
      boman-web-core/src/main/java/com/boman/web/core/domain/TableContext.java
  38. 6 9
      boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java
  39. 57 9
      boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java
  40. 40 7
      boman-web-core/src/main/java/com/boman/web/core/service/save/BaseSaveServiceImpl.java
  41. 4 10
      boman-web-core/src/main/java/com/boman/web/core/service/save/IBaseSaveService.java
  42. 1 1
      boman-web-core/src/main/java/com/boman/web/core/service/select/BaseSelectServiceImpl.java
  43. 9 11
      boman-web-core/src/main/java/com/boman/web/core/service/update/BaseUpdateServiceImpl.java
  44. 3 7
      boman-web-core/src/main/java/com/boman/web/core/service/update/IBaseUpdateService.java
  45. 87 0
      boman-web-core/src/main/java/com/boman/web/core/utils/ColumnUtils.java
  46. 3 3
      ruoyi-ui/src/views/system/table/index.vue

+ 33 - 0
boman-api/boman-api-gen/src/main/java/com/boman/gen/api/RemoteGenTableColumnService.java

@@ -0,0 +1,33 @@
+package com.boman.gen.api;
+
+import com.boman.common.core.constant.ServiceNameConstants;
+import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.gen.domain.GenTableColumn;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+/**
+ * 生成代码模块,远程调用入口,如需其他接口,在此添加
+ *
+ * @author shiqian
+ * @date 2021年04月06日 14:22
+ **/
+@FeignClient(contextId = "remoteGenTableColumnService", value = ServiceNameConstants.GEN_SERVICE)
+public interface RemoteGenTableColumnService {
+
+
+    /**
+     * 功能描述: 通过表名查找表对应的所有的列
+     *
+     * @param tableId tableId
+     * @return GenTable
+     */
+    @GetMapping(value = "/genTableColumn/{tableId}")
+    AjaxResult listColumnsByTableId(@PathVariable("tableId") Long tableId);
+
+    @GetMapping(value = "/pk/{columnId}")
+    GenTableColumn getById(@PathVariable("columnId") Long columnId);
+
+
+}

+ 9 - 2
boman-api/boman-api-gen/src/main/java/com/boman/gen/api/RemoteGenTableService.java

@@ -15,6 +15,15 @@ import org.springframework.web.bind.annotation.PathVariable;
 @FeignClient(contextId = "remoteGenTableService", value = ServiceNameConstants.GEN_SERVICE)
 public interface RemoteGenTableService {
 
+    /**
+     * 功能描述: 通过表名查找表对应的所有的列
+     *
+     * @param tableId tableId
+     * @return GenTable
+     */
+    @GetMapping(value = "/gen/tableId/{tableId}")
+    GenTable getByTableId(@PathVariable("tableId") Long tableId);
+
 
     /**
      * 功能描述: 通过表名查找表信息
@@ -24,6 +33,4 @@ public interface RemoteGenTableService {
      */
     @GetMapping(value = "/gen/table/{tableName}")
     GenTable getByTableName(@PathVariable("tableName") String tableName);
-
-
 }

+ 25 - 0
boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteDeptService.java

@@ -0,0 +1,25 @@
+package com.boman.system.api;
+
+import com.boman.common.core.constant.ServiceNameConstants;
+import com.boman.system.api.domain.SysDept;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+/**
+ * @author shiqian
+ * @date 2021年04月07日 10:31
+ **/
+@FeignClient(contextId = "remoteDeptService", value = ServiceNameConstants.SYSTEM_SERVICE)
+public interface RemoteDeptService {
+
+    /**
+     * 功能描述: 根据id查找
+     *
+     * @param id deptId
+     * @return com.boman.common.core.web.domain.AjaxResult
+     */
+    @GetMapping(value = "/dept/getById/{id}")
+    SysDept getById(@PathVariable("id") Long id);
+}
+

+ 15 - 0
boman-api/boman-api-system/src/main/java/com/boman/system/api/model/LoginUser.java

@@ -2,6 +2,8 @@ package com.boman.system.api.model;
 
 import java.io.Serializable;
 import java.util.Set;
+
+import com.alibaba.fastjson.JSONObject;
 import com.boman.system.api.domain.SysUser;
 
 /**
@@ -58,6 +60,11 @@ public class LoginUser implements Serializable
      */
     private SysUser sysUser;
 
+    /**
+     * 用户变量
+     */
+    private JSONObject userEnv;
+
     public String getToken()
     {
         return token;
@@ -147,4 +154,12 @@ public class LoginUser implements Serializable
     {
         this.sysUser = sysUser;
     }
+
+    public JSONObject getUserEnv() {
+        return userEnv;
+    }
+
+    public void setUserEnv(JSONObject userEnv) {
+        this.userEnv = userEnv;
+    }
 }

+ 20 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/UserEnvConstant.java

@@ -0,0 +1,20 @@
+package com.boman.domain;
+
+
+
+/**
+ * @author shiqian
+ * @date 2021年04月14日 09:46
+ **/
+public class UserEnvConstant {
+
+
+    public static String USER_ID = "user.id";
+    public static final String USERNAME = "user.name";
+    public static final String USER_DEPT_ID = "user.dept.id";
+    public static final String USER_DEPT_NAME = "user.dept.name";
+    public static final String USER_PARENT_DEPT_ID = "user.parent.dept.id";
+    public static final String USER_PARENT_DEPT_NAME = "user.parent.dept.name";
+
+
+}

+ 5 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/constant/UserConstants.java

@@ -75,4 +75,9 @@ public class UserConstants
     public static final int PASSWORD_MIN_LENGTH = 5;
 
     public static final int PASSWORD_MAX_LENGTH = 20;
+
+    /**
+     * 是自增
+     */
+    public static final String INCREMENT = "1";
 }

+ 4 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/obj/ObjectUtils.java

@@ -121,6 +121,10 @@ public class ObjectUtils {
         return input != null && !input.isEmpty();
     }
 
+    public static boolean isEmpty(JSONArray input){
+        return !isNotEmpty(input);
+    }
+
     /**
      * 功能描述: 暂且只做 string collection long 三种类型的校验
      *

+ 2 - 0
boman-common/boman-common-security/pom.xml

@@ -21,6 +21,8 @@
             <groupId>com.boman</groupId>
             <artifactId>boman-api-system</artifactId>
         </dependency>
+
+
         
         <!-- RuoYi Common Redis-->
         <dependency>

File diff suppressed because it is too large
+ 0 - 0
boman-common/boman-common-security/src/main/java/com/boman/common/security/service/TokenService.java


+ 55 - 0
boman-jflows/pom.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.4.4</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+	<groupId>com.boman</groupId>
+	<artifactId>boman-jflow</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>boman-jflow</name>
+	<description>Demo project for Spring Boot</description>
+	<properties>
+		<java.version>1.8</java.version>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+	<repositories>
+		<repository>
+			<id>spring-milestones</id>
+			<name>Spring Milestones</name>
+			<url>https://repo.spring.io/milestone</url>
+		</repository>
+	</repositories>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>spring-milestones</id>
+			<name>Spring Milestones</name>
+			<url>https://repo.spring.io/milestone</url>
+		</pluginRepository>
+	</pluginRepositories>
+
+</project>

+ 13 - 0
boman-jflows/src/main/java/com/boman/jflow/BomanJflowApplication.java

@@ -0,0 +1,13 @@
+package com.boman.jflow;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class BomanJflowApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(BomanJflowApplication.class, args);
+	}
+
+}

+ 1 - 0
boman-jflows/src/main/resources/application.properties

@@ -0,0 +1 @@
+

+ 13 - 0
boman-jflows/src/test/java/com/boman/jflow/BomanJflowApplicationTests.java

@@ -0,0 +1,13 @@
+package com.boman.jflow;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class BomanJflowApplicationTests {
+
+	@Test
+	void contextLoads() {
+	}
+
+}

+ 15 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/controller/GenController.java

@@ -106,6 +106,17 @@ public class GenController extends BaseController {
         return genTableService.selectGenTableByName(tableName);
     }
 
+    /**
+     * 功能描述: 根据表id查询表信息
+     *
+     * @param tableId tableId
+     * @return GenTable
+     */
+    @GetMapping(value = "/tableId/{tableId}")
+    public GenTable getByTableName(@PathVariable Long tableId) {
+        return genTableService.getByTableId(tableId);
+    }
+
     /**
      * 导入表结构(保存)
      */
@@ -216,6 +227,10 @@ public class GenController extends BaseController {
      */
     @PostMapping("/addTable")
     public AjaxResult add(@Validated @RequestBody GenTable genTable) {
+        if (UserConstants.NOT_UNIQUE.equals(genTableService.checkTableNameUnique(genTable)))
+        {
+            return AjaxResult.error("新增表名'" + genTable.getTableName() + "'失败,表名已存在");
+        }
         return genTableService.insertGenTable(genTable);
     }
 }

+ 9 - 1
boman-modules/boman-gen/src/main/java/com/boman/gen/controller/GenTableColumnController.java

@@ -67,7 +67,7 @@ public class GenTableColumnController extends BaseController {
     @DeleteMapping("/{columnIds}")
     public AjaxResult remove(@PathVariable String columnIds)
     {
-        return toAjax(genTableColumnService.deleteGenTableColumnByIds(columnIds));
+        return toAjax(genTableColumnService.deleteGenTableColumnByColumnIds(columnIds));
     }
 
     /**
@@ -79,4 +79,12 @@ public class GenTableColumnController extends BaseController {
         return AjaxResult.success(genTableColumnService.selectGenTableColumnListByTableId(tableId));
     }
 
+    /**
+     * 根据主键查找
+     */
+    @GetMapping(value = "/pk/{columnId}")
+    public GenTableColumn getById(@PathVariable Long columnId) {
+        return genTableColumnService.selectGenTableColumnListByColumnId(columnId);
+    }
+
 }

+ 1 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/controller/MyController.java

@@ -119,6 +119,7 @@ public class MyController extends BaseController {
             List<GenTableColumn> columnList = new ArrayList<>(16);
             for (GenTableColumn tableColumn : genTableColumns) {
                 if (table.getTableId().equals(tableColumn.getTableId())) {
+                    tableColumn.setTableName(table.getTableName());
                     columnList.add(tableColumn);
                 }
             }

+ 63 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/controller/TableSqlController.java

@@ -0,0 +1,63 @@
+package com.boman.gen.controller;
+
+import com.boman.common.core.web.controller.BaseController;
+import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.gen.domain.TableSql;
+import com.boman.gen.service.ITableSqlService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author tjf
+ * @Date: 2021/04/14/10:27
+ */
+@RequestMapping("/tableSql")
+@RestController
+public class TableSqlController extends BaseController {
+
+
+    @Autowired
+    private ITableSqlService tableSqlService;
+
+
+    /**
+     * @Description 新增建表sql语句
+     * @author tjf
+     * @Date 2021/3/24
+     */
+    @PostMapping
+    public AjaxResult add(@Validated @RequestBody TableSql tableSql) {
+        return tableSqlService.insertTableSql(tableSql);
+    }
+
+    /**
+     * @Description 刷新建表sql语句
+     * @author tjf
+     * @Date 2021/3/24
+     */
+    @PostMapping("/reload")
+    public AjaxResult reload(@Validated @RequestBody TableSql tableSql) {
+        return tableSqlService.reloadTableSql(tableSql);
+    }
+
+
+    /**
+     * 执行创建语句
+     * @param tableSql
+     * @return
+     */
+    @PostMapping("/implement")
+    public AjaxResult implementSql(@Validated @RequestBody TableSql tableSql) {
+        return tableSqlService.implementSql(tableSql);
+    }
+
+    /**
+     * 查询
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable Long id)
+    {
+        return tableSqlService.selectTableSqlByTableId(id);
+    }
+}

+ 20 - 6
boman-modules/boman-gen/src/main/java/com/boman/gen/domain/GenTable.java

@@ -35,30 +35,30 @@ public class GenTable extends BaseEntity
     private String subTableFkName;
 
     /** 实体类名称(首字母大写) */
-    @NotBlank(message = "实体类名称不能为空")
+    //@NotBlank(message = "实体类名称不能为空")
     private String className;
 
     /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
     private String tplCategory;
 
     /** 生成包路径 */
-    @NotBlank(message = "生成包路径不能为空")
+    //@NotBlank(message = "生成包路径不能为空")
     private String packageName;
 
     /** 生成模块名 */
-    @NotBlank(message = "生成模块名不能为空")
+    //@NotBlank(message = "生成模块名不能为空")
     private String moduleName;
 
     /** 生成业务名 */
-    @NotBlank(message = "生成业务名不能为空")
+    //@NotBlank(message = "生成业务名不能为空")
     private String businessName;
 
     /** 生成功能名 */
-    @NotBlank(message = "生成功能名不能为空")
+    //@NotBlank(message = "生成功能名不能为空")
     private String functionName;
 
     /** 生成作者 */
-    @NotBlank(message = "作者不能为空")
+    //@NotBlank(message = "作者不能为空")
     private String functionAuthor;
 
     /** 生成代码方式(0zip压缩包 1自定义路径) */
@@ -161,6 +161,20 @@ public class GenTable extends BaseEntity
     /** 上级菜单名称字段 */
     private String parentMenuName;
 
+
+    /**
+     * 对应表主键
+     */
+    private Long tablePrimaryKey;
+
+    public Long getTablePrimaryKey() {
+        return tablePrimaryKey;
+    }
+
+    public void setTablePrimaryKey(Long tablePrimaryKey) {
+        this.tablePrimaryKey = tablePrimaryKey;
+    }
+
     public String getRealTableName() {
         return realTableName;
     }

+ 64 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/domain/GenTableColumn.java

@@ -29,6 +29,9 @@ public class GenTableColumn extends BaseEntity
     /** 归属表编号 */
     private Long tableId;
 
+    /** 归属表名 数据库没有此字段*/
+    private String tableName;
+
     /** 列名称 */
     private String columnName;
 
@@ -110,6 +113,59 @@ public class GenTableColumn extends BaseEntity
      */
     private String numColumns;
 
+    /**
+     * 字段翻译器
+     */
+    private String fieldTranslator;
+
+    /**
+     * 扩展属性
+     */
+    private String extendedAttributes;
+
+    /**
+     *是否输入 Y是
+     */
+    private String isIn;
+
+    /**
+     * 是否显示 Y是
+     */
+    private String isOut;
+
+
+    public String getFieldTranslator() {
+        return fieldTranslator;
+    }
+
+    public void setFieldTranslator(String fieldTranslator) {
+        this.fieldTranslator = fieldTranslator;
+    }
+
+    public String getExtendedAttributes() {
+        return extendedAttributes;
+    }
+
+    public void setExtendedAttributes(String extendedAttributes) {
+        this.extendedAttributes = extendedAttributes;
+    }
+
+    public String getIsIn() {
+        return isIn;
+    }
+
+    public void setIsIn(String isIn) {
+        this.isIn = isIn;
+    }
+
+    public String getIsOut() {
+        return isOut;
+    }
+
+    public void setIsOut(String isOut) {
+        this.isOut = isOut;
+    }
+
     public String getMask() {
         return mask;
     }
@@ -476,4 +532,12 @@ public class GenTableColumn extends BaseEntity
     public void setHrChildren(List<GenTableColumn> hrChildren) {
         this.hrChildren = hrChildren;
     }
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
 }

+ 51 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/domain/GenTableRelation.java

@@ -34,6 +34,16 @@ public class GenTableRelation extends BaseEntity {
      */
     private Long relationType;
 
+    /**
+     * 内嵌查询
+     */
+    private Long embedEdit;
+
+    /**
+     * 显示条件
+     */
+    private String displayConditions;
+
     /**
      * 排序
      */
@@ -43,6 +53,47 @@ public class GenTableRelation extends BaseEntity {
      * 是否删除(Y是)
      */
     private String isDel;
+    /**
+     * 字段名称
+     */
+    private String columnName;
+
+    /**
+     * 表名称
+     */
+    private String tableName;
+
+    public String getColumnName() {
+        return columnName;
+    }
+
+    public void setColumnName(String columnName) {
+        this.columnName = columnName;
+    }
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public Long getEmbedEdit() {
+        return embedEdit;
+    }
+
+    public void setEmbedEdit(Long embedEdit) {
+        this.embedEdit = embedEdit;
+    }
+
+    public String getDisplayConditions() {
+        return displayConditions;
+    }
+
+    public void setDisplayConditions(String displayConditions) {
+        this.displayConditions = displayConditions;
+    }
 
     public Long getSort() {
         return sort;

+ 66 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/domain/TableSql.java

@@ -0,0 +1,66 @@
+package com.boman.gen.domain;
+
+import com.boman.common.core.web.domain.BaseEntity;
+
+/**
+ * @author tjf
+ * @Date: 2021/04/14/10:56
+ */
+public class TableSql extends BaseEntity {
+    private Long id;
+    private Long tableId;
+    private String createSql;
+    private String createLog;
+    private String isDel;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getTableId() {
+        return tableId;
+    }
+
+    public void setTableId(Long tableId) {
+        this.tableId = tableId;
+    }
+
+    public String getCreateSql() {
+        return createSql;
+    }
+
+    public void setCreateSql(String createSql) {
+        this.createSql = createSql;
+    }
+
+    public String getCreateLog() {
+        return createLog;
+    }
+
+    public void setCreateLog(String createLog) {
+        this.createLog = createLog;
+    }
+
+    public String getIsDel() {
+        return isDel;
+    }
+
+    public void setIsDel(String isDel) {
+        this.isDel = isDel;
+    }
+
+    @Override
+    public String toString() {
+        return "TableSql{" +
+                "id=" + id +
+                ", tableId=" + tableId +
+                ", createSql='" + createSql + '\'' +
+                ", createLog='" + createLog + '\'' +
+                ", isDel='" + isDel + '\'' +
+                '}';
+    }
+}

+ 8 - 1
boman-modules/boman-gen/src/main/java/com/boman/gen/mapper/GenTableColumnMapper.java

@@ -69,11 +69,18 @@ public interface GenTableColumnMapper
     /**
      * 批量删除业务字段
      * 
-     * @param ids 需要删除的数据ID
+     * @param ids 需要删除的数据ID 表id
      * @return 结果
      */
     public int deleteGenTableColumnByIds(Long[] ids);
 
+    /**
+     * 批量删除业务字段
+     * @param ids 字段id
+     * @return
+     */
+    public int deleteGenTableColumnByColumnIds(Long[] ids);
+
 
 
     /**校验column_name是否重复

+ 20 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/mapper/TableSqlMapper.java

@@ -0,0 +1,20 @@
+package com.boman.gen.mapper;
+
+import com.boman.gen.domain.TableSql;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author tjf
+ * @Date: 2021/04/14/10:46
+ */
+@Mapper
+public interface TableSqlMapper {
+
+    public int insertTableSql(TableSql tableSql);
+
+
+    public int updateTableSql(TableSql tableSql);
+
+
+    public TableSql selectTableSqlByTableId(Long id);
+}

+ 40 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/service/GenTableColumnServiceImpl.java

@@ -2,9 +2,12 @@ package com.boman.gen.service;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.locks.Condition;
 
 import com.boman.common.core.constant.UserConstants;
 import com.boman.common.core.utils.StringUtils;
+import com.boman.gen.domain.GenTable;
+import com.boman.gen.mapper.GenTableMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.boman.common.core.text.Convert;
@@ -20,6 +23,8 @@ import com.boman.gen.mapper.GenTableColumnMapper;
 public class GenTableColumnServiceImpl implements IGenTableColumnService {
     @Autowired
     private GenTableColumnMapper genTableColumnMapper;
+    @Autowired
+    private GenTableMapper genTableMapper;
 
     /**
      * 查询业务字段列表
@@ -76,9 +81,34 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
      */
     @Override
     public int updateGenTableColumn(GenTableColumn genTableColumn) {
+        isAk(genTableColumn);
         return genTableColumnMapper.updateGenTableColumn(genTableColumn);
     }
 
+    /**
+     * 判断对象是否设置显示和输入字段
+     * @param genTableColumn
+     */
+    public void isAk(GenTableColumn genTableColumn) {
+        //是否是输入
+        String isIn = genTableColumn.getIsIn();
+        //是否是显示
+        String isOut = genTableColumn.getIsOut();
+        GenTable genTable = new GenTable();
+        if (UserConstants.YES.equals(isIn)){
+            genTable.setTableId(genTableColumn.getTableId());
+            genTable.setAkColumn(genTableColumn.getColumnId());
+        }
+        if (UserConstants.YES.equals(isOut)){
+            genTable.setTableId(genTableColumn.getTableId());
+            genTable.setDkColumn(genTableColumn.getColumnId());
+        }
+        if (genTable.getTableId() != null){
+            genTableMapper.updateGenTable(genTable);
+        }
+    }
+
+
     /**
      * 删除业务字段对象
      *
@@ -90,6 +120,16 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
         return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
     }
 
+    /**
+     * 删除业务字段对象
+     * @param ids 字段id
+     * @return
+     */
+    @Override
+    public int deleteGenTableColumnByColumnIds(String ids) {
+        return genTableColumnMapper.deleteGenTableColumnByColumnIds(Convert.toLongArray(ids));
+    }
+
     /**
      * 校验column_name是否重复
      *

+ 40 - 2
boman-modules/boman-gen/src/main/java/com/boman/gen/service/GenTableServiceImpl.java

@@ -14,6 +14,8 @@ import java.util.zip.ZipOutputStream;
 import com.boman.common.core.constant.UserConstants;
 import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.gen.domain.TableSql;
+
 import com.boman.system.api.RemoteSysMenuService;
 import com.boman.system.api.domain.SysMenu;
 import org.apache.commons.io.IOUtils;
@@ -59,6 +61,9 @@ public class GenTableServiceImpl implements IGenTableService {
 
     @Autowired
     private RemoteSysMenuService remoteSysMenuService;
+
+    @Autowired
+    private TableSqlServiceImpl tableSqlService;
     /**
      * 查询业务信息
      *
@@ -72,6 +77,11 @@ public class GenTableServiceImpl implements IGenTableService {
         return genTable;
     }
 
+    @Override
+    public GenTable getByTableId(Long id) {
+        return genTableMapper.selectGenTableById(id);
+    }
+
     /**
      * 查询业务列表
      *
@@ -393,9 +403,17 @@ public class GenTableServiceImpl implements IGenTableService {
         //新增表成功的时候,新增字段公共字段
         int i = genTableMapper.insertGenTable(genTable);
         if (i > 0) {
-            insertCommonColumn(genTable.getTableId());
+            Long id = insertCommonColumn(genTable.getTableId());
+            if (id != -1){
+                genTable.setTablePrimaryKey(id);
+                genTableMapper.updateGenTable(genTable);
+            }
             //判断是否是菜单
             isMenu(genTable);
+            //新建表时新增建表语句
+            TableSql tableSql = new TableSql();
+            tableSql.setTableId(genTable.getTableId());
+            tableSqlService.insertTableSql(tableSql);
             return AjaxResult.success();
         }
         return AjaxResult.error();
@@ -406,7 +424,7 @@ public class GenTableServiceImpl implements IGenTableService {
      *
      * @param tableId
      */
-    public void insertCommonColumn(Long tableId) {
+    public Long insertCommonColumn(Long tableId) {
         GenTableColumn genTableColumnLog = new GenTableColumn();
         GenTableColumn genTableColumnBaseInfo = new GenTableColumn();
 
@@ -439,6 +457,7 @@ public class GenTableServiceImpl implements IGenTableService {
         genTableColumnMapper.insertGenTableColumn(genTableColumnBaseInfo);
 
 
+        Long columnId = -1L;
         String[] columnName = new String[]{"id", "create_by", "create_time", "update_by", "update_time", "is_del"};
         String[] columnComment = new String[]{"编号","创建者", "创建时间", "更新者", "更新时间", "是否删除"};
         String[] columnType = new String[]{"bigint(20)","varchar(64)", "datetime", "varchar(64)", "datetime", "char(1)"};
@@ -463,7 +482,12 @@ public class GenTableServiceImpl implements IGenTableService {
                 genTableColumn.setHrParentId(genTableColumnLog.getColumnId());
             }
             genTableColumnMapper.insertGenTableColumn(genTableColumn);
+            //获得id字段的id
+            if (i == 0){
+                 columnId = genTableColumn.getColumnId();
+            }
         }
+        return columnId;
     }
 
     /**
@@ -578,4 +602,18 @@ public class GenTableServiceImpl implements IGenTableService {
         }
         return genPath + File.separator + VelocityUtils.getFileName(template, table);
     }
+
+    /**
+     *校验表名称是否存在
+     * @param genTable
+     * @return
+     */
+    @Override
+    public String checkTableNameUnique(GenTable genTable){
+        List<GenTable> genTables = genTableMapper.selectGenTableList(genTable);
+        if (genTables.size() > 0){
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
 }

+ 8 - 1
boman-modules/boman-gen/src/main/java/com/boman/gen/service/IGenTableColumnService.java

@@ -52,11 +52,18 @@ public interface IGenTableColumnService
     /**
      * 删除业务字段信息
      * 
-     * @param ids 需要删除的数据ID
+     * @param ids 需要删除的数据ID 表id
      * @return 结果
      */
     public int deleteGenTableColumnByIds(String ids);
 
+    /**
+     * 删除字段
+     * @param ids 字段id
+     * @return
+     */
+    public int deleteGenTableColumnByColumnIds(String ids);
+
 
     /**
     *校验column_name是否重复

+ 28 - 18
boman-modules/boman-gen/src/main/java/com/boman/gen/service/IGenTableService.java

@@ -8,14 +8,13 @@ import com.boman.gen.domain.GenTable;
 
 /**
  * 业务 服务层
- * 
+ *
  * @author ruoyi
  */
-public interface IGenTableService
-{
+public interface IGenTableService {
     /**
      * 查询业务列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 业务集合
      */
@@ -23,7 +22,7 @@ public interface IGenTableService
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 数据库表集合
      */
@@ -31,7 +30,7 @@ public interface IGenTableService
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param tableNames 表名称组
      * @return 数据库表集合
      */
@@ -47,22 +46,30 @@ public interface IGenTableService
 
     /**
      * 查询所有表信息
-     * 
+     *
      * @return 表信息集合
      */
     public List<GenTable> selectGenTableAll();
 
     /**
      * 查询业务信息
-     * 
+     *
      * @param id 业务ID
      * @return 业务信息
      */
     public GenTable selectGenTableById(Long id);
 
+    /**
+     * 查询业务信息
+     *
+     * @param id 业务ID
+     * @return 业务信息
+     */
+    public GenTable getByTableId(Long id);
+
     /**
      * 修改业务
-     * 
+     *
      * @param genTable 业务信息
      * @return 结果
      */
@@ -70,7 +77,7 @@ public interface IGenTableService
 
     /**
      * 删除业务信息
-     * 
+     *
      * @param tableIds 需要删除的表数据ID
      * @return 结果
      */
@@ -78,14 +85,14 @@ public interface IGenTableService
 
     /**
      * 导入表结构
-     * 
+     *
      * @param tableList 导入表列表
      */
     public void importGenTable(List<GenTable> tableList);
 
     /**
      * 预览代码
-     * 
+     *
      * @param tableId 表编号
      * @return 预览数据列表
      */
@@ -93,7 +100,7 @@ public interface IGenTableService
 
     /**
      * 生成代码(下载方式)
-     * 
+     *
      * @param tableName 表名称
      * @return 数据
      */
@@ -101,7 +108,7 @@ public interface IGenTableService
 
     /**
      * 生成代码(自定义路径)
-     * 
+     *
      * @param tableName 表名称
      * @return 数据
      */
@@ -109,14 +116,14 @@ public interface IGenTableService
 
     /**
      * 同步数据库
-     * 
+     *
      * @param tableName 表名称
      */
     public void synchDb(String tableName);
 
     /**
      * 批量生成代码(下载方式)
-     * 
+     *
      * @param tableNames 表数组
      * @return 数据
      */
@@ -124,15 +131,18 @@ public interface IGenTableService
 
     /**
      * 修改保存参数校验
-     * 
+     *
      * @param genTable 业务信息
      */
     public void validateEdit(GenTable genTable);
 
     /**
      * 代码生成业务新增
+     *
      * @param genTable
      * @return
      */
     public AjaxResult insertGenTable(GenTable genTable);
-}
+
+    public String checkTableNameUnique(GenTable genTable);
+}

+ 40 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/service/ITableSqlService.java

@@ -0,0 +1,40 @@
+package com.boman.gen.service;
+
+import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.gen.domain.TableSql;
+
+/**
+ * @author tjf
+ * @Date: 2021/04/14/10:43
+ */
+public interface ITableSqlService {
+
+    /**
+     * 创建sql语句
+     * @param tableSql
+     * @return
+     */
+    public AjaxResult insertTableSql(TableSql tableSql);
+
+    /**
+     * 刷新建表语句
+     * @param tableSql
+     * @return
+     */
+    public AjaxResult reloadTableSql(TableSql tableSql);
+
+    /**
+     * 执行建表语句
+     * @param tableSql
+     * @return
+     */
+    public AjaxResult implementSql(TableSql tableSql);
+
+
+    /**
+     * 根据表id查询该表的建表语句
+     * @param id
+     * @return
+     */
+    public AjaxResult selectTableSqlByTableId(Long id);
+}

+ 151 - 0
boman-modules/boman-gen/src/main/java/com/boman/gen/service/TableSqlServiceImpl.java

@@ -0,0 +1,151 @@
+package com.boman.gen.service;
+
+import com.boman.common.core.constant.UserConstants;
+import com.boman.common.core.utils.DateUtils;
+import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.core.utils.StringUtils;
+import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.gen.domain.GenTable;
+import com.boman.gen.domain.GenTableColumn;
+import com.boman.gen.domain.TableSql;
+import com.boman.gen.mapper.GenTableColumnMapper;
+import com.boman.gen.mapper.GenTableMapper;
+import com.boman.gen.mapper.TableSqlMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author tjf
+ * @Date: 2021/04/14/10:43
+ */
+@Service
+public class TableSqlServiceImpl implements ITableSqlService {
+
+    @Autowired
+    private TableSqlMapper tableSqlMapper;
+
+    @Autowired
+    private GenTableColumnMapper genTableColumnMapper;
+
+    @Autowired
+    private GenTableMapper genTableMapper;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+
+    /**
+     * 创建sql语句
+     *
+     * @param tableSql
+     * @return
+     */
+    @Override
+    public AjaxResult insertTableSql(TableSql tableSql) {
+        Long tableId = tableSql.getTableId();
+        if (tableId == null) {
+            return AjaxResult.error("缺少表id");
+        }
+        GenTable genTable = genTableMapper.selectGenTableById(tableSql.getTableId());
+        String tableName = genTable.getTableName();
+        tableSql.setCreateSql(createSql(tableSql, tableName));
+        tableSql.setCreateBy(SecurityUtils.getUsername());
+        tableSql.setCreateLog(DateUtils.getNowDate() + SecurityUtils.getUsername() + " 创建表 " + tableName);
+        tableSqlMapper.insertTableSql(tableSql);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 刷新建表语句
+     *
+     * @param tableSql
+     * @return
+     */
+    @Override
+    public AjaxResult reloadTableSql(TableSql tableSql) {
+        GenTable genTable = genTableMapper.selectGenTableById(tableSql.getTableId());
+        String tableName = genTable.getTableName();
+        tableSql.setCreateSql(createSql(tableSql, tableName));
+        String createLog = tableSql.getCreateLog();
+        StringBuffer sb = new StringBuffer(createLog);
+        sb.append("\r\n").append(DateUtils.getNowDate() + SecurityUtils.getUsername() + "刷新创建语句");
+        tableSql.setCreateLog(sb.toString());
+        tableSql.setUpdateBy(SecurityUtils.getUsername());
+        tableSqlMapper.updateTableSql(tableSql);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 执行建表语句
+     *
+     * @param tableSql
+     * @return
+     */
+    @Override
+    public AjaxResult implementSql(TableSql tableSql) {
+        String createSql = tableSql.getCreateSql();
+        try {
+            jdbcTemplate.execute(createSql);
+        } catch (DataAccessException e) {
+            e.printStackTrace();
+            return AjaxResult.error("当前表已存在");
+        }
+        String createLog = tableSql.getCreateLog();
+        StringBuffer sb = new StringBuffer(createLog);
+        sb.append(DateUtils.getNowDate() + SecurityUtils.getUsername() +" 执行建表语句");
+        tableSqlMapper.updateTableSql(tableSql);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 查询建表SQL
+     * @param id
+     * @return
+     */
+    @Override
+    public AjaxResult selectTableSqlByTableId(Long id) {
+        TableSql tableSql = tableSqlMapper.selectTableSqlByTableId(id);
+        return AjaxResult.success(tableSql);
+    }
+
+
+    /**
+     * 生成建表语句
+     *
+     * @param tableSql
+     * @param tableName
+     * @return
+     */
+    private String createSql(TableSql tableSql, String tableName) {
+        //根据表id查询所有字段
+        List<GenTableColumn> genTableColumns = genTableColumnMapper.selectGenTableColumnListByTableId(tableSql.getTableId());
+        //定义主键id
+        String primaryKey = null;
+        //拼接建表语句
+        StringBuffer sb = new StringBuffer("create table if not exists ");
+        sb.append(tableName).append(" (\r\n");
+
+        for (GenTableColumn genTableColumn : genTableColumns) {
+            sb.append(genTableColumn.getColumnName()).append(" " + genTableColumn.getColumnType());
+            if (genTableColumn.getIsIncrement().equals(UserConstants.INCREMENT)) {
+                sb = genTableColumn.getDefaultValue() == null ? sb.append(" DEFAULT NULL AUTO_INCREMENT COMMENT ") : sb.append(" DEFAULT '" + genTableColumn.getDefaultValue() + "' AUTO_INCREMENT COMMENT '");
+            } else {
+                sb = genTableColumn.getDefaultValue() == null ? sb.append(" DEFAULT NULL COMMENT ") : sb.append(" DEFAULT '" + genTableColumn.getDefaultValue() + "' COMMENT '");
+            }
+            sb.append(genTableColumn.getColumnComment() + "'").append(",\r\n");
+            if (genTableColumn.getIsPk().equals(UserConstants.INCREMENT)) {
+                primaryKey = genTableColumn.getColumnName();
+            }
+        }
+        if (StringUtils.isNotBlank(primaryKey)) {
+            sb.append(" PRIMARY KEY (" + primaryKey + " ) USING BTREE\r\n");
+        }
+        sb.append(") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='" + tableName + "';");
+        return sb.toString();
+    }
+
+}

+ 31 - 6
boman-modules/boman-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml

@@ -33,10 +33,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="defaultValue"     column="default_value"    />
         <result property="numRows"     column="num_rows"    />
         <result property="numColumns"     column="num_columns"    />
+        <result property="fieldTranslator"     column="field_translator"    />
+        <result property="extendedAttributes"     column="extended_attributes"    />
+        <result property="isIn"     column="is_in"    />
+        <result property="isOut"     column="is_out"    />
     </resultMap>
 	
 	<sql id="selectGenTableColumnVo">
-        select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, foreign_key, dict_type, sort, create_by, create_time, update_by, update_time, hr_parent_id, mask, default_value, num_rows, num_columns from gen_table_column
+        select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, foreign_key, dict_type, sort, create_by, create_time, update_by, update_time, hr_parent_id, mask, default_value, num_rows, num_columns, field_translator, extended_attributes, is_in, is_out from gen_table_column
     </sql>
 	
     <select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
@@ -92,6 +96,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="defaultValue != null and defaultValue != ''">default_value,</if>
 			<if test="numRows != null and numRows != ''">num_rows,</if>
 			<if test="numColumns != null and numColumns != ''">num_columns,</if>
+			<if test="fieldTranslator != null and fieldTranslator != ''">field_translator,</if>
+			<if test="extendedAttributes != null and extendedAttributes != ''">extended_attributes,</if>
+			<if test="isIn != null and isIn != ''">is_in,</if>
+			<if test="isOut != null and isOut != ''">is_out,</if>
 			create_time
          )values(
 			<if test="tableId != null and tableId != ''">#{tableId},</if>
@@ -118,6 +126,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="defaultValue != null and defaultValue != ''">#{defaultValue},</if>
 			<if test="numRows != null and numRows != ''">#{numRows},</if>
 			<if test="numColumns != null and numColumns != ''">#{numColumns},</if>
+			<if test="fieldTranslator != null and fieldTranslator != ''">#{fieldTranslator},</if>
+			<if test="extendedAttributes != null and extendedAttributes != ''">#{extendedAttributes},</if>
+			<if test="isIn != null and isIn != ''">#{isIn},</if>
+			<if test="isOut != null and isOut != ''">#{isOut},</if>
 			sysdate()
          )
     </insert>
@@ -125,14 +137,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateGenTableColumn" parameterType="GenTableColumn">
         update gen_table_column
         <set>
-            <if test="tableId != null and tableId != ''">#{tableId},</if>
-            <if test="columnName != null and columnName != ''">#{columnName},</if>
+            <if test="tableId != null and tableId != ''">table_id = #{tableId},</if>
+            <if test="columnName != null and columnName != ''">column_name = #{columnName},</if>
             <if test="columnComment != null and columnComment != ''">column_comment = #{columnComment},</if>
-            <if test="columnType != null and columnType != ''">#{columnType},</if>
+            <if test="columnType != null and columnType != ''">column_type = #{columnType},</if>
             <if test="javaType != null and javaType != ''">java_type = #{javaType},</if>
             <if test="javaField != null and javaField != ''">java_field = #{javaField},</if>
-            <if test="isPk != null and isPk != ''">#{isPk},</if>
-            <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
+            <if test="isPk != null and isPk != ''">is_pk = #{isPk},</if>
+            <if test="isIncrement != null and isIncrement != ''">is_increment = #{isIncrement},</if>
             <if test="isRequired != null and isRequired != ''">is_required = #{isRequired},</if>
             <if test="isInsert != null and isInsert != ''">is_insert = #{isInsert},</if>
             <if test="isEdit != null and isEdit != ''">is_edit = #{isEdit},</if>
@@ -150,6 +162,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="defaultValue != null and defaultValue != ''">default_value = #{defaultValue},</if>
             <if test="numRows != null and numRows != ''">num_rows = #{numRows},</if>
             <if test="numColumns != null and numColumns != ''">num_columns = #{numColumns},</if>
+            <if test="fieldTranslator != null and fieldTranslator != ''">field_translator = #{fieldTranslator},</if>
+            <if test="extendedAttributes != null and extendedAttributes != ''">extended_attributes = #{extendedAttributes},</if>
+            <if test="isIn != null and isIn != ''">is_in = #{isIn},</if>
+            <if test="isOut != null and isOut != ''">is_out = #{isOut},</if>
             update_time = sysdate()
         </set>
         where column_id = #{columnId}
@@ -175,4 +191,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+
+
+    <delete id="deleteGenTableColumnByColumnIds" parameterType="Long">
+        delete from gen_table_column where column_id in
+        <foreach collection="array" item="columnId" open="(" separator="," close=")">
+            #{columnId}
+        </foreach>
+    </delete>
+
 </mapper>

+ 8 - 4
boman-modules/boman-gen/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="realTableName"         column="real_table_name"            />
 		<result property="filterConditions"         column="filter_conditions"            />
 		<result property="extendedAttributes"         column="extended_attributes"            />
+		<result property="tablePrimaryKey"         column="table_primary_key"            />
 		<collection  property="columns"  javaType="java.util.List"  resultMap="GenTableColumnResult" />
 	</resultMap>
 	
@@ -67,7 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	
 	<sql id="selectGenTableVo">
         select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options,
-         create_by, create_time, update_by, update_time, remark, is_menu, menu_role, ak_column, dk_column, trigger_create, trigger_retrieve, trigger_update, trigger_delete, trigger_submit, real_table_name, filter_conditions, extended_attributes from gen_table
+         create_by, create_time, update_by, update_time, remark, is_menu, menu_role, ak_column, dk_column, trigger_create, trigger_retrieve, trigger_update, trigger_delete, trigger_submit, real_table_name, filter_conditions, extended_attributes, table_primary_key from gen_table
     </sql>
     
     <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
@@ -126,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
-	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, t.is_menu, t.menu_role, t.ak_column, t.dk_column, t.trigger_create, t.trigger_retrieve, t.trigger_update, t.trigger_delete, t.trigger_submit, t.real_table_name, t.filter_conditions, t.extended_attributes,
+	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, t.is_menu, t.menu_role, t.ak_column, t.dk_column, t.trigger_create, t.trigger_retrieve, t.trigger_update, t.trigger_delete, t.trigger_submit, t.real_table_name, t.filter_conditions, t.extended_attributes, t.table_primary_key,
 			   c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
 		FROM gen_table t
 			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
@@ -134,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
-	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, t.is_menu, t.menu_role, t.ak_column, t.dk_column, t.trigger_create, t.trigger_retrieve, t.trigger_update, t.trigger_delete, t.trigger_submit, t.real_table_name, t.filter_conditions, t.extended_attributes
+	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, t.is_menu, t.menu_role, t.ak_column, t.dk_column, t.trigger_create, t.trigger_retrieve, t.trigger_update, t.trigger_delete, t.trigger_submit, t.real_table_name, t.filter_conditions, t.extended_attributes, t.table_primary_key,
 			   c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
 		FROM gen_table t
 			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
@@ -142,7 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
-	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, t.is_menu, t.menu_role, t.ak_column, t.dk_column, t.trigger_create, t.trigger_retrieve, t.trigger_update, t.trigger_delete, t.trigger_submit, t.real_table_name, t.filter_conditions, t.extended_attributes
+	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, t.is_menu, t.menu_role, t.ak_column, t.dk_column, t.trigger_create, t.trigger_retrieve, t.trigger_update, t.trigger_delete, t.trigger_submit, t.real_table_name, t.filter_conditions, t.extended_attributes, t.table_primary_key,
 			   c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
 		FROM gen_table t
 			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
@@ -175,6 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="realTableName != null and realTableName != ''">real_table_name,</if>
  			<if test="filterConditions != null and filterConditions != ''">filter_conditions,</if>
  			<if test="extendedAttributes != null and extendedAttributes != ''">extended_attributes,</if>
+ 			<if test="tablePrimaryKey != null and tablePrimaryKey != ''">table_primary_key,,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
 			create_time
          )values(
@@ -202,6 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="realTableName != null and realTableName != ''">#{realTableName},</if>
  			<if test="filterConditions != null and filterConditions != ''">#{filterConditions},</if>
  			<if test="extendedAttributes != null and extendedAttributes != ''">#{extendedAttributes},</if>
+ 			<if test="tablePrimaryKey != null and tablePrimaryKey != ''">#{tablePrimaryKey},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
 			sysdate()
          )
@@ -238,6 +241,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="realTableName != null and realTableName !=''">real_table_name = #{realTableName},</if>
 			<if test="filterConditions != null and filterConditions !=''">filter_conditions = #{filterConditions},</if>
 			<if test="extendedAttributes != null and extendedAttributes !=''">extended_attributes = #{extendedAttributes},</if>
+			<if test="tablePrimaryKey != null and tablePrimaryKey !=''">table_primary_key = #{tablePrimaryKey},</if>
             update_time = sysdate()
         </set>
         where table_id = #{tableId}

+ 24 - 7
boman-modules/boman-gen/src/main/resources/mapper/generator/GenTableRelationMapper.xml

@@ -10,21 +10,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="relationParentId"     column="relation_parent_id"      />
 		<result property="relationChildId"     column="relation_child_id"      />
 		<result property="relationType"     column="relation_type"      />
+		<result property="embedEdit"     column="embed_edit"      />
+		<result property="displayConditions"     column="display_conditions"      />
 		<result property="sort"     column="sort"      />
 		<result property="createBy"     column="create_by"      />
 		<result property="createTime"     column="create_time"      />
 		<result property="updateBy"     column="update_by"      />
 		<result property="updateTime"     column="update_time"      />
 		<result property="isDel"     column="is_del"      />
+		<result property="tableName"     column="table_name"      />
+		<result property="columnName"     column="column_name"      />
 	</resultMap>
 
 	<sql id="selectGenTableRelationVo">
-        select id, description, relation_parent_id, relation_child_id, relation_type, sort, create_by, create_time, update_by, update_time, is_del
+        select id, description, relation_parent_id, relation_child_id, relation_type, sort, embed_edit, display_conditions, create_by, create_time, update_by, update_time, is_del
 		from gen_table_relation
     </sql>
 
 	<select id="selectGenTableRelationList" parameterType="GenTableRelation" resultMap="GenTableRelationResult">
-		<include refid="selectGenTableRelationVo"/>
+		select r.id, r.description, r.relation_parent_id, r.relation_child_id, r.relation_type, r.sort, r.embed_edit, r.display_conditions, r.create_by, r.create_time, r.update_by, r.update_time, r.is_del,
+		t.table_name, c.column_name
+		from gen_table_relation r
+		left join gen_table t on t.table_id = r.relation_parent_id
+		left join gen_table_column c on c.column_id = r.relation_child_id
 		<where>
 			<if test="description != null and description != ''">
 				AND description like concat('%', #{description}, '%')
@@ -59,20 +67,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="relationParentId != null">relation_parent_id,</if>
 		<if test="relationChildId != null">relation_child_id,</if>
 		<if test="relationType != null">relation_type,</if>
+		<if test="embedEdit != null">embed_edit,</if>
+		<if test="displayConditions != null and displayConditions != ''">display_conditions,</if>
 		<if test="sort != null">sort,</if>
 		<if test="createBy != null and createBy != ''">create_by,</if>
 		<if test="updateBy != null and updateBy != ''">update_by,</if>
 		<if test="updateTime != null and updateTime != ''">update_time,</if>
+		<if test="isDel != null and isDel != ''">is_del,</if>
 		create_time
 		)values(
 		<if test="description != null and description != ''">#{description},</if>
 		<if test="relationParentId != null">#{relationParentId},</if>
 		<if test="relationChildId != null">#{relationChildId},</if>
 		<if test="relationType != null">#{relationType},</if>
+		<if test="embedEdit != null">#{embedEdit},</if>
+		<if test="displayConditions != null and displayConditions != ''">#{displayConditions},</if>
 		<if test="sort != null">#{sort},</if>
 		<if test="createBy != null and createBy != ''">#{createBy},</if>
 		<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
 		<if test="updateTime != null and updateTime != ''">#{updateTime},</if>
+		<if test="isDel != null and isDel != ''">#{isDel},</if>
 		sysdate()
 		)
 	</insert>
@@ -84,20 +98,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="relationParentId != null">relation_parent_id = #{relationParentId},</if>
 			<if test="relationChildId != null">relation_child_id = #{relationChildId},</if>
 			<if test="relationType != null">relation_type = #{relationType},</if>
+			<if test="embedEdit != null">embed_edit = #{embedEdit},</if>
+			<if test="displayConditions != null and displayConditions != ''">display_conditions = #{displayConditions},</if>
 			<if test="sort != null">sort = #{sort},</if>
 			<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
-			<if test="create_time != null">create_time = #{createTime},</if>
+			<if test="createTime != null ">create_time = #{createTime},</if>
 			<if test="updateBy != null and updateBy != null">update_by = #{updateBy},</if>
+			<if test="isDel != null and isDel != null">is_del = #{isDel},</if>
 			update_time = sysdate()
 		</set>
 		where id = #{id}
 	</update>
 
-	<update id="deleteGenTableRelation" parameterType="GenTableRelation">
-		update gen_table_relation
-		set is_del = '1' where id in
+	<delete id="deleteGenTableRelation" parameterType="GenTableRelation">
+		delete from gen_table_relation
+		where id in
 		<foreach item="ids" collection="array" open="(" separator="," close=")">
 			#{ids}
 		</foreach>
-	</update>
+	</delete>
 </mapper> 

+ 61 - 0
boman-modules/boman-gen/src/main/resources/mapper/generator/TableSqlMapper.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.boman.gen.mapper.TableSqlMapper">
+    
+    <resultMap type="TableSql" id="TableSqlResult">
+        <result property="id"       column="id"      />
+        <result property="tableId"           column="table_id"           />
+        <result property="createSql"           column="create_sql"           />
+        <result property="createLog"           column="create_log"           />
+        <result property="createBy"       column="create_by"      />
+        <result property="createTime"     column="create_time"    />
+        <result property="updateBy"       column="update_by"      />
+        <result property="updateTime"     column="update_time"    />
+        <result property="remark"     column="remark"    />
+        <result property="isDel"     column="is_del"    />
+	</resultMap>
+
+	
+	<sql id="selectTableSqlVo">
+        select id, table_id, create_sql, create_log, create_by, create_time, update_by, update_time, remark, is_del from table_sql
+    </sql>
+
+    <select id="selectTableSqlByTableId" parameterType="Long" resultMap="TableSqlResult">
+        <include refid="selectTableSqlVo"></include>
+        where table_id = #{id} limit 1
+    </select>
+    <insert id="insertTableSql" parameterType="TableSql" useGeneratedKeys="true" keyProperty="id">
+        insert into table_sql (
+			<if test="tableId != null and tableId != ''">table_id,</if>
+			<if test="createSql != null and createSql != ''">create_sql,</if>
+			<if test="createLog != null and createLog != ''">create_log,</if>
+			<if test="remark != null and remark != ''">remark,</if>
+			<if test="createBy != null and createBy != ''">create_by,</if>
+			create_time
+         )values(
+			<if test="tableId != null and tableId != ''">#{tableId},</if>
+			<if test="createSql != null and createSql != ''">#{createSql},</if>
+			<if test="createLog != null and createLog != ''">#{createLog},</if>
+			<if test="remark != null and remark != ''">#{remark},</if>
+			<if test="createBy != null and createBy != ''">#{createBy},</if>
+			sysdate()
+         )
+    </insert>
+
+
+    <update id="updateTableSql" parameterType="TableSql">
+        update table_sql
+        <set>
+            <if test="tableId != null">table_id = #{tableId},</if>
+            <if test="createSql != null and createSql != ''">create_sql = #{createSql},</if>
+            <if test="createLog != null and createLog != ''">create_log = #{createLog},</if>
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+            <if test="remark != null and remark != ''">remark = #{remark},</if>
+            <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
+            update_time = sysdate()
+        </set>
+        where id = #{id}
+    </update>
+</mapper>

+ 10 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysDeptController.java

@@ -78,6 +78,16 @@ public class SysDeptController extends BaseController
         return AjaxResult.success(deptService.selectDeptById(id));
     }
 
+    /**
+     * 根据部门编号获取详细信息
+     */
+    @PreAuthorize(hasPermi = "system:dept:query")
+    @GetMapping(value = "/getById/{id}")
+    public SysDept getById(@PathVariable("id") Long id)
+    {
+        return deptService.selectDeptById(id);
+    }
+
     /**
      * 获取部门下拉树列表
      */

+ 9 - 0
boman-web-core/src/main/java/com/boman/web/core/constant/MaskConstant.java

@@ -10,9 +10,18 @@ public class MaskConstant {
     /**  新增可修改  **/
     public static final String INSERT_CAN_EDIT = "1";
 
+    /**  新增可见  **/
+    public static final String INSERT_VISIBLE = "1";
+
     /**  修改可修改  **/
     public static final String UPDATE_CAN_EDIT = "1";
 
+    /**  修改可见  **/
+    public static final String UPDATE_VISIBLE = "1";
+
+    /**  列表可见  **/
+    public static final String LIST_VISIBLE = "1";
+
     /**  列表可修改  **/
     public static final String LIST_CAN_EDIT = "1";
 }

+ 16 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/TableController.java

@@ -1,6 +1,7 @@
 package com.boman.web.core.controller;
 
 import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.gen.domain.GenTable;
 import com.boman.web.core.domain.BaseTableSaveDTO;
 import com.boman.web.core.service.TableServiceCmdService;
 import io.swagger.annotations.ApiOperation;
@@ -39,5 +40,20 @@ public class TableController {
         return tableServiceCmdService.getByTableName(condition);
     }
 
+    /**
+     * 功能描述: 根据表名获取表信息、表字段和表字段对应的字典值
+     *                          {
+     *                              "tableId": 1
+     *                          }
+     *
+     * @param table table
+     * @return com.boman.common.core.web.domain.AjaxResult
+     */
+    @ApiOperation(value = "根据表名获取表单所有信息, 没有过滤")
+    @PostMapping("/listAllColumnsByTableId")
+    public AjaxResult listAllColumnsByTableId(@RequestBody GenTable table) {
+        return tableServiceCmdService.listAllColumnsByTableId(table);
+    }
+
 
 }

+ 14 - 10
boman-web-core/src/main/java/com/boman/web/core/domain/TableContext.java

@@ -14,8 +14,7 @@ import java.util.Map;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.ltZero;
 import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
-import static com.boman.web.core.constant.MaskConstant.INSERT_CAN_EDIT;
-import static com.boman.web.core.constant.MaskConstant.UPDATE_CAN_EDIT;
+import static com.boman.web.core.constant.MaskConstant.*;
 
 /**
  * @author shiqian
@@ -40,18 +39,21 @@ public class TableContext {
 
         RedisService redisService = SpringUtils.getBean(RedisService.class);
         GenTable table = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
-        requireNonNull(table, "redis中没有此表,表名: " + tableName);
-        context.setTable(table);
+        context.setTable(requireNonNull(table, "redis中没有此表,表名: " + tableName));
+
         List<GenTableColumn> columns = table.getColumns();
-        context.setColumns(table.getColumns());
+        context.setColumns(columns);
+
         String pkName = IdUtils.getPkName(columns);
         context.setPkName(pkName);
 
         JSONObject fixedData = requireNonNull(dto.getFixedData(), "fixedData is empty");
         context.setFixedData(fixedData);
+
         JSONObject commitData = new JSONObject();
         packCommitData(dto, context, columns, fixedData, commitData);
         context.setCommitData(commitData);
+
         return context;
 
     }
@@ -63,21 +65,23 @@ public class TableContext {
         for (GenTableColumn column : columns) {
             String[] maskArray = requireNonNull(column.getMask(), "mask is empty").split("");
             assert maskArray.length == 6;
+            // 新增可见 修改可见
+            String insertVisible = maskArray[0], updateVisible = maskArray[2];
             // 新增可修改 修改可修改
-            String insertVisible = maskArray[1], updateVisible = maskArray[3];
+            String insertCanEdit = maskArray[1], updateCanEdit = maskArray[3];
             for (Map.Entry<String, Object> entry : fixedData.entrySet()) {
                 if (column.getColumnName().equalsIgnoreCase(entry.getKey())) {
                     // 新增
                     if (isInsert) {
-                        // 新增可修改, 把新增的字段单独拿出来
-                        if (INSERT_CAN_EDIT.equals(insertVisible)) {
+                        // 新增可修改, 并且新增可见,把新增的字段单独拿出来
+                        if (INSERT_CAN_EDIT.equals(insertCanEdit) && INSERT_VISIBLE.equals(insertVisible)) {
                             commitData.put(entry.getKey(), entry.getValue());
                         } else {
                             // ignore
                         }
                     } else {
-                        // 编辑可修改
-                        if (UPDATE_CAN_EDIT.equals(updateVisible)) {
+                        // 编辑可修改, 并且编辑可见
+                        if (UPDATE_CAN_EDIT.equals(updateCanEdit) && UPDATE_VISIBLE.equals(updateVisible)) {
                             commitData.put(entry.getKey(), entry.getValue());
                         } else {
                             // ignore

+ 6 - 9
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java

@@ -508,16 +508,13 @@ public interface StandardlyMapper {
             wholeSql.append("select ");
             // showData
             StringBuilder showDataSql = new StringBuilder();
-            if (ObjectUtils.isNotEmpty(showData)) {
-                for (Object columnObj : showData) {
-                    String columnName = (String) columnObj;
-                    showDataSql.append(columnName).append(", ");
-                }
-                wholeSql.append(StringUtils.substringBeforeLast(showDataSql.toString(), ","));
-            } else {
-                showDataSql.append(" * ");
+            // 调用之前进行了判空,showData肯定不为空
+            for (Object columnObj : showData) {
+                String columnName = (String) columnObj;
+                showDataSql.append(columnName).append(", ");
             }
-
+            wholeSql.append(StringUtils.substringBeforeLast(showDataSql.toString(), ","));
+//
             wholeSql.append(showDataSql).append(" from ").append(tableName);
             // 条件
             packCondition(packCondition, wholeSql);

+ 57 - 9
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -11,6 +11,7 @@ import com.boman.common.core.web.domain.AjaxResult;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.domain.SysDictData;
+import com.boman.gen.api.RemoteGenTableColumnService;
 import com.boman.gen.api.RemoteGenTableService;
 import com.boman.gen.controller.MyController;
 import com.boman.gen.domain.GenTable;
@@ -18,6 +19,7 @@ import com.boman.gen.domain.GenTableColumn;
 import com.boman.gen.domain.GenTableRelation;
 import com.boman.system.api.RemoteDictDataService;
 import com.boman.web.core.constant.FormDataConstant;
+import com.boman.web.core.constant.MaskConstant;
 import com.boman.web.core.constant.SubmitConstant;
 import com.boman.web.core.domain.*;
 import com.boman.web.core.service.delete.IBaseDeleteService;
@@ -25,6 +27,7 @@ import com.boman.web.core.service.save.IBaseSaveService;
 import com.boman.web.core.service.select.IBaseSelectService;
 import com.boman.web.core.service.submit.IBaseSubmitService;
 import com.boman.web.core.service.update.IBaseUpdateService;
+import com.boman.web.core.utils.ColumnUtils;
 import com.boman.web.core.utils.IdUtils;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
@@ -44,6 +47,7 @@ import java.util.stream.Collectors;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.web.core.constant.FormDataConstant.*;
+import static com.boman.web.core.utils.ColumnUtils.*;
 
 /**
  * @author shiqian
@@ -71,6 +75,8 @@ public class TableServiceCmdService {
     private RemoteDictDataService remoteDictDataService;
     @Resource
     private RemoteGenTableService remoteGenTableService;
+    @Resource
+    private RemoteGenTableColumnService remoteGenTableColumnService;
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
 
@@ -124,14 +130,13 @@ public class TableServiceCmdService {
 
         TableContext context = TableContext.createContext(dto);
         // 拿到pkName和maxId
-        List<GenTableColumn> columns = context.getColumns();
         String pkName = context.getPkName();
         JSONObject commitData = context.getCommitData();
 
         // 新增
         if (ActionType.INSERT.equals(context.getActionType())) {
             Long maxId = IdUtils.getMaxId(dto.getTable(), pkName);
-            RowResult rowResult = saveService.insertRow(context.getTableName(), pkName, maxId, commitData, columns);
+            RowResult rowResult = saveService.insertRow(context, maxId);
             if (RowResult.checkSuccess(rowResult)) {
                 LOGGER.info("保存成功,封装到数据库的数据为: {}", JSON.toJSONString(rowResult.getData()));
             } else {
@@ -140,7 +145,7 @@ public class TableServiceCmdService {
             }
         } else {
             // 编辑
-            int effective = updateService.updateByIdList(context, pkName, Collections.singletonList(context.getId()), commitData, columns);
+            int effective = updateService.updateByIdList(context, Collections.singletonList(context.getId()));
             if (effective > 0) {
                 LOGGER.info("修改成功,封装到数据库的数据为: {}", JSON.toJSONString(commitData));
             } else {
@@ -226,8 +231,9 @@ public class TableServiceCmdService {
         List<GenTableColumn> columns = genTable.getColumns();
         // 封装好以后的查询条件
         JSONObject packCondition = ifNullSetEmpty(packColCondition(columns, condition));
-        // 需要返回到前台的列
-        JSONArray showData = ifNullSetEmpty(fixedData.getJSONArray(SHOW_DATA));
+        // 需要返回到前台的列, 需要判断是否是列表展示, 4为判断列表是否可见
+        JSONArray showData = filterData(columns, 4, fixedData.getJSONArray(SHOW_DATA), MaskConstant.LIST_VISIBLE::equals);
+
         JSONObject rows = new JSONObject();
         int total = selectService.countByCondition(genTable.getTableName(), condition, packCondition);
         rows.put(FormDataConstant.PAGE_TOTAL, total);
@@ -238,13 +244,52 @@ public class TableServiceCmdService {
 
         List<JSONObject> result = selectService.selectByCondition(genTable.getTableName(), condition, packCondition
                 , showData, dto.getOrderBy(), dto.getLimit(), dto.getOffset());
+        // 处理时间
         handlerDate(result, columns);
+        // 处理字典值
         handlerSysDictData(result, columns);
+        // 处理外键
+        handlerForeignKey(result, columns);
+        // 定制接口
         result = isCustomized(dto.getTable(),result,"trigger_retrieve");
+
         rows.put(FormDataConstant.PAGE_ROWS, result);
         return AjaxResult.success(rows);
     }
 
+    private void handlerForeignKey(List<JSONObject> result, List<GenTableColumn> columns) {
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(result)) {
+            return;
+        }
+
+        // 拿到所有有fk的列
+        columns = filter(columns, col -> ObjectUtils.isNotEmpty(col.getForeignKey()));
+        for (GenTableColumn column : columns) {
+            JSONObject jsonObject = new JSONObject();
+//            Long selfTableId = column.getTableId();
+            String selfColumnName = column.getColumnName();
+            for (JSONObject json : result) {
+                if (json.containsKey(selfColumnName)) {
+                    Object value = json.get(selfColumnName);
+
+                    Long fkColumnId = Long.parseLong(column.getForeignKey());
+                    GenTableColumn fkTableColumn = remoteGenTableColumnService.getById(fkColumnId);
+                    Long fkTableId = fkTableColumn.getTableId();
+                    GenTable fkGenTable = remoteGenTableService.getByTableId(fkTableId);
+                    String fkTableName= fkGenTable.getTableName();
+
+                    // select * from fkTableName where fkTableColumn.columnName = value;
+
+//                    jsonObject.put(columnName, "");
+//                    jsonObject.put("columnName", "");
+
+                }
+            }
+
+
+        }
+    }
+
     /**
      * 功能描述: 把timeStamp转为string
      *
@@ -361,7 +406,7 @@ public class TableServiceCmdService {
 
     /**
      * 功能描述: 封装成查询条件 key: 列名,  value:查询条件_查询类别
-     * eg: [{"config_name":"系统配置_like"}, {"config_name":"_like"}]
+     * eg: [{"config_name": ["系统配置", "EQ", "varchar(100)"]}]
      *
      * @param columns columns
      * @return com.alibaba.fastjson.JSONObject
@@ -498,9 +543,7 @@ public class TableServiceCmdService {
     public List<GenTableColumn> getTableHeadList(GenTable genTable){
         List<GenTableColumn> columns = genTable.getColumns();
         // 表头
-        return columns.stream()
-                .filter(genTableColumn -> GenTableColumn.IS_LIST.equals(genTableColumn.getIsList()))
-                .collect(Collectors.toList());
+        return filterData(columns, 4, MaskConstant.LIST_VISIBLE::equals);
     }
 
     /**
@@ -697,6 +740,8 @@ public class TableServiceCmdService {
         requireNonNull(condition.getIsUi(), "根据表名获取表字段,未传 isUi 这个字段");
         GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, condition.getTable());
         List<GenTableColumn> allColumns = genTable.getColumns();
+        // 把新增可见的列过滤出来
+//        List<GenTableColumn> returnData = ColumnUtils.filterNeedShowData(allColumns, 0, INSERT_VISIBLE::equals);
         // 普通的展示,不带折叠的
         if (BooleanUtils.isFalse(condition.getIsUi())) {
             packDictDataToColumns(allColumns, ObjectUtils::isNotEmpty);
@@ -741,5 +786,8 @@ public class TableServiceCmdService {
     }
 
 
+    public AjaxResult listAllColumnsByTableId(GenTable table) {
+        return remoteGenTableColumnService.listColumnsByTableId(table.getTableId());
+    }
 }
 

+ 40 - 7
boman-web-core/src/main/java/com/boman/web/core/service/save/BaseSaveServiceImpl.java

@@ -1,9 +1,15 @@
 package com.boman.web.core.service.save;
 
 import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.constant.CacheConstants;
+import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.core.utils.obj.ObjectUtils;
+import com.boman.common.redis.service.RedisService;
 import com.boman.gen.domain.GenTableColumn;
+import com.boman.system.api.model.LoginUser;
 import com.boman.web.core.constant.FormDataConstant;
 import com.boman.web.core.domain.RowResult;
+import com.boman.web.core.domain.TableContext;
 import com.boman.web.core.mapper.StandardlyMapper;
 import com.boman.web.core.utils.ColumnUtils;
 import org.slf4j.Logger;
@@ -26,26 +32,35 @@ public class BaseSaveServiceImpl implements IBaseSaveService {
 
     @Autowired
     private StandardlyMapper mapper;
+    @Autowired
+    private RedisService redisService;
 
     /**
      * 功能描述: 保存一行
      *
-     * @param tableName  tableName
-     * @param pkName     主键名称
-     * @param maxId      最大的SEQ
-     * @param commitData commitData
-     * @param columns    这是此表的所有字段属性名称,用来判断是否所有UPDATE_BY和UPDATE_TIME,和时间类型
+     * @param context context
+     * @param maxId   最大的SEQ
      * @return com.boman.system.common.RowResult
      */
     @Override
-    public RowResult insertRow(String tableName, String pkName, Long maxId, JSONObject commitData, List<GenTableColumn> columns) {
+    public RowResult insertRow(TableContext context, Long maxId) {
+        List<GenTableColumn> columns = context.getColumns();
+        JSONObject commitData = context.getCommitData();
+        String pkName = context.getPkName();
+        String tableName = context.getTableName();
         Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+        commitData.put(pkName.toUpperCase(), maxId);
+
         ColumnUtils.packUpdateByAndTime(columns, commitData, currentTime);
+        // 处理默认值
+        handlerDefaultValue(commitData, columns);
+
+        // 默认创建人和创建时间是都有的
         commitData.put(FormDataConstant.CREATE_TIME.toUpperCase(), currentTime);
         commitData.put(FormDataConstant.CREATE_BY.toUpperCase(), "张三");
-        commitData.put(pkName.toUpperCase(), maxId);
         int ret = mapper.insert(tableName, commitData);
         if (ret > 0) {
+            LOGGER.info("保存成功,保存的数据为:{}", commitData);
             commitData.put(FormDataConstant.SUCCESS_CNT, ret);
             return RowResult.ok("保存成功", commitData);
         }
@@ -53,4 +68,22 @@ public class BaseSaveServiceImpl implements IBaseSaveService {
         return RowResult.error("失败");
     }
 
+    private void handlerDefaultValue(JSONObject jsonObject, List<GenTableColumn> columns) {
+        String token = SecurityUtils.getToken();
+        LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
+        JSONObject userEnv = loginUser.getUserEnv();
+        for (GenTableColumn column : columns) {
+            // 有默认值的列, 并且前台传过来的key中不包含
+            if (ObjectUtils.isNotEmpty(column.getDefaultValue())
+                    && !jsonObject.containsKey(column.getColumnName().toLowerCase())
+                    && !jsonObject.containsKey(column.getColumnName().toUpperCase())) {
+                String dbDefaultValue = column.getDefaultValue();
+                String defaultValue = ColumnUtils.parseVariables(dbDefaultValue);
+                String variables = dbDefaultValue.equalsIgnoreCase(defaultValue) ? dbDefaultValue : userEnv.getString(defaultValue);
+                jsonObject.put(column.getColumnName(), variables);
+            }
+        }
+    }
+
+
 }

+ 4 - 10
boman-web-core/src/main/java/com/boman/web/core/service/save/IBaseSaveService.java

@@ -1,11 +1,8 @@
 package com.boman.web.core.service.save;
 
 
-import com.alibaba.fastjson.JSONObject;
-import com.boman.gen.domain.GenTableColumn;
 import com.boman.web.core.domain.RowResult;
-
-import java.util.List;
+import com.boman.web.core.domain.TableContext;
 
 /**
  * @author shiqian
@@ -18,13 +15,10 @@ public interface IBaseSaveService {
     /**
      * 功能描述: 保存一行
      *
-     * @param tableName  tableName
-     * @param pkName     主键名称
-     * @param maxId      最大的SEQ
-     * @param commitData commitData
-     * @param columns    这是此表的所有字段属性名称,用来判断是否所有UPDATE_BY和UPDATE_TIME,和时间类型
+     * @param context context
+     * @param maxId   最大的SEQ
      * @return com.boman.system.common.RowResult
      */
-    RowResult insertRow(String tableName, String pkName, Long maxId, JSONObject commitData, List<GenTableColumn> columns);
+    RowResult insertRow(TableContext context, Long maxId);
 
 }

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/service/select/BaseSelectServiceImpl.java

@@ -41,7 +41,7 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
     public List<JSONObject> selectByCondition(String tableName, JSONObject condition
             , JSONObject packCondition, JSONArray showData, String orderBy, Integer limit, Integer offset) {
         requireNonNull(tableName, "表名为空");
-//        requireNonNull(showData);
+        requireNonNull(showData, "数据库中此表: [" + tableName + "] , 没有列表展示的字段");
         requireNonNull(orderBy);
         return mapper.selectByCondition(tableName, condition, packCondition, showData, orderBy, limit, offset);
     }

+ 9 - 11
boman-web-core/src/main/java/com/boman/web/core/service/update/BaseUpdateServiceImpl.java

@@ -34,25 +34,23 @@ public class BaseUpdateServiceImpl implements IBaseUpdateService {
     /**
      * 功能描述: 批量修改, 默认需要更改的model,更改的字段类型和字段值都是一致的
      *
-     * @param context    用到其中的表名和所有的列(用来判断是否需要转义字符)
-     * @param pkName     主键名
-     * @param idList     idList
-     * @param commitData 需要更改的model, 已经转义好了,不需要到mapper层再去转义
-     * @param columns    这是此表的所有字段属性名称,用来判断是否所有UPDATE_BY和UPDATE_TIME,和时间类型
+     * @param context 用到其中的表名和所有的列(用来判断是否需要转义字符)
+     * @param idList  idList
      * @return int
      */
     @Override
-    public int updateByIdList(TableContext context, String pkName, List<Long> idList, JSONObject commitData, List<GenTableColumn> columns) {
-        requireNonNull(context.getTableName(), "表名为空");
-        requireNonNull(pkName, "主键名称为空");;
+    public int updateByIdList(TableContext context, List<Long> idList) {
+        String tableName = requireNonNull(context.getTableName(), "表名为空");
+        String pkName = requireNonNull(context.getPkName(), "主键名称为空");;
         requireNonNull(idList, "需要修改的idList为空");
-        requireNonNull(commitData, "需要更改的参数为空");
-
+        JSONObject commitData = requireNonNull(context.getCommitData(), "需要更改的参数为空");
+        List<GenTableColumn> columns = context.getColumns();
         Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+
         commitData = ObjectUtils.ifNullSetEmpty(escapeByQueryType(columns, commitData));
         ColumnUtils.packUpdateByAndTime(columns, commitData, currentTime);
 
-        return mapper.updateByIdList(context.getTableName(), pkName, idList, commitData);
+        return mapper.updateByIdList(tableName, pkName, idList, commitData);
     }
 
     private JSONObject escapeByQueryType(List<GenTableColumn> columns, JSONObject commitData) {

+ 3 - 7
boman-web-core/src/main/java/com/boman/web/core/service/update/IBaseUpdateService.java

@@ -1,7 +1,5 @@
 package com.boman.web.core.service.update;
 
-import com.alibaba.fastjson.JSONObject;
-import com.boman.gen.domain.GenTableColumn;
 import com.boman.web.core.domain.TableContext;
 
 import java.util.List;
@@ -15,11 +13,9 @@ public interface IBaseUpdateService {
     /**
      * 功能描述: 批量修改, 默认需要更改的model,更改的字段类型和字段值都是一致的
      *
-     * @param context    用到其中的表名和所有的列(用来判断是否需要转义字符)
-     * @param pkName     主键名
-     * @param idList     idList
-     * @param commitData 需要更改的model, 已经转义好了,不需要到mapper层再去转义
+     * @param context 用到其中的表名和所有的列(用来判断是否需要转义字符)
+     * @param idList  idList
      * @return int
      */
-    int updateByIdList(TableContext context, String pkName, List<Long> idList, JSONObject commitData, List<GenTableColumn> columns);
+    int updateByIdList(TableContext context, List<Long> idList);
 }

+ 87 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/ColumnUtils.java

@@ -1,11 +1,18 @@
 package com.boman.web.core.utils;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.boman.gen.domain.GenTableColumn;
 import com.boman.web.core.constant.FormDataConstant;
+import com.google.common.collect.Lists;
 
 import java.sql.Timestamp;
 import java.util.List;
+import java.util.function.Predicate;
+
+import static com.boman.common.core.utils.obj.ObjectUtils.isEmpty;
+import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
+import static com.boman.web.core.constant.FormDataConstant.HR;
 
 /**
  * @author shiqian
@@ -37,4 +44,84 @@ public class ColumnUtils {
             }
         }
     }
+
+    /**
+     * 功能描述: 把新增可见或者修改可见或者.....的列过滤出来
+     *
+     * @param allColumns 所有的列
+     * @param sort       那六个1的顺序 [1,1,1,1,1,1]
+     *                   sort=0  =>  新增可见
+     *                   sort=1  =>  新增可修改
+     *                   sort=2  =>  修改可见
+     *                   sort=3  =>  修改可修改
+     *                   sort=4  =>  列表可见
+     *                   sort=5  =>  列表可修改
+     * @return List<GenTableColumn>
+     */
+    public static List<GenTableColumn> filterData(List<GenTableColumn> allColumns, int sort, Predicate<String> predicate) {
+        assert sort < 6;
+        List<GenTableColumn> returnData = Lists.newArrayListWithCapacity(16);
+        for (GenTableColumn allColumn : allColumns) {
+            if (!HR.equalsIgnoreCase(allColumn.getHtmlType())) {
+                String[] maskArray = requireNonNull(allColumn.getMask(), "mask is empty").split("");
+                assert maskArray.length == 6;
+                // sort
+                String insertVisible = maskArray[sort];
+                if (predicate.test(insertVisible)) {
+                    returnData.add(allColumn);
+                }
+            }
+
+        }
+
+        return returnData;
+    }
+
+    /**
+     * 功能描述: 按照predicate的规则过滤allColumns中包含data并且符合过滤规则的数据
+     *
+     * @param allColumns 所有的列
+     * @param sort       同{@link ColumnUtils#filterData(java.util.List, int, java.util.function.Predicate)}
+     * @param data       从其中过滤符合规则的数据,data中字符串全部是大写的
+     * @param predicate  predicate
+     * @return JSONArray
+     */
+    public static JSONArray filterData(List<GenTableColumn> allColumns, int sort, JSONArray data, Predicate<String> predicate) {
+        assert sort < 6;
+        JSONArray returnData = new JSONArray(data.size());
+        boolean dataIsEmpty = isEmpty(data);
+        if (dataIsEmpty) {
+            // data为空,拿出所有列中列表可见的
+            for (GenTableColumn allColumn : allColumns) {
+                String columnName = allColumn.getColumnName().toUpperCase();
+                String[] maskArray = requireNonNull(allColumn.getMask(), "mask is empty").split("");
+                assert maskArray.length == 6;
+                String maskValue = maskArray[sort];
+                if (predicate.test(maskValue)) {
+                    returnData.add(columnName);
+                }
+            }
+        } else {
+            // data不为空,拿出前端传过来的列中可见的
+            for (GenTableColumn allColumn : allColumns) {
+                String columnName = allColumn.getColumnName().toUpperCase();
+                if (data.contains(columnName)) {
+                    String[] maskArray = requireNonNull(allColumn.getMask(), "mask is empty").split("");
+                    assert maskArray.length == 6;
+                    String maskValue = maskArray[sort];
+                    if (predicate.test(maskValue)) {
+                        returnData.add(columnName);
+                    }
+                }
+            }
+        }
+
+
+        return returnData;
+    }
+
+    public static String parseVariables(String variables) {
+        return variables.replaceAll("\\$", "");
+    }
+
 }

+ 3 - 3
ruoyi-ui/src/views/system/table/index.vue

@@ -107,12 +107,12 @@
          if(index == 'D'){
            //删除
            this.handleDelete(index)
-         }else if(index == 'S'){
+         }else if(index == 'S' || index == 'A'){
            //提交  保存
            this.forme.table = 'obj_test'
            this.forme.objId = -1
            this.forme.fixedData = this.queryParams
-           this.submitForm()
+           // this.submitForm()
          }else if(index == 'M'){
            this.forme.table = 'obj_test'
            this.forme.objId = 1
@@ -120,7 +120,7 @@
            this.submitForm()
          }
 
-        console.log(this.queryParams)
+        console.log(this.forme)
         // this.getList();
       },
       getList() {

Some files were not shown because too many files changed in this diff