mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
refactor: 拆分公司/系统账户权限与模块,系统账户迁至 sys/account 并更新菜单
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
-- 公司账户权限:挂到 org:company 下,权限码 org:company:account:*
|
||||
|
||||
UPDATE `sys_permission` p
|
||||
JOIN `sys_permission` company ON company.code = 'org:company'
|
||||
SET p.parent_id = company.id, p.code = 'org:company:account', p.name = '公司账户'
|
||||
WHERE p.code = 'org:account';
|
||||
|
||||
UPDATE `sys_permission` SET `code` = 'org:company:account:read' WHERE `code` = 'org:account:read';
|
||||
UPDATE `sys_permission` SET `code` = 'org:company:account:create' WHERE `code` = 'org:account:create';
|
||||
UPDATE `sys_permission` SET `code` = 'org:company:account:update' WHERE `code` = 'org:account:update';
|
||||
UPDATE `sys_permission` SET `code` = 'org:company:account:delete' WHERE `code` = 'org:account:delete';
|
||||
|
||||
-- 平台系统账户权限:挂到 sys 下,权限码 sys:account:*
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1220, (SELECT id FROM `sys_permission` WHERE `code` = 'sys' LIMIT 1), 'sys:account', '系统账户', 'module', 1, '', 25
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1220 OR `code` = 'sys:account');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1221, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:read', '查看', 'api', 1, '', 1
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1221 OR `code` = 'sys:account:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1222, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:create', '创建', 'api', 1, '', 2
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1222 OR `code` = 'sys:account:create');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1223, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:update', '更新', 'api', 1, '', 3
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1223 OR `code` = 'sys:account:update');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1224, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:delete', '删除', 'api', 1, '', 4
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1224 OR `code` = 'sys:account:delete');
|
||||
|
||||
-- 「系统账户」菜单改绑 sys:account(原 sys:user / 平台账户)
|
||||
DELETE mp FROM `sys_menu_permission` mp
|
||||
JOIN `sys_menu` m ON m.id = mp.menu_id
|
||||
JOIN `sys_permission` p ON p.id = mp.permission_id
|
||||
WHERE m.name IN ('平台账户', '系统账户') AND p.code LIKE 'sys:user:%';
|
||||
|
||||
UPDATE `sys_menu`
|
||||
SET `name` = '系统账户',
|
||||
`title` = '系统账户',
|
||||
`route_name` = 'SysAccountManagement',
|
||||
`path` = '/sys/account',
|
||||
`component` = '/sys/account/index'
|
||||
WHERE `name` = '平台账户' OR `path` = '/sys/account-super' OR `route_name` = 'SuperAccountManagement';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m
|
||||
JOIN `sys_permission` p ON p.code LIKE 'sys:account:%'
|
||||
WHERE m.name = '系统账户';
|
||||
+6
-6
@@ -15,7 +15,7 @@ import top.xyquan.ecomdmbbackend.modules.org.company.account.service.AccountServ
|
||||
/**
|
||||
* 公司账户管理控制器
|
||||
* <p>
|
||||
* 供公司拥有者管理本公司成员账户;需 org:account:* 权限,超管可访问全部接口。
|
||||
* 供公司拥有者管理本公司成员账户;需 org:company:account:* 权限,超管可访问全部接口。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/company/account")
|
||||
@@ -29,7 +29,7 @@ public class AccountController {
|
||||
|
||||
/** 创建账户:手机号已注册则拉入公司,未注册则新建用户(密码必填) */
|
||||
@PostMapping("/create")
|
||||
@RequirePermission(value = "org:account:create", description = "创建账户", allowSuper = true)
|
||||
@RequirePermission(value = "org:company:account:create", description = "创建账户", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> createAccountForCompany(@Valid @RequestBody CreateAccountDTO createAccountDTO) {
|
||||
CompanyAccountVO accountVO = accountService.createAccountForCompany(createAccountDTO);
|
||||
return ApiResponse.success("账户创建成功", accountVO);
|
||||
@@ -37,7 +37,7 @@ public class AccountController {
|
||||
|
||||
/** 分页查询当前公司成员对应的账户列表 */
|
||||
@PostMapping("/list")
|
||||
@RequirePermission(value = "org:account:read", description = "查询账户列表", allowSuper = true)
|
||||
@RequirePermission(value = "org:company:account:read", description = "查询账户列表", allowSuper = true)
|
||||
public ApiResponse<PageResultVO<CompanyAccountVO>> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||
PageResultVO<CompanyAccountVO> pageResult = accountService.getAccountPageForCompany(pageQuery);
|
||||
return ApiResponse.success("获取账户列表成功", pageResult);
|
||||
@@ -45,7 +45,7 @@ public class AccountController {
|
||||
|
||||
/** 更新账户基本信息及职位、部门关联 */
|
||||
@PutMapping("/update/{accountId}")
|
||||
@RequirePermission(value = "org:account:update", description = "更新账户", allowSuper = true)
|
||||
@RequirePermission(value = "org:company:account:update", description = "更新账户", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> updateAccount(
|
||||
@PathVariable Long accountId,
|
||||
@Valid @RequestBody UpdateAccountDTO updateAccountDTO) {
|
||||
@@ -55,7 +55,7 @@ public class AccountController {
|
||||
|
||||
/** 删除本公司账户:解绑本公司成员;用户无其他公司时才停用 sys_user */
|
||||
@DeleteMapping("/delete/{accountId}")
|
||||
@RequirePermission(value = "org:account:delete", description = "删除账户", allowSuper = true)
|
||||
@RequirePermission(value = "org:company:account:delete", description = "删除账户", allowSuper = true)
|
||||
public ApiResponse<Void> deleteAccount(
|
||||
@PathVariable Long accountId) {
|
||||
accountService.deleteAccount(accountId);
|
||||
@@ -63,7 +63,7 @@ public class AccountController {
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{accountId}")
|
||||
@RequirePermission(value = "org:account:read", description = "获取账户详情", allowSuper = true)
|
||||
@RequirePermission(value = "org:company:account:read", description = "获取账户详情", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> getAccountDetail(
|
||||
@PathVariable Long accountId) {
|
||||
CompanyAccountVO accountVO = accountService.getAccountDetail(accountId);
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.org.company.account.controller;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.service.SuperAccountService;
|
||||
|
||||
/**
|
||||
* 超级管理员账户管理控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/super/account")
|
||||
public class SuperAccountController {
|
||||
|
||||
private final SuperAccountService superAccountService;
|
||||
|
||||
public SuperAccountController(SuperAccountService superAccountService) {
|
||||
this.superAccountService = superAccountService;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission(value = "org:account:create", description = "创建账户", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> createAccount(@Valid @RequestBody SuperCreateAccountDTO superCreateAccountDTO) {
|
||||
CompanyAccountVO accountVO = superAccountService.createAccount(superCreateAccountDTO);
|
||||
return ApiResponse.success("账户创建成功", accountVO);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@RequirePermission(value = "org:account:read", description = "查询账户列表", allowSuper = true)
|
||||
public ApiResponse<PageResultVO<CompanyAccountVO>> getAccountPage(@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||
PageResultVO<CompanyAccountVO> pageResult = superAccountService.getAccountPage(pageQuery);
|
||||
return ApiResponse.success("获取账户列表成功", pageResult);
|
||||
}
|
||||
|
||||
@PutMapping("/update/{accountId}")
|
||||
@RequirePermission(value = "org:account:update", description = "更新账户", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> updateAccount(
|
||||
@PathVariable Long accountId,
|
||||
@Valid @RequestBody SuperUpdateAccountDTO superUpdateAccountDTO) {
|
||||
CompanyAccountVO accountVO = superAccountService.updateAccount(superUpdateAccountDTO, accountId);
|
||||
return ApiResponse.success("账户更新成功", accountVO);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{accountId}")
|
||||
@RequirePermission(value = "org:account:delete", description = "删除账户", allowSuper = true)
|
||||
public ApiResponse<Void> deleteAccount(
|
||||
@PathVariable Long accountId) {
|
||||
superAccountService.deleteAccount(accountId);
|
||||
return ApiResponse.success("账户删除成功");
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{accountId}")
|
||||
@RequirePermission(value = "org:account:read", description = "查询账户详情", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> getAccountDetail(
|
||||
@PathVariable Long accountId) {
|
||||
CompanyAccountVO accountVO = superAccountService.getAccountDetail(accountId);
|
||||
return ApiResponse.success("获取账户详情成功", accountVO);
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.org.company.account.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
|
||||
|
||||
/**
|
||||
* 超级管理员账户管理服务接口
|
||||
*/
|
||||
public interface SuperAccountService extends IService<UserPO> {
|
||||
|
||||
/**
|
||||
* 创建账户(超管接口)
|
||||
*
|
||||
* @param superCreateAccountDTO 创建账户信息
|
||||
* @return 账户信息
|
||||
*/
|
||||
CompanyAccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO);
|
||||
|
||||
/**
|
||||
* 更新账户信息(超管接口)
|
||||
*
|
||||
* @param superUpdateAccountDTO 更新账户信息
|
||||
* @param accountId 账户ID
|
||||
* @return 更新后的账户信息
|
||||
*/
|
||||
CompanyAccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId);
|
||||
|
||||
/**
|
||||
* 删除账户(逻辑删除)
|
||||
*
|
||||
* @param accountId 账户ID
|
||||
*/
|
||||
void deleteAccount(Long accountId);
|
||||
|
||||
/**
|
||||
* 获取账户详情
|
||||
*
|
||||
* @param accountId 账户ID
|
||||
* @return 账户详情
|
||||
*/
|
||||
CompanyAccountVO getAccountDetail(Long accountId);
|
||||
|
||||
/**
|
||||
* 分页查询账户(超管接口)
|
||||
*
|
||||
* @param pageQuery 分页查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<CompanyAccountVO> getAccountPage(PageQueryDTO<AccountFilterDTO> pageQuery);
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.account.controller;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.model.dto.CreateSysAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.model.dto.UpdateSysAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.service.SysAccountService;
|
||||
|
||||
/**
|
||||
* 平台系统账户管理:超管跨公司维护 sys_user 及组织关系。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/sys/account")
|
||||
@RequiredArgsConstructor
|
||||
public class SysAccountController {
|
||||
|
||||
private final SysAccountService sysAccountService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission(value = "sys:account:create", description = "创建系统账户", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> create(@Valid @RequestBody CreateSysAccountDTO dto) {
|
||||
return ApiResponse.success("账户创建成功", sysAccountService.createAccount(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@RequirePermission(value = "sys:account:read", description = "查询系统账户列表", allowSuper = true)
|
||||
public ApiResponse<PageResultVO<CompanyAccountVO>> list(
|
||||
@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
|
||||
return ApiResponse.success("获取账户列表成功", sysAccountService.getAccountPage(pageQuery));
|
||||
}
|
||||
|
||||
@PutMapping("/update/{accountId}")
|
||||
@RequirePermission(value = "sys:account:update", description = "更新系统账户", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> update(
|
||||
@PathVariable Long accountId,
|
||||
@Valid @RequestBody UpdateSysAccountDTO dto) {
|
||||
return ApiResponse.success("账户更新成功", sysAccountService.updateAccount(dto, accountId));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{accountId}")
|
||||
@RequirePermission(value = "sys:account:delete", description = "删除系统账户", allowSuper = true)
|
||||
public ApiResponse<Void> delete(@PathVariable Long accountId) {
|
||||
sysAccountService.deleteAccount(accountId);
|
||||
return ApiResponse.success("账户删除成功");
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{accountId}")
|
||||
@RequirePermission(value = "sys:account:read", description = "查询系统账户详情", allowSuper = true)
|
||||
public ApiResponse<CompanyAccountVO> detail(@PathVariable Long accountId) {
|
||||
return ApiResponse.success("获取账户详情成功", sysAccountService.getAccountDetail(accountId));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.account.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -7,10 +7,10 @@ import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 超级管理员创建账户DTO
|
||||
* 平台创建系统账户。
|
||||
*/
|
||||
@Data
|
||||
public class SuperCreateAccountDTO {
|
||||
public class CreateSysAccountDTO {
|
||||
|
||||
@NotBlank(message = "登录账号不能为空")
|
||||
@Size(min = 3, max = 20, message = "登录账号长度必须在3-20个字符之间")
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.account.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 超级管理员更新账户DTO
|
||||
* 平台更新系统账户。
|
||||
*/
|
||||
@Data
|
||||
public class SuperUpdateAccountDTO {
|
||||
public class UpdateSysAccountDTO {
|
||||
|
||||
@Size(min = 3, max = 20, message = "登录账号长度必须在3-20个字符之间")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9_]+$", message = "登录账号只能包含字母、数字和下划线")
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.account.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.model.dto.CreateSysAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.model.dto.UpdateSysAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
|
||||
|
||||
/**
|
||||
* 平台系统账户管理。
|
||||
*/
|
||||
public interface SysAccountService extends IService<UserPO> {
|
||||
|
||||
CompanyAccountVO createAccount(CreateSysAccountDTO dto);
|
||||
|
||||
CompanyAccountVO updateAccount(UpdateSysAccountDTO dto, Long accountId);
|
||||
|
||||
void deleteAccount(Long accountId);
|
||||
|
||||
CompanyAccountVO getAccountDetail(Long accountId);
|
||||
|
||||
PageResultVO<CompanyAccountVO> getAccountPage(PageQueryDTO<AccountFilterDTO> pageQuery);
|
||||
}
|
||||
+58
-58
@@ -1,4 +1,4 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.org.company.account.service.impl;
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.account.service.impl;
|
||||
|
||||
import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -12,11 +12,11 @@ import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.user.mapper.UserMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.service.SuperAccountService;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.model.dto.CreateSysAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.model.dto.UpdateSysAccountDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.account.service.SysAccountService;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.company.service.CompanyService;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.department.member.model.po.DepartmentMemberPO;
|
||||
@@ -35,10 +35,10 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 超级管理员账户管理服务实现类
|
||||
* 平台系统账户管理服务。
|
||||
*/
|
||||
@Service
|
||||
public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implements SuperAccountService {
|
||||
public class SysAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implements SysAccountService {
|
||||
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
@@ -47,12 +47,12 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
private final DepartmentMemberService departmentMemberService;
|
||||
private final PositionService positionService;
|
||||
|
||||
public SuperAccountServiceImpl(PasswordEncoder passwordEncoder,
|
||||
CurrentUserContext currentUserContext,
|
||||
CompanyService companyService,
|
||||
CompanyMemberService companyMemberService,
|
||||
DepartmentMemberService departmentMemberService,
|
||||
PositionService positionService) {
|
||||
public SysAccountServiceImpl(PasswordEncoder passwordEncoder,
|
||||
CurrentUserContext currentUserContext,
|
||||
CompanyService companyService,
|
||||
CompanyMemberService companyMemberService,
|
||||
DepartmentMemberService departmentMemberService,
|
||||
PositionService positionService) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.companyService = companyService;
|
||||
@@ -63,24 +63,24 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
|
||||
/**
|
||||
* 创建账户(超管接口)
|
||||
* @param superCreateAccountDTO 创建账户DTO
|
||||
* @param createAccountDTO 创建账户DTO
|
||||
* @return 账户VO
|
||||
*/
|
||||
@Override
|
||||
public CompanyAccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO) {
|
||||
public CompanyAccountVO createAccount(CreateSysAccountDTO createAccountDTO) {
|
||||
// 验证登录账号是否已存在
|
||||
if (StringUtils.hasText(superCreateAccountDTO.getLoginCode())) {
|
||||
if (StringUtils.hasText(createAccountDTO.getLoginCode())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getLoginCode, superCreateAccountDTO.getLoginCode());
|
||||
wrapper.eq(UserPO::getLoginCode, createAccountDTO.getLoginCode());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("登录账号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 验证手机号码是否已存在
|
||||
if (StringUtils.hasText(superCreateAccountDTO.getPhone())) {
|
||||
if (StringUtils.hasText(createAccountDTO.getPhone())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getPhone, superCreateAccountDTO.getPhone());
|
||||
wrapper.eq(UserPO::getPhone, createAccountDTO.getPhone());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("手机号码已存在");
|
||||
}
|
||||
@@ -88,13 +88,13 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
|
||||
// 创建账户
|
||||
UserPO user = new UserPO();
|
||||
BeanCopyUtils.copyProperties(superCreateAccountDTO, user);
|
||||
BeanCopyUtils.copyProperties(createAccountDTO, user);
|
||||
if (user.getIsSuper() == null) {
|
||||
user.setIsSuper(0);
|
||||
}
|
||||
user.setPassword(passwordEncoder.encode(superCreateAccountDTO.getPassword()));
|
||||
user.setPassword(passwordEncoder.encode(createAccountDTO.getPassword()));
|
||||
user.setStatus(1); // 正常状态(与 sys_user 表定义一致:1=正常,0=停用)
|
||||
user.setPwdSecurityLevel(calculatePasswordSecurityLevel(superCreateAccountDTO.getPassword()));
|
||||
user.setPwdSecurityLevel(calculatePasswordSecurityLevel(createAccountDTO.getPassword()));
|
||||
user.setPwdUpdateTime(LocalDateTime.now());
|
||||
user.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
@@ -102,14 +102,14 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
this.save(user);
|
||||
|
||||
// 如果有公司ID,创建公司成员关系
|
||||
if (superCreateAccountDTO.getCompanyId() != null) {
|
||||
companyMemberService.create(user.getId(), superCreateAccountDTO.getCompanyId(),
|
||||
CompanyMemberRole.member, superCreateAccountDTO.getPositionId());
|
||||
if (createAccountDTO.getCompanyId() != null) {
|
||||
companyMemberService.create(user.getId(), createAccountDTO.getCompanyId(),
|
||||
CompanyMemberRole.member, createAccountDTO.getPositionId());
|
||||
}
|
||||
|
||||
// 如果有部门ID,创建部门成员关系
|
||||
if (superCreateAccountDTO.getDepartmentId() != null) {
|
||||
departmentMemberService.addMember(superCreateAccountDTO.getDepartmentId(), user.getId());
|
||||
if (createAccountDTO.getDepartmentId() != null) {
|
||||
departmentMemberService.addMember(createAccountDTO.getDepartmentId(), user.getId());
|
||||
}
|
||||
|
||||
// 转换为VO并返回
|
||||
@@ -118,12 +118,12 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
|
||||
/**
|
||||
* 更新账户信息(超管接口)
|
||||
* @param superUpdateAccountDTO 更新账户DTO
|
||||
* @param updateAccountDTO 更新账户DTO
|
||||
* @param accountId 账户ID
|
||||
* @return 账户VO
|
||||
*/
|
||||
@Override
|
||||
public CompanyAccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId) {
|
||||
public CompanyAccountVO updateAccount(UpdateSysAccountDTO updateAccountDTO, Long accountId) {
|
||||
// 查询账户
|
||||
UserPO user = super.getById(accountId);
|
||||
if (user == null) {
|
||||
@@ -131,10 +131,10 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
}
|
||||
|
||||
// 检查登录账号是否被其他用户使用
|
||||
if (StringUtils.hasText(superUpdateAccountDTO.getLoginCode()) &&
|
||||
!superUpdateAccountDTO.getLoginCode().equals(user.getLoginCode())) {
|
||||
if (StringUtils.hasText(updateAccountDTO.getLoginCode()) &&
|
||||
!updateAccountDTO.getLoginCode().equals(user.getLoginCode())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getLoginCode, superUpdateAccountDTO.getLoginCode());
|
||||
wrapper.eq(UserPO::getLoginCode, updateAccountDTO.getLoginCode());
|
||||
wrapper.ne(UserPO::getId, accountId);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("登录账号已被其他用户使用");
|
||||
@@ -142,10 +142,10 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
}
|
||||
|
||||
// 检查手机号码是否被其他用户使用
|
||||
if (StringUtils.hasText(superUpdateAccountDTO.getPhone()) &&
|
||||
!superUpdateAccountDTO.getPhone().equals(user.getPhone())) {
|
||||
if (StringUtils.hasText(updateAccountDTO.getPhone()) &&
|
||||
!updateAccountDTO.getPhone().equals(user.getPhone())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getPhone, superUpdateAccountDTO.getPhone());
|
||||
wrapper.eq(UserPO::getPhone, updateAccountDTO.getPhone());
|
||||
wrapper.ne(UserPO::getId, accountId);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("手机号码已被其他用户使用");
|
||||
@@ -153,26 +153,26 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
}
|
||||
|
||||
// 更新账户信息
|
||||
if (StringUtils.hasText(superUpdateAccountDTO.getLoginCode())) {
|
||||
user.setLoginCode(superUpdateAccountDTO.getLoginCode());
|
||||
if (StringUtils.hasText(updateAccountDTO.getLoginCode())) {
|
||||
user.setLoginCode(updateAccountDTO.getLoginCode());
|
||||
}
|
||||
if (StringUtils.hasText(superUpdateAccountDTO.getPhone())) {
|
||||
user.setPhone(superUpdateAccountDTO.getPhone());
|
||||
if (StringUtils.hasText(updateAccountDTO.getPhone())) {
|
||||
user.setPhone(updateAccountDTO.getPhone());
|
||||
}
|
||||
if (StringUtils.hasText(superUpdateAccountDTO.getRealName())) {
|
||||
user.setRealName(superUpdateAccountDTO.getRealName());
|
||||
if (StringUtils.hasText(updateAccountDTO.getRealName())) {
|
||||
user.setRealName(updateAccountDTO.getRealName());
|
||||
}
|
||||
if (superUpdateAccountDTO.getAvatarImageId() != null) {
|
||||
user.setAvatarImageId(superUpdateAccountDTO.getAvatarImageId());
|
||||
if (updateAccountDTO.getAvatarImageId() != null) {
|
||||
user.setAvatarImageId(updateAccountDTO.getAvatarImageId());
|
||||
}
|
||||
if (superUpdateAccountDTO.getIsSuper() != null) {
|
||||
user.setIsSuper(superUpdateAccountDTO.getIsSuper());
|
||||
if (updateAccountDTO.getIsSuper() != null) {
|
||||
user.setIsSuper(updateAccountDTO.getIsSuper());
|
||||
}
|
||||
if (superUpdateAccountDTO.getStatus() != null) {
|
||||
user.setStatus(superUpdateAccountDTO.getStatus());
|
||||
if (updateAccountDTO.getStatus() != null) {
|
||||
user.setStatus(updateAccountDTO.getStatus());
|
||||
}
|
||||
if (StringUtils.hasText(superUpdateAccountDTO.getRemark())) {
|
||||
user.setRemark(superUpdateAccountDTO.getRemark());
|
||||
if (StringUtils.hasText(updateAccountDTO.getRemark())) {
|
||||
user.setRemark(updateAccountDTO.getRemark());
|
||||
}
|
||||
|
||||
user.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
@@ -181,32 +181,32 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
this.updateById(user);
|
||||
|
||||
// 如果公司ID有更新,更新公司成员关系
|
||||
if (superUpdateAccountDTO.getCompanyId() != null) {
|
||||
if (updateAccountDTO.getCompanyId() != null) {
|
||||
// 删除旧的公司成员关系
|
||||
List<CompanyMemberVO> oldMembers = companyMemberService.getByUserId(user.getId());
|
||||
for (CompanyMemberVO old : oldMembers) {
|
||||
companyMemberService.removeByUserIdAndCompanyId(user.getId(), old.getCompanyId());
|
||||
}
|
||||
// 创建新的公司成员关系
|
||||
companyMemberService.create(user.getId(), superUpdateAccountDTO.getCompanyId(),
|
||||
CompanyMemberRole.member, superUpdateAccountDTO.getPositionId());
|
||||
companyMemberService.create(user.getId(), updateAccountDTO.getCompanyId(),
|
||||
CompanyMemberRole.member, updateAccountDTO.getPositionId());
|
||||
}
|
||||
|
||||
// 如果职位有更新,更新公司成员
|
||||
if (superUpdateAccountDTO.getPositionId() != null && superUpdateAccountDTO.getCompanyId() != null) {
|
||||
if (updateAccountDTO.getPositionId() != null && updateAccountDTO.getCompanyId() != null) {
|
||||
CompanyMemberPO member = companyMemberService.getByUserIdAndCompanyId(
|
||||
user.getId(), superUpdateAccountDTO.getCompanyId());
|
||||
user.getId(), updateAccountDTO.getCompanyId());
|
||||
if (member != null) {
|
||||
companyMemberService.updatePosition(member.getId(), superUpdateAccountDTO.getPositionId());
|
||||
companyMemberService.updatePosition(member.getId(), updateAccountDTO.getPositionId());
|
||||
}
|
||||
}
|
||||
|
||||
// 如果部门有更新,更新部门成员
|
||||
if (superUpdateAccountDTO.getDepartmentId() != null) {
|
||||
if (updateAccountDTO.getDepartmentId() != null) {
|
||||
DepartmentMemberPO existingMember = departmentMemberService.getByUserIdAndDepartmentId(
|
||||
user.getId(), superUpdateAccountDTO.getDepartmentId());
|
||||
user.getId(), updateAccountDTO.getDepartmentId());
|
||||
if (existingMember == null) {
|
||||
departmentMemberService.addMember(superUpdateAccountDTO.getDepartmentId(), user.getId());
|
||||
departmentMemberService.addMember(updateAccountDTO.getDepartmentId(), user.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,26 @@ INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status
|
||||
SELECT 1202, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:user' LIMIT 1), 'sys:user:update', '更新', 'api', 1, '', 2
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1202 OR `code` = 'sys:user:update');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1220, (SELECT id FROM `sys_permission` WHERE `code` = 'sys' LIMIT 1), 'sys:account', '系统账户', 'module', 1, '', 25
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1220 OR `code` = 'sys:account');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1221, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:read', '查看', 'api', 1, '', 1
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1221 OR `code` = 'sys:account:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1222, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:create', '创建', 'api', 1, '', 2
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1222 OR `code` = 'sys:account:create');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1223, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:update', '更新', 'api', 1, '', 3
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1223 OR `code` = 'sys:account:update');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1224, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:account' LIMIT 1), 'sys:account:delete', '删除', 'api', 1, '', 4
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1224 OR `code` = 'sys:account:delete');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 1300, (SELECT id FROM `sys_permission` WHERE `code` = 'sys' LIMIT 1), 'sys:permission', '权限', 'module', 1, '', 30
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1300 OR `code` = 'sys:permission');
|
||||
@@ -184,24 +204,24 @@ SELECT 2104, (SELECT id FROM `sys_permission` WHERE `code` = 'org:company' LIMIT
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2104 OR `code` = 'org:company:delete');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 2150, (SELECT id FROM `sys_permission` WHERE `code` = 'org' LIMIT 1), 'org:account', '账户', 'module', 1, '', 15
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2150 OR `code` = 'org:account');
|
||||
SELECT 2150, (SELECT id FROM `sys_permission` WHERE `code` = 'org:company' LIMIT 1), 'org:company:account', '公司账户', 'module', 1, '', 30
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2150 OR `code` = 'org:company:account');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 2151, (SELECT id FROM `sys_permission` WHERE `code` = 'org:account' LIMIT 1), 'org:account:read', '查看', 'api', 1, '', 1
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2151 OR `code` = 'org:account:read');
|
||||
SELECT 2151, (SELECT id FROM `sys_permission` WHERE `code` = 'org:company:account' LIMIT 1), 'org:company:account:read', '查看', 'api', 1, '', 1
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2151 OR `code` = 'org:company:account:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 2152, (SELECT id FROM `sys_permission` WHERE `code` = 'org:account' LIMIT 1), 'org:account:create', '创建', 'api', 1, '', 2
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2152 OR `code` = 'org:account:create');
|
||||
SELECT 2152, (SELECT id FROM `sys_permission` WHERE `code` = 'org:company:account' LIMIT 1), 'org:company:account:create', '创建', 'api', 1, '', 2
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2152 OR `code` = 'org:company:account:create');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 2153, (SELECT id FROM `sys_permission` WHERE `code` = 'org:account' LIMIT 1), 'org:account:update', '更新', 'api', 1, '', 3
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2153 OR `code` = 'org:account:update');
|
||||
SELECT 2153, (SELECT id FROM `sys_permission` WHERE `code` = 'org:company:account' LIMIT 1), 'org:company:account:update', '更新', 'api', 1, '', 3
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2153 OR `code` = 'org:company:account:update');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 2154, (SELECT id FROM `sys_permission` WHERE `code` = 'org:account' LIMIT 1), 'org:account:delete', '删除', 'api', 1, '', 4
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2154 OR `code` = 'org:account:delete');
|
||||
SELECT 2154, (SELECT id FROM `sys_permission` WHERE `code` = 'org:company:account' LIMIT 1), 'org:company:account:delete', '删除', 'api', 1, '', 4
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 2154 OR `code` = 'org:company:account:delete');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 2200, (SELECT id FROM `sys_permission` WHERE `code` = 'org' LIMIT 1), 'org:department', '部门', 'module', 1, '', 20
|
||||
@@ -708,8 +728,8 @@ SELECT 23, (SELECT id FROM `sys_menu` WHERE `id` = 14 OR `name` = '组织管理'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 23 OR `name` = '账户管理');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 24, (SELECT id FROM `sys_menu` WHERE `id` = 1 OR `name` = '系统设置' LIMIT 1), 1, '平台账户', 'SuperAccountManagement', '平台账户', '/sys/account-super', '/org/account-super/index', '', 'lucide:users', 'menu', 1, 1, 0, 4
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 24 OR `name` = '平台账户');
|
||||
SELECT 24, (SELECT id FROM `sys_menu` WHERE `id` = 1 OR `name` = '系统设置' LIMIT 1), 1, '系统账户', 'SysAccountManagement', '系统账户', '/sys/account', '/sys/account/index', '', 'lucide:users', 'menu', 1, 1, 0, 4
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 24 OR `name` = '系统账户');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 25, (SELECT id FROM `sys_menu` WHERE `id` = 1 OR `name` = '系统设置' LIMIT 1), 1, '系统权限', 'PermissionManagement', '系统权限', '/sys/permission', '/sys/permission/index', '', 'lucide:code-2', 'menu', 1, 1, 0, 2
|
||||
@@ -811,7 +831,7 @@ INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'sys:menu:%' WHERE m.name = '系统菜单';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'sys:user:%' WHERE m.name = '平台账户';
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'sys:account:%' WHERE m.name = '系统账户';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'sys:permission:%' WHERE m.name = '系统权限';
|
||||
@@ -832,7 +852,7 @@ INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'org:position:%' WHERE m.name = '职位管理';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON (p.code LIKE 'org:account:%' OR p.code LIKE 'org:member:%') WHERE m.name = '账户管理';
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON (p.code LIKE 'org:company:account:%' OR p.code LIKE 'org:member:%') WHERE m.name = '账户管理';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code = 'org:position:menu:assign' WHERE m.name = '职位菜单';
|
||||
|
||||
@@ -4,40 +4,25 @@ import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
import type { SuperAccountDTO, SuperAccountVO } from './types';
|
||||
|
||||
/**
|
||||
* 超管账户管理API
|
||||
* 平台系统账户管理 API(/api/sys/account)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 创建账户(超管)
|
||||
*/
|
||||
export async function super_createAccountApi(data: SuperAccountDTO.SuperCreateAccountDTO) {
|
||||
return requestClient.post<SuperAccountVO.AccountInfoVO>('/super/account/create', data);
|
||||
return requestClient.post<SuperAccountVO.AccountInfoVO>('/sys/account/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询账户(超管)
|
||||
*/
|
||||
export async function super_getAccountPageApi(params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO>) {
|
||||
return requestClient.post<PageResultVO<SuperAccountVO.AccountInfoVO>>('/super/account/list', params);
|
||||
return requestClient.post<PageResultVO<SuperAccountVO.AccountInfoVO>>('/sys/account/list', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新账户信息(超管)
|
||||
*/
|
||||
export async function super_updateAccountApi(accountId: number, data: SuperAccountDTO.SuperUpdateAccountDTO) {
|
||||
return requestClient.put<SuperAccountVO.AccountInfoVO>(`/super/account/update/${accountId}`, data);
|
||||
return requestClient.put<SuperAccountVO.AccountInfoVO>(`/sys/account/update/${accountId}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除账户(超管)
|
||||
*/
|
||||
export async function super_deleteAccountApi(accountId: number) {
|
||||
return requestClient.delete<void>(`/super/account/delete/${accountId}`);
|
||||
return requestClient.delete<void>(`/sys/account/delete/${accountId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账户详情(超管)
|
||||
*/
|
||||
export async function super_getAccountDetailApi(accountId: number) {
|
||||
return requestClient.get<SuperAccountVO.AccountInfoVO>(`/super/account/detail/${accountId}`);
|
||||
return requestClient.get<SuperAccountVO.AccountInfoVO>(`/sys/account/detail/${accountId}`);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ const statusOptions = [
|
||||
];
|
||||
|
||||
const accountActionCodes = [
|
||||
'org:account:create',
|
||||
'org:account:update',
|
||||
'org:account:delete',
|
||||
'org:company:account:create',
|
||||
'org:company:account:update',
|
||||
'org:company:account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(accountActionCodes);
|
||||
|
||||
@@ -374,13 +374,13 @@ function handleModalSuccess() {
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<PermissionGate code="org:account:create">
|
||||
<PermissionGate code="org:company:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<PermissionGate code="org:company:account:delete">
|
||||
<Button v-if="hasSelected" danger @click="handleBatchDelete">
|
||||
批量删除
|
||||
</Button>
|
||||
@@ -405,10 +405,10 @@ function handleModalSuccess() {
|
||||
<!-- 操作列 -->
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="org:account:update">
|
||||
<PermissionGate code="org:company:account:update">
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<PermissionGate code="org:company:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ interface Emits {
|
||||
(e: 'success'): void;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'SuperAccountFormModal' });
|
||||
defineOptions({ name: 'SysAccountFormModal' });
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
+11
-16
@@ -34,7 +34,7 @@ import {
|
||||
super_getAccountPageApi,
|
||||
} from '#/api/sys/account';
|
||||
|
||||
import SuperAccountFormModal from './components/SuperAccountFormModal.vue';
|
||||
import AccountFormModal from './components/AccountFormModal.vue';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
sidebarListRowClass,
|
||||
} from '#/utils/sidebar-list-styles';
|
||||
|
||||
defineOptions({ name: 'SuperAccountManagement' });
|
||||
defineOptions({ name: 'SysAccountManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||
@@ -88,9 +88,9 @@ const selectedCompanyLabel = computed(() => {
|
||||
});
|
||||
|
||||
const accountActionCodes = [
|
||||
'org:account:create',
|
||||
'org:account:update',
|
||||
'org:account:delete',
|
||||
'sys:account:create',
|
||||
'sys:account:update',
|
||||
'sys:account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(accountActionCodes);
|
||||
|
||||
@@ -361,7 +361,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="超级账户管理" :auto-content-height="true">
|
||||
<Page title="系统账户管理" :auto-content-height="true">
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
左侧选择公司筛选右侧账户;首项「全部账户」展示所有账户,可在公司行快捷新增。
|
||||
@@ -370,7 +370,7 @@ onMounted(() => {
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<PermissionGate code="org:account:create">
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增账户
|
||||
@@ -380,7 +380,6 @@ onMounted(() => {
|
||||
</template>
|
||||
|
||||
<Flex gap="middle" class="h-full min-h-0">
|
||||
<!-- 左:公司 -->
|
||||
<Card
|
||||
class="flex h-full w-[420px] shrink-0 flex-col"
|
||||
:body-style="{
|
||||
@@ -458,7 +457,7 @@ onMounted(() => {
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</span>
|
||||
</button>
|
||||
<PermissionGate code="org:account:create">
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
@@ -487,7 +486,6 @@ onMounted(() => {
|
||||
</Spin>
|
||||
</Card>
|
||||
|
||||
<!-- 右:账户列表 -->
|
||||
<Card
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
@@ -568,10 +566,10 @@ onMounted(() => {
|
||||
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="org:account:update">
|
||||
<PermissionGate code="sys:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<PermissionGate code="sys:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
@@ -586,9 +584,6 @@ onMounted(() => {
|
||||
</Card>
|
||||
</Flex>
|
||||
|
||||
<SuperAccountFormModal
|
||||
ref="accountFormModalRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
<AccountFormModal ref="accountFormModalRef" @success="handleModalSuccess" />
|
||||
</Page>
|
||||
</template>
|
||||
Reference in New Issue
Block a user