package org.jeecg.modules.hrm.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import io.swagger.annotations.Api;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.modules.system.entity.SysDepart;
|
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.model.DepartOrgVo;
|
import org.jeecg.modules.system.service.ISysDepartService;
|
import org.jeecg.modules.system.service.ISysUserDepartService;
|
import org.jeecg.modules.system.vo.SysDepartVo;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@Api(tags = "hrm_board")
|
@RestController
|
@RequestMapping("/hrm/board")
|
public class HrmBoardController {
|
@Autowired
|
private ISysDepartService sysDepartService;
|
@Autowired
|
private ISysUserDepartService sysUserDepartService;
|
|
@RequestMapping(value = "/departUserList", method = RequestMethod.GET)
|
public Result<List<SysDepartVo>> queryTreeList(@RequestParam(name = "departName", required = true) String departName) {
|
Result<List<SysDepartVo>> result = new Result<>();
|
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<>();
|
queryWrapper.lambda().eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
queryWrapper.lambda().eq(SysDepart::getDepartName, departName);
|
SysDepart depart = sysDepartService.getOne(queryWrapper);
|
if (depart == null) {
|
return result.error500("查询部门不存在!");
|
}
|
String orgCode = depart.getOrgCode();
|
queryWrapper.clear();
|
queryWrapper.lambda().eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
queryWrapper.lambda().likeRight(SysDepart::getOrgCode, orgCode);
|
queryWrapper.lambda().orderByAsc(SysDepart::getOrgType);
|
queryWrapper.lambda().orderByAsc(SysDepart::getDepartOrder);
|
List<SysDepart> departList = sysDepartService.list(queryWrapper);
|
//转换vo
|
List<SysDepartVo> departVoList = departList.stream().map(d -> {
|
SysDepartVo vo = new SysDepartVo();
|
BeanUtils.copyProperties(d, vo);
|
//查询部门用户
|
List<SysUser> sysUsers = sysUserDepartService.queryUserByDepCode(d.getOrgCode(),null);
|
vo.setUserList(sysUsers);
|
return vo;
|
}).collect(Collectors.toList());
|
|
result.setResult(departVoList);
|
|
return result;
|
}
|
|
}
|