53a5bbdb31a4a9d5c160b9b7d4cbb1661d4b0305.svn-base 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package cn.com.goldenwater.dcproj.controller.general;
  2. import cn.com.goldenwater.dcproj.model.Dic;
  3. import cn.com.goldenwater.dcproj.service.DicService;
  4. import cn.com.goldenwater.core.web.BaseController;
  5. import cn.com.goldenwater.core.web.BaseResponse;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.util.Assert;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import java.util.List;
  19. /**
  20. * @author lhc
  21. * @date 2020-8-5
  22. */
  23. @Api(value = "系统字典管理", tags = "系统字典管理")
  24. @RestController
  25. @RequestMapping("/bis/insp/dic")
  26. public class DicController extends BaseController {
  27. private Logger logger = LoggerFactory.getLogger(getClass());
  28. @Autowired
  29. private DicService dicService;
  30. @ApiOperation(value = "添加系统字典")
  31. @RequestMapping(value = "/add", method = RequestMethod.POST)
  32. public BaseResponse<Dic> insert(@ApiParam(name = "dic", value = "Dic", required = true) @RequestBody Dic dic) {
  33. int ret = dicService.insert(dic);
  34. return buildSuccessResponse(dic);
  35. }
  36. @ApiOperation(value = "根据ID删除系统字典")
  37. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  38. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  39. int ret = dicService.delete(id);
  40. return buildSuccessResponse();
  41. }
  42. @ApiOperation(value = "更新系统字典信息")
  43. @RequestMapping(value = "/update", method = RequestMethod.POST)
  44. public BaseResponse<Dic> update(@ApiParam(name = "dic", value = "Dic", required = true) @RequestBody Dic dic) {
  45. Assert.notNull(dic.getId(), "主键id为必填参数");
  46. int ret = dicService.update(dic);
  47. return buildSuccessResponse(dic);
  48. }
  49. @ApiOperation(value = "根据ID获取系统字典(单表)")
  50. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  51. public BaseResponse<Dic> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  52. Dic dic = dicService.get(id);
  53. return buildSuccessResponse(dic);
  54. }
  55. @ApiOperation(value = "根据ID获取系统字典(单表)")
  56. @RequestMapping(value = "getDic/{bzCode}/{itemCode}", method = RequestMethod.GET)
  57. public BaseResponse<List<Dic>> getDic(@ApiParam(name = "bzCode", value = "bzCode", required = true) @PathVariable String bzCode,
  58. @ApiParam(name = "itemCode", value = "itemCode", required = true) @PathVariable String itemCode) {
  59. List<Dic> dics = dicService.getDic(bzCode, itemCode);
  60. return buildSuccessResponse(dics);
  61. }
  62. @ApiOperation(value = "根据ID获取系统字典(单表)")
  63. @RequestMapping(value = "getDic/{bzCode}/{itemCode}/{code}", method = RequestMethod.GET)
  64. public BaseResponse<Dic> getDicSingle(@ApiParam(name = "bzCode", value = "bzCode", required = true) @PathVariable String bzCode,
  65. @ApiParam(name = "itemCode", value = "itemCode", required = true) @PathVariable String itemCode,
  66. @ApiParam(name = "code", value = "code", required = true) @PathVariable String code) {
  67. Dic dic = dicService.getDicSingle(bzCode, itemCode, code);
  68. return buildSuccessResponse(dic );
  69. }
  70. }