Bläddra i källkod

Merge branch 'boman-jflow/v1.0.0' of boman/boman-framwork into qianshan_data_bureau

gogs 4 år sedan
förälder
incheckning
ee3776c2a1

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

@@ -12,6 +12,11 @@ public class HttpStatus
      */
     public static final int SUCCESS = 200;
 
+
+    /**
+     * 操作成功
+     */
+    public static final int ZEROSUCCESS = 0;
     /**
      * 对象创建成功
      */

+ 12 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/web/domain/AjaxResult.java

@@ -115,6 +115,18 @@ public class AjaxResult extends HashMap<String, Object>
         return new AjaxResult(HttpStatus.SUCCESS, msg, data);
     }
 
+    /**
+     * 返回成功消息
+     *
+     * @param msg 返回内容
+     * @param data 数据对象
+     * @return 成功消息
+     */
+    public static AjaxResult successZero( Object data)
+    {
+        return new AjaxResult(HttpStatus.ZEROSUCCESS, "", data);
+    }
+
     /**
      * 返回错误消息
      * 

+ 105 - 86
boman-web-core/src/main/java/com/boman/web/core/controller/ObjController.java

@@ -25,17 +25,17 @@ public class ObjController {
 
     /**
      * 功能描述: 通用保存接口
-     *                {
-     *                    "objId": 1,
-     *                    "table": "sys_config",
-     *                    "fixedData": {
-     *                        "CONFIG_NAME": "测试config_name",
-     *                        "CONFIG_KEY": "测试config_key",
-     *                        "CONFIG_VALUE": "测试config_value",
-     *                        "CONFIG_TYPE": "Y",
-     *                        "REMARK": "测试remark"
-     *                    }
-     *                }
+     * {
+     * "objId": 1,
+     * "table": "sys_config",
+     * "fixedData": {
+     * "CONFIG_NAME": "测试config_name",
+     * "CONFIG_KEY": "测试config_key",
+     * "CONFIG_VALUE": "测试config_value",
+     * "CONFIG_TYPE": "Y",
+     * "REMARK": "测试remark"
+     * }
+     * }
      *
      * @param formDataDto 前台传过来的dto
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -48,15 +48,13 @@ public class ObjController {
 
     /**
      * 功能描述: 通用删除接口 (真的删除)
-     *               eg:  {
-     *                         "table": "sys_config",
-     *                         "idList": [
-     *                             141,
-     *                             142
-     *                         ]
-     *                     }
-     *
-     *
+     * eg:  {
+     * "table": "sys_config",
+     * "idList": [
+     * 141,
+     * 142
+     * ]
+     * }
      *
      * @param formDataDto 前台传过来的dto
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -69,16 +67,16 @@ public class ObjController {
 
     /**
      * 功能描述: 通用删除接口 (逻辑删除)
-     *
-     *                    eg:{
-     *                           "table": "sys_config",
-     *                           "logicDelName": "CONFIG_KEY",
-     *                           "logicDelValue": "我被修改了吧",
-     *                           "idList": [
-     *                               141,
-     *                               142
-     *                           ]
-     *                       }
+     * <p>
+     * eg:{
+     * "table": "sys_config",
+     * "logicDelName": "CONFIG_KEY",
+     * "logicDelValue": "我被修改了吧",
+     * "idList": [
+     * 141,
+     * 142
+     * ]
+     * }
      *
      * @param formDataDto 前台传过来的dto
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -91,12 +89,13 @@ public class ObjController {
 
     /**
      * 功能描述: 获取单表单数据 默认查所有字段
-     *                    eg:{
-     *                          "table": "sys_config",
-     *                          "fixedData": {
-     *                              "id": 20
-     *                            }
-     *                        }
+     * eg:{
+     * "table": "sys_config",
+     * "fixedData": {
+     * "id": 20
+     * }
+     * }
+     *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult
      */
@@ -106,24 +105,45 @@ public class ObjController {
         return tableServiceCmdService.getObject(condition);
     }
 
+
+    /**
+     * 功能描述: 获取单表单数据 默认查所有字段
+     * eg:{
+     * "table": "sys_config",
+     * "fixedData": {
+     * "id": 20
+     * }
+     * }
+     *
+     * @param condition condition
+     * @return com.boman.common.core.web.domain.AjaxResult
+     */
+    @ApiOperation(value = "获取单表单数据")
+    @PostMapping("/getObjectAllColumns")
+    public AjaxResult getObjectAllColumns(@RequestBody FormDataDto condition) {
+        return tableServiceCmdService.getObjectAllColumns(condition);
+    }
+
+
     /**
      * 功能描述: 获取表单列表数据
-     *                    eg:{
-     *                          "table": "sys_config",
-     *                          "limit": 0,
-     *                          "offset": 10,
-     *                          "orderBy": "create_time asc",
-     *                          "fixedData": {
-     *                              "condition": {
-     *                                  "CONFIG_NAME": "主框架",
-     *                                  "CONFIG_VALUE": "skin-blue",
-     *                                  "CREATE_TIME": ["2017-01-01", "2019-02-02"]
-     *                              },
-     *                              "showData": [
-     *                                  "CONFIG_ID", "CONFIG_NAME", "CONFIG_VALUE"
-     *                              ]
-     *                            }
-     *                        }
+     * eg:{
+     * "table": "sys_config",
+     * "limit": 0,
+     * "offset": 10,
+     * "orderBy": "create_time asc",
+     * "fixedData": {
+     * "condition": {
+     * "CONFIG_NAME": "主框架",
+     * "CONFIG_VALUE": "skin-blue",
+     * "CREATE_TIME": ["2017-01-01", "2019-02-02"]
+     * },
+     * "showData": [
+     * "CONFIG_ID", "CONFIG_NAME", "CONFIG_VALUE"
+     * ]
+     * }
+     * }
+     *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult
      */
@@ -136,10 +156,10 @@ public class ObjController {
     /**
      * 功能描述: 获取表单查询字段、按钮、表头
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     *
-     *                    eg:{
-     *                          "table": "sys_config"
-     *                        }
+     * <p>
+     * eg:{
+     * "table": "sys_config"
+     * }
      *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -153,10 +173,10 @@ public class ObjController {
     /**
      * 功能描述: 获取表单查询字段
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     *
-     *                    eg:{
-     *                          "table": "sys_config"
-     *                        }
+     * <p>
+     * eg:{
+     * "table": "sys_config"
+     * }
      *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -189,10 +209,10 @@ public class ObjController {
     /**
      * 功能描述: 获取表单按钮
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     *
-     *                    eg:{
-     *                          "table": "sys_config"
-     *                        }
+     * <p>
+     * eg:{
+     * "table": "sys_config"
+     * }
      *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -200,7 +220,7 @@ public class ObjController {
     @ApiOperation(value = "获取表单按钮")
     @PostMapping("/getButton")
     public AjaxResult getButton(@RequestBody FormDataDto condition) {
-        return AjaxResult.success( tableServiceCmdService.getButton(condition.getTable()));
+        return AjaxResult.success(tableServiceCmdService.getButton(condition.getTable()));
     }
 
     /**
@@ -217,16 +237,16 @@ public class ObjController {
 
     /**
      * 功能描述: 表单提交接口, 更改的字段类型和字段值都是一致的
-     *              {
-     *                  "table": "sys_test",
-     *                  "commitData": [
-     *                      {
-     *                          "id": 1,
-     *                          "status": "2",
-     *                          "remark": "提交了吧"
-     *                      }
-     *                  ]
-     *              }
+     * {
+     * "table": "sys_test",
+     * "commitData": [
+     * {
+     * "id": 1,
+     * "status": "2",
+     * "remark": "提交了吧"
+     * }
+     * ]
+     * }
      *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult
@@ -240,17 +260,16 @@ public class ObjController {
 
     /**
      * 功能描述: 反提交接口, 更改的字段类型和字段值都是一致的
-     *                {
-     *                    "table": "sys_config",
-     *                    "fixedData": {
-     *                        "idList": [
-     *                            3
-     *                        ],
-     *                        "status": "1",
-     *                        "remark": "理由不够充分"
-     *                    }
-     *                }
-     *
+     * {
+     * "table": "sys_config",
+     * "fixedData": {
+     * "idList": [
+     * 3
+     * ],
+     * "status": "1",
+     * "remark": "理由不够充分"
+     * }
+     * }
      *
      * @param condition condition
      * @return com.boman.common.core.web.domain.AjaxResult

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

@@ -113,7 +113,7 @@ public class TableServiceCmdService {
             RowResult rowResult = saveService.insertRow(context, maxId);
             if (RowResult.checkSuccess(rowResult)) {
                 LOGGER.info("保存成功,封装到数据库的数据为: {}", JSON.toJSONString(rowResult.getData()));
-                 result = AjaxResult.success(maxId);
+                result = AjaxResult.success(maxId);
             } else {
                 LOGGER.error("保存失败,保持的原始数据为: {}", JSON.toJSONString(dto));
                 result = AjaxResult.error();
@@ -359,7 +359,7 @@ public class TableServiceCmdService {
         }
 
         //给基本属性和日志信息添加上cssClass
-        if (StringUtils.isNotBlank(cssClass)){
+        if (StringUtils.isNotBlank(cssClass)) {
             for (GenTableColumn parentColumn : parentColumns) {
                 parentColumn.setCssClass(cssClass);
             }
@@ -368,23 +368,69 @@ public class TableServiceCmdService {
         result.put(SHOW_DATA, removeHr(parentColumns));
         result.put(BUTTON_LIST, getButton(tableName));
         Integer tableColumn = genTable.getTableColumn();
-        if (tableColumn != null){
+        if (tableColumn != null) {
             result.put(TABLE_COLUMN, tableColumn);
         }
         return AjaxResult.success(result);
     }
 
+
+    /**
+     * 功能描述: 获取单表单所有数据
+     *
+     * @param dto condition
+     * @return com.boman.common.core.web.domain.AjaxResult
+     */
+    public AjaxResult getObjectAllColumns(FormDataDto dto) {
+
+        GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
+
+        JSONObject jsonObject = selectService.selectById(dto.getTable(), IdUtils.getPkName(genTable.getColumns()), dto.getObjId());
+        List<GenTableColumn> columns = genTable.getColumns();
+        JSONArray addcolums = new JSONArray();
+
+        for (GenTableColumn column : columns) {
+            JSONObject jo = new JSONObject();
+
+            jo.put("col", column.getId());
+            jo.put("colid", column.getId());
+            jo.put("colname", column.getColumnName());
+            jo.put("datelimit", "all");
+            jo.put("display", "text");
+            if (column.getIsRequired() != null && Integer.parseInt(column.getIsRequired()) == 1) {
+                jo.put("isnotnull", true);
+            }
+            jo.put("name", column.getColumnComment());
+            jo.put("readonly", false);
+            jo.put("type", "STRING");
+            jo.put("valuedata", jsonObject.get(column.getColumnName()));
+            addcolums.add(jo);
+        }
+        JSONObject result = new JSONObject();
+        result.put("childs", addcolums);
+        result.put("size",columns.size());
+
+        JSONArray adc = new JSONArray();
+        adc.add(result);
+        JSONObject jo = new JSONObject();
+        jo.put("addcolums", adc);
+        return AjaxResult.successZero(jo);
+
+    }
+
+
     /**
      * 判断hr字段里面是否有值
+     *
      * @param parentColumns
      * @return
      */
-    private List<GenTableColumn> removeHr(List<GenTableColumn> parentColumns){
+    private List<GenTableColumn> removeHr(List<GenTableColumn> parentColumns) {
         Iterator<GenTableColumn> iterator = parentColumns.iterator();
-        while (iterator.hasNext()){
+        while (iterator.hasNext()) {
             GenTableColumn next = iterator.next();
             List<GenTableColumn> hrChildren = next.getHrChildren();
-            if (hrChildren.size() == 0){
+            if (hrChildren.size() == 0) {
                 iterator.remove();
             }
         }
@@ -683,7 +729,7 @@ public class TableServiceCmdService {
      * 功能描述: 根据表名封装列的对应关系, 同时封装好字典值
      *
      * @param genTable genTable
-     * @param isUi       带折叠true, 不带折叠false
+     * @param isUi     带折叠true, 不带折叠false
      * @return com.boman.common.core.web.domain.AjaxResult
      */
     public AjaxResult getByTableName(GenTable genTable, Boolean isUi) {
@@ -720,8 +766,8 @@ public class TableServiceCmdService {
         result.put(SHOW_DATA, resultCols);
         result.put(RULES, packRequireColumn(insertVisibleColumns));
         Integer tableColumn = genTable.getTableColumn();
-        if (tableColumn != null){
-            result.put(TABLE_COLUMN,tableColumn);
+        if (tableColumn != null) {
+            result.put(TABLE_COLUMN, tableColumn);
         }
         return AjaxResult.success(result);
     }