Przeglądaj źródła

add 增加常量类

18339543638 3 lat temu
rodzic
commit
e460fbc1ab

+ 14 - 12
coffee-system/src/main/java/com/coffee/bus/controller/BusConstantController.java

@@ -55,18 +55,7 @@ public class BusConstantController {
     @PostMapping("/{type}/remove")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id",value = "主键id",required = true),
-            @ApiImplicitParam(name = "type",value = "常量类型",required = true,example ="****type请从一下的key值中选取,否则即查询失败****\n" +
-                    "{\n" +
-                    "    \"ward\":\"病区\",\n" +
-                    "    \"doctor\":\"人员\",\n" +
-                    "    \"surgery\":\"手术名称\",\n" +
-                    "    \"asa\":\"asa\",\n" +
-                    "    \"anaesthesia\":\"麻醉方式\",\n" +
-                    "    \"anal\":\"镇痛方式\",\n" +
-                    "    \"alarmCause\":\"报警原因\",\n" +
-                    "    \"drugCate\":\"药品分类\",\n" +
-                    "    \"entrust\":\"医嘱\"\n" +
-                    "}")
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class)
     })
     @ApiOperation(value = "根据ID删除")
     public R delete(@PathVariable("type") ConstantEnum type,@RequestParam("id") Serializable id) {
@@ -81,4 +70,17 @@ public class BusConstantController {
         return constantService
                 .removeById(key)? R.success():R.fail("删除失败");
     }
+
+    @PostMapping("/_batch")
+    @ApiOperation(value = "批量新增数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class)
+    })
+    public R add(@PathVariable("type") ConstantEnum type,@RequestBody List<?> payload) {
+        AbstractConstantService constantService = constantHashMap.get(type);
+        if(constantService==null){
+            return R.success("常量类型{"+type+"}不存在");
+        }
+        return constantService.saveBatch(payload)?R.success():R.fail("数据新增失败");
+    }
 }