|
|
@@ -0,0 +1,68 @@
|
|
|
+package cn.reghao.autodop.dmaster.app3.controller;
|
|
|
+
|
|
|
+import cn.reghao.autodop.common.result.WebResult;
|
|
|
+import cn.reghao.autodop.dmaster.app3.entity.App3;
|
|
|
+import cn.reghao.autodop.dmaster.app3.service.App3CrudService;
|
|
|
+import cn.reghao.autodop.common.utils.data.serializer.DefaultJsonSerializer;
|
|
|
+import cn.reghao.autodop.common.utils.data.serializer.JsonSerializer;
|
|
|
+import cn.reghao.autodop.common.utils.data.db.PageList;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author reghao
|
|
|
+ * @date 2019-11-15 08:44:50
|
|
|
+ */
|
|
|
+@Api(tags = "第三方应用 CRUD 接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/app3")
|
|
|
+public class App3CrudController {
|
|
|
+ private App3CrudService app3CrudService;
|
|
|
+ private JsonSerializer<App3> jsonSerializer = new DefaultJsonSerializer<>();
|
|
|
+
|
|
|
+ public App3CrudController(App3CrudService app3CrudService) {
|
|
|
+ this.app3CrudService = app3CrudService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ public String addApp3(@RequestBody String jsonData) {
|
|
|
+ App3 app3 = jsonSerializer.fromJson(jsonData, App3.class);
|
|
|
+ if (isArgsValid(app3)) {
|
|
|
+ app3CrudService.addOrModify(app3);
|
|
|
+ return WebResult.success("add done...");
|
|
|
+ }
|
|
|
+
|
|
|
+ return WebResult.fail("add failed...");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping
|
|
|
+ public String getApp3ByPage(@RequestParam("page") int page, @RequestParam("size") int size) {
|
|
|
+ if (page < 0 || size <0) {
|
|
|
+ return WebResult.fail("get failed...");
|
|
|
+ }
|
|
|
+
|
|
|
+ PageList<App3> list = app3CrudService.getByPage(page, size);
|
|
|
+ return WebResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ public String modifyApp3(@RequestBody String jsonData) {
|
|
|
+ App3 app3 = jsonSerializer.fromJson(jsonData, App3.class);
|
|
|
+ if (isArgsValid(app3)) {
|
|
|
+ app3CrudService.addOrModify(app3);
|
|
|
+ return WebResult.success("put done...");
|
|
|
+ }
|
|
|
+
|
|
|
+ return WebResult.fail("modify failed...");
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/{app3Name}")
|
|
|
+ public String deleteApp3(@PathVariable("app3Name") String app3Name) throws Exception {
|
|
|
+ app3CrudService.delete(app3Name);
|
|
|
+ return WebResult.success("delete done...");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isArgsValid(App3 app3) {
|
|
|
+ return app3.getApp3Name() != null && app3.getExecPath() != null;
|
|
|
+ }
|
|
|
+}
|