Jelajahi Sumber

修改返回结构

gushoubang 2 bulan lalu
induk
melakukan
a716656d35

+ 53 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/JsgcghxkController.java

@@ -0,0 +1,53 @@
+package com.siwei.apply.controller;
+
+import com.siwei.apply.domain.Jsgcghxk;
+import com.siwei.apply.service.JsgcghxkService;
+import com.siwei.common.core.domain.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 建设工程规划许可 控制器
+ */
+@RestController
+@RequestMapping("/jsgcghxk")
+public class JsgcghxkController {
+
+    @Autowired
+    private JsgcghxkService jsgcghxkService;
+
+    @PostMapping("/add")
+    public R<Map> add(@RequestBody Jsgcghxk jsgcghxk) {
+        try {
+            String id = jsgcghxkService.add(jsgcghxk);
+            Map<String, String> map = new HashMap<>();
+            map.put("id", id);
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    @GetMapping("/get/{id}")
+    public R<Jsgcghxk> get(@PathVariable String id) {
+        try {
+            Jsgcghxk jsgcghxk = jsgcghxkService.get(id);
+            return R.ok(jsgcghxk);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    @PostMapping("/update")
+    public R<Void> update(@RequestBody Jsgcghxk jsgcghxk) {
+        try {
+            jsgcghxkService.update(jsgcghxk);
+            return R.ok();
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+}

+ 27 - 6
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/JsydghxkController.java

@@ -2,9 +2,13 @@ package com.siwei.apply.controller;
 
 import com.siwei.apply.domain.Jsydghxk;
 import com.siwei.apply.service.JsydghxkService;
+import com.siwei.common.core.domain.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 建设用地规划许可 控制器
  */
@@ -15,17 +19,34 @@ public class JsydghxkController {
     private JsydghxkService jsydghxkService;
 
     @PostMapping("/add")
-    public String add(@RequestBody Jsydghxk jsydghxk) {
-        return jsydghxkService.add(jsydghxk);
+    public R<Map> add(@RequestBody Jsydghxk jsydghxk) {
+        try {
+            String id = jsydghxkService.add(jsydghxk);
+            Map<String, String> map = new HashMap<>();
+            map.put("id", id);
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
     }
 
     @GetMapping("/get/{id}")
-    public Jsydghxk get(@PathVariable String id) {
-        return jsydghxkService.get(id);
+    public R<Jsydghxk> get(@PathVariable String id) {
+        try {
+            Jsydghxk jsydghxk = jsydghxkService.get(id);
+            return R.ok(jsydghxk);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
     }
 
     @PostMapping("/update")
-    public void update(@RequestBody Jsydghxk jsydghxk) {
-        jsydghxkService.update(jsydghxk);
+    public R<Void> update(@RequestBody Jsydghxk jsydghxk) {
+        try {
+            jsydghxkService.update(jsydghxk);
+            return R.ok();
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
     }
 }

+ 4 - 6
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/ProjectController.java

@@ -47,12 +47,10 @@ public class ProjectController extends BaseController {
      * @return
      */
     @GetMapping("/{id}")
-    public R<Map> Get(@PathVariable String id) {
+    public R<Project> Get(@PathVariable String id) {
         try {
-            Map<String, Object> map = new HashMap<>();
             Project project = projectService.get(id);
-            map.put("project", project);
-            return R.ok(map);
+            return R.ok(project);
         } catch (Exception e) {
             return R.fail(e.getMessage());
         }
@@ -80,7 +78,7 @@ public class ProjectController extends BaseController {
      * @return
      */
     @PutMapping("")
-    public R<Map> Update(@RequestBody ProjectUpdateVo projectUpdateVo) {
+    public R<Void> Update(@RequestBody ProjectUpdateVo projectUpdateVo) {
         try {
             projectService.update(projectUpdateVo);
             return R.ok();
@@ -96,7 +94,7 @@ public class ProjectController extends BaseController {
      * @return
      */
     @DeleteMapping("/{id}")
-    public R<Map> Delete(@PathVariable String id) {
+    public R<Void> Delete(@PathVariable String id) {
         try {
             projectService.delete(id);
             return R.ok();