|
|
@@ -1,11 +1,18 @@
|
|
|
package com.coffee.bus.controller;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.coffee.bus.enums.ConstantEnum;
|
|
|
+import com.coffee.bus.service.constant.AbstractConstantService;
|
|
|
+import com.coffee.common.entity.QueryParamEntity;
|
|
|
+import com.coffee.common.result.R;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.Serializable;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author lifang
|
|
|
@@ -15,13 +22,63 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
* @createTime 2022年04月08日 10:19:00
|
|
|
*/
|
|
|
@RestController
|
|
|
-@AllArgsConstructor
|
|
|
@RequestMapping("/bus/constant")
|
|
|
-@Api(tags = "常量管理",description = "统一权限前缀(bus:constant),例如新增bus:constant:add")
|
|
|
+@Api(tags = "常量管理",value = "统一权限前缀(bus:constant),例如新增bus:constant:add")
|
|
|
public class BusConstantController {
|
|
|
- @GetMapping
|
|
|
- @ApiOperation("改接口无意义,当该模块下存在接口时,将该接口删除")
|
|
|
- public void show(){
|
|
|
|
|
|
+ private HashMap<ConstantEnum, AbstractConstantService> constantHashMap=new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public BusConstantController(List<AbstractConstantService> constantList) {
|
|
|
+ constantList.stream().collect(Collectors.groupingBy(AbstractConstantService::getName)).forEach((k, vs)->{
|
|
|
+ constantHashMap.merge(k,vs.get(0),(o1,o2)->{
|
|
|
+ throw new RuntimeException("常量服务类名称不可重复[{"+o1.getName()+"}]");
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/{type}/page")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class),
|
|
|
+ @ApiImplicitParam(name = "query",value = "查询参数",required = true)
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "使用POST方式分页动态查询")
|
|
|
+ public R<IPage<?>> queryPager(@PathVariable("type") ConstantEnum type,@RequestBody QueryParamEntity<?> query) {
|
|
|
+ AbstractConstantService constantService = constantHashMap.get(type);
|
|
|
+ if(constantService==null){
|
|
|
+ return R.fail("常量类型{"+type+"}不存在");
|
|
|
+ }
|
|
|
+ return R.success(constantService.list(query));
|
|
|
+ }
|
|
|
+
|
|
|
+ @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" +
|
|
|
+ "}")
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "根据ID删除")
|
|
|
+ public R delete(@PathVariable("type") ConstantEnum type,@RequestParam("id") Serializable id) {
|
|
|
+ if(StrUtil.isNullOrUndefined(String.valueOf(id))){
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+ AbstractConstantService constantService = constantHashMap.get(type);
|
|
|
+ if(constantService==null){
|
|
|
+ return R.success("常量类型{"+type+"}不存在");
|
|
|
+ }
|
|
|
+ String key=String.valueOf(id);
|
|
|
+ return constantService
|
|
|
+ .removeById(key)? R.success():R.fail("删除失败");
|
|
|
}
|
|
|
}
|