mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 18:29:19 +08:00
feat: 获取公司菜单列表和菜单数接口
This commit is contained in:
+19
-52
@@ -3,14 +3,11 @@ package top.xyquan.ecomdmbbackend.modules.org.controller;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.CreateCompanyMenuDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.UpdateCompanyMenuDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.CompanyMenuVO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
||||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -28,53 +25,7 @@ public class CompanyMenuController {
|
|||||||
this.companyMenuService = companyMenuService;
|
this.companyMenuService = companyMenuService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "创建公司菜单", description = "创建新的公司菜单")
|
@Operation(summary = "获取公司所有菜单ID(超管)", description = "获取指定公司的所有菜单ID列表")
|
||||||
@PostMapping("/create")
|
|
||||||
@RequireRole(description = "创建公司菜单", allowUser = false)
|
|
||||||
public ApiResponse<CompanyMenuVO> createCompanyMenu(@Valid @RequestBody CreateCompanyMenuDTO createCompanyMenuDTO) {
|
|
||||||
CompanyMenuVO companyMenuVO = companyMenuService.createCompanyMenu(createCompanyMenuDTO);
|
|
||||||
return ApiResponse.success(companyMenuVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "更新公司菜单", description = "更新现有公司菜单信息")
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
@RequireRole(description = "更新公司菜单", allowUser = false)
|
|
||||||
public ApiResponse<CompanyMenuVO> updateCompanyMenu(@Valid @RequestBody UpdateCompanyMenuDTO updateCompanyMenuDTO,
|
|
||||||
@PathVariable Long id) {
|
|
||||||
CompanyMenuVO companyMenuVO = companyMenuService.updateCompanyMenu(updateCompanyMenuDTO, id);
|
|
||||||
return ApiResponse.success(companyMenuVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除公司菜单", description = "删除指定公司菜单")
|
|
||||||
@DeleteMapping("/delete/{id}")
|
|
||||||
@RequireRole(description = "删除公司菜单", allowUser = false)
|
|
||||||
public ApiResponse<Void> deleteCompanyMenu(
|
|
||||||
@Parameter(description = "公司菜单ID") @PathVariable Long id) {
|
|
||||||
companyMenuService.deleteCompanyMenu(id);
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "批量创建公司菜单", description = "批量创建公司菜单权限关联")
|
|
||||||
@PostMapping("/batch-create/{id}")
|
|
||||||
@RequireRole(description = "批量创建公司菜单", allowUser = false)
|
|
||||||
public ApiResponse<List<CompanyMenuVO>> batchCreateCompanyMenu(
|
|
||||||
@Parameter(description = "公司ID") @PathVariable Long id,
|
|
||||||
@Parameter(description = "菜单ID列表") @RequestBody List<Long> menuIds) {
|
|
||||||
List<CompanyMenuVO> result = companyMenuService.batchCreateCompanyMenu(id, menuIds);
|
|
||||||
return ApiResponse.success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "批量删除公司菜单", description = "批量删除公司菜单权限关联")
|
|
||||||
@DeleteMapping("/batch-delete/{id}")
|
|
||||||
@RequireRole(description = "批量删除公司菜单", allowUser = false)
|
|
||||||
public ApiResponse<Void> batchDeleteCompanyMenu(
|
|
||||||
@Parameter(description = "公司ID") @PathVariable Long id,
|
|
||||||
@Parameter(description = "菜单ID列表") @RequestBody List<Long> menuIds) {
|
|
||||||
companyMenuService.batchDeleteCompanyMenu(id, menuIds);
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "获取公司所有菜单ID", description = "获取指定公司的所有菜单ID列表")
|
|
||||||
@GetMapping("/menu-ids/{id}")
|
@GetMapping("/menu-ids/{id}")
|
||||||
@RequireRole(description = "获取公司菜单ID", allowUser = false)
|
@RequireRole(description = "获取公司菜单ID", allowUser = false)
|
||||||
public ApiResponse<List<Long>> getCompanyMenuIds(
|
public ApiResponse<List<Long>> getCompanyMenuIds(
|
||||||
@@ -83,7 +34,7 @@ public class CompanyMenuController {
|
|||||||
return ApiResponse.success(menuIds);
|
return ApiResponse.success(menuIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "批量更新公司菜单", description = "批量更新公司菜单状态,新增缺失的菜单,停用多余的菜单,启用已有的菜单")
|
@Operation(summary = "批量更新公司菜单(超管)", description = "批量更新公司菜单状态,新增缺失的菜单,停用多余的菜单,启用已有的菜单")
|
||||||
@PostMapping("/batch-update/{id}")
|
@PostMapping("/batch-update/{id}")
|
||||||
@RequireRole(description = "批量更新公司菜单", allowUser = false)
|
@RequireRole(description = "批量更新公司菜单", allowUser = false)
|
||||||
public ApiResponse<Void> batchUpdateCompanyMenus(
|
public ApiResponse<Void> batchUpdateCompanyMenus(
|
||||||
@@ -92,4 +43,20 @@ public class CompanyMenuController {
|
|||||||
companyMenuService.batchUpdateCompanyMenus(id, menuIds);
|
companyMenuService.batchUpdateCompanyMenus(id, menuIds);
|
||||||
return ApiResponse.success();
|
return ApiResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取公司所有菜单列表", description = "获取当前用户公司的所有菜单列表,中间表只作为过滤条件,不覆盖系统菜单字段")
|
||||||
|
@GetMapping("/menus")
|
||||||
|
@RequireRole(description = "获取公司菜单列表", allowUser = false)
|
||||||
|
public ApiResponse<List<MenuVO>> getCompanyMenus() {
|
||||||
|
List<MenuVO> menus = companyMenuService.getCompanyMenus();
|
||||||
|
return ApiResponse.success(menus);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取公司完整菜单树", description = "获取当前用户公司的完整菜单树结构,中间表只作为过滤条件,不覆盖系统菜单字段")
|
||||||
|
@GetMapping("/menu-tree")
|
||||||
|
@RequireRole(description = "获取公司菜单树", allowUser = false)
|
||||||
|
public ApiResponse<List<MenuVO>> getCompanyMenuTree() {
|
||||||
|
List<MenuVO> menuTree = companyMenuService.getCompanyMenuTree();
|
||||||
|
return ApiResponse.success(menuTree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-33
@@ -2,7 +2,6 @@ package top.xyquan.ecomdmbbackend.modules.org.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.CreateCompanyMenuDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.CreateCompanyMenuDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.UpdateCompanyMenuDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.po.CompanyMenuPO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.po.CompanyMenuPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.CompanyMenuVO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.vo.CompanyMenuVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||||
@@ -22,38 +21,6 @@ public interface CompanyMenuService extends IService<CompanyMenuPO> {
|
|||||||
*/
|
*/
|
||||||
CompanyMenuVO createCompanyMenu(CreateCompanyMenuDTO createCompanyMenuDTO);
|
CompanyMenuVO createCompanyMenu(CreateCompanyMenuDTO createCompanyMenuDTO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新公司菜单
|
|
||||||
*
|
|
||||||
* @param updateCompanyMenuDTO 公司菜单信息
|
|
||||||
* @return 公司菜单信息
|
|
||||||
*/
|
|
||||||
CompanyMenuVO updateCompanyMenu(UpdateCompanyMenuDTO updateCompanyMenuDTO, Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除公司菜单
|
|
||||||
*
|
|
||||||
* @param id 公司菜单ID
|
|
||||||
*/
|
|
||||||
void deleteCompanyMenu(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量创建公司菜单
|
|
||||||
*
|
|
||||||
* @param companyId 公司ID
|
|
||||||
* @param menuIds 菜单ID列表
|
|
||||||
* @return 创建结果
|
|
||||||
*/
|
|
||||||
List<CompanyMenuVO> batchCreateCompanyMenu(Long companyId, List<Long> menuIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除公司菜单
|
|
||||||
*
|
|
||||||
* @param companyId 公司ID
|
|
||||||
* @param menuIds 菜单ID列表
|
|
||||||
*/
|
|
||||||
void batchDeleteCompanyMenu(Long companyId, List<Long> menuIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取公司所有菜单(以MenuVO格式返回,用于动态路由)
|
* 获取公司所有菜单(以MenuVO格式返回,用于动态路由)
|
||||||
*
|
*
|
||||||
@@ -78,4 +45,18 @@ public interface CompanyMenuService extends IService<CompanyMenuPO> {
|
|||||||
*/
|
*/
|
||||||
void batchUpdateCompanyMenus(Long companyId, List<Long> menuIds);
|
void batchUpdateCompanyMenus(Long companyId, List<Long> menuIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公司所有菜单列表
|
||||||
|
*
|
||||||
|
* @return 菜单列表
|
||||||
|
*/
|
||||||
|
List<MenuVO> getCompanyMenus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公司完整菜单树
|
||||||
|
*
|
||||||
|
* @return 菜单树列表
|
||||||
|
*/
|
||||||
|
List<MenuVO> getCompanyMenuTree();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
@@ -46,6 +46,11 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建公司账户
|
||||||
|
* @param createAccountDTO 创建账户DTO
|
||||||
|
* @return 账户VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AccountVO createAccountForCompany(CreateAccountDTO createAccountDTO) {
|
public AccountVO createAccountForCompany(CreateAccountDTO createAccountDTO) {
|
||||||
// 从用户上下文获取公司ID
|
// 从用户上下文获取公司ID
|
||||||
@@ -91,6 +96,12 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新公司账户
|
||||||
|
* @param updateAccountDTO 更新账户DTO
|
||||||
|
* @param accountId 账户ID
|
||||||
|
* @return 账户VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId) {
|
public AccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId) {
|
||||||
// 查询账户
|
// 查询账户
|
||||||
@@ -156,6 +167,10 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
return convertToVO(user);
|
return convertToVO(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除账户
|
||||||
|
* @param accountId 账户ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteAccount(Long accountId) {
|
public void deleteAccount(Long accountId) {
|
||||||
// 查询账户
|
// 查询账户
|
||||||
@@ -170,6 +185,11 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
this.updateById(user);
|
this.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取账户详情
|
||||||
|
* @param accountId 账户ID
|
||||||
|
* @return 账户VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AccountVO getAccountDetail(Long accountId) {
|
public AccountVO getAccountDetail(Long accountId) {
|
||||||
// 查询账户
|
// 查询账户
|
||||||
@@ -182,6 +202,11 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
return convertToVO(user);
|
return convertToVO(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取账户分页列表
|
||||||
|
* @param pageQuery 分页查询DTO
|
||||||
|
* @return 分页结果VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<AccountVO> getAccountPage(PageQueryDTO<AccountFilterDTO> pageQuery) {
|
public PageResultVO<AccountVO> getAccountPage(PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
@@ -200,6 +225,11 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
return PageResultVO.create(records, pageResult.getTotal(), pageQuery.getPage(), pageQuery.getPageSize());
|
return PageResultVO.create(records, pageResult.getTotal(), pageQuery.getPage(), pageQuery.getPageSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公司账户分页列表
|
||||||
|
* @param pageQuery 分页查询DTO
|
||||||
|
* @return 分页结果VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<AccountVO> getAccountPageForCompany(PageQueryDTO<AccountFilterDTO> pageQuery) {
|
public PageResultVO<AccountVO> getAccountPageForCompany(PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||||
// 从用户上下文获取公司ID
|
// 从用户上下文获取公司ID
|
||||||
@@ -220,6 +250,8 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建查询条件
|
* 构建查询条件
|
||||||
|
* @param filterDTO 过滤条件
|
||||||
|
* @return 查询条件
|
||||||
*/
|
*/
|
||||||
private LambdaQueryWrapper<UserPO> buildQueryWrapper(AccountFilterDTO filterDTO) {
|
private LambdaQueryWrapper<UserPO> buildQueryWrapper(AccountFilterDTO filterDTO) {
|
||||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -282,6 +314,8 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为VO
|
* 转换为VO
|
||||||
|
* @param user 用户PO
|
||||||
|
* @return 账户VO
|
||||||
*/
|
*/
|
||||||
private AccountVO convertToVO(UserPO user) {
|
private AccountVO convertToVO(UserPO user) {
|
||||||
AccountVO accountVO = new AccountVO();
|
AccountVO accountVO = new AccountVO();
|
||||||
@@ -301,6 +335,8 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取状态名称
|
* 获取状态名称
|
||||||
|
* @param status 状态
|
||||||
|
* @return 状态名称
|
||||||
*/
|
*/
|
||||||
private String getStatusName(Integer status) {
|
private String getStatusName(Integer status) {
|
||||||
if (status == null) return "未知";
|
if (status == null) return "未知";
|
||||||
@@ -315,6 +351,8 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色名称
|
* 获取角色名称
|
||||||
|
* @param role 角色
|
||||||
|
* @return 角色名称
|
||||||
*/
|
*/
|
||||||
private String getRoleName(String role) {
|
private String getRoleName(String role) {
|
||||||
if (role == null) return "未知";
|
if (role == null) return "未知";
|
||||||
@@ -328,6 +366,8 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算密码安全级别
|
* 计算密码安全级别
|
||||||
|
* @param password 密码
|
||||||
|
* @return 密码安全级别
|
||||||
*/
|
*/
|
||||||
private Integer calculatePasswordSecurityLevel(String password) {
|
private Integer calculatePasswordSecurityLevel(String password) {
|
||||||
if (password == null || password.length() < 8) {
|
if (password == null || password.length() < 8) {
|
||||||
|
|||||||
+126
-97
@@ -8,13 +8,15 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.mapper.CompanyMenuMapper;
|
import top.xyquan.ecomdmbbackend.modules.org.mapper.CompanyMenuMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.CreateCompanyMenuDTO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.CreateCompanyMenuDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.UpdateCompanyMenuDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.po.CompanyMenuPO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.po.CompanyMenuPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.CompanyMenuVO;
|
import top.xyquan.ecomdmbbackend.modules.org.model.vo.CompanyMenuVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.mapper.MenuMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.po.MenuPO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.po.MenuPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.PermissionVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.service.MenuService;
|
import top.xyquan.ecomdmbbackend.modules.sys.service.MenuService;
|
||||||
|
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||||
import top.xyquan.ecomdmbbackend.utils.SecurityUtils;
|
import top.xyquan.ecomdmbbackend.utils.SecurityUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -30,9 +32,13 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
|||||||
implements CompanyMenuService {
|
implements CompanyMenuService {
|
||||||
|
|
||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
|
private final MenuMapper menuMapper;
|
||||||
|
private final CurrentUserContext currentUserContext;
|
||||||
|
|
||||||
public CompanyMenuServiceImpl(MenuService menuService) {
|
public CompanyMenuServiceImpl(MenuService menuService, MenuMapper menuMapper, CurrentUserContext currentUserContext) {
|
||||||
this.menuService = menuService;
|
this.menuService = menuService;
|
||||||
|
this.menuMapper = menuMapper;
|
||||||
|
this.currentUserContext = currentUserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,101 +86,6 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
|||||||
return convertToVO(companyMenu);
|
return convertToVO(companyMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public CompanyMenuVO updateCompanyMenu(UpdateCompanyMenuDTO updateCompanyMenuDTO, Long id) {
|
|
||||||
// 检查公司菜单是否存在
|
|
||||||
CompanyMenuPO existingCompanyMenu = this.getById(id);
|
|
||||||
if (existingCompanyMenu == null) {
|
|
||||||
throw new BusinessException("公司菜单不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证菜单是否存在
|
|
||||||
MenuPO menu = menuService.getById(updateCompanyMenuDTO.getMenuId());
|
|
||||||
if (menu == null) {
|
|
||||||
throw new BusinessException("菜单不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否已存在相同的公司菜单关联(排除自己)
|
|
||||||
LambdaQueryWrapper<CompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(CompanyMenuPO::getCompanyId, updateCompanyMenuDTO.getCompanyId())
|
|
||||||
.eq(CompanyMenuPO::getMenuId, updateCompanyMenuDTO.getMenuId())
|
|
||||||
.ne(CompanyMenuPO::getId, id);
|
|
||||||
if (this.count(wrapper) > 0) {
|
|
||||||
throw new BusinessException("该公司已关联此菜单");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新公司菜单
|
|
||||||
CompanyMenuPO companyMenu = new CompanyMenuPO();
|
|
||||||
BeanUtils.copyProperties(updateCompanyMenuDTO, companyMenu);
|
|
||||||
|
|
||||||
// 从菜单表拷贝自定义字段
|
|
||||||
companyMenu.setCustomName(menu.getName());
|
|
||||||
companyMenu.setCustomTitle(menu.getTitle());
|
|
||||||
companyMenu.setCustomIcon(menu.getIcon());
|
|
||||||
companyMenu.setCustomOrder(menu.getOrder());
|
|
||||||
|
|
||||||
// 设置更新人ID
|
|
||||||
companyMenu.setUpdateBy(SecurityUtils.getCurrentUserId());
|
|
||||||
|
|
||||||
// 更新公司菜单
|
|
||||||
this.updateById(companyMenu);
|
|
||||||
|
|
||||||
// 转换为VO并返回
|
|
||||||
return convertToVO(companyMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteCompanyMenu(Long id) {
|
|
||||||
// 检查公司菜单是否存在
|
|
||||||
CompanyMenuPO companyMenu = this.getById(id);
|
|
||||||
if (companyMenu == null) {
|
|
||||||
throw new BusinessException("公司菜单不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否有子菜单
|
|
||||||
LambdaQueryWrapper<CompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(CompanyMenuPO::getParentId, id);
|
|
||||||
if (this.count(wrapper) > 0) {
|
|
||||||
throw new BusinessException("存在子菜单,无法删除");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除公司菜单
|
|
||||||
this.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public List<CompanyMenuVO> batchCreateCompanyMenu(Long companyId, List<Long> menuIds) {
|
|
||||||
List<CompanyMenuVO> result = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Long menuId : menuIds) {
|
|
||||||
CreateCompanyMenuDTO createCompanyMenuDTO = new CreateCompanyMenuDTO();
|
|
||||||
createCompanyMenuDTO.setCompanyId(companyId);
|
|
||||||
createCompanyMenuDTO.setMenuId(menuId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
CompanyMenuVO companyMenuVO = createCompanyMenu(createCompanyMenuDTO);
|
|
||||||
result.add(companyMenuVO);
|
|
||||||
} catch (BusinessException e) {
|
|
||||||
// 如果已存在,跳过
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void batchDeleteCompanyMenu(Long companyId, List<Long> menuIds) {
|
|
||||||
LambdaQueryWrapper<CompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(CompanyMenuPO::getCompanyId, companyId)
|
|
||||||
.in(CompanyMenuPO::getMenuId, menuIds);
|
|
||||||
|
|
||||||
this.remove(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MenuVO> getCompanyMenusForRoute(Long companyId) {
|
public List<MenuVO> getCompanyMenusForRoute(Long companyId) {
|
||||||
// 查询公司所有菜单
|
// 查询公司所有菜单
|
||||||
@@ -249,6 +160,11 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新公司菜单
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @param menuIds 菜单ID列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchUpdateCompanyMenus(Long companyId, List<Long> menuIds) {
|
public void batchUpdateCompanyMenus(Long companyId, List<Long> menuIds) {
|
||||||
@@ -293,6 +209,119 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公司所有菜单列表
|
||||||
|
* @return 菜单列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MenuVO> getCompanyMenus() {
|
||||||
|
// 从用户上下文获取公司ID
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
if (companyId == null) {
|
||||||
|
throw new BusinessException("无法获取公司信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询公司菜单中间表,只获取status=1的记录
|
||||||
|
LambdaQueryWrapper<CompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(CompanyMenuPO::getCompanyId, companyId)
|
||||||
|
.eq(CompanyMenuPO::getStatus, 1);
|
||||||
|
|
||||||
|
List<CompanyMenuPO> companyMenus = this.list(wrapper);
|
||||||
|
|
||||||
|
if (companyMenus.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取菜单ID列表
|
||||||
|
List<Long> menuIds = companyMenus.stream()
|
||||||
|
.map(CompanyMenuPO::getMenuId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 查询系统菜单信息(不覆盖自定义字段,中间表只作为过滤条件)
|
||||||
|
LambdaQueryWrapper<MenuPO> menuWrapper = new LambdaQueryWrapper<>();
|
||||||
|
menuWrapper.in(MenuPO::getId, menuIds)
|
||||||
|
.orderByAsc(MenuPO::getOrder);
|
||||||
|
|
||||||
|
List<MenuPO> menus = menuService.list(menuWrapper);
|
||||||
|
|
||||||
|
// 转换为MenuVO,不覆盖自定义字段
|
||||||
|
return menus.stream()
|
||||||
|
.map(this::convertMenuToVO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公司完整菜单树
|
||||||
|
* @return 菜单树列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MenuVO> getCompanyMenuTree() {
|
||||||
|
// 获取公司所有菜单列表
|
||||||
|
List<MenuVO> menuList = getCompanyMenus();
|
||||||
|
|
||||||
|
// 构建树形结构
|
||||||
|
return buildMenuTree(menuList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建菜单树
|
||||||
|
*/
|
||||||
|
private List<MenuVO> buildMenuTree(List<MenuVO> menuList) {
|
||||||
|
// 按父ID分组
|
||||||
|
Map<Long, List<MenuVO>> parentMap = menuList.stream()
|
||||||
|
.collect(Collectors.groupingBy(menu -> menu.getParentId() != null ? menu.getParentId() : 0L));
|
||||||
|
|
||||||
|
// 递归构建树
|
||||||
|
return buildTreeRecursive(parentMap, 0L, new ArrayList<>(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归构建树形结构(带循环引用检测)
|
||||||
|
*/
|
||||||
|
private List<MenuVO> buildTreeRecursive(Map<Long, List<MenuVO>> parentMap, Long parentId,
|
||||||
|
List<Long> visitedIds, int depth) {
|
||||||
|
// 防止无限递归,设置最大深度限制
|
||||||
|
if (depth > 100) {
|
||||||
|
throw new BusinessException("菜单层级过深,可能存在循环引用");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MenuVO> children = parentMap.get(parentId);
|
||||||
|
if (children == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MenuVO menu : children) {
|
||||||
|
// 检查是否已经访问过该节点,防止循环引用
|
||||||
|
if (visitedIds.contains(menu.getId())) {
|
||||||
|
throw new BusinessException("检测到菜单循环引用,菜单ID: " + menu.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建新访问路径,包含当前节点
|
||||||
|
List<Long> newVisitedIds = new ArrayList<>(visitedIds);
|
||||||
|
newVisitedIds.add(menu.getId());
|
||||||
|
|
||||||
|
// 递归构建子菜单
|
||||||
|
List<MenuVO> childList = buildTreeRecursive(parentMap, menu.getId(), newVisitedIds, depth + 1);
|
||||||
|
menu.setChildren(childList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换MenuPO为MenuVO(包含权限信息)
|
||||||
|
*/
|
||||||
|
private MenuVO convertMenuToVO(MenuPO menu) {
|
||||||
|
MenuVO menuVO = new MenuVO();
|
||||||
|
BeanUtils.copyProperties(menu, menuVO);
|
||||||
|
|
||||||
|
// 查询菜单关联的权限
|
||||||
|
List<PermissionVO> permissions = menuMapper.selectPermissionsByMenuId(menu.getId());
|
||||||
|
menuVO.setPermissions(permissions);
|
||||||
|
|
||||||
|
return menuVO;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为VO
|
* 转换为VO
|
||||||
*/
|
*/
|
||||||
|
|||||||
+37
@@ -71,6 +71,11 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
this.menuService = menuService;
|
this.menuService = menuService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建公司
|
||||||
|
* @param createCompanyDTO 创建公司DTO
|
||||||
|
* @return 公司VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public CompanyVO createCompany(CreateCompanyDTO createCompanyDTO) {
|
public CompanyVO createCompany(CreateCompanyDTO createCompanyDTO) {
|
||||||
@@ -124,6 +129,12 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
return convertToVO(company);
|
return convertToVO(company);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新公司
|
||||||
|
* @param updateCompanyDTO 更新公司DTO
|
||||||
|
* @param id 公司ID
|
||||||
|
* @return 公司VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CompanyVO updateCompany(UpdateCompanyDTO updateCompanyDTO, Long id) {
|
public CompanyVO updateCompany(UpdateCompanyDTO updateCompanyDTO, Long id) {
|
||||||
// 检查公司是否存在
|
// 检查公司是否存在
|
||||||
@@ -166,6 +177,10 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
return convertToVO(company);
|
return convertToVO(company);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公司
|
||||||
|
* @param id 公司ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteCompany(Long id) {
|
public void deleteCompany(Long id) {
|
||||||
// 检查公司是否存在
|
// 检查公司是否存在
|
||||||
@@ -178,6 +193,11 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公司分页列表
|
||||||
|
* @param pageQuery 分页查询DTO
|
||||||
|
* @return 分页结果VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<CompanyVO> getCompanyPage(PageQueryDTO<CompanyFilterDTO> pageQuery) {
|
public PageResultVO<CompanyVO> getCompanyPage(PageQueryDTO<CompanyFilterDTO> pageQuery) {
|
||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
@@ -218,6 +238,11 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
return PageResultVO.create(records, pageResult.getTotal(), pageQuery.getPage(), pageQuery.getPageSize());
|
return PageResultVO.create(records, pageResult.getTotal(), pageQuery.getPage(), pageQuery.getPageSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传公司Logo
|
||||||
|
* @param file 文件
|
||||||
|
* @return 公司VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CompanyVO uploadLogo(MultipartFile file) {
|
public CompanyVO uploadLogo(MultipartFile file) {
|
||||||
// 获取当前用户所属公司ID
|
// 获取当前用户所属公司ID
|
||||||
@@ -244,6 +269,10 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
return convertToVO(company);
|
return convertToVO(company);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化公司菜单
|
||||||
|
* @param companyId 公司ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initCompanyMenus(Long companyId) {
|
public void initCompanyMenus(Long companyId) {
|
||||||
// 查询所有非超级菜单,按层级顺序排序
|
// 查询所有非超级菜单,按层级顺序排序
|
||||||
@@ -312,6 +341,10 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化公司部门
|
||||||
|
* @param companyId 公司ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initCompanyDepartments(Long companyId) {
|
public void initCompanyDepartments(Long companyId) {
|
||||||
// 创建默认部门
|
// 创建默认部门
|
||||||
@@ -338,6 +371,10 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化公司岗位
|
||||||
|
* @param companyId 公司ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initCompanyPositions(Long companyId) {
|
public void initCompanyPositions(Long companyId) {
|
||||||
// 创建默认岗位
|
// 创建默认岗位
|
||||||
|
|||||||
+28
@@ -34,6 +34,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建部门
|
||||||
|
* @param createDepartmentDTO 创建部门DTO
|
||||||
|
* @return 部门VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public DepartmentVO createDepartment(CreateDepartmentDTO createDepartmentDTO) {
|
public DepartmentVO createDepartment(CreateDepartmentDTO createDepartmentDTO) {
|
||||||
@@ -70,6 +75,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
return convertToVO(department);
|
return convertToVO(department);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新部门
|
||||||
|
* @param updateDepartmentDTO 更新部门DTO
|
||||||
|
* @param id 部门ID
|
||||||
|
* @return 部门VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public DepartmentVO updateDepartment(UpdateDepartmentDTO updateDepartmentDTO, Long id) {
|
public DepartmentVO updateDepartment(UpdateDepartmentDTO updateDepartmentDTO, Long id) {
|
||||||
@@ -112,6 +123,10 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
return convertToVO(department);
|
return convertToVO(department);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除部门
|
||||||
|
* @param id 部门ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteDepartment(Long id) {
|
public void deleteDepartment(Long id) {
|
||||||
// 从token中获取公司ID
|
// 从token中获取公司ID
|
||||||
@@ -139,6 +154,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门分页列表
|
||||||
|
* @param pageQueryDTO 分页查询DTO
|
||||||
|
* @return 分页结果VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO) {
|
public PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO) {
|
||||||
// 从token中获取公司ID
|
// 从token中获取公司ID
|
||||||
@@ -180,6 +200,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为指定公司创建部门
|
||||||
|
* @param createDepartmentDTO 创建部门DTO
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @return 部门VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public DepartmentVO createDepartmentForCompany(CreateDepartmentDTO createDepartmentDTO, Long companyId) {
|
public DepartmentVO createDepartmentForCompany(CreateDepartmentDTO createDepartmentDTO, Long companyId) {
|
||||||
@@ -215,6 +241,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为VO
|
* 转换为VO
|
||||||
|
* @param department 部门PO
|
||||||
|
* @return 部门VO
|
||||||
*/
|
*/
|
||||||
private DepartmentVO convertToVO(DepartmentPO department) {
|
private DepartmentVO convertToVO(DepartmentPO department) {
|
||||||
DepartmentVO departmentVO = new DepartmentVO();
|
DepartmentVO departmentVO = new DepartmentVO();
|
||||||
|
|||||||
+40
@@ -47,6 +47,10 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
this.menuService = menuService;
|
this.menuService = menuService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量分配岗位菜单权限
|
||||||
|
* @param batchAssignDTO 批量分配DTO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchAssignPositionMenus(BatchAssignPositionMenuDTO batchAssignDTO) {
|
public void batchAssignPositionMenus(BatchAssignPositionMenuDTO batchAssignDTO) {
|
||||||
@@ -73,6 +77,11 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除岗位菜单权限
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param companyMenuId 公司菜单权限ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removePositionMenu(Long positionId, Long companyMenuId) {
|
public void removePositionMenu(Long positionId, Long companyMenuId) {
|
||||||
LambdaQueryWrapper<PositionCompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PositionCompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -85,6 +94,11 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位ID查询菜单权限列表
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @return 菜单权限列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PositionMenuVO> getMenusByPositionId(Long positionId) {
|
public List<PositionMenuVO> getMenusByPositionId(Long positionId) {
|
||||||
// 查询岗位菜单权限关联记录
|
// 查询岗位菜单权限关联记录
|
||||||
@@ -137,6 +151,11 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位ID列表查询菜单权限列表
|
||||||
|
* @param positionIds 岗位ID列表
|
||||||
|
* @return 菜单权限列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PositionMenuVO> getMenusByPositionIds(List<Long> positionIds) {
|
public List<PositionMenuVO> getMenusByPositionIds(List<Long> positionIds) {
|
||||||
if (positionIds == null || positionIds.isEmpty()) {
|
if (positionIds == null || positionIds.isEmpty()) {
|
||||||
@@ -197,6 +216,12 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查岗位是否有指定菜单权限
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param companyMenuId 公司菜单权限ID
|
||||||
|
* @return 是否有权限
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPositionMenu(Long positionId, Long companyMenuId) {
|
public boolean hasPositionMenu(Long positionId, Long companyMenuId) {
|
||||||
LambdaQueryWrapper<PositionCompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PositionCompanyMenuPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -206,6 +231,11 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
return this.count(wrapper) > 0;
|
return this.count(wrapper) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据职位获取菜单(以MenuVO格式返回,用于动态路由)
|
||||||
|
* @param positionId 职位ID
|
||||||
|
* @return 菜单列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MenuVO> getPositionMenusForRoute(Long positionId) {
|
public List<MenuVO> getPositionMenusForRoute(Long positionId) {
|
||||||
// 使用现有的方法获取职位菜单权限
|
// 使用现有的方法获取职位菜单权限
|
||||||
@@ -281,6 +311,11 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取岗位所有公司菜单ID列表
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @return 公司菜单ID列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Long> getPositionCompanyMenuIds(Long positionId) {
|
public List<Long> getPositionCompanyMenuIds(Long positionId) {
|
||||||
// 查询岗位菜单权限关联记录
|
// 查询岗位菜单权限关联记录
|
||||||
@@ -295,6 +330,11 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新岗位菜单权限
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param companyMenuIds 公司菜单ID列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchUpdatePositionCompanyMenus(Long positionId, List<Long> companyMenuIds) {
|
public void batchUpdatePositionCompanyMenus(Long positionId, List<Long> companyMenuIds) {
|
||||||
|
|||||||
-1
@@ -4,7 +4,6 @@ import top.xyquan.ecomdmbbackend.modules.sys.model.dto.menu_permission.AddMenuPe
|
|||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.dto.menu_permission.RemoveMenuPermissionDTO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.dto.menu_permission.RemoveMenuPermissionDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuPermissionVO;
|
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuPermissionVO;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单权限映射服务接口
|
* 菜单权限映射服务接口
|
||||||
|
|||||||
+9
@@ -25,6 +25,11 @@ public class MenuPermissionServiceImpl implements MenuPermissionService {
|
|||||||
|
|
||||||
private final MenuPermissionMapper menuPermissionMapper;
|
private final MenuPermissionMapper menuPermissionMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加菜单权限映射
|
||||||
|
* @param addMenuPermissionDTO 添加菜单权限映射DTO
|
||||||
|
* @return 菜单权限映射VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public MenuPermissionVO addMenuPermission(AddMenuPermissionDTO addMenuPermissionDTO) {
|
public MenuPermissionVO addMenuPermission(AddMenuPermissionDTO addMenuPermissionDTO) {
|
||||||
@@ -60,6 +65,10 @@ public class MenuPermissionServiceImpl implements MenuPermissionService {
|
|||||||
.orElseThrow(() -> new BusinessException("查询菜单权限映射失败"));
|
.orElseThrow(() -> new BusinessException("查询菜单权限映射失败"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除菜单权限映射
|
||||||
|
* @param removeMenuPermissionDTO 删除菜单权限映射DTO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void removeMenuPermission(RemoveMenuPermissionDTO removeMenuPermissionDTO) {
|
public void removeMenuPermission(RemoveMenuPermissionDTO removeMenuPermissionDTO) {
|
||||||
|
|||||||
+32
@@ -35,6 +35,11 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建菜单
|
||||||
|
* @param createMenuDTO 创建菜单DTO
|
||||||
|
* @return 菜单VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MenuVO createMenu(CreateMenuDTO createMenuDTO) {
|
public MenuVO createMenu(CreateMenuDTO createMenuDTO) {
|
||||||
// 验证父菜单是否存在
|
// 验证父菜单是否存在
|
||||||
@@ -83,6 +88,12 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
return convertToVO(menu);
|
return convertToVO(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新菜单
|
||||||
|
* @param updateMenuDTO 更新菜单DTO
|
||||||
|
* @param id 菜单ID
|
||||||
|
* @return 菜单VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MenuVO updateMenu(UpdateMenuDTO updateMenuDTO, Long id) {
|
public MenuVO updateMenu(UpdateMenuDTO updateMenuDTO, Long id) {
|
||||||
// 检查菜单是否存在
|
// 检查菜单是否存在
|
||||||
@@ -124,6 +135,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
return convertToVO(existingMenu);
|
return convertToVO(existingMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除菜单
|
||||||
|
* @param id 菜单ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteMenu(Long id) {
|
public void deleteMenu(Long id) {
|
||||||
// 检查菜单是否存在
|
// 检查菜单是否存在
|
||||||
@@ -143,6 +158,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单树
|
||||||
|
* @return 菜单树列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MenuVO> getMenuTree() {
|
public List<MenuVO> getMenuTree() {
|
||||||
// 查询所有菜单
|
// 查询所有菜单
|
||||||
@@ -159,6 +178,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
return buildMenuTree(menuVOList);
|
return buildMenuTree(menuVOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有菜单
|
||||||
|
* @return 菜单列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MenuVO> getAllMenus() {
|
public List<MenuVO> getAllMenus() {
|
||||||
// 查询所有菜单
|
// 查询所有菜单
|
||||||
@@ -172,6 +195,11 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单详情
|
||||||
|
* @param id 菜单ID
|
||||||
|
* @return 菜单详情
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MenuVO getMenuDetail(Long id) {
|
public MenuVO getMenuDetail(Long id) {
|
||||||
// 根据ID查询菜单
|
// 根据ID查询菜单
|
||||||
@@ -184,6 +212,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuPO> implements
|
|||||||
return convertToVO(menuPO);
|
return convertToVO(menuPO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量菜单排序
|
||||||
|
* @param batchSortMenuDTO 批量排序DTO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchSortMenu(BatchSortMenuDTO batchSortMenuDTO) {
|
public void batchSortMenu(BatchSortMenuDTO batchSortMenuDTO) {
|
||||||
|
|||||||
+21
@@ -28,6 +28,13 @@ public class PermissionCheckServiceImpl implements PermissionCheckService {
|
|||||||
this.menuPermissionMapper = menuPermissionMapper;
|
this.menuPermissionMapper = menuPermissionMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位ID和权限代码检查是否有权限
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param permissionCode 权限代码
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @return 是否有权限
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionByPosition(Long positionId, String permissionCode, Long companyId) {
|
public boolean hasPermissionByPosition(Long positionId, String permissionCode, Long companyId) {
|
||||||
if (positionId == null || permissionCode == null || companyId == null) {
|
if (positionId == null || permissionCode == null || companyId == null) {
|
||||||
@@ -55,6 +62,12 @@ public class PermissionCheckServiceImpl implements PermissionCheckService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取岗位权限列表
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @return 权限列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPositionPermissions(Long positionId, Long companyId) {
|
public List<String> getPositionPermissions(Long positionId, Long companyId) {
|
||||||
if (positionId == null || companyId == null) {
|
if (positionId == null || companyId == null) {
|
||||||
@@ -84,6 +97,14 @@ public class PermissionCheckServiceImpl implements PermissionCheckService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色和权限代码检查是否有权限
|
||||||
|
* @param role 角色
|
||||||
|
* @param permissionCode 权限代码
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @return 是否有权限
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionByRole(String role, String permissionCode, Long positionId, Long companyId) {
|
public boolean hasPermissionByRole(String role, String permissionCode, Long positionId, Long companyId) {
|
||||||
if (role == null || permissionCode == null) {
|
if (role == null || permissionCode == null) {
|
||||||
|
|||||||
+42
@@ -41,6 +41,11 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
this.positionCompanyMenuService = positionCompanyMenuService;
|
this.positionCompanyMenuService = positionCompanyMenuService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建权限
|
||||||
|
* @param createPermissionDTO 创建权限DTO
|
||||||
|
* @return 权限VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PermissionVO createPermission(CreatePermissionDTO createPermissionDTO) {
|
public PermissionVO createPermission(CreatePermissionDTO createPermissionDTO) {
|
||||||
// 检查权限码是否已存在
|
// 检查权限码是否已存在
|
||||||
@@ -66,6 +71,12 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
return convertToVO(permissionPO);
|
return convertToVO(permissionPO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新权限
|
||||||
|
* @param updatePermissionDTO 更新权限DTO
|
||||||
|
* @param id 权限ID
|
||||||
|
* @return 权限VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PermissionVO updatePermission(UpdatePermissionDTO updatePermissionDTO, Long id) {
|
public PermissionVO updatePermission(UpdatePermissionDTO updatePermissionDTO, Long id) {
|
||||||
PermissionPO existingPermission = permissionMapper.selectById(id);
|
PermissionPO existingPermission = permissionMapper.selectById(id);
|
||||||
@@ -89,6 +100,10 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
return convertToVO(existingPermission);
|
return convertToVO(existingPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除权限
|
||||||
|
* @param id 权限ID
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deletePermission(Long id) {
|
public void deletePermission(Long id) {
|
||||||
PermissionPO permission = permissionMapper.selectById(id);
|
PermissionPO permission = permissionMapper.selectById(id);
|
||||||
@@ -99,6 +114,11 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
permissionMapper.deleteById(id);
|
permissionMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取权限列表
|
||||||
|
* @param filterDTO 过滤条件
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<PermissionVO> getPermissionPage(PageQueryDTO<PermissionFilterDTO> filterDTO) {
|
public PageResultVO<PermissionVO> getPermissionPage(PageQueryDTO<PermissionFilterDTO> filterDTO) {
|
||||||
Page<PermissionPO> page = new Page<>(filterDTO.getPage(), filterDTO.getPageSize());
|
Page<PermissionPO> page = new Page<>(filterDTO.getPage(), filterDTO.getPageSize());
|
||||||
@@ -140,6 +160,11 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
(int) permissionPage.getSize());
|
(int) permissionPage.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取权限详情
|
||||||
|
* @param id 权限ID
|
||||||
|
* @return 权限详情
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PermissionVO getPermissionDetail(Long id) {
|
public PermissionVO getPermissionDetail(Long id) {
|
||||||
PermissionPO permission = permissionMapper.selectById(id);
|
PermissionPO permission = permissionMapper.selectById(id);
|
||||||
@@ -150,6 +175,10 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
return convertToVO(permission);
|
return convertToVO(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有权限列表
|
||||||
|
* @return 权限列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PermissionVO> getAllPermissions() {
|
public List<PermissionVO> getAllPermissions() {
|
||||||
LambdaQueryWrapper<PermissionPO> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PermissionPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -163,6 +192,13 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位ID和权限代码检查是否有权限
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param permissionCode 权限代码
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @return 是否有权限
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissionByPosition(Long positionId, String permissionCode, Long companyId) {
|
public boolean hasPermissionByPosition(Long positionId, String permissionCode, Long companyId) {
|
||||||
if (positionId == null || permissionCode == null || companyId == null) {
|
if (positionId == null || permissionCode == null || companyId == null) {
|
||||||
@@ -180,6 +216,12 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||||||
return !positionMenus.isEmpty();
|
return !positionMenus.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取岗位权限列表
|
||||||
|
* @param positionId 岗位ID
|
||||||
|
* @param companyId 公司ID
|
||||||
|
* @return 权限列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPositionPermissions(Long positionId, Long companyId) {
|
public List<String> getPositionPermissions(Long positionId, Long companyId) {
|
||||||
if (positionId == null || companyId == null) {
|
if (positionId == null || companyId == null) {
|
||||||
|
|||||||
+12
@@ -37,6 +37,10 @@ public class UserMenuServiceImpl implements UserMenuService {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户菜单
|
||||||
|
* @return 用户菜单列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<UserMenuVO> getUserMenus() {
|
public List<UserMenuVO> getUserMenus() {
|
||||||
// 从Security上下文获取用户ID
|
// 从Security上下文获取用户ID
|
||||||
@@ -109,6 +113,8 @@ public class UserMenuServiceImpl implements UserMenuService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建路由树形结构
|
* 构建路由树形结构
|
||||||
|
* @param menus 菜单列表
|
||||||
|
* @return 路由树形结构
|
||||||
*/
|
*/
|
||||||
private List<UserMenuVO> buildRouteTree(List<MenuVO> menus) {
|
private List<UserMenuVO> buildRouteTree(List<MenuVO> menus) {
|
||||||
// 按父ID分组
|
// 按父ID分组
|
||||||
@@ -121,6 +127,9 @@ public class UserMenuServiceImpl implements UserMenuService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归构建树形结构
|
* 递归构建树形结构
|
||||||
|
* @param parentMap 父ID分组
|
||||||
|
* @param parentId 父ID
|
||||||
|
* @return 路由树形结构
|
||||||
*/
|
*/
|
||||||
private List<UserMenuVO> buildTreeRecursive(Map<Long, List<MenuVO>> parentMap, Long parentId) {
|
private List<UserMenuVO> buildTreeRecursive(Map<Long, List<MenuVO>> parentMap, Long parentId) {
|
||||||
List<MenuVO> children = parentMap.get(parentId);
|
List<MenuVO> children = parentMap.get(parentId);
|
||||||
@@ -143,6 +152,8 @@ public class UserMenuServiceImpl implements UserMenuService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将单个MenuVO转换为RouteVO - 符合 vben 动态路由标准
|
* 将单个MenuVO转换为RouteVO - 符合 vben 动态路由标准
|
||||||
|
* @param menu 菜单VO
|
||||||
|
* @return 路由VO
|
||||||
*/
|
*/
|
||||||
private UserMenuVO convertMenuToRoute(MenuVO menu) {
|
private UserMenuVO convertMenuToRoute(MenuVO menu) {
|
||||||
UserMenuVO route = new UserMenuVO();
|
UserMenuVO route = new UserMenuVO();
|
||||||
@@ -186,6 +197,7 @@ public class UserMenuServiceImpl implements UserMenuService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建测试菜单数据(临时用于调试)
|
* 创建测试菜单数据(临时用于调试)
|
||||||
|
* @return 测试菜单列表
|
||||||
*/
|
*/
|
||||||
private List<MenuVO> createTestMenus() {
|
private List<MenuVO> createTestMenus() {
|
||||||
List<MenuVO> testMenus = new ArrayList<>();
|
List<MenuVO> testMenus = new ArrayList<>();
|
||||||
|
|||||||
+50
@@ -48,6 +48,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
this.mediaImageService = mediaImageService;
|
this.mediaImageService = mediaImageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户
|
||||||
|
* @param registerDTO 注册DTO
|
||||||
|
* @return 登录VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LoginVO register(RegisterDTO registerDTO) {
|
public LoginVO register(RegisterDTO registerDTO) {
|
||||||
// 验证登录账号和手机号码至少填写一个
|
// 验证登录账号和手机号码至少填写一个
|
||||||
@@ -91,6 +96,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return generateLoginResponse(user);
|
return generateLoginResponse(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录
|
||||||
|
* @param loginDTO 登录DTO
|
||||||
|
* @return 登录VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LoginVO login(LoginDTO loginDTO) {
|
public LoginVO login(LoginDTO loginDTO) {
|
||||||
// 根据账号查询用户
|
// 根据账号查询用户
|
||||||
@@ -117,6 +127,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return generateLoginResponse(user);
|
return generateLoginResponse(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据账号查询用户
|
||||||
|
* @param account 账号
|
||||||
|
* @return 用户PO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserPO findByAccount(String account) {
|
public UserPO findByAccount(String account) {
|
||||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -126,6 +141,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return this.getOne(wrapper);
|
return this.getOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户信息
|
||||||
|
* @return 用户VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserVO getCurrentUserInfo() {
|
public UserVO getCurrentUserInfo() {
|
||||||
// 从Security上下文获取用户ID
|
// 从Security上下文获取用户ID
|
||||||
@@ -146,6 +165,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return userVO;
|
return userVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新当前用户信息
|
||||||
|
* @param updateUserInfoDTO 更新用户信息DTO
|
||||||
|
* @return 用户VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserVO updateCurrentUserInfo(UpdateUserInfoDTO updateUserInfoDTO) {
|
public UserVO updateCurrentUserInfo(UpdateUserInfoDTO updateUserInfoDTO) {
|
||||||
// 从Security上下文获取用户ID
|
// 从Security上下文获取用户ID
|
||||||
@@ -200,6 +224,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return userVO;
|
return userVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
* @param changePasswordDTO 修改密码DTO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void changePassword(ChangePasswordDTO changePasswordDTO) {
|
public void changePassword(ChangePasswordDTO changePasswordDTO) {
|
||||||
// 从Security上下文获取用户ID
|
// 从Security上下文获取用户ID
|
||||||
@@ -228,6 +256,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
this.updateById(user);
|
this.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传头像
|
||||||
|
* @param file 文件
|
||||||
|
* @return 用户VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserVO uploadAvatar(MultipartFile file) {
|
public UserVO uploadAvatar(MultipartFile file) {
|
||||||
// 从Security上下文获取用户ID
|
// 从Security上下文获取用户ID
|
||||||
@@ -256,6 +289,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return userVO;
|
return userVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新令牌
|
||||||
|
* @param refreshTokenDTO 刷新令牌DTO
|
||||||
|
* @return 登录VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LoginVO refreshToken(RefreshTokenDTO refreshTokenDTO) {
|
public LoginVO refreshToken(RefreshTokenDTO refreshTokenDTO) {
|
||||||
// 验证刷新令牌
|
// 验证刷新令牌
|
||||||
@@ -289,6 +327,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return generateLoginResponseWithRole(user, refreshPayload.getRole());
|
return generateLoginResponseWithRole(user, refreshPayload.getRole());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切换账户
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 登录VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LoginVO switchAccount(Long userId) {
|
public LoginVO switchAccount(Long userId) {
|
||||||
// 查询目标用户信息
|
// 查询目标用户信息
|
||||||
@@ -306,6 +349,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
return generateLoginResponseWithRole(targetUser, "super");
|
return generateLoginResponseWithRole(targetUser, "super");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户分页列表
|
||||||
|
* @param pageQuery 分页查询DTO
|
||||||
|
* @return 分页结果VO
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<UserVO> getUserPage(PageQueryDTO<UserFilterDTO> pageQuery) {
|
public PageResultVO<UserVO> getUserPage(PageQueryDTO<UserFilterDTO> pageQuery) {
|
||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
@@ -424,6 +472,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算密码安全级别
|
* 计算密码安全级别
|
||||||
|
* @param password 密码
|
||||||
|
* @return 密码安全级别
|
||||||
*/
|
*/
|
||||||
private Integer calculatePasswordSecurityLevel(String password) {
|
private Integer calculatePasswordSecurityLevel(String password) {
|
||||||
if (password == null || password.length() < 8) {
|
if (password == null || password.length() < 8) {
|
||||||
|
|||||||
Reference in New Issue
Block a user