|
@@ -6,6 +6,9 @@ import com.th.demo.model.system.ResultJSON;
|
6
|
6
|
import com.th.demo.model.system.Type;
|
7
|
7
|
import com.th.demo.service.maint.WareService;
|
8
|
8
|
import com.th.demo.tools.JSONTools;
|
|
9
|
+import org.activiti.rest.editor.model.ModelEditorJsonRestResource;
|
|
10
|
+import org.slf4j.Logger;
|
|
11
|
+import org.slf4j.LoggerFactory;
|
9
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
13
|
import org.springframework.web.bind.annotation.RequestMapping;
|
11
|
14
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
@@ -20,6 +23,7 @@ public class WareController {
|
20
|
23
|
@Autowired
|
21
|
24
|
public WareService wareService;
|
22
|
25
|
String result = Type.FAIL;
|
|
26
|
+ protected static final Logger logger = LoggerFactory.getLogger(ModelEditorJsonRestResource.class);
|
23
|
27
|
|
24
|
28
|
@RequestMapping(value = "/query.do")//查询方法 前两个参数是分页参数
|
25
|
29
|
public String query(int page,
|
|
@@ -98,5 +102,28 @@ public class WareController {
|
98
|
102
|
}
|
99
|
103
|
}
|
100
|
104
|
//
|
|
105
|
+ @RequestMapping(value = "/queryWare.do")
|
|
106
|
+ public String queryWare(HttpServletRequest request) {
|
|
107
|
+ String result = ""; // 初始化结果变量
|
|
108
|
+ try {
|
|
109
|
+ String userId = (String) request.getAttribute("userId");
|
|
110
|
+ String belongId = (String) request.getAttribute("belongId");
|
|
111
|
+
|
|
112
|
+ // 参数校验
|
|
113
|
+ if (userId == null || belongId == null) {
|
|
114
|
+ result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "用户ID或归属ID缺失");
|
|
115
|
+ return result;
|
|
116
|
+ }
|
|
117
|
+ // 调用服务并序列化结果
|
|
118
|
+
|
|
119
|
+ result = wareService.queryWare(userId,belongId);
|
101
|
120
|
|
|
121
|
+ } catch(Exception ex) { // 捕获业务异常
|
|
122
|
+ logger.error("业务逻辑异常", ex);
|
|
123
|
+ result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
|
|
124
|
+ } finally {
|
|
125
|
+ logger.info("业务逻辑正常");
|
|
126
|
+ return result;
|
|
127
|
+ }
|
|
128
|
+ }
|
102
|
129
|
}
|