mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:19:19 +08:00
feat: 系统账户页改搜索表单布局,新增支持下拉选公司部门职位
This commit is contained in:
+6
-4
@@ -60,15 +60,17 @@ public class DepartmentController {
|
||||
|
||||
@GetMapping("/all")
|
||||
@RequirePermission(value = "org:department:read", description = "查询全部部门", allowSuper = true)
|
||||
public ApiResponse<List<DepartmentVO>> getAllDepartments() {
|
||||
List<DepartmentVO> result = departmentService.getAllDepartments();
|
||||
public ApiResponse<List<DepartmentVO>> getAllDepartments(
|
||||
@RequestParam(required = false) Long companyId) {
|
||||
List<DepartmentVO> result = departmentService.getAllDepartments(companyId);
|
||||
return ApiResponse.success("获取全部部门成功", result);
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@RequirePermission(value = "org:department:read", description = "查询部门树", allowSuper = true)
|
||||
public ApiResponse<List<DepartmentVO>> getDepartmentTree() {
|
||||
List<DepartmentVO> result = departmentService.getDepartmentTree();
|
||||
public ApiResponse<List<DepartmentVO>> getDepartmentTree(
|
||||
@RequestParam(required = false) Long companyId) {
|
||||
List<DepartmentVO> result = departmentService.getDepartmentTree(companyId);
|
||||
return ApiResponse.success("获取部门树成功", result);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -22,4 +22,9 @@ public class DepartmentFilterDTO {
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 公司ID(仅超管可跨公司查询)
|
||||
*/
|
||||
private Long companyId;
|
||||
}
|
||||
|
||||
+16
@@ -55,6 +55,14 @@ public interface DepartmentService extends IService<DepartmentPO> {
|
||||
*/
|
||||
List<DepartmentVO> getAllDepartments();
|
||||
|
||||
/**
|
||||
* 获取指定公司全部部门(companyId 为空则取当前公司;跨公司仅超管)
|
||||
*
|
||||
* @param companyId 公司ID,可空
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<DepartmentVO> getAllDepartments(Long companyId);
|
||||
|
||||
/**
|
||||
* 获取当前公司部门树
|
||||
*
|
||||
@@ -62,6 +70,14 @@ public interface DepartmentService extends IService<DepartmentPO> {
|
||||
*/
|
||||
List<DepartmentVO> getDepartmentTree();
|
||||
|
||||
/**
|
||||
* 获取指定公司部门树(companyId 为空则取当前公司;跨公司仅超管)
|
||||
*
|
||||
* @param companyId 公司ID,可空
|
||||
* @return 部门树
|
||||
*/
|
||||
List<DepartmentVO> getDepartmentTree(Long companyId);
|
||||
|
||||
/**
|
||||
* 为指定公司创建部门(用于初始化)
|
||||
*
|
||||
|
||||
+35
-20
@@ -158,6 +158,19 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析查询用公司ID:超管可传 companyId 跨公司;否则强制当前公司。
|
||||
*/
|
||||
private Long resolveCompanyId(Long requestedCompanyId) {
|
||||
if (requestedCompanyId == null) {
|
||||
return currentUserContext.getCurrentCompanyId();
|
||||
}
|
||||
if (!currentUserContext.isCurrentUserSuper()) {
|
||||
throw new BusinessException("无权跨公司查询部门");
|
||||
}
|
||||
return requestedCompanyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门分页列表
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
@@ -165,14 +178,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
Long companyId = resolveCompanyId(queryDTO != null ? queryDTO.getCompanyId() : null);
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加过滤条件
|
||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||
wrapper.like(DepartmentPO::getName, queryDTO.getName());
|
||||
@@ -184,37 +194,36 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
wrapper.eq(DepartmentPO::getStatus, queryDTO.getStatus());
|
||||
}
|
||||
}
|
||||
// 强制添加公司ID过滤条件
|
||||
wrapper.eq(DepartmentPO::getCompanyId, companyId);
|
||||
|
||||
// 排序
|
||||
wrapper.orderByAsc(DepartmentPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<DepartmentPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<DepartmentPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<DepartmentVO> records = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.toList();
|
||||
PageResultVO<DepartmentVO> result = PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
return PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
pageQueryDTO.getPageSize());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前公司全部部门
|
||||
*
|
||||
* @return 部门列表
|
||||
*/
|
||||
@Override
|
||||
public List<DepartmentVO> getAllDepartments() {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
return getAllDepartments(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定公司全部部门
|
||||
*/
|
||||
@Override
|
||||
public List<DepartmentVO> getAllDepartments(Long companyId) {
|
||||
Long resolvedCompanyId = resolveCompanyId(companyId);
|
||||
|
||||
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DepartmentPO::getCompanyId, companyId)
|
||||
wrapper.eq(DepartmentPO::getCompanyId, resolvedCompanyId)
|
||||
.orderByAsc(DepartmentPO::getCreateTime);
|
||||
|
||||
return this.list(wrapper).stream()
|
||||
@@ -224,12 +233,18 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
|
||||
/**
|
||||
* 获取当前公司部门树
|
||||
*
|
||||
* @return 部门树
|
||||
*/
|
||||
@Override
|
||||
public List<DepartmentVO> getDepartmentTree() {
|
||||
List<DepartmentVO> allDepartments = getAllDepartments();
|
||||
return getDepartmentTree(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定公司部门树
|
||||
*/
|
||||
@Override
|
||||
public List<DepartmentVO> getDepartmentTree(Long companyId) {
|
||||
List<DepartmentVO> allDepartments = getAllDepartments(companyId);
|
||||
if (allDepartments.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
+5
@@ -17,4 +17,9 @@ public class PositionFilterDTO {
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 公司ID(仅超管可跨公司查询)
|
||||
*/
|
||||
private Long companyId;
|
||||
}
|
||||
|
||||
+16
-13
@@ -147,6 +147,19 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析查询用公司ID:超管可传 companyId 跨公司;否则强制当前公司。
|
||||
*/
|
||||
private Long resolveCompanyId(Long requestedCompanyId) {
|
||||
if (requestedCompanyId == null) {
|
||||
return currentUserContext.getCurrentCompanyId();
|
||||
}
|
||||
if (!currentUserContext.isCurrentUserSuper()) {
|
||||
throw new BusinessException("无权跨公司查询岗位");
|
||||
}
|
||||
return requestedCompanyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位分页列表
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
@@ -154,14 +167,11 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<PositionVO> getPositionPage(PageQueryDTO<PositionFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
Long companyId = resolveCompanyId(queryDTO != null ? queryDTO.getCompanyId() : null);
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PositionPO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加过滤条件
|
||||
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||
wrapper.like(PositionPO::getName, queryDTO.getName());
|
||||
@@ -170,24 +180,17 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
wrapper.eq(PositionPO::getStatus, queryDTO.getStatus());
|
||||
}
|
||||
}
|
||||
// 强制添加公司ID过滤条件
|
||||
wrapper.eq(PositionPO::getCompanyId, companyId);
|
||||
|
||||
// 排序
|
||||
wrapper.orderByAsc(PositionPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<PositionPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<PositionPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<PositionVO> records = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.toList();
|
||||
PageResultVO<PositionVO> result = PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
return PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
pageQueryDTO.getPageSize());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class CreateSysAccountDTO {
|
||||
private String username;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
@Size(min = 8, max = 20, message = "密码长度必须在8-20个字符之间")
|
||||
@Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "用户姓名不能为空")
|
||||
|
||||
Reference in New Issue
Block a user