Browse Source

ValueHolder 换成 AjaxResult

shiqian 4 years ago
parent
commit
367931c69f

+ 9 - 8
boman-modules/boman-system/src/main/java/com/boman/system/common/TableServiceCmdService.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
+import com.boman.common.core.web.domain.AjaxResult;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.gen.domain.GenTable;
@@ -56,7 +57,7 @@ public class TableServiceCmdService {
         return baseTableDTO;
     }
 
-    public final ValueHolder<RowResult> objectSave(BaseTableSaveDTO baseTableSaveDTO) {
+    public final AjaxResult objectSave(BaseTableSaveDTO baseTableSaveDTO) {
         BaseTableDTO baseTableDTO = packTableDTO(baseTableSaveDTO);
         TableServiceContext context = TableServiceContext.createFrom(baseTableDTO);
 //        BaseSaveService baseSaveService = SpringUtils.getBean(BaseSaveService.class);
@@ -72,7 +73,7 @@ public class TableServiceCmdService {
             LOGGER.error("保存失败,保持的原始数据为: {}", JSON.toJSONString(baseTableSaveDTO));
         }
 
-        return ValueHolder.ok(rowResult);
+        return AjaxResult.success(rowResult);
     }
 
     /**
@@ -81,7 +82,7 @@ public class TableServiceCmdService {
      * @param dto 前台传过来的dto
      * @return com.boman.system.common.ValueHolder
      */
-    public ValueHolder<RowResult> objectDelete(BaseTableSaveDTO dto) {
+    public AjaxResult objectDelete(BaseTableSaveDTO dto) {
         requireNonNull(dto.getTable());
         Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
         requiredNonNull(idArr);
@@ -92,7 +93,7 @@ public class TableServiceCmdService {
 
         RowResult rowResult = deleteService.objectDelete(idArr, dto.getTable(), requireNonNull(pkName));
         LOGGER.info(rowResult.getMessage() + ", id: {}", Arrays.toString(idArr));
-        return ValueHolder.ok(rowResult);
+        return AjaxResult.success(rowResult);
     }
 
 
@@ -102,7 +103,7 @@ public class TableServiceCmdService {
      * @param dto 前台传过来的dto
      * @return com.boman.system.common.ValueHolder
      */
-    public ValueHolder<RowResult> objectLogicDelete(BaseTableSaveDTO dto) {
+    public AjaxResult objectLogicDelete(BaseTableSaveDTO dto) {
         requireNonNull(dto.getTable());
         Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
         requiredNonNull(idArr);
@@ -117,7 +118,7 @@ public class TableServiceCmdService {
 
         RowResult rowResult = deleteService.objectLogicDelete(idArr, dto.getTable(), requireNonNull(pkName), jsonObject);
         LOGGER.info(rowResult.getMessage() + ", id: {}", Arrays.toString(idArr));
-        return ValueHolder.ok(rowResult);
+        return AjaxResult.success(rowResult);
     }
 
     /**
@@ -126,7 +127,7 @@ public class TableServiceCmdService {
      * @param dto condition
      * @return com.boman.system.common.ValueHolder
      */
-    public ValueHolder<List<JSONObject>> getObject(BaseTableSaveDTO dto) {
+    public AjaxResult getObject(BaseTableSaveDTO dto) {
         requireNonNull(dto.getTable());
 
         // 拿到每个字段对应的查询类型,=、 like、 >、 <
@@ -143,7 +144,7 @@ public class TableServiceCmdService {
         JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
         List<JSONObject> result = selectService.selectByCondition(genTable.getTableName(), condition, packCondition
                 , showData, dto.getOrderBy(), dto.getLimit(), dto.getOffset());
-        return ValueHolder.ok(result);
+        return AjaxResult.success(result);
     }
 
     /**

+ 6 - 10
boman-modules/boman-system/src/main/java/com/boman/system/controller/ObjController.java

@@ -1,10 +1,8 @@
 package com.boman.system.controller;
 
-import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.web.domain.AjaxResult;
 import com.boman.system.common.BaseTableSaveDTO;
-import com.boman.system.common.RowResult;
 import com.boman.system.common.TableServiceCmdService;
-import com.boman.system.common.ValueHolder;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -12,8 +10,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
-
 
 /**
  * @author shiqian
@@ -46,7 +42,7 @@ public class ObjController {
      */
     @ApiOperation(value = "单对象保存")
     @PostMapping("/objectSave")
-    public ValueHolder<RowResult> objectSave(@RequestBody BaseTableSaveDTO baseTableSaveDTO) {
+    public AjaxResult objectSave(@RequestBody BaseTableSaveDTO baseTableSaveDTO) {
         return tableServiceCmdService.objectSave(baseTableSaveDTO);
     }
 
@@ -67,7 +63,7 @@ public class ObjController {
      */
     @ApiOperation(value = "单对象删除")
     @PostMapping("/objectDelete")
-    public ValueHolder<RowResult> objectDelete(@RequestBody BaseTableSaveDTO baseTableSaveDTO) {
+    public AjaxResult objectDelete(@RequestBody BaseTableSaveDTO baseTableSaveDTO) {
         return tableServiceCmdService.objectDelete(baseTableSaveDTO);
     }
 
@@ -89,7 +85,7 @@ public class ObjController {
      */
     @ApiOperation(value = "单对象逻辑删除")
     @PostMapping("/objectLogicDelete")
-    public ValueHolder<RowResult> objectLogicDelete(@RequestBody BaseTableSaveDTO baseTableSaveDTO) {
+    public AjaxResult objectLogicDelete(@RequestBody BaseTableSaveDTO baseTableSaveDTO) {
         return tableServiceCmdService.objectLogicDelete(baseTableSaveDTO);
     }
 
@@ -116,14 +112,14 @@ public class ObjController {
      */
     @ApiOperation(value = "获取单表单数据")
     @PostMapping("/getObject")
-    public ValueHolder<List<JSONObject>> getObject(@RequestBody BaseTableSaveDTO condition) {
+    public AjaxResult getObject(@RequestBody BaseTableSaveDTO condition) {
         return tableServiceCmdService.getObject(condition);
     }
 
 
     @ApiOperation(value = "表单提交接口")
     @PostMapping("/objectSubmit")
-    public ValueHolder<List<JSONObject>> objectSubmit(@RequestBody BaseTableSaveDTO condition) {
+    public AjaxResult objectSubmit(@RequestBody BaseTableSaveDTO condition) {
         return tableServiceCmdService.getObject(condition);
     }