|
@@ -0,0 +1,59 @@
|
|
|
+package com.bosshand.virgo.api.controller;
|
|
|
+
|
|
|
+import com.bosshand.virgo.api.model.Encoding;
|
|
|
+import com.bosshand.virgo.api.model.EncodingGenerator;
|
|
|
+import com.bosshand.virgo.api.service.EncodingGeneratorService;
|
|
|
+import com.bosshand.virgo.core.response.Response;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("encodingGenerator")
|
|
|
+@Api(tags = {"编码生成器"})
|
|
|
+public class EncodingGeneratorController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ EncodingGeneratorService encodingGeneratorService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "生成编码", notes = "生成编码")
|
|
|
+ @RequestMapping(value = "", method = RequestMethod.POST)
|
|
|
+ public Response save(@RequestBody EncodingGenerator data) {
|
|
|
+ EncodingGenerator eg = encodingGeneratorService.generateCode(data);
|
|
|
+ if (encodingGeneratorService.getCode(eg.getCode()) != null) {
|
|
|
+ return Response.fail(200000, "自定义编码已存在");
|
|
|
+ }
|
|
|
+ encodingGeneratorService.save(eg);
|
|
|
+ return Response.ok(eg.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询编码类型", notes = "查询编码类型")
|
|
|
+ @RequestMapping(value = "/type/query", method = RequestMethod.POST)
|
|
|
+ public Response query(@RequestBody Encoding data) {
|
|
|
+ return Response.ok( encodingGeneratorService.get(data));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增编码类型", notes = "新增编码类型")
|
|
|
+ @RequestMapping(value = "/type", method = RequestMethod.POST)
|
|
|
+ public Response save(@RequestBody Encoding data) {
|
|
|
+ encodingGeneratorService.save(data);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新编码类型", notes = "更新编码类型")
|
|
|
+ @RequestMapping(value = "/type", method = RequestMethod.PUT)
|
|
|
+ public Response update(@RequestBody Encoding data) {
|
|
|
+ encodingGeneratorService.update(data);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除编码类型", notes = "删除编码类型")
|
|
|
+ @RequestMapping(value = "/type/{id}", method = RequestMethod.DELETE)
|
|
|
+ public Response delete(@PathVariable long id) {
|
|
|
+ encodingGeneratorService.delete(id);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|