HsPostConfigServiceImpl.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.willalp.system.service.impl;
  2. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  3. import com.willalp.system.domain.HsPostConfig;
  4. import com.willalp.system.domain.vo.PostTreeVo;
  5. import com.willalp.system.mapper.HsPostConfigMapper;
  6. import com.willalp.system.service.IHsPostConfigService;
  7. import org.springframework.stereotype.Service;
  8. import javax.annotation.Resource;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. /**
  12. * 岗位配置Service业务层处理
  13. *
  14. * @author willalp
  15. * @date 2022-09-21
  16. */
  17. @Service
  18. public class HsPostConfigServiceImpl extends ServiceImpl<HsPostConfigMapper, HsPostConfig> implements IHsPostConfigService {
  19. @Resource
  20. private HsPostConfigMapper hsPostConfigMapper;
  21. /**
  22. * 查询岗位配置列表
  23. *
  24. * @param hsPostConfig 岗位配置
  25. * @return 岗位配置
  26. */
  27. @Override
  28. public List<HsPostConfig> selectHsPostConfigList(HsPostConfig hsPostConfig) {
  29. return hsPostConfigMapper.selectHsPostConfigList(hsPostConfig);
  30. }
  31. @Override
  32. public List<PostTreeVo> getTreePost() {
  33. List<HsPostConfig> hsPostConfigs = selectHsPostConfigList(null);
  34. if (0 != hsPostConfigs.size()) {
  35. List<PostTreeVo> list = new ArrayList<>();
  36. String userBS = "AA";
  37. hsPostConfigs.forEach(item -> {
  38. PostTreeVo postTreeVo = new PostTreeVo();
  39. postTreeVo.setText(item.getPostName());
  40. postTreeVo.setValue(item.getId());
  41. String postUserG = item.getPostUserG();
  42. List<PostTreeVo> postTreeCcVos = new ArrayList<>();
  43. if (postUserG != null) {
  44. String[] split = postUserG.split(",");
  45. for (int i = 0; i < split.length; i++) {
  46. PostTreeVo postTreeCcVo = new PostTreeVo();
  47. String nick;
  48. String userId;
  49. int of = split[i].indexOf(userBS);
  50. if (of != -1) {
  51. nick = split[i].substring(0, of);
  52. userId = split[i].substring(of);
  53. } else {
  54. nick = "WILLALP";
  55. userId = "admin";
  56. }
  57. postTreeCcVo.setText(nick);
  58. postTreeCcVo.setValue(userId);
  59. postTreeCcVos.add(postTreeCcVo);
  60. }
  61. }
  62. if (postTreeCcVos.size() != 0) {
  63. postTreeVo.setChildren(postTreeCcVos);
  64. } else {
  65. postTreeVo.setChildren(null);
  66. }
  67. list.add(postTreeVo);
  68. });
  69. return list;
  70. }
  71. return null;
  72. }
  73. }