FieldClassifyController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package com.dragoninfo.dcuc.authweb.restcontroller.sub;
  2. import com.dragoninfo.dcuc.app.facade.sub.IFieldClaFacade;
  3. import com.dragoninfo.dcuc.app.dto.sub.FieldClaAcceptDTO;
  4. import com.dragoninfo.dcuc.app.dto.sub.FieldClaDTO;
  5. import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.data.FieldClaAcceptVo;
  6. import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.data.FieldClaVo;
  7. import com.dragoninfo.dcuc.authweb.util.VersionUtils;
  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 com.dragonsoft.duceap.core.search.Searchable;
  12. import io.swagger.annotations.*;
  13. import org.springframework.beans.BeanUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.data.domain.Page;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.List;
  18. import java.util.stream.Collectors;
  19. /**
  20. * @author mazq
  21. * @date 2021/5/25
  22. */
  23. @Api(tags = {"主客体授权-字段分类表码接口"})
  24. @RestController
  25. @RequestMapping(value = "/fieldclassifysvr/"+ VersionUtils.VERSION_UID)
  26. public class FieldClassifyController {
  27. @Autowired
  28. private IFieldClaFacade fieldClaFacade;
  29. @ApiOperation(value = "数据资源分类分页列表")
  30. @ApiImplicitParam(name = "Searchable", value = "Searchable 数据资源分类分页查询对象,查询条件[name:firName op: like] [name: secName op: like] ")
  31. @PostMapping(value = "search")
  32. public Result dataClassifyPageList(Searchable searchable) {
  33. Page<FieldClaAcceptDTO> page = fieldClaFacade.pageSearch(searchable.toSearchDTO());
  34. List<FieldClaAcceptDTO> content = page.getContent();
  35. List<FieldClaAcceptVo> vos = content.stream().map(item -> {
  36. FieldClaAcceptVo vo = new FieldClaAcceptVo();
  37. BeanUtils.copyProperties(item, vo);
  38. return vo;
  39. }).collect(Collectors.toList());
  40. return Result.success(page.getTotalElements(), vos);
  41. }
  42. @ApiOperation(value = "添加字段分类表")
  43. @ApiImplicitParam(name = "FieldClaAcceptVo", value = "FieldClaAcceptVo 字段分类表Vo")
  44. @PostMapping(value = "save")
  45. public Result fieldClaAdd(@RequestBody FieldClaAcceptVo vo){
  46. FieldClaAcceptDTO dto = new FieldClaAcceptDTO();
  47. BeanUtils.copyProperties(vo,dto);
  48. ResponseStatus status = fieldClaFacade.fieldClassifyAdd(dto);
  49. if(status.getStatusCode().equals(ResponseStatus.SUCCESS_CODE)) {
  50. return Result.success(ResponseStatus.SUCCESS_CODE);
  51. }else {
  52. return Result.fail(ResponseStatus.FAIL_CODE,status.getMessage());
  53. }
  54. }
  55. @ApiOperation(value = "修改字段分类")
  56. @ApiImplicitParam(name = "FieldClaAcceptVo", value = "FieldClaAcceptVo 字段分类Vo")
  57. @PostMapping(value = "update")
  58. public Result dataClassifyUpdate(@RequestBody FieldClaAcceptVo vo){
  59. FieldClaAcceptDTO dto = new FieldClaAcceptDTO();
  60. BeanUtils.copyProperties(vo,dto);
  61. Boolean b = fieldClaFacade.fieldClassifyUpdate(dto);
  62. if (b) {
  63. return Result.success();
  64. } else {
  65. return Result.fail();
  66. }
  67. }
  68. @ApiOperation(value = "字段分类详情")
  69. @ApiImplicitParam(name = "id", value = "id 字段分类 字段分类id")
  70. @GetMapping(value = "detailAllLevel/{id}")
  71. public Result<FieldClaAcceptVo> detailAllLevel(@PathVariable("id") String id){
  72. FieldClaAcceptDTO viewDTO = fieldClaFacade.detailAllLevel(id);
  73. FieldClaAcceptVo vo = new FieldClaAcceptVo();
  74. BeanUtils.copyProperties(viewDTO, vo);
  75. return Result.success(vo);
  76. }
  77. @ApiOperation(value = "根据code和path查询字段分类详情")
  78. @ApiImplicitParams({
  79. @ApiImplicitParam(name = "code", value = "code: 该级代码"),
  80. @ApiImplicitParam(name = "path", value = "path: 上级层级id组成 1-2-3-4 一级为空")
  81. })
  82. @GetMapping(value = "getByCodeAndPath")
  83. public Result<FieldClaVo> getByCodeAndPath(@RequestParam("code") String code, @RequestParam(value = "path", required = false) String path) {
  84. FieldClaDTO dto = fieldClaFacade.getByCodeAndPath(code, path);
  85. FieldClaVo vo = new FieldClaVo();
  86. BeanUtils.copyProperties(dto, vo);
  87. return Result.success(vo);
  88. }
  89. @ApiOperation(value = "字段分类删除,根据Id删除所有层级数据")
  90. @ApiImplicitParam(name = "id", value = "字段分类id")
  91. @DeleteMapping(value = "deleteById/{id}")
  92. public Result deleteAllLevel(@PathVariable("id") String id){
  93. Boolean b = fieldClaFacade.deleteAllLevel(id);
  94. if (b) {
  95. return Result.success();
  96. } else {
  97. return Result.fail();
  98. }
  99. }
  100. @ApiModelProperty(value = "查询二级字段分类")
  101. @ApiImplicitParam(name = "Searchable", value = "Searchable 查询条件 id not in")
  102. @PostMapping(value = "getSecLevelColumn")
  103. public Result<List<FieldClaVo>> getSecLevelColumn(SearchDTO searchDTO) {
  104. List<FieldClaDTO> dtos = fieldClaFacade.getSecLevelColumn(searchDTO);
  105. List<FieldClaVo> vos = dtos.stream().map(item -> {
  106. FieldClaVo vo = new FieldClaVo();
  107. BeanUtils.copyProperties(item, vo);
  108. return vo;
  109. }).collect(Collectors.toList());
  110. return Result.success(vos);
  111. }
  112. }