DepEnumController.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.persagy.fm.department.controller;
  2. import com.persagy.fm.common.model.dto.EnumQueryDTO;
  3. import com.persagy.fm.common.model.vo.EnumVO;
  4. import com.persagy.fm.common.response.CommonResult;
  5. import com.persagy.fm.common.response.PageList;
  6. import com.persagy.fm.common.utils.ResultHelper;
  7. import com.persagy.fm.department.service.IDepEnumService;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.assertj.core.util.Lists;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.PostMapping;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import javax.validation.Valid;
  18. import java.util.List;
  19. /**
  20. * @author lixing
  21. * @version V1.0 2021/3/12 6:36 下午
  22. **/
  23. @RestController
  24. @Validated
  25. @RequestMapping("/departments/enums")
  26. @Api(tags = "部门枚举")
  27. public class DepEnumController {
  28. @Autowired
  29. IDepEnumService depEnumService;
  30. @PostMapping("/get")
  31. @ApiOperation(value="查询(部门类型:dept_type,数据来源:resource_from)")
  32. public CommonResult<PageList<EnumVO>> queryEnum(
  33. @Valid @RequestBody EnumQueryDTO enumQueryDTO) {
  34. String type = enumQueryDTO.getType();
  35. List<EnumVO> resultList = Lists.newArrayList();
  36. switch (type){
  37. case "dept_type":
  38. resultList = depEnumService.queryDepTypeEnum();
  39. break;
  40. case "resource_from":
  41. resultList = depEnumService.queryDepResourceFromEnum();
  42. break;
  43. default:
  44. throw new IllegalArgumentException("暂不提供这种类型的枚举信息查询");
  45. }
  46. return ResultHelper.multi(resultList);
  47. }
  48. }