package com.willalp.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.willalp.system.domain.HsPostConfig; import com.willalp.system.domain.vo.PostTreeVo; import com.willalp.system.mapper.HsPostConfigMapper; import com.willalp.system.service.IHsPostConfigService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** * 岗位配置Service业务层处理 * * @author willalp * @date 2022-09-21 */ @Service public class HsPostConfigServiceImpl extends ServiceImpl implements IHsPostConfigService { @Resource private HsPostConfigMapper hsPostConfigMapper; /** * 查询岗位配置列表 * * @param hsPostConfig 岗位配置 * @return 岗位配置 */ @Override public List selectHsPostConfigList(HsPostConfig hsPostConfig) { return hsPostConfigMapper.selectHsPostConfigList(hsPostConfig); } @Override public List getTreePost() { List hsPostConfigs = selectHsPostConfigList(null); if (0 != hsPostConfigs.size()) { List list = new ArrayList<>(); String userBS = "AA"; hsPostConfigs.forEach(item -> { PostTreeVo postTreeVo = new PostTreeVo(); postTreeVo.setText(item.getPostName()); postTreeVo.setValue(item.getId()); String postUserG = item.getPostUserG(); List postTreeCcVos = new ArrayList<>(); if (postUserG != null) { String[] split = postUserG.split(","); for (int i = 0; i < split.length; i++) { PostTreeVo postTreeCcVo = new PostTreeVo(); String nick; String userId; int of = split[i].indexOf(userBS); if (of != -1) { nick = split[i].substring(0, of); userId = split[i].substring(of); } else { nick = "WILLALP"; userId = "admin"; } postTreeCcVo.setText(nick); postTreeCcVo.setValue(userId); postTreeCcVos.add(postTreeCcVo); } } if (postTreeCcVos.size() != 0) { postTreeVo.setChildren(postTreeCcVos); } else { postTreeVo.setChildren(null); } list.add(postTreeVo); }); return list; } return null; } }