afe99291625c206ccef56845bbcdaef2ed72f7fe.svn-base 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package cn.com.goldenwater.dcproj.controller.ducha;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.DictType;
  5. import cn.com.goldenwater.dcproj.param.DictTypeParam;
  6. import cn.com.goldenwater.dcproj.service.DictTypeService;
  7. import cn.com.goldenwater.dcproj.util.CheckUtil;
  8. import cn.com.goldenwater.dcproj.utils.Builder;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. /**
  16. * @author
  17. * @date Mar 4, 2022
  18. */
  19. @Api(value = "xxx管理", tags = "xxx管理")
  20. @RestController
  21. @RequestMapping("/dict/type")
  22. public class DictTypeController extends BaseController {
  23. @Autowired
  24. private DictTypeService dictTypeService;
  25. @ApiOperation(value = "修改xxx")
  26. @RequestMapping(value = "", method = RequestMethod.POST)
  27. public BaseResponse<DictType> insert(@ApiParam(name = "dictType", value = "DictType", required = true) @RequestBody DictType dictType) {
  28. int ret = 0;
  29. if (StringUtils.isBlank(dictType.getId())) {
  30. ret = dictTypeService.insert(dictType);
  31. } else {
  32. ret = dictTypeService.update(dictType);
  33. }
  34. return buildSuccessResponse(dictType);
  35. }
  36. @ApiOperation(value = "根据ID删除xxx")
  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 = dictTypeService.delete(id);
  40. return buildSuccessResponse();
  41. }
  42. @ApiOperation(value = "根据ID获取xxx(单表)")
  43. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  44. public BaseResponse<DictType> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  45. DictType dictType = dictTypeService.get(id);
  46. return buildSuccessResponse(dictType);
  47. }
  48. @ApiOperation(value = "根据ID获取xxx(单表)")
  49. @GetMapping("/by/{type}")
  50. public BaseResponse getByType(@ApiParam(name = "type", value = "type", required = true)
  51. @PathVariable String type) {
  52. CheckUtil.notEmpty(type, "type no");
  53. String curentOrgId = getCurrentOrgId();
  54. return buildSuccessResponse(dictTypeService.findList(Builder.of(DictTypeParam::new).with(DictTypeParam::setOwnerSystem, type).with(DictTypeParam::setOwnerOfc, curentOrgId).build()));
  55. }
  56. }