|
@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.entity.Company;
|
|
|
+import com.management.platform.entity.Department;
|
|
|
import com.management.platform.entity.User;
|
|
|
import com.management.platform.entity.vo.UserVO;
|
|
|
import com.management.platform.mapper.CompanyMapper;
|
|
|
+import com.management.platform.mapper.DepartmentMapper;
|
|
|
import com.management.platform.mapper.UserMapper;
|
|
|
import com.management.platform.service.UserService;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
@@ -44,6 +46,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
private UserMapper userMapper;
|
|
|
@Resource
|
|
|
private CompanyMapper companyMapper;
|
|
|
+ @Resource
|
|
|
+ private DepartmentMapper departmentMapper;
|
|
|
|
|
|
//登录网页端 管理员或负责人可以登录
|
|
|
@Override
|
|
@@ -152,15 +156,39 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ //获取某个部门所有子部门id
|
|
|
+ private List<Integer> getBranchDepartment(Integer departmentId, Integer companyId) {
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>()
|
|
|
+ .eq("company_id", companyId));
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ list.add(departmentId);
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ Integer targetId = list.get(i);
|
|
|
+ for (int j = 0; j < departmentList.size(); j++) {
|
|
|
+ Integer superiorId = departmentList.get(j).getSuperiorId();
|
|
|
+ if (superiorId == null) {
|
|
|
+ departmentList.remove(j--);
|
|
|
+ } else if (superiorId.equals(targetId)) {
|
|
|
+ list.add(departmentList.get(j).getDepartmentId());
|
|
|
+ departmentList.remove(j--);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
//获取员工的列表
|
|
|
@Override
|
|
|
public HttpRespMsg getEmployeeList(Integer departmentId, Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
- User requester = userMapper.selectById(request.getHeader("Token"));
|
|
|
- QueryWrapper<User> queryWrapper = new QueryWrapper<User>().eq("company_id", requester.getCompanyId());
|
|
|
- if (departmentId != -1) {
|
|
|
+// Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ Integer companyId = 6;
|
|
|
+ QueryWrapper<User> queryWrapper = new QueryWrapper<User>().eq("company_id", companyId);
|
|
|
+ if (departmentId == 0) {
|
|
|
queryWrapper.eq("department_id", departmentId);
|
|
|
+ } else if (departmentId != -1) {
|
|
|
+ queryWrapper.in("department_id", getBranchDepartment(departmentId, companyId));
|
|
|
}
|
|
|
httpRespMsg.data = userMapper.selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
|
|
|
} catch (NullPointerException e) {
|