|
@@ -0,0 +1,70 @@
|
|
|
|
+package com.steerinfo.dil.util;
|
|
|
|
+
|
|
|
|
+import com.steerinfo.framework.controller.BaseController;
|
|
|
|
+import com.steerinfo.framework.controller.RESTfulResult;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Author zhangnan
|
|
|
|
+ * @Date 2021/7/8 11:33
|
|
|
|
+ * @Version 1.0
|
|
|
|
+ */
|
|
|
|
+public class BaseRESTfulController extends BaseController {
|
|
|
|
+ public BaseRESTfulController() {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult success() {
|
|
|
|
+ RESTfulResult result = new RESTfulResult();
|
|
|
|
+ result.setSucceed();
|
|
|
|
+ result.setMessage(result.getResultMessage());
|
|
|
|
+ result.setData(true);
|
|
|
|
+ result.setCode("200");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult success(Object obj) {
|
|
|
|
+ RESTfulResult result = new RESTfulResult();
|
|
|
|
+ result.setSucceed();
|
|
|
|
+ result.setMessage(result.getResultMessage());
|
|
|
|
+ result.setData(obj);
|
|
|
|
+ result.setCode("200");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult success(Object obj, String msg) {
|
|
|
|
+ RESTfulResult result = this.success(obj);
|
|
|
|
+ result.setMessage(msg);
|
|
|
|
+ result.setCode("200");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult success(Object obj, String code, String msg) {
|
|
|
|
+ RESTfulResult result = this.success(obj, msg);
|
|
|
|
+ result.setCode(code);
|
|
|
|
+ result.setCode("200");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult failed() {
|
|
|
|
+ return this.failed((Object)null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult failed(Object obj) {
|
|
|
|
+ RESTfulResult result = new RESTfulResult("201", (String)null);
|
|
|
|
+ result.setMessage(result.getResultMessage());
|
|
|
|
+ result.setData(obj);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult failed(Object obj, String msg) {
|
|
|
|
+ RESTfulResult result = new RESTfulResult("201", msg);
|
|
|
|
+ result.setData(obj);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected RESTfulResult failed(Object obj, String code, String msg) {
|
|
|
|
+ RESTfulResult result = this.failed(obj, msg);
|
|
|
|
+ result = new RESTfulResult("201", msg);
|
|
|
|
+ result.setCode(code);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+}
|