mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
系统管理bug修复:1、字典管理权限串和菜单拉平;2、用户操作接口增加自身修改权限;3、组织套餐增删接口增加套餐名唯一校验;
This commit is contained in:
+1
@@ -128,6 +128,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode TENANT_PACKAGE_DISABLE = new ErrorCode(1_002_016_002, "名字为【{}】的组织套餐已被禁用");
|
ErrorCode TENANT_PACKAGE_DISABLE = new ErrorCode(1_002_016_002, "名字为【{}】的组织套餐已被禁用");
|
||||||
ErrorCode TENANT_PACKAGE_DEPT_EXIT = new ErrorCode(1_002_016_003, "无法修改内置组织权限套餐");
|
ErrorCode TENANT_PACKAGE_DEPT_EXIT = new ErrorCode(1_002_016_003, "无法修改内置组织权限套餐");
|
||||||
ErrorCode TENANT_PACKAGE_DELETED_EXIT = new ErrorCode(1_002_016_004, "无法删除内置组织权限套餐");
|
ErrorCode TENANT_PACKAGE_DELETED_EXIT = new ErrorCode(1_002_016_004, "无法删除内置组织权限套餐");
|
||||||
|
ErrorCode TENANT_PACKAGE_NAME_UNIQE_ERROR = new ErrorCode(1_002_016_005, "套餐名已存在,请编辑套餐名后重试");
|
||||||
|
|
||||||
// ========== 错误码模块 1-002-017-000 ==========
|
// ========== 错误码模块 1-002-017-000 ==========
|
||||||
ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1_002_017_000, "错误码不存在");
|
ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1_002_017_000, "错误码不存在");
|
||||||
|
|||||||
+6
-6
@@ -40,7 +40,7 @@ public class DictDataController {
|
|||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "新增字典数据")
|
@Operation(summary = "新增字典数据")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
@PreAuthorize("@ss.hasPermission('dict:create')")
|
||||||
public CommonResult<Long> createDictData(@Valid @RequestBody DictDataSaveReqVO createReqVO) {
|
public CommonResult<Long> createDictData(@Valid @RequestBody DictDataSaveReqVO createReqVO) {
|
||||||
Long dictDataId = dictDataService.createDictData(createReqVO);
|
Long dictDataId = dictDataService.createDictData(createReqVO);
|
||||||
return success(dictDataId);
|
return success(dictDataId);
|
||||||
@@ -48,7 +48,7 @@ public class DictDataController {
|
|||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "修改字典数据")
|
@Operation(summary = "修改字典数据")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
@PreAuthorize("@ss.hasPermission('dict:update')")
|
||||||
public CommonResult<Boolean> updateDictData(@Valid @RequestBody DictDataSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateDictData(@Valid @RequestBody DictDataSaveReqVO updateReqVO) {
|
||||||
dictDataService.updateDictData(updateReqVO);
|
dictDataService.updateDictData(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -57,7 +57,7 @@ public class DictDataController {
|
|||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除字典数据")
|
@Operation(summary = "删除字典数据")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:delete')")
|
@PreAuthorize("@ss.hasPermission('dict:delete')")
|
||||||
public CommonResult<Boolean> deleteDictData(Long id) {
|
public CommonResult<Boolean> deleteDictData(Long id) {
|
||||||
dictDataService.deleteDictData(id);
|
dictDataService.deleteDictData(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -74,7 +74,7 @@ public class DictDataController {
|
|||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "/获得字典类型的分页列表")
|
@Operation(summary = "/获得字典类型的分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
@PreAuthorize("@ss.hasPermission('dict:query')")
|
||||||
public CommonResult<PageResult<DictDataRespVO>> getDictTypePage(@Valid DictDataPageReqVO pageReqVO) {
|
public CommonResult<PageResult<DictDataRespVO>> getDictTypePage(@Valid DictDataPageReqVO pageReqVO) {
|
||||||
PageResult<DictDataDO> pageResult = dictDataService.getDictDataPage(pageReqVO);
|
PageResult<DictDataDO> pageResult = dictDataService.getDictDataPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, DictDataRespVO.class));
|
return success(BeanUtils.toBean(pageResult, DictDataRespVO.class));
|
||||||
@@ -83,7 +83,7 @@ public class DictDataController {
|
|||||||
@GetMapping(value = "/get")
|
@GetMapping(value = "/get")
|
||||||
@Operation(summary = "/查询字典数据详细")
|
@Operation(summary = "/查询字典数据详细")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
@PreAuthorize("@ss.hasPermission('dict:query')")
|
||||||
public CommonResult<DictDataRespVO> getDictData(@RequestParam("id") Long id) {
|
public CommonResult<DictDataRespVO> getDictData(@RequestParam("id") Long id) {
|
||||||
DictDataDO dictData = dictDataService.getDictData(id);
|
DictDataDO dictData = dictDataService.getDictData(id);
|
||||||
return success(BeanUtils.toBean(dictData, DictDataRespVO.class));
|
return success(BeanUtils.toBean(dictData, DictDataRespVO.class));
|
||||||
@@ -91,7 +91,7 @@ public class DictDataController {
|
|||||||
|
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@Operation(summary = "导出字典数据")
|
@Operation(summary = "导出字典数据")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:export')")
|
@PreAuthorize("@ss.hasPermission('dict:export')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void export(HttpServletResponse response, @Valid DictDataPageReqVO exportReqVO) throws IOException {
|
public void export(HttpServletResponse response, @Valid DictDataPageReqVO exportReqVO) throws IOException {
|
||||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
|||||||
+6
-6
@@ -39,7 +39,7 @@ public class DictTypeController {
|
|||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建字典类型")
|
@Operation(summary = "创建字典类型")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
@PreAuthorize("@ss.hasPermission('dict:create')")
|
||||||
public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeSaveReqVO createReqVO) {
|
public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeSaveReqVO createReqVO) {
|
||||||
Long dictTypeId = dictTypeService.createDictType(createReqVO);
|
Long dictTypeId = dictTypeService.createDictType(createReqVO);
|
||||||
return success(dictTypeId);
|
return success(dictTypeId);
|
||||||
@@ -47,7 +47,7 @@ public class DictTypeController {
|
|||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "修改字典类型")
|
@Operation(summary = "修改字典类型")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
@PreAuthorize("@ss.hasPermission('dict:update')")
|
||||||
public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeSaveReqVO updateReqVO) {
|
||||||
dictTypeService.updateDictType(updateReqVO);
|
dictTypeService.updateDictType(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -56,7 +56,7 @@ public class DictTypeController {
|
|||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除字典类型")
|
@Operation(summary = "删除字典类型")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:delete')")
|
@PreAuthorize("@ss.hasPermission('dict:delete')")
|
||||||
public CommonResult<Boolean> deleteDictType(Long id) {
|
public CommonResult<Boolean> deleteDictType(Long id) {
|
||||||
dictTypeService.deleteDictType(id);
|
dictTypeService.deleteDictType(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -64,7 +64,7 @@ public class DictTypeController {
|
|||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得字典类型的分页列表")
|
@Operation(summary = "获得字典类型的分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
@PreAuthorize("@ss.hasPermission('dict:query')")
|
||||||
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
||||||
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
||||||
@@ -73,7 +73,7 @@ public class DictTypeController {
|
|||||||
@Operation(summary = "/查询字典类型详细")
|
@Operation(summary = "/查询字典类型详细")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@GetMapping(value = "/get")
|
@GetMapping(value = "/get")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
@PreAuthorize("@ss.hasPermission('dict:query')")
|
||||||
public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) {
|
public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) {
|
||||||
DictTypeDO dictType = dictTypeService.getDictType(id);
|
DictTypeDO dictType = dictTypeService.getDictType(id);
|
||||||
return success(BeanUtils.toBean(dictType, DictTypeRespVO.class));
|
return success(BeanUtils.toBean(dictType, DictTypeRespVO.class));
|
||||||
@@ -89,7 +89,7 @@ public class DictTypeController {
|
|||||||
|
|
||||||
@Operation(summary = "导出数据类型")
|
@Operation(summary = "导出数据类型")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
@PreAuthorize("@ss.hasPermission('dict:query')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException {
|
public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException {
|
||||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
|||||||
-9
@@ -10,7 +10,6 @@ import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
|||||||
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
|
||||||
import com.cf.imes.module.system.controller.admin.user.vo.user.*;
|
import com.cf.imes.module.system.controller.admin.user.vo.user.*;
|
||||||
import com.cf.imes.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
import com.cf.imes.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
||||||
import com.cf.imes.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
import com.cf.imes.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
||||||
@@ -26,10 +25,8 @@ import com.cf.imes.module.system.dal.dataobject.dept.PostDO;
|
|||||||
import com.cf.imes.module.system.dal.dataobject.dept.UserPostDO;
|
import com.cf.imes.module.system.dal.dataobject.dept.UserPostDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO;
|
import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import com.cf.imes.module.system.dal.mysql.dept.PostMapper;
|
import com.cf.imes.module.system.dal.mysql.dept.PostMapper;
|
||||||
import com.cf.imes.module.system.dal.mysql.dept.UserPostMapper;
|
|
||||||
import com.cf.imes.module.system.enums.common.SexEnum;
|
import com.cf.imes.module.system.enums.common.SexEnum;
|
||||||
import com.cf.imes.module.system.service.dept.DeptService;
|
import com.cf.imes.module.system.service.dept.DeptService;
|
||||||
import com.cf.imes.module.system.service.dept.PostService;
|
|
||||||
import com.cf.imes.module.system.service.user.AdminUserService;
|
import com.cf.imes.module.system.service.user.AdminUserService;
|
||||||
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;
|
||||||
@@ -47,7 +44,6 @@ import java.io.IOException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||||
@@ -122,11 +118,6 @@ public class UserController {
|
|||||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
return success(new PageResult<>(pageResult.getTotal()));
|
return success(new PageResult<>(pageResult.getTotal()));
|
||||||
}
|
}
|
||||||
// 用户列表不展示当前登录人
|
|
||||||
boolean removeCurrentUser = pageResult.getList().removeIf(user -> Objects.equals(user.getId(), SecurityFrameworkUtils.getLoginUserId()));
|
|
||||||
if (removeCurrentUser) {
|
|
||||||
pageResult.setTotal(pageResult.getTotal() - 1);
|
|
||||||
}
|
|
||||||
// 拼接数据
|
// 拼接数据
|
||||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
||||||
convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
||||||
|
|||||||
+22
@@ -1,9 +1,12 @@
|
|||||||
package com.cf.imes.module.system.service.organ;
|
package com.cf.imes.module.system.service.organ;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.module.system.controller.admin.organ.vo.packages.TenantPackagePageReqVO;
|
import com.cf.imes.module.system.controller.admin.organ.vo.packages.TenantPackagePageReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.organ.vo.packages.TenantPackageSaveReqVO;
|
import com.cf.imes.module.system.controller.admin.organ.vo.packages.TenantPackageSaveReqVO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
|
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
|
||||||
@@ -39,6 +42,8 @@ public class TenantPackageServiceImpl implements TenantPackageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTenantPackage(TenantPackageSaveReqVO createReqVO) {
|
public Long createTenantPackage(TenantPackageSaveReqVO createReqVO) {
|
||||||
|
// 唯一性校验
|
||||||
|
validateTenantPackageUnique(createReqVO);
|
||||||
// 插入
|
// 插入
|
||||||
TenantPackageDO tenantPackage = BeanUtils.toBean(createReqVO, TenantPackageDO.class);
|
TenantPackageDO tenantPackage = BeanUtils.toBean(createReqVO, TenantPackageDO.class);
|
||||||
tenantPackageMapper.insert(tenantPackage);
|
tenantPackageMapper.insert(tenantPackage);
|
||||||
@@ -49,6 +54,8 @@ public class TenantPackageServiceImpl implements TenantPackageService {
|
|||||||
@Override
|
@Override
|
||||||
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
||||||
public void updateTenantPackage(TenantPackageSaveReqVO updateReqVO) {
|
public void updateTenantPackage(TenantPackageSaveReqVO updateReqVO) {
|
||||||
|
// 唯一性校验
|
||||||
|
validateTenantPackageUnique(updateReqVO);
|
||||||
// 校验存在
|
// 校验存在
|
||||||
TenantPackageDO tenantPackage = validateTenantPackageExists(updateReqVO.getId());
|
TenantPackageDO tenantPackage = validateTenantPackageExists(updateReqVO.getId());
|
||||||
if(Objects.equals(tenantPackage.getId(), SYSTEM_ORGAN_PACKAGE_ID) || Objects.equals(tenantPackage.getId(), SYSTEM_SUPER_PACKAGE_ID)) {
|
if(Objects.equals(tenantPackage.getId(), SYSTEM_ORGAN_PACKAGE_ID) || Objects.equals(tenantPackage.getId(), SYSTEM_SUPER_PACKAGE_ID)) {
|
||||||
@@ -87,6 +94,21 @@ public class TenantPackageServiceImpl implements TenantPackageService {
|
|||||||
return tenantPackage;
|
return tenantPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验唯一性约束
|
||||||
|
* @param reqVO
|
||||||
|
*/
|
||||||
|
private void validateTenantPackageUnique(TenantPackageSaveReqVO reqVO) {
|
||||||
|
Long packageId = reqVO.getId();
|
||||||
|
LambdaQueryWrapper<TenantPackageDO> wrapper = new LambdaQueryWrapperX<TenantPackageDO>().eq(TenantPackageDO::getName, reqVO.getName());
|
||||||
|
if (ObjectUtil.isNotNull(packageId)) {
|
||||||
|
wrapper.ne(TenantPackageDO::getId, packageId);
|
||||||
|
}
|
||||||
|
if (tenantPackageMapper.exists(wrapper)) {
|
||||||
|
throw exception(TENANT_PACKAGE_NAME_UNIQE_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void validateOrganUsed(Long id) {
|
private void validateOrganUsed(Long id) {
|
||||||
if (organService.getOrganCountByPackageId(id) > 0) {
|
if (organService.getOrganCountByPackageId(id) > 0) {
|
||||||
throw exception(TENANT_PACKAGE_USED);
|
throw exception(TENANT_PACKAGE_USED);
|
||||||
|
|||||||
+31
-38
@@ -1,9 +1,8 @@
|
|||||||
package com.cf.imes.module.system.service.user;
|
package com.cf.imes.module.system.service.user;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
@@ -39,6 +38,7 @@ import com.cf.imes.module.system.service.organ.OrganService;
|
|||||||
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
@@ -103,7 +103,6 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
// 校验账户配合
|
// 校验账户配合
|
||||||
organService.handleOrganInfo(organ -> {
|
organService.handleOrganInfo(organ -> {
|
||||||
long count = userMapper.selectCount(new LambdaQueryWrapperX<AdminUserDO>().eq(AdminUserDO::getOrganId, organId));
|
long count = userMapper.selectCount(new LambdaQueryWrapperX<AdminUserDO>().eq(AdminUserDO::getOrganId, organId));
|
||||||
//long count = userMapper.selectCount();
|
|
||||||
if (count >= organ.getAccountCount()) {
|
if (count >= organ.getAccountCount()) {
|
||||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.USER_COUNT_MAX, organ.getAccountCount());
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.USER_COUNT_MAX, organ.getAccountCount());
|
||||||
}
|
}
|
||||||
@@ -118,14 +117,14 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
|
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
|
||||||
|
|
||||||
String pinyinFull = PinYinUtils.convertToPinyin(user.getNickname());
|
String pinyinFull = PinYinUtils.convertToPinyin(user.getNickname());
|
||||||
if (StrUtil.isNotBlank(pinyinFull)) {
|
if (StringUtils.isNotBlank(pinyinFull)) {
|
||||||
pinyinFull = pinyinFull.replaceAll(" ", "");
|
pinyinFull = pinyinFull.replace(" ", "");
|
||||||
}
|
}
|
||||||
user.setPinyinFull(pinyinFull);
|
user.setPinyinFull(pinyinFull);
|
||||||
user.setPinyinInitial(PinYinUtils.convertFirstChar(user.getNickname()));
|
user.setPinyinInitial(PinYinUtils.convertFirstChar(user.getNickname()));
|
||||||
userMapper.insert(user);
|
userMapper.insert(user);
|
||||||
// 插入关联岗位
|
// 插入关联岗位
|
||||||
if (CollectionUtil.isNotEmpty(user.getPostIds())) {
|
if (CollUtil.isNotEmpty(user.getPostIds())) {
|
||||||
userPostMapper.insertBatch(convertList(user.getPostIds(),
|
userPostMapper.insertBatch(convertList(user.getPostIds(),
|
||||||
postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId)));
|
postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId)));
|
||||||
}
|
}
|
||||||
@@ -137,6 +136,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
public void updateUser(UserSaveReqVO updateReqVO) {
|
public void updateUser(UserSaveReqVO updateReqVO) {
|
||||||
Long organId = updateReqVO.getOrganId() == null ? OrganContextHolder.getOrganId(): updateReqVO.getOrganId();
|
Long organId = updateReqVO.getOrganId() == null ? OrganContextHolder.getOrganId(): updateReqVO.getOrganId();
|
||||||
updateReqVO.setPassword(null); // 特殊:此处不更新密码
|
updateReqVO.setPassword(null); // 特殊:此处不更新密码
|
||||||
|
// 不允许自身操作
|
||||||
|
checkCurrentWhenOperate(updateReqVO.getId());
|
||||||
// 校验正确性
|
// 校验正确性
|
||||||
validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
|
validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
|
||||||
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(),null, organId);
|
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(),null, organId);
|
||||||
@@ -146,8 +147,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
if(!Objects.isNull(updateReqVO.getNickname())) {
|
if(!Objects.isNull(updateReqVO.getNickname())) {
|
||||||
|
|
||||||
String pinyinFull = PinYinUtils.convertToPinyin(updateReqVO.getNickname());
|
String pinyinFull = PinYinUtils.convertToPinyin(updateReqVO.getNickname());
|
||||||
if (StrUtil.isNotBlank(pinyinFull)) {
|
if (StringUtils.isNotBlank(pinyinFull)) {
|
||||||
pinyinFull = pinyinFull.replaceAll(" ", "");
|
pinyinFull = pinyinFull.replace(" ", "");
|
||||||
}
|
}
|
||||||
updateObj.setPinyinFull(pinyinFull);
|
updateObj.setPinyinFull(pinyinFull);
|
||||||
updateObj.setPinyinInitial(PinYinUtils.convertFirstChar(updateReqVO.getNickname()));
|
updateObj.setPinyinInitial(PinYinUtils.convertFirstChar(updateReqVO.getNickname()));
|
||||||
@@ -166,11 +167,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
Collection<Long> createPostIds = CollUtil.subtract(postIds, dbPostIds);
|
Collection<Long> createPostIds = CollUtil.subtract(postIds, dbPostIds);
|
||||||
Collection<Long> deletePostIds = CollUtil.subtract(dbPostIds, postIds);
|
Collection<Long> deletePostIds = CollUtil.subtract(dbPostIds, postIds);
|
||||||
// 执行新增和删除。对于已经授权的菜单,不用做任何处理
|
// 执行新增和删除。对于已经授权的菜单,不用做任何处理
|
||||||
if (!CollectionUtil.isEmpty(createPostIds)) {
|
if (!CollUtil.isEmpty(createPostIds)) {
|
||||||
userPostMapper.insertBatch(convertList(createPostIds,
|
userPostMapper.insertBatch(convertList(createPostIds,
|
||||||
postId -> new UserPostDO().setUserId(userId).setPostId(postId)));
|
postId -> new UserPostDO().setUserId(userId).setPostId(postId)));
|
||||||
}
|
}
|
||||||
if (!CollectionUtil.isEmpty(deletePostIds)) {
|
if (!CollUtil.isEmpty(deletePostIds)) {
|
||||||
userPostMapper.deleteByUserIdAndPostId(userId, deletePostIds);
|
userPostMapper.deleteByUserIdAndPostId(userId, deletePostIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,6 +230,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUserStatus(Long id, Integer status) {
|
public void updateUserStatus(Long id, Integer status) {
|
||||||
|
// 不允许自身操作
|
||||||
|
checkCurrentWhenOperate(id);
|
||||||
// 校验用户存在
|
// 校验用户存在
|
||||||
validateUserExists(id);
|
validateUserExists(id);
|
||||||
// 更新状态
|
// 更新状态
|
||||||
@@ -241,9 +244,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteUser(Long id) {
|
public void deleteUser(Long id) {
|
||||||
if(Objects.equals(id, SecurityFrameworkUtils.getLoginUserId())) {
|
// 不允许自身操作
|
||||||
throw exception(USER_ME_ERROR);
|
checkCurrentWhenOperate(id);
|
||||||
}
|
|
||||||
// 校验用户存在
|
// 校验用户存在
|
||||||
validateUserExists(id);
|
validateUserExists(id);
|
||||||
// 删除用户
|
// 删除用户
|
||||||
@@ -275,9 +277,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
|
public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
|
||||||
if (StrUtil.isNotBlank(reqVO.getNickname())) {
|
if (StringUtils.isNotBlank(reqVO.getNickname())) {
|
||||||
reqVO.setPyFirstChar(PinYinUtils.convertFirstChar(reqVO.getNickname()));
|
reqVO.setPyFirstChar(PinYinUtils.convertFirstChar(reqVO.getNickname()));
|
||||||
reqVO.setPyAll(PinYinUtils.convertToPinyin(reqVO.getNickname()).replaceAll(" ", ""));
|
reqVO.setPyAll(PinYinUtils.convertToPinyin(reqVO.getNickname()).replace(" ", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
PageResult<AdminUserDO> adminUserDOPageResult = userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()));
|
PageResult<AdminUserDO> adminUserDOPageResult = userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()));
|
||||||
@@ -416,11 +418,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateUsernameUnique(Long id, String username, Long organId) {
|
void validateUsernameUnique(Long id, String username, Long organId) {
|
||||||
if (StrUtil.isBlank(username)) {
|
if (StringUtils.isBlank(username)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdminUserDO user = userMapper.selectOne(AdminUserDO::getUsername, username, AdminUserDO::getOrganId, organId);
|
AdminUserDO user = userMapper.selectOne(AdminUserDO::getUsername, username, AdminUserDO::getOrganId, organId);
|
||||||
//AdminUserDO user = userMapper.selectByUsername(username);
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -435,7 +436,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateEmailUnique(Long id, String email, Long organId) {
|
void validateEmailUnique(Long id, String email, Long organId) {
|
||||||
if (StrUtil.isBlank(email)) {
|
if (StringUtils.isBlank(email)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdminUserDO user = userMapper.selectOne(AdminUserDO::getOrganId, organId, AdminUserDO::getEmail, email);
|
AdminUserDO user = userMapper.selectOne(AdminUserDO::getOrganId, organId, AdminUserDO::getEmail, email);
|
||||||
@@ -453,7 +454,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateMobileUnique(Long id, String mobile, Long organId) {
|
void validateMobileUnique(Long id, String mobile, Long organId) {
|
||||||
if (StrUtil.isBlank(mobile)) {
|
if (StringUtils.isBlank(mobile)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdminUserDO user = userMapper.selectOne(AdminUserDO::getOrganId, organId, AdminUserDO::getMobile, mobile);
|
AdminUserDO user = userMapper.selectOne(AdminUserDO::getOrganId, organId, AdminUserDO::getMobile, mobile);
|
||||||
@@ -538,9 +539,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
public List<AdminUserDO> getUserListByTerms(Integer status, String name) {
|
public List<AdminUserDO> getUserListByTerms(Integer status, String name) {
|
||||||
String namePyFirstChar = "";
|
String namePyFirstChar = "";
|
||||||
String namePyAll = "";
|
String namePyAll = "";
|
||||||
if(StrUtil.isNotBlank(name)) {
|
if(StringUtils.isNotBlank(name)) {
|
||||||
namePyFirstChar = PinYinUtils.convertToPinyin(name);
|
namePyFirstChar = PinYinUtils.convertToPinyin(name);
|
||||||
namePyAll = PinYinUtils.convertToPinyin(name).replaceAll(" ", "");
|
namePyAll = PinYinUtils.convertToPinyin(name).replace(" ", "");
|
||||||
}
|
}
|
||||||
return userMapper.selectListByTerms(status, namePyAll, namePyFirstChar, name, SecurityFrameworkUtils.getUserOrganId());
|
return userMapper.selectListByTerms(status, namePyAll, namePyFirstChar, name, SecurityFrameworkUtils.getUserOrganId());
|
||||||
}
|
}
|
||||||
@@ -548,7 +549,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
@Override
|
@Override
|
||||||
@OrganIgnore
|
@OrganIgnore
|
||||||
public List<OrganAdminUserRespDTO> getOrganAdminByOrganIds(Collection<Long> organIds) {
|
public List<OrganAdminUserRespDTO> getOrganAdminByOrganIds(Collection<Long> organIds) {
|
||||||
if(CollectionUtil.isEmpty(organIds)) {
|
if(CollUtil.isEmpty(organIds)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
MPJLambdaWrapperX<AdminUserDO> wrapperX = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<AdminUserDO> wrapperX = new MPJLambdaWrapperX<>();
|
||||||
@@ -557,22 +558,6 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
;
|
;
|
||||||
List<OrganAdminUserRespDTO> organAdminUserRespDTOS = userMapper.selectJoinList(OrganAdminUserRespDTO.class, wrapperX);
|
List<OrganAdminUserRespDTO> organAdminUserRespDTOS = userMapper.selectJoinList(OrganAdminUserRespDTO.class, wrapperX);
|
||||||
return organAdminUserRespDTOS;
|
return organAdminUserRespDTOS;
|
||||||
|
|
||||||
/*List<AdminUserDO> adminUserDOS = userMapper.selectList(new LambdaQueryWrapperX<AdminUserDO>()
|
|
||||||
.in(AdminUserDO::getOrganId, organIds)
|
|
||||||
);
|
|
||||||
if(CollectionUtil.isNotEmpty(adminUserDOS)) {
|
|
||||||
return adminUserDOS.stream().map(e->
|
|
||||||
OrganAdminUserRespDTO.builder()
|
|
||||||
.organId(e.getOrganId())
|
|
||||||
.userId(e.getId())
|
|
||||||
.nickname(e.getNickname())
|
|
||||||
.username(e.getUsername())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
).toList();
|
|
||||||
}*/
|
|
||||||
// return new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -585,4 +570,12 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
return passwordEncoder.encode(password);
|
return passwordEncoder.encode(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否当前用户操作
|
||||||
|
*/
|
||||||
|
private void checkCurrentWhenOperate(Long userId) {
|
||||||
|
if (ObjectUtil.equal(userId, SecurityFrameworkUtils.getLoginUserId())) {
|
||||||
|
throw exception(USER_ME_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user