Blame view

src/main/java/com/objecteye/controller/BasicController.java 954 Bytes
e7ccccc1   Liu Haoyu   添加权限配置以及控制接口;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  package com.objecteye.controller;
  
  import com.alibaba.fastjson.JSONObject;
  import com.objecteye.common.CommonResult;
  import com.objecteye.entity.PageResult;
  
  public class BasicController {
  
      /**
       * jsonObject通用处理
       *
       * @param resultObj 返回参数
       * @return 结果集
       */
      CommonResult jsonObjectResultHandle(JSONObject resultObj) {
          if (resultObj.containsKey("error")) {
              return CommonResult.success(201, resultObj.getString("error"), null);
          }
          return CommonResult.success(resultObj);
      }
  
      /**
       * pageResult统一处理
       *
       * @param pageResult 返回参数
       * @return 结果集
       */
      CommonResult pageResultHandle(PageResult<?> pageResult) {
          if (pageResult.getRow().size() > 0) {
              return CommonResult.success(pageResult);
          } else {
              return CommonResult.success(201, "没有找到有效数据", null);
          }
      }
  }