正元同步
This commit is contained in:
1 parent
00d159c8c0
commit
54a46dd9ee
20 files changed
+474
-137
No files matched your search
+14
-6
@@ -24,6 +24,7 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,11 +35,18 @@ import java.util.List;
|
||||
@FeignClient(contextId = "remoteRoleService", value = ServiceNameConstants.UPMS_SERVICE)
|
||||
public interface RemoteRoleService {
|
||||
|
||||
/**
|
||||
* 获取所有部门接口
|
||||
* @return R 返回结果对象,包含所有部门信息列表
|
||||
*/
|
||||
@GetMapping("/role/list")
|
||||
R<List<SysRole>> getAllRole();
|
||||
/**
|
||||
* 获取所有部门接口
|
||||
*
|
||||
* @return R 返回结果对象,包含所有部门信息列表
|
||||
*/
|
||||
@GetMapping("/role/list")
|
||||
R<List<SysRole>> getAllRole();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@GetMapping("/role/by-codes")
|
||||
R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes);
|
||||
|
||||
}
|
||||
+7
@@ -33,6 +33,7 @@ import com.bsd.pjcloud.common.excel.annotation.RequestExcel;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -58,6 +59,12 @@ public class SysRoleController {
|
||||
|
||||
private final SysRoleService sysRoleService;
|
||||
|
||||
@Inner
|
||||
@PostMapping("/by-codes")
|
||||
public R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes) {
|
||||
return R.ok(sysRoleService.findRolesByCodes(codes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ID查询角色信息
|
||||
* @param id ID
|
||||
|
||||
+7
@@ -53,6 +53,13 @@ public interface SysRoleService extends IService<SysRole> {
|
||||
*/
|
||||
List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key);
|
||||
|
||||
/**
|
||||
* 根据角色标识 查询角色列表
|
||||
* @param codes 角色标识
|
||||
* @return
|
||||
*/
|
||||
List<SysRole> findRolesByCodes(List<String> codes);
|
||||
|
||||
/**
|
||||
* 通过角色ID,删除角色
|
||||
* @param ids
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
package com.bsd.pjcloud.admin.service;
|
||||
|
||||
public interface SysThirdZyService {
|
||||
|
||||
|
||||
}
|
||||
+119
-104
@@ -22,6 +22,8 @@ package com.bsd.pjcloud.admin.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||
@@ -59,120 +61,133 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||
|
||||
private SysRoleMenuService roleMenuService;
|
||||
private SysRoleMenuService roleMenuService;
|
||||
|
||||
/**
|
||||
* 通过用户ID,查询角色信息
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List findRolesByUserId(Long userId) {
|
||||
return baseMapper.listRolesByUserId(userId);
|
||||
}
|
||||
/**
|
||||
* 通过用户ID,查询角色信息
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List findRolesByUserId(Long userId) {
|
||||
return baseMapper.listRolesByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID 查询角色列表,注意缓存删除
|
||||
* @param roleIdList 角色ID列表
|
||||
* @param key 缓存key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
|
||||
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
|
||||
return baseMapper.selectBatchIds(roleIdList);
|
||||
}
|
||||
/**
|
||||
* 根据角色ID 查询角色列表,注意缓存删除
|
||||
*
|
||||
* @param roleIdList 角色ID列表
|
||||
* @param key 缓存key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
|
||||
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
|
||||
return baseMapper.selectBatchIds(roleIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID,删除角色,并清空角色菜单缓存
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean removeRoleByIds(Long[] ids) {
|
||||
roleMenuService
|
||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||
return this.removeBatchByIds(CollUtil.toList(ids));
|
||||
}
|
||||
@Override
|
||||
public List<SysRole> findRolesByCodes(List<String> codes) {
|
||||
if (ObjectUtil.isEmpty(codes)) return null;
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysRole>()
|
||||
.in(SysRole::getRoleCode, codes)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色菜单列表
|
||||
* @param roleVo 角色&菜单列表
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateRoleMenus(RoleMenuVO roleVo) {
|
||||
return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds());
|
||||
}
|
||||
/**
|
||||
* 通过角色ID,删除角色,并清空角色菜单缓存
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean removeRoleByIds(Long[] ids) {
|
||||
roleMenuService
|
||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||
return this.removeBatchByIds(CollUtil.toList(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入角色
|
||||
* @param excelVOList 角色列表
|
||||
* @param bindingResult 错误信息列表
|
||||
* @return ok fail
|
||||
*/
|
||||
@Override
|
||||
public R importRole(List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
|
||||
// 通用校验获取失败的数据
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
/**
|
||||
* 根据角色菜单列表
|
||||
*
|
||||
* @param roleVo 角色&菜单列表
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateRoleMenus(RoleMenuVO roleVo) {
|
||||
return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds());
|
||||
}
|
||||
|
||||
// 个性化校验逻辑
|
||||
List<SysRole> roleList = this.list();
|
||||
/**
|
||||
* 导入角色
|
||||
*
|
||||
* @param excelVOList 角色列表
|
||||
* @param bindingResult 错误信息列表
|
||||
* @return ok fail
|
||||
*/
|
||||
@Override
|
||||
public R importRole(List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
|
||||
// 通用校验获取失败的数据
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
|
||||
// 执行数据插入操作 组装 RoleDto
|
||||
for (RoleExcelVO excel : excelVOList) {
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 检验角色名称或者角色编码是否存在
|
||||
boolean existRole = roleList.stream()
|
||||
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||
// 个性化校验逻辑
|
||||
List<SysRole> roleList = this.list();
|
||||
|
||||
if (existRole) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
||||
excel.getRoleCode()));
|
||||
}
|
||||
// 执行数据插入操作 组装 RoleDto
|
||||
for (RoleExcelVO excel : excelVOList) {
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 检验角色名称或者角色编码是否存在
|
||||
boolean existRole = roleList.stream()
|
||||
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||
|
||||
// 数据合法情况
|
||||
if (CollUtil.isEmpty(errorMsg)) {
|
||||
insertExcelRole(excel);
|
||||
}
|
||||
else {
|
||||
// 数据不合法情况
|
||||
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(errorMessageList)) {
|
||||
return R.failed(errorMessageList);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
if (existRole) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
||||
excel.getRoleCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部的角色
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
||||
List<SysRole> roleList = this
|
||||
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
||||
// 转换成execl 对象输出
|
||||
return roleList.stream().map(role -> {
|
||||
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
||||
BeanUtil.copyProperties(role, roleExcelVO);
|
||||
return roleExcelVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
// 数据合法情况
|
||||
if (CollUtil.isEmpty(errorMsg)) {
|
||||
insertExcelRole(excel);
|
||||
} else {
|
||||
// 数据不合法情况
|
||||
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(errorMessageList)) {
|
||||
return R.failed(errorMessageList);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入excel Role
|
||||
*/
|
||||
private void insertExcelRole(RoleExcelVO excel) {
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setRoleName(excel.getRoleName());
|
||||
sysRole.setRoleDesc(excel.getRoleDesc());
|
||||
sysRole.setRoleCode(excel.getRoleCode());
|
||||
this.save(sysRole);
|
||||
}
|
||||
/**
|
||||
* 查询全部的角色
|
||||
*
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
||||
List<SysRole> roleList = this
|
||||
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
||||
// 转换成execl 对象输出
|
||||
return roleList.stream().map(role -> {
|
||||
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
||||
BeanUtil.copyProperties(role, roleExcelVO);
|
||||
return roleExcelVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入excel Role
|
||||
*/
|
||||
private void insertExcelRole(RoleExcelVO excel) {
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setRoleName(excel.getRoleName());
|
||||
sysRole.setRoleDesc(excel.getRoleDesc());
|
||||
sysRole.setRoleCode(excel.getRoleCode());
|
||||
this.save(sysRole);
|
||||
}
|
||||
|
||||
}
|
||||
+18
-5
@@ -1,25 +1,38 @@
|
||||
package com.bsd.pjcloud.admin.service.impl.third;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.service.SysRoleService;
|
||||
import com.bsd.pjcloud.admin.service.SysThirdZyService;
|
||||
import com.bsd.pjcloud.admin.service.SysUserService;
|
||||
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysThirdZyServiceImpl implements SysThirdZyService {
|
||||
|
||||
private static final String TAG = "用户模块同步到正元信息";
|
||||
|
||||
private RemoterThirdZyService thirdZyService;
|
||||
private final SysRoleService roleService;
|
||||
private final SysUserService userService;
|
||||
|
||||
private final RemoterThirdZyService thirdZyService;
|
||||
|
||||
private void syncRole() {
|
||||
|
||||
}
|
||||
|
||||
private void syncUser() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user