Compare commits
2 Commits
8f22c87451
...
4712f74476
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4712f74476 | ||
![]() |
e0d77b7893 |
@ -95,4 +95,9 @@ public interface DeptApi {
|
||||
@GetMapping("/getCompanyDept")
|
||||
@Operation(summary = "获取部门类型为公司的部门信息")
|
||||
CommonResult<List<DeptRespDTO>> getCompanyDept();
|
||||
|
||||
@GetMapping("/getUserCompanyDept")
|
||||
@Operation(summary = "获取用户所在公司的信息")
|
||||
@Parameter(name = "userId", description = "用户编号", example = "1024", required = true)
|
||||
CommonResult<DeptRespDTO> getUserCompanyDept(@RequestParam("userId") Long userId);
|
||||
}
|
||||
|
@ -134,4 +134,12 @@ public class DeptApiImpl implements DeptApi {
|
||||
List<DeptDO> deptDOS = deptService.getCompanyDept();
|
||||
return success(BeanUtils.toBean(deptDOS, DeptRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false)
|
||||
public CommonResult<DeptRespDTO> getUserCompanyDept(Long userId) {
|
||||
|
||||
DeptDO deptDO = deptService.getUserCompanyDept(userId);
|
||||
return success(BeanUtils.toBean(deptDO, DeptRespDTO.class));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.dept;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -46,4 +49,15 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
|
||||
|
||||
return selectList(new LambdaQueryWrapperX<DeptDO>().orderByAsc(DeptDO::getFlag));
|
||||
}
|
||||
|
||||
default DeptDO selectDeptByUserId(Long userId) {
|
||||
|
||||
MPJLambdaWrapperX<DeptDO> query = new MPJLambdaWrapperX<DeptDO>();
|
||||
query.selectAll(DeptDO.class);
|
||||
query.innerJoin(AdminUserDO.class, on -> on
|
||||
.eq(AdminUserDO::getDeptId, DeptDO::getId)
|
||||
.eq(AdminUserDO::getId, userId));
|
||||
|
||||
return selectJoinOne(DeptDO.class, query);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public class DataPermissionConfiguration {
|
||||
// dept
|
||||
rule.addDeptColumn(AdminUserDO.class);
|
||||
rule.addDeptColumn(DeptDO.class, "id");
|
||||
rule.addDeptColumn(LogUseDO.class, "use_user_dept");
|
||||
rule.addDeptColumn(LogStatisticsDO.class, "dept_id");
|
||||
rule.addDeptColumn(LogInstanceDO.class, "dept_id");
|
||||
rule.addDeptColumn(DeptAssetsDO.class, "dept_id");
|
||||
@ -31,7 +30,6 @@ public class DataPermissionConfiguration {
|
||||
|
||||
// user
|
||||
rule.addUserColumn(AdminUserDO.class, "id");
|
||||
rule.addUserColumn(LogUseDO.class, "use_user_id");
|
||||
rule.addUserColumn(LogStatisticsDO.class, "user_id");
|
||||
rule.addUserColumn(LogInstanceDO.class, "start_user_id");
|
||||
};
|
||||
|
@ -160,4 +160,11 @@ public interface DeptService {
|
||||
* @return
|
||||
*/
|
||||
List<DeptDO> getDeptListByFactoryIds(List<Long> factoryIds);
|
||||
|
||||
/**
|
||||
* 获取用户所在公司的信息
|
||||
* @param userId 用户编号
|
||||
* @return 公司信息
|
||||
*/
|
||||
DeptDO getUserCompanyDept(Long userId);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.service.dept;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -24,6 +25,7 @@ import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_OPERATE_FAIL_USER_NO_DEPT;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -319,6 +321,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false)
|
||||
public List<DeptDO> getCompanyDept() {
|
||||
|
||||
return deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
@ -345,4 +348,27 @@ public class DeptServiceImpl implements DeptService {
|
||||
return deptMapper.selectList(new LambdaQueryWrapper<DeptDO>()
|
||||
.in(DeptDO::getFactoryId, factoryIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false)
|
||||
public DeptDO getUserCompanyDept(Long userId) {
|
||||
|
||||
// 获取用户所在部门信息
|
||||
DeptDO deptDo = deptMapper.selectDeptByUserId(userId);
|
||||
|
||||
if (deptDo == null) {
|
||||
throw exception(TASK_OPERATE_FAIL_USER_NO_DEPT);
|
||||
}
|
||||
|
||||
// 根据所在部门信息获取 所在公司信息
|
||||
List<DeptDO> companyDeptList = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
.likeIfPresent(DeptDO::getFlag, deptDo.getFlag())
|
||||
.eq(DeptDO::getType, 0));
|
||||
|
||||
if (CollectionUtil.isEmpty(companyDeptList)) {
|
||||
return new DeptDO();
|
||||
}
|
||||
|
||||
return companyDeptList.get(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user