mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-04-26 23:09:36 +08:00
add 新增 通用翻译模块 ruoyi-common-translation 实现(部门名、字典、oss、用户名)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.system.dubbo;
|
||||
|
||||
import com.ruoyi.system.api.RemoteDeptService;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 部门服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
@DubboService
|
||||
public class RemoteDeptServiceImpl implements RemoteDeptService {
|
||||
|
||||
private final ISysDeptService sysDeptService;
|
||||
|
||||
@Override
|
||||
public String selectDeptNameByIds(String deptIds) {
|
||||
return sysDeptService.selectDeptNameByIds(deptIds);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
* 字典服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
* 用户服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@@ -98,6 +98,11 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||
return userService.registerUser(sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
return userService.selectUserNameById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建登录用户
|
||||
*/
|
||||
|
||||
@@ -51,6 +51,14 @@ public interface ISysDeptService {
|
||||
*/
|
||||
SysDept selectDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 通过部门ID查询部门名称
|
||||
*
|
||||
* @param deptIds 部门ID串逗号分隔
|
||||
* @return 部门名称串逗号分隔
|
||||
*/
|
||||
String selectDeptNameByIds(String deptIds);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
*
|
||||
|
||||
@@ -206,4 +206,12 @@ public interface ISysUserService {
|
||||
*/
|
||||
int deleteUserByIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户账户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户账户
|
||||
*/
|
||||
String selectUserNameById(Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,14 @@ import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.TreeBuildUtils;
|
||||
import com.ruoyi.common.mybatis.helper.DataBaseHelper;
|
||||
import com.ruoyi.common.redis.utils.CacheUtils;
|
||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import com.ruoyi.system.api.domain.SysRole;
|
||||
@@ -20,11 +23,14 @@ import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门管理 服务实现
|
||||
@@ -106,6 +112,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
@Override
|
||||
public SysDept selectDeptById(Long deptId) {
|
||||
SysDept dept = baseMapper.selectById(deptId);
|
||||
@@ -115,6 +122,24 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
return dept;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过部门ID查询部门名称
|
||||
*
|
||||
* @param deptIds 部门ID串逗号分隔
|
||||
* @return 部门名称串逗号分隔
|
||||
*/
|
||||
@Override
|
||||
public String selectDeptNameByIds(String deptIds) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Long id : Arrays.stream(deptIds.split(",")).map(Long::parseLong).collect(Collectors.toList())) {
|
||||
SysDept dept = SpringUtils.getAopProxy(this).selectDeptById(id);
|
||||
if (ObjectUtil.isNotNull(dept)) {
|
||||
list.add(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
return String.join(",", list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
*
|
||||
@@ -210,6 +235,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#dept.deptId")
|
||||
@Override
|
||||
public int updateDept(SysDept dept) {
|
||||
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
|
||||
@@ -260,7 +286,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
list.add(dept);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
baseMapper.updateBatchById(list);
|
||||
if (baseMapper.updateBatchById(list)) {
|
||||
list.forEach(dept -> CacheUtils.evict(CacheNames.SYS_DEPT, dept.getDeptId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +298,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId) {
|
||||
return baseMapper.deleteById(deptId);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.StreamUtils;
|
||||
@@ -27,6 +28,7 @@ import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -486,4 +488,12 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
return baseMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserName).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getUserName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user