EnvElementController.java 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.dragoninfo.dcuc.authweb.restcontroller.element;
  2. import com.dragoninfo.dcuc.auth.element.facade.IEnvElementFacade;
  3. import com.dragoninfo.dcuc.auth.element.vo.ElementUserRelRespVo;
  4. import com.dragoninfo.dcuc.auth.element.vo.ElementUserSaveVo;
  5. import com.dragoninfo.dcuc.auth.element.vo.EnvElementSaveVo;
  6. import com.dragoninfo.dcuc.auth.element.vo.RespEnvElementVo;
  7. import com.dragoninfo.dcuc.auth.sub.vo.AuthUserVo;
  8. import com.dragoninfo.duceap.core.response.Result;
  9. import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
  10. import com.dragonsoft.duceap.base.entity.search.SearchDTO;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.data.domain.Page;
  14. import org.springframework.web.bind.annotation.*;
  15. import javax.validation.Valid;
  16. import java.util.List;
  17. /**
  18. * @author mazq
  19. * @date 2022/8/25
  20. */
  21. @RestController
  22. @RequestMapping("/envElement")
  23. public class EnvElementController {
  24. @Autowired
  25. private IEnvElementFacade envElementFacade;
  26. @GetMapping("getById/{id}")
  27. public Result<RespEnvElementVo> getById(@PathVariable("id") String id) {
  28. RespEnvElementVo vo = envElementFacade.getById(id);
  29. return Result.success(vo);
  30. }
  31. @PostMapping("search")
  32. public Result<List<RespEnvElementVo>> pageSearch(SearchDTO searchDTO) {
  33. Page<RespEnvElementVo> page = envElementFacade.pageSearch(searchDTO);
  34. return Result.success(page.getTotalElements(), page.getContent());
  35. }
  36. @PostMapping("save")
  37. public Result save(@RequestBody EnvElementSaveVo envElementVo) {
  38. ResponseStatus responseStatus = envElementFacade.save(envElementVo);
  39. return getResult(responseStatus);
  40. }
  41. @PostMapping("update")
  42. public Result update(@RequestBody EnvElementSaveVo envElementVo) {
  43. ResponseStatus responseStatus = envElementFacade.update(envElementVo);
  44. return getResult(responseStatus);
  45. }
  46. @DeleteMapping("deleteById/{id}")
  47. public Result deleteById(@PathVariable("id") String id) {
  48. ResponseStatus responseStatus = envElementFacade.deleteById(id);
  49. return getResult(responseStatus);
  50. }
  51. private Result getResult(ResponseStatus responseStatus) {
  52. Result result = new Result();
  53. result.setMsg(responseStatus.getMessage());
  54. result.setResult(responseStatus.getStatusCode());
  55. return result;
  56. }
  57. @ApiOperation(value = "关联用户分页查询")
  58. @PostMapping("userRelPage")
  59. public Result<List<ElementUserRelRespVo>> userRelPage(SearchDTO searchDTO) {
  60. return envElementFacade.userRelPage(searchDTO);
  61. }
  62. @ApiOperation(value = "非关联用户分页查询")
  63. @PostMapping("notInUserRelPage")
  64. public Result<List<AuthUserVo>> notInUserRelPage(SearchDTO searchDTO) {
  65. return envElementFacade.notInUserRelPage(searchDTO);
  66. }
  67. @ApiOperation(value = "关联关系添加")
  68. @PostMapping("userRelSave")
  69. public Result<Object> userRelSave(@Valid @RequestBody ElementUserSaveVo relSaveVo) {
  70. return envElementFacade.userRelSave(relSaveVo);
  71. }
  72. @ApiOperation(value = "关联关系移除")
  73. @DeleteMapping("deleteUserRel/{id}")
  74. public Result<Object> deleteUserRel(@PathVariable("id") String id) {
  75. return envElementFacade.deleteUserRel(id);
  76. }
  77. }