【jeecgboot 3.7.0里程碑版本发布——合并springboot3sas分支】

Merge remote-tracking branch 'origin/springboot3' into springboot3_sas

# Conflicts:
#	.gitignore
#	db/tables_nacos.sql
#	jeecg-boot-base-core/pom.xml
#	jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/config/DruidWallConfigRegister.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/filters/JwtFilter.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/BaseCommonServiceImpl.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartRoleController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysTableWhiteListController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysTenantController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysAnnouncementServiceImpl.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantPackServiceImpl.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantServiceImpl.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserDepartServiceImpl.java
#	jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml
#	jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml
#	jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml
#	pom.xml
This commit is contained in:
JEECG
2024-06-22 19:55:35 +08:00
328 changed files with 12050 additions and 53106 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>jeecg-system-api</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>3.6.1</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -85,6 +85,14 @@ public interface ISysBaseAPI extends CommonAPI {
*/
@GetMapping("/sys/api/getRolesByUsername")
List<String> getRolesByUsername(@RequestParam("username") String username);
/**
* 7通过用户账号查询角色集合
* @param userId
* @return
*/
@GetMapping("/sys/api/getRolesByUserId")
List<String> getRolesByUserId(@RequestParam("userId") String userId);
/**
* 8通过用户账号查询部门集合
@ -93,7 +101,31 @@ public interface ISysBaseAPI extends CommonAPI {
*/
@GetMapping("/sys/api/getDepartIdsByUsername")
List<String> getDepartIdsByUsername(@RequestParam("username") String username);
/**
* 8通过用户账号查询部门集合
* @param userId
* @return 部门 id
*/
@GetMapping("/sys/api/getDepartIdsByUserId")
List<String> getDepartIdsByUserId(@RequestParam("userId") String userId);
/**
* 8.2 通过用户账号查询部门父ID集合
* @param username
* @return 部门 parentIds
*/
@GetMapping("/sys/api/getDepartParentIdsByUsername")
Set<String> getDepartParentIdsByUsername(@RequestParam("username")String username);
/**
* 8.3 查询部门父ID集合
* @param depIds
* @return 部门 parentIds
*/
@GetMapping("/sys/api/getDepartParentIdsByDepIds")
Set<String> getDepartParentIdsByDepIds(@RequestParam("depIds") Set<String> depIds);
/**
* 9通过用户账号查询部门 name
* @param username
@ -197,7 +229,7 @@ public interface ISysBaseAPI extends CommonAPI {
* @return
*/
@GetMapping("/sys/api/queryAllUser")
public JSONObject queryAllUser(@RequestParam(name="userIds",required=false)String userIds, @RequestParam(name="pageNo",required=false) Integer pageNo,@RequestParam(name="pageSize",required=false) int pageSize);
public JSONObject queryAllUser(@RequestParam(name="userIds",required=false)String userIds, @RequestParam(name="pageNo",required=false) Integer pageNo,@RequestParam(name="pageSize",required=false) Integer pageSize);
/**
@ -288,14 +320,22 @@ public interface ISysBaseAPI extends CommonAPI {
*/
@GetMapping("/sys/api/getUserRoleSet")
Set<String> getUserRoleSet(@RequestParam("username")String username);
/**
* 30获取用户的角色集合
* @param userId
* @return
*/
@GetMapping("/sys/api/getUserRoleSetById")
Set<String> getUserRoleSetById(@RequestParam("userId")String userId);
/**
* 31获取用户的权限集合
* @param username
* @param userId
* @return
*/
@GetMapping("/sys/api/getUserPermissionSet")
Set<String> getUserPermissionSet(@RequestParam("username") String username);
Set<String> getUserPermissionSet(@RequestParam("userId") String userId);
/**
* 32判断是否有online访问的权限
@ -332,15 +372,24 @@ public interface ISysBaseAPI extends CommonAPI {
@Override
@GetMapping("/sys/api/queryUserRoles")
Set<String> queryUserRoles(@RequestParam("username")String username);
/**
* 35查询用户角色信息
* @param userId
* @return
*/
@Override
@GetMapping("/sys/api/queryUserRolesById")
Set<String> queryUserRolesById(@RequestParam("userId")String userId);
/**
* 36查询用户权限信息
* @param username
* @param userId
* @return
*/
@Override
@GetMapping("/sys/api/queryUserAuths")
Set<String> queryUserAuths(@RequestParam("username")String username);
Set<String> queryUserAuths(@RequestParam("userId")String userId);
/**
* 37根据 id 查询数据库中存储的 DynamicDataSourceModel
@ -371,6 +420,15 @@ public interface ISysBaseAPI extends CommonAPI {
@SensitiveDecode
@GetMapping("/sys/api/getUserByName")
LoginUser getUserByName(@RequestParam("username") String username);
/**
* 39根据用户账号查询用户ID CommonAPI中定义
* @param username
* @return 用户ID
*/
@Override
@GetMapping("/sys/api/getUserIdByName")
String getUserIdByName(@RequestParam("username") String username);
/**
* 40字典表的 翻译
@ -481,6 +539,14 @@ public interface ISysBaseAPI extends CommonAPI {
@GetMapping("/sys/api/loadCategoryDictItem")
List<String> loadCategoryDictItem(@RequestParam("ids") String ids);
/**
* 44 反向翻译分类字典,用于导入
*
* @param names 名称,逗号分割
*/
@GetMapping("/sys/api/loadCategoryDictItemByNames")
List<String> loadCategoryDictItemByNames(@RequestParam("names") String names, @RequestParam("delNotExist") boolean delNotExist);
/**
* 43 根据字典code加载字典text
*
@ -551,17 +617,20 @@ public interface ISysBaseAPI extends CommonAPI {
@GetMapping("/sys/api/translateManyDict")
Map<String, List<DictModel>> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys);
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/**
* 49 字典表的 翻译,可批量
* @param table
* @param text
* @param code
* @param keys 多个用逗号分割
* @param ds
* @return
*/
@Override
@GetMapping("/sys/api/translateDictFromTableByKeys")
List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys);
List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys, @RequestParam("ds") String ds);
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/**
* 发送模板消息
@ -582,21 +651,7 @@ public interface ISysBaseAPI extends CommonAPI {
* @param dataLogDto
*/
@PostMapping("/sys/api/saveDataLog")
void saveDataLog(DataLogDTO dataLogDto);
/**
* 添加文件到知识库
* @param sysFilesModel
*/
@PostMapping("/sys/api/addSysFiles")
void addSysFiles(SysFilesModel sysFilesModel);
/**
* 通过文件路径获取文件id
* @param fileId
*/
@GetMapping("/sys/api/getFileUrl")
String getFileUrl(@RequestParam(name="fileId") String fileId);
void saveDataLog(@RequestBody DataLogDTO dataLogDto);
/**
* 更新头像
@ -734,7 +789,7 @@ public interface ISysBaseAPI extends CommonAPI {
@GetMapping("/sys/api/dictTableWhiteListCheckByDict")
boolean dictTableWhiteListCheckByDict(
@RequestParam("tableOrDictCode") String tableOrDictCode,
@RequestParam(value = "fields", required = false) String[] fields
@RequestParam(value = "fields", required = false) String... fields
);
@GetMapping("/sys/api/getUserByPhone")

View File

@ -60,11 +60,31 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
return null;
}
@Override
public List<String> getRolesByUserId(String userId) {
return null;
}
@Override
public List<String> getDepartIdsByUsername(String username) {
return null;
}
@Override
public List<String> getDepartIdsByUserId(String userId) {
return null;
}
@Override
public Set<String> getDepartParentIdsByUsername(String username) {
return null;
}
@Override
public Set<String> getDepartParentIdsByDepIds(Set<String> depIds) {
return null;
}
@Override
public List<String> getDepartNamesByUsername(String username) {
return null;
@ -123,7 +143,7 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public JSONObject queryAllUser(String userIds, Integer pageNo, int pageSize) {
public JSONObject queryAllUser(String userIds, Integer pageNo, Integer pageSize) {
return null;
}
@ -184,7 +204,12 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public Set<String> getUserPermissionSet(String username) {
public Set<String> getUserRoleSetById(String userId) {
return null;
}
@Override
public Set<String> getUserPermissionSet(String userId) {
return null;
}
@ -209,7 +234,12 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public Set<String> queryUserAuths(String username) {
public Set<String> queryUserRolesById(String userId) {
return null;
}
@Override
public Set<String> queryUserAuths(String userId) {
return null;
}
@ -229,6 +259,11 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
return null;
}
@Override
public String getUserIdByName(String username) {
return null;
}
@Override
public String translateDictFromTable(String table, String text, String code, String key) {
return null;
@ -275,10 +310,12 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
return null;
}
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
@Override
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys) {
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys, String dataSource) {
return null;
}
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
@Override
public void sendTemplateMessage(MessageDTO message) {
@ -319,6 +356,11 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
return null;
}
@Override
public List<String> loadCategoryDictItemByNames(String names, boolean delNotExist) {
return null;
}
@Override
public List<String> loadDictItem(String dictCode, String keys) {
return null;
@ -344,17 +386,6 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
return null;
}
@Override
public void addSysFiles(SysFilesModel sysFilesModel) {
}
@Override
public String getFileUrl(String fileId) {
return null;
}
@Override
public void updateAvatar(LoginUser loginUser) { }
@ -429,7 +460,7 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public boolean dictTableWhiteListCheckByDict(String tableOrDictCode, String[] fields) {
public boolean dictTableWhiteListCheckByDict(String tableOrDictCode, String... fields) {
return false;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>jeecg-system-api</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>3.6.1</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -81,6 +81,13 @@ public interface ISysBaseAPI extends CommonAPI {
* @return
*/
List<String> getRolesByUsername(String username);
/**
* 7通过用户账号查询角色集合
* @param userId
* @return
*/
List<String> getRolesByUserId(String userId);
/**
* 8通过用户账号查询部门集合
@ -88,6 +95,26 @@ public interface ISysBaseAPI extends CommonAPI {
* @return 部门 id
*/
List<String> getDepartIdsByUsername(String username);
/**
* 8通过用户账号查询部门集合
* @param userId
* @return 部门 id
*/
List<String> getDepartIdsByUserId(String userId);
/**
* 8.2 通过用户账号查询部门父ID集合
* @param username
* @return 部门 parentIds
*/
Set<String> getDepartParentIdsByUsername(String username);
/**
* 8.2 查询部门父ID集合
* @param depIds
* @return 部门 parentIds
*/
Set<String> getDepartParentIdsByDepIds(Set<String> depIds);
/**
* 9通过用户账号查询部门 name
@ -285,13 +312,19 @@ public interface ISysBaseAPI extends CommonAPI {
* @return
*/
Set<String> getUserRoleSet(String username);
/**
* 32获取用户的权限集合
* @param username
* 31获取用户的角色集合
* @param useId
* @return
*/
Set<String> getUserPermissionSet(String username);
Set<String> getUserRoleSetById(String useId);
/**
* 32获取用户的权限集合
* @param userId
* @return
*/
Set<String> getUserPermissionSet(String userId);
/**
* 33判断是否有online访问的权限
@ -373,6 +406,13 @@ public interface ISysBaseAPI extends CommonAPI {
*/
List<String> loadCategoryDictItem(String ids);
/**
* 反向翻译分类字典,用于导入
*
* @param names 名称,逗号分割
*/
List<String> loadCategoryDictItemByNames(String names, boolean delNotExist);
/**
* 根据字典code加载字典text
*
@ -424,19 +464,6 @@ public interface ISysBaseAPI extends CommonAPI {
* @param dataLogDto
*/
void saveDataLog(DataLogDTO dataLogDto);
/**
* 添加文件到知识库
* @param sysFilesModel
*/
void addSysFiles(SysFilesModel sysFilesModel);
/**
* 通过文件路径获取文件id
* @param fileId
*/
String getFileUrl(String fileId);
/**
* 更新头像
* @param loginUser

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>jeecg-module-system</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>3.6.1</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-system</artifactId>
<version>3.6.1</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -36,14 +36,14 @@
</dependency>
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>drag-free</artifactId>
<version>1.0.2</version>
<artifactId>jimureport-drag</artifactId>
<version>2.0.2</version>
</dependency>
<!-- 积木报表 mongo redis 支持包
<!-- 积木报表 mongo redis 支持包
<dependency>
<groupId>org.jeecgframework.jimureport</groupId>
<artifactId>jimureport-nosql-starter</artifactId>
</dependency> -->
</dependency>-->
</dependencies>
</project>

View File

@ -15,6 +15,10 @@ import org.springframework.context.annotation.Configuration;
* 提醒: 达梦数据库需要修改下面的参数${spring.datasource.dynamic.datasource.master.url:}配置
* @author: scott
* @date: 2021年02月18日 16:30
*
* 重要说明:此类改路径或者名称,需要同步修改
* org/jeecg/interceptor/OnlineRepairCodeGenerateDbConfig.java里面的注解
* @ConditionalOnMissingClass("org.jeecg.config.init.CodeGenerateDbConfig")
*/
@Slf4j
@Configuration

View File

@ -0,0 +1,102 @@
//package org.jeecg.config.jimureport;
//
//import lombok.extern.slf4j.Slf4j;
//import org.jeecg.common.api.dto.LogDTO;
//import org.jeecg.common.system.api.ISysBaseAPI;
//import org.jeecg.common.system.vo.DictModel;
//import org.jeecg.common.util.oConvertUtils;
//import org.jeecg.modules.base.service.BaseCommonService;
//import org.jeecg.modules.drag.service.IOnlDragExternalService;
//import org.jeecg.modules.drag.vo.DragDictModel;
//import org.jeecg.modules.drag.vo.DragLogDTO;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Lazy;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * @Description: 字典处理
// * @Author: lsq
// * @Date:2023-01-09
// * @Version:V1.0
// */
//@Slf4j
//@Service("onlDragExternalServiceImpl")
//public class JimuDragExternalServiceImpl implements IOnlDragExternalService {
//
// @Autowired
// @Lazy
// private BaseCommonService baseCommonService;
//
// @Autowired
// @Lazy
// private ISysBaseAPI sysBaseApi;
// /**
// * 根据多个字典code查询多个字典项
// * @param codeList
// * @return key = dictCode value=对应的字典项
// */
// @Override
// public Map<String, List<DragDictModel>> getManyDictItems(List<String> codeList) {
// Map<String, List<DragDictModel>> manyDragDictItems = new HashMap<>();
// Map<String, List<DictModel>> dictItemsMap = sysBaseApi.getManyDictItems(codeList);
// dictItemsMap.forEach((k,v)->{
// List<DragDictModel> dictItems = new ArrayList<>();
// v.forEach(dictItem->{
// DragDictModel dictModel = new DragDictModel();
// BeanUtils.copyProperties(dictItem,dictModel);
// dictItems.add(dictModel);
// });
// manyDragDictItems.put(k,dictItems);
// });
// return manyDragDictItems;
// }
//
// /**
// *
// * @param dictCode
// * @return
// */
// @Override
// public List<DragDictModel> getDictItems(String dictCode) {
// List<DragDictModel> dictItems = new ArrayList<>();
// if(oConvertUtils.isNotEmpty(dictCode)){
// List<DictModel> dictItemsList = sysBaseApi.getDictItems(dictCode);
// dictItemsList.forEach(dictItem->{
// DragDictModel dictModel = new DragDictModel();
// BeanUtils.copyProperties(dictItem,dictModel);
// dictItems.add(dictModel);
// });
// }
// return dictItems;
// }
//
// /**
// * 添加日志
// * @param dragLogDTO
// */
// @Override
// public void addLog(DragLogDTO dragLogDTO) {
// if(oConvertUtils.isNotEmpty(dragLogDTO)){
// LogDTO dto = new LogDTO();
// BeanUtils.copyProperties(dragLogDTO,dto);
// baseCommonService.addLog(dto);
// }
// }
//
// /**
// * 保存日志
// * @param logMsg
// * @param logType
// * @param operateType
// */
// @Override
// public void addLog(String logMsg, int logType, int operateType) {
// baseCommonService.addLog(logMsg,logType,operateType);
// }
//}

View File

@ -8,6 +8,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.jeecg.common.api.dto.LogDTO;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.config.security.utils.SecureUtil;
import org.jeecg.modules.base.service.BaseCommonService;
@ -54,7 +55,7 @@ public class TenantPackUserLogAspect {
for(Object obj: args){
if(obj instanceof SysTenantPack){
// logType=3 租户操作日志
logType = 3;
logType = CommonConstant.LOG_TYPE_3;
SysTenantPack pack = (SysTenantPack)obj;
if(opType==2){
content = "创建了角色权限 "+ pack.getPackName();
@ -62,7 +63,7 @@ public class TenantPackUserLogAspect {
tenantId = pack.getTenantId();
break;
}else if(obj instanceof SysTenantPackUser){
logType = 3;
logType = CommonConstant.LOG_TYPE_3;
SysTenantPackUser packUser = (SysTenantPackUser)obj;
if(opType==2){
content = ""+packUser.getRealname()+" 添加到角色 "+ packUser.getPackName();

View File

@ -102,6 +102,17 @@ public class SystemApiController {
}
return loginUser;
}
/**
* 根据用户账号查询用户ID
* @param username
* @return
*/
@GetMapping("/getUserIdByName")
public String getUserIdByName(@RequestParam("username") String username){
String userId = sysBaseApi.getUserIdByName(username);
return userId;
}
/**
* 根据用户id查询用户信息
@ -129,6 +140,16 @@ public class SystemApiController {
List<String> getRolesByUsername(@RequestParam("username") String username){
return sysBaseApi.getRolesByUsername(username);
}
/**
* 通过用户账号查询角色集合
* @param userId
* @return
*/
@GetMapping("/getRolesByUserId")
List<String> getRolesByUserId(@RequestParam("userId") String userId){
return sysBaseApi.getRolesByUserId(userId);
}
/**
* 通过用户账号查询部门集合
@ -139,6 +160,36 @@ public class SystemApiController {
List<String> getDepartIdsByUsername(@RequestParam("username") String username){
return sysBaseApi.getDepartIdsByUsername(username);
}
/**
* 通过用户账号查询部门集合
* @param userId
* @return 部门 id
*/
@GetMapping("/getDepartIdsByUserId")
List<String> getDepartIdsByUserId(@RequestParam("userId") String userId){
return sysBaseApi.getDepartIdsByUserId(userId);
}
/**
* 通过用户账号查询部门父ID集合
* @param username
* @return 部门 id
*/
@GetMapping("/getDepartParentIdsByUsername")
Set<String> getDepartParentIdsByUsername(@RequestParam("username") String username){
return sysBaseApi.getDepartParentIdsByUsername(username);
}
/**
* 查询部门父ID集合
* @param depIds
* @return 部门 id
*/
@GetMapping("/getDepartParentIdsByDepIds")
Set<String> getDepartParentIdsByDepIds(@RequestParam("depIds") Set<String> depIds){
return sysBaseApi.getDepartParentIdsByDepIds(depIds);
}
/**
* 通过用户账号查询部门 name
@ -327,7 +378,7 @@ public class SystemApiController {
* @return
*/
@GetMapping("/queryAllUser")
public JSONObject queryAllUser(@RequestParam(name="userIds",required=false)String userIds, @RequestParam(name="pageNo",required=false) Integer pageNo,@RequestParam(name="pageSize",required=false) int pageSize){
public JSONObject queryAllUser(@RequestParam(name="userIds",required=false)String userIds, @RequestParam(name="pageNo",required=false) Integer pageNo,@RequestParam(name="pageSize",required=false) Integer pageSize){
return sysBaseApi.queryAllUser(userIds, pageNo, pageSize);
}
@ -363,15 +414,25 @@ public class SystemApiController {
public Set<String> getUserRoleSet(@RequestParam("username")String username){
return sysBaseApi.getUserRoleSet(username);
}
/**
* 获取用户的角色集合
* @param userId
* @return
*/
@GetMapping("/getUserRoleSetById")
public Set<String> getUserRoleSetById(@RequestParam("userId")String userId){
return sysBaseApi.getUserRoleSetById(userId);
}
/**
* 获取用户的权限集合
* @param username
* @param userId 用户表ID
* @return
*/
@GetMapping("/getUserPermissionSet")
public Set<String> getUserPermissionSet(@RequestParam("username") String username){
return sysBaseApi.getUserPermissionSet(username);
public Set<String> getUserPermissionSet(@RequestParam("userId") String userId){
return sysBaseApi.getUserPermissionSet(userId);
}
//-----
@ -395,16 +456,26 @@ public class SystemApiController {
public Set<String> queryUserRoles(@RequestParam("username") String username){
return sysUserService.getUserRolesSet(username);
}
/**
* 查询用户角色信息
* @param userId
* @return
*/
@GetMapping("/queryUserRolesById")
public Set<String> queryUserRolesById(@RequestParam("userId") String userId){
return sysUserService.getUserRoleSetById(userId);
}
/**
* 查询用户权限信息
* @param username
* @param userId
* @return
*/
@GetMapping("/queryUserAuths")
public Set<String> queryUserAuths(@RequestParam("username") String username){
return sysUserService.getUserPermissionsSet(username);
public Set<String> queryUserAuths(@RequestParam("userId") String userId){
return sysUserService.getUserPermissionsSet(userId);
}
/**
@ -527,6 +598,17 @@ public class SystemApiController {
return sysBaseApi.loadCategoryDictItem(ids);
}
/**
* 反向翻译分类字典,用于导入
*
* @param names 名称,逗号分割
* @return
*/
@GetMapping("/loadCategoryDictItemByNames")
List<String> loadCategoryDictItemByNames(@RequestParam("names") String names, @RequestParam("delNotExist") boolean delNotExist) {
return sysBaseApi.loadCategoryDictItemByNames(names, delNotExist);
}
/**
* 根据字典code加载字典text
*
@ -547,7 +629,7 @@ public class SystemApiController {
* @param tenantId 新的租户ID
* @return Map<String, String> Map<原字典编码, 新字典编码>
*/
@GetMapping("/sys/api/copyLowAppDict")
@GetMapping("/copyLowAppDict")
Map<String, String> copyLowAppDict(@RequestParam("originalAppId") String originalAppId, @RequestParam("appId") String appId, @RequestParam("tenantId") String tenantId) {
return sysBaseApi.copyLowAppDict(originalAppId, appId, tenantId);
}
@ -655,6 +737,7 @@ public class SystemApiController {
}
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/**
* 【接口签名验证】
* 49 字典表的 翻译,可批量
@ -663,12 +746,14 @@ public class SystemApiController {
* @param text
* @param code
* @param keys 多个用逗号分割
* @param ds 数据源
* @return
*/
@GetMapping("/translateDictFromTableByKeys")
public List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys) {
return this.sysBaseApi.translateDictFromTableByKeys(table, text, code, keys);
public List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys, @RequestParam("ds") String ds) {
return this.sysBaseApi.translateDictFromTableByKeys(table, text, code, keys, ds);
}
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/**
* 发送模板信息
@ -698,14 +783,6 @@ public class SystemApiController {
this.sysBaseApi.saveDataLog(dataLogDto);
}
@PostMapping("/addSysFiles")
public void addSysFiles(@RequestBody SysFilesModel sysFilesModel){this.sysBaseApi.addSysFiles(sysFilesModel);}
@GetMapping("/getFileUrl")
public String getFileUrl(@RequestParam(name="fileId") String fileId){
return this.sysBaseApi.getFileUrl(fileId);
}
/**
* 更新头像
* @param loginUser
@ -824,7 +901,7 @@ public class SystemApiController {
* @param deptIds
* @return
*/
@GetMapping("/sys/api/queryUserIdsByDeptIds")
@GetMapping("/queryUserIdsByDeptIds")
public List<String> queryUserIdsByDeptIds(@RequestParam("deptIds") List<String> deptIds){
return sysBaseApi.queryUserIdsByDeptIds(deptIds);
}
@ -834,7 +911,7 @@ public class SystemApiController {
* @param deptIds
* @return
*/
@GetMapping("/sys/api/queryUserAccountsByDeptIds")
@GetMapping("/queryUserAccountsByDeptIds")
public List<String> queryUserAccountsByDeptIds(@RequestParam("deptIds") List<String> deptIds){
return sysBaseApi.queryUserAccountsByDeptIds(deptIds);
}
@ -844,7 +921,7 @@ public class SystemApiController {
* @param roleCodes
* @return
*/
@GetMapping("/sys/api/queryUserIdsByRoleds")
@GetMapping("/queryUserIdsByRoleds")
public List<String> queryUserIdsByRoleds(@RequestParam("roleCodes") List<String> roleCodes){
return sysBaseApi.queryUserIdsByRoleds(roleCodes);
}
@ -854,7 +931,7 @@ public class SystemApiController {
* @param positionIds
* @return
*/
@GetMapping("/sys/api/queryUserIdsByPositionIds")
@GetMapping("/queryUserIdsByPositionIds")
public List<String> queryUserIdsByPositionIds(@RequestParam("positionIds") List<String> positionIds){
return sysBaseApi.queryUserIdsByPositionIds(positionIds);
}
@ -866,8 +943,8 @@ public class SystemApiController {
* @param orgCode 部门编码
* @return
*/
@GetMapping("/sys/api/getUserAccountsByDepCode")
public List<String> getUserAccountsByDepCode(String orgCode){
@GetMapping("/getUserAccountsByDepCode")
public List<String> getUserAccountsByDepCode(@RequestParam("orgCode") String orgCode){
return sysBaseApi.getUserAccountsByDepCode(orgCode);
}
@ -877,7 +954,7 @@ public class SystemApiController {
* @param selectSql
* @return
*/
@GetMapping("/sys/api/dictTableWhiteListCheckBySql")
@GetMapping("/dictTableWhiteListCheckBySql")
public boolean dictTableWhiteListCheckBySql(@RequestParam("selectSql") String selectSql) {
return sysBaseApi.dictTableWhiteListCheckBySql(selectSql);
}
@ -889,10 +966,10 @@ public class SystemApiController {
* @param fields 如果传的是dictCode则该参数必须传null
* @return
*/
@GetMapping("/sys/api/dictTableWhiteListCheckByDict")
@GetMapping("/dictTableWhiteListCheckByDict")
public boolean dictTableWhiteListCheckByDict(
@RequestParam("tableOrDictCode") String tableOrDictCode,
@RequestParam(value = "fields", required = false) String[] fields
@RequestParam(value = "fields", required = false) String... fields
) {
return sysBaseApi.dictTableWhiteListCheckByDict(tableOrDictCode, fields);
}

View File

@ -173,7 +173,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
sysBaseApi.sendTemplateMessage(md);
return result.success("消息发送成功!");
} catch (Exception e) {
log.error("发送消息出错", e.getMessage());
log.error("发送消息出错" + e.getMessage(), e);
return result.error500("发送消息出错!");
}
}

View File

@ -31,8 +31,13 @@ public class WebSocket {
* Redis触发监听名字
*/
public static final String REDIS_TOPIC_NAME = "socketHandler";
//避免初次调用出现空指针的情况
private static JeecgRedisClient jeecgRedisClient;
@Autowired
private JeecgRedisClient jeecgRedisClient;
private void setJeecgRedisClient(JeecgRedisClient jeecgRedisClient){
WebSocket.jeecgRedisClient = jeecgRedisClient;
}
//==========【websocket接受、推送消息等方法 —— 具体服务节点推送ws消息】========================================================================================
@ -109,6 +114,9 @@ public class WebSocket {
log.debug("【系统 WebSocket】收到客户端消息:" + message);
}else{
log.debug("【系统 WebSocket】收到客户端消息:" + message);
//update-begin---author:wangshuai---date:2024-05-07---for:【issues/1161】前端websocket因心跳导致监听不起作用---
this.sendMessage(userId, "ping");
//update-end---author:wangshuai---date:2024-05-07---for:【issues/1161】前端websocket因心跳导致监听不起作用---
}
// //------------------------------------------------------------------------------

View File

@ -0,0 +1,38 @@
package org.jeecg.modules.monitor.actuator;
import org.jeecg.modules.monitor.actuator.httptrace.CustomInMemoryHttpTraceRepository;
import org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesProperties;
import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 自定义健康监控配置类
*
* @Author: chenrui
* @Date: 2024/5/13 17:20
*/
@Configuration
@EnableConfigurationProperties(HttpExchangesProperties.class)
@AutoConfigureBefore(HttpExchangesAutoConfiguration.class)
public class CustomActuatorConfig {
/**
* 请求追踪
* @return
* @author chenrui
* @date 2024/5/14 14:52
*/
@Bean
@ConditionalOnProperty(prefix = "management.trace.http", name = "enabled", matchIfMissing = true)
@ConditionalOnMissingBean(HttpExchangeRepository.class)
public CustomInMemoryHttpTraceRepository traceRepository() {
return new CustomInMemoryHttpTraceRepository();
}
}

View File

@ -0,0 +1,44 @@
package org.jeecg.modules.monitor.actuator.httptrace;
import lombok.Getter;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.web.exchanges.HttpExchange;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.util.List;
import static org.springframework.boot.actuate.endpoint.annotation.Selector.Match.ALL_REMAINING;
/**
* @Description: ENDPOINT: 请求追踪(新),支持通过responseCode筛选
* @Author: chenrui
* @Date: 2024/5/13 17:02
*/
@Component
@Endpoint(id = "httptrace-new")
public class CustomHttpTraceEndpoint{
private final CustomInMemoryHttpTraceRepository repository;
public CustomHttpTraceEndpoint(CustomInMemoryHttpTraceRepository repository) {
Assert.notNull(repository, "Repository must not be null");
this.repository = repository;
}
@ReadOperation
public HttpTraceDescriptor traces(@Selector(match = ALL_REMAINING) String query) {
return new HttpTraceDescriptor(this.repository.findAll(query));
}
@Getter
public static final class HttpTraceDescriptor {
private final List<HttpExchange> traces;
private HttpTraceDescriptor(List<HttpExchange> traces) {
this.traces = traces;
}
}
}

View File

@ -0,0 +1,94 @@
package org.jeecg.modules.monitor.actuator.httptrace;
import org.springframework.boot.actuate.web.exchanges.HttpExchange;
import org.springframework.boot.actuate.web.exchanges.InMemoryHttpExchangeRepository;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description: 自定义内存请求追踪存储
* @Author: chenrui
* @Date: 2024/5/13 17:02
*/
public class CustomInMemoryHttpTraceRepository extends InMemoryHttpExchangeRepository {
@Override
public List<HttpExchange> findAll() {
return super.findAll();
}
public List<HttpExchange> findAll(String query) {
List<HttpExchange> allTrace = super.findAll();
if (null != allTrace && !allTrace.isEmpty()) {
Stream<HttpExchange> stream = allTrace.stream();
String[] params = query.split(",");
stream = filter(params, stream);
stream = sort(params, stream);
allTrace = stream.collect(Collectors.toList());
}
return allTrace;
}
private Stream<HttpExchange> sort(String[] params, Stream<HttpExchange> stream) {
if (params.length < 2) {
return stream;
}
String sortBy = params[1];
String order;
if (params.length > 2) {
order = params[2];
} else {
order = "desc";
}
return stream.sorted((o1, o2) -> {
int i = 0;
if("timeTaken".equalsIgnoreCase(sortBy)) {
i = o1.getTimeTaken().compareTo(o2.getTimeTaken());
}else if("timestamp".equalsIgnoreCase(sortBy)){
i = o1.getTimestamp().compareTo(o2.getTimestamp());
}
if("desc".equalsIgnoreCase(order)){
i *=-1;
}
return i;
});
}
private static Stream<HttpExchange> filter(String[] params, Stream<HttpExchange> stream) {
if (params.length == 0) {
return stream;
}
String statusQuery = params[0];
if (null != statusQuery && !statusQuery.isEmpty()) {
statusQuery = statusQuery.toLowerCase().trim();
switch (statusQuery) {
case "error":
stream = stream.filter(httpTrace -> {
int status = httpTrace.getResponse().getStatus();
return status >= 404 && status < 501;
});
break;
case "warn":
stream = stream.filter(httpTrace -> {
int status = httpTrace.getResponse().getStatus();
return status >= 201 && status < 404;
});
break;
case "success":
stream = stream.filter(httpTrace -> {
int status = httpTrace.getResponse().getStatus();
return status == 200;
});
break;
case "all":
default:
break;
}
return stream;
}
return stream;
}
}

View File

@ -0,0 +1,52 @@
package org.jeecg.modules.monitor.controller;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.util.HashMap;
import java.util.Map;
/**
* @Description: 内存健康检查
* @author: chenrui
*/
@Slf4j
@RestController
@RequestMapping("/sys/actuator/memory")
public class ActuatorMemoryController {
/**
* 内存详情
* @return
* @throws Exception
*/
@GetMapping("/info")
public Result<?> getRedisInfo() throws Exception {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
JSONObject operatingSystemJson = JSONObject.parseObject(JSONObject.toJSONString(operatingSystemMXBean));
long totalPhysicalMemory = operatingSystemJson.getLongValue("totalPhysicalMemorySize");
long freePhysicalMemory = operatingSystemJson.getLongValue("freePhysicalMemorySize");
long usedPhysicalMemory = totalPhysicalMemory - freePhysicalMemory;
Runtime runtime = Runtime.getRuntime();
Map<String,Number> result = new HashMap<>();
result.put("memory.physical.total", totalPhysicalMemory);
result.put("memory.physical.used", freePhysicalMemory);
result.put("memory.physical.free", usedPhysicalMemory);
result.put("memory.physical.usage", NumberUtil.div(usedPhysicalMemory, totalPhysicalMemory));
result.put("memory.runtime.total", runtime.totalMemory());
result.put("memory.runtime.used", runtime.freeMemory());
result.put("memory.runtime.max", runtime.totalMemory() - runtime.freeMemory());
result.put("memory.runtime.free", runtime.maxMemory() - runtime.totalMemory() + runtime.freeMemory());
result.put("memory.runtime.usage", NumberUtil.div(runtime.totalMemory() - runtime.freeMemory(), runtime.totalMemory()));
return Result.ok(result);
}
}

View File

@ -43,6 +43,21 @@ public class ActuatorRedisController {
return Result.ok(infoList);
}
//update-begin---author:chenrui ---date:20240514 for[QQYUN-9247]系统监控功能优化------------
/**
* Redis历史性能指标查询(过去一小时)
* @return
* @throws Exception
* @author chenrui
* @date 2024/5/14 14:56
*/
@GetMapping(value = "/metrics/history")
public Result<?> getMetricsHistory() throws Exception {
Map<String,List<Map<String,Object>>> metricsHistory = this.redisService.getMetricsHistory();
return Result.OK(metricsHistory);
}
//update-end---author:chenrui ---date:20240514 for[QQYUN-9247]系统监控功能优化------------
@GetMapping("/keysSize")
public Map<String, Object> getKeysSize() throws Exception {
return redisService.getKeysSize();

View File

@ -44,4 +44,12 @@ public interface RedisService {
* @throws RedisConnectException
*/
Map<String, JSONArray> getMapForReport(String type) throws RedisConnectException ;
/**
* 获取历史性能指标
* @return
* @author chenrui
* @date 2024/5/14 14:57
*/
Map<String, List<Map<String, Object>>> getMetricsHistory();
}

View File

@ -1,10 +1,6 @@
package org.jeecg.modules.monitor.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import jakarta.annotation.Resource;
@ -12,13 +8,13 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.monitor.domain.RedisInfo;
import org.jeecg.modules.monitor.exception.RedisConnectException;
import org.jeecg.modules.monitor.service.RedisService;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
@ -40,6 +36,11 @@ public class RedisServiceImpl implements RedisService {
*/
private static final String REDIS_MESSAGE = "3";
/**
* redis性能信息记录
*/
private static final Map<String,List<Map<String, Object>>> REDIS_METRICS = new HashMap<>(2);
/**
* Redis详细信息
*/
@ -126,4 +127,48 @@ public class RedisServiceImpl implements RedisService {
mapJson.put("data",json);
return mapJson;
}
//update-begin---author:chenrui ---date:20240514 for[QQYUN-9247]系统监控功能优化------------
/**
* 获取历史性能指标
* @return
* @author chenrui
* @date 2024/5/14 14:57
*/
@Override
public Map<String, List<Map<String, Object>>> getMetricsHistory() {
return REDIS_METRICS;
}
/**
* 记录近一小时redis监控数据 <br/>
* 60s一次,,记录存储keysize和内存
* @throws RedisConnectException
* @author chenrui
* @date 2024/5/14 14:09
*/
@Scheduled(fixedRate = 60000)
public void recordCustomMetric() throws RedisConnectException {
List<Map<String, Object>> list= new ArrayList<>();
if(REDIS_METRICS.containsKey("dbSize")){
list = REDIS_METRICS.get("dbSize");
}else{
REDIS_METRICS.put("dbSize",list);
}
if(list.size()>60){
list.remove(0);
}
list.add(getKeysSize());
list= new ArrayList<>();
if(REDIS_METRICS.containsKey("memory")){
list = REDIS_METRICS.get("memory");
}else{
REDIS_METRICS.put("memory",list);
}
if(list.size()>60){
list.remove(0);
}
list.add(getMemoryInfo());
}
//update-end---author:chenrui ---date:20240514 for[QQYUN-9247]系统监控功能优化------------
}

View File

@ -0,0 +1,69 @@
package org.jeecg.modules.system.cache;
import jakarta.annotation.PostConstruct;
import me.zhyd.oauth.cache.AuthCacheConfig;
import me.zhyd.oauth.cache.AuthStateCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import java.util.concurrent.TimeUnit;
public class AuthStateRedisCache implements AuthStateCache {
@Autowired
private RedisTemplate<String, String> redisTemplate;
private ValueOperations<String, String> valueOperations;
@PostConstruct
public void init() {
valueOperations = redisTemplate.opsForValue();
}
/**
* 存入缓存默认3分钟
*
* @param key 缓存key
* @param value 缓存内容
*/
@Override
public void cache(String key, String value) {
valueOperations.set(key, value, AuthCacheConfig.timeout, TimeUnit.MILLISECONDS);
}
/**
* 存入缓存
*
* @param key 缓存key
* @param value 缓存内容
* @param timeout 指定缓存过期时间(毫秒)
*/
@Override
public void cache(String key, String value, long timeout) {
valueOperations.set(key, value, timeout, TimeUnit.MILLISECONDS);
}
/**
* 获取缓存内容
*
* @param key 缓存key
* @return 缓存内容
*/
@Override
public String get(String key) {
return valueOperations.get(key);
}
/**
* 是否存在key如果对应key的value值已过期也返回false
*
* @param key 缓存key
* @return true存在key并且value没过期falsekey不存在或者已过期
*/
@Override
public boolean containsKey(String key) {
return redisTemplate.hasKey(key);
}
}

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.system.config;
import me.zhyd.oauth.cache.AuthStateCache;
import org.jeecg.modules.system.cache.AuthStateRedisCache;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AuthStateConfiguration {
@Bean
public AuthStateCache authStateCache() {
return new AuthStateRedisCache();
}
}

View File

@ -0,0 +1,25 @@
package org.jeecg.modules.system.constant;
/**
* 默认首页常量
*/
public interface DefIndexConst {
/**
* 默认首页的roleCode
*/
String DEF_INDEX_ALL = "DEF_INDEX_ALL";
/**
* 默认首页的缓存key
*/
String CACHE_KEY = "sys:cache:def_index";
/**
* 默认首页的初始值
*/
String DEF_INDEX_NAME = "首页";
String DEF_INDEX_URL = "/dashboard/analysis";
String DEF_INDEX_COMPONENT = "dashboard/Analysis";
}

View File

@ -9,9 +9,8 @@ import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.filter.SsrfFileTypeFilter;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.service.ISysFilesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
@ -52,7 +51,7 @@ public class CommonController {
*/
@GetMapping("/403")
public Result<?> noauth() {
return Result.error("没有权限,请联系管理员授权");
return Result.error("没有权限,请联系管理员授权,后刷新缓存!");
}
/**

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.constant.CommonConstant;
@ -91,32 +92,24 @@ public class LoginController {
@Deprecated
// @Operation(summary = "登录接口")
// @RequestMapping(value = "/login", method = RequestMethod.POST)
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel){
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel, HttpServletRequest request){
Result<JSONObject> result = new Result<JSONObject>();
String username = sysLoginModel.getUsername();
String password = sysLoginModel.getPassword();
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
if(isLoginFailOvertimes(username)){
return result.error500("该用户登录失败次数过多请于10分钟后再次登录");
}
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
//update-begin--Author:scott Date:20190805 for暂时注释掉密码加密逻辑有点问题
//前端密码加密,后端进行密码解密
//password = AesEncryptUtil.desEncrypt(sysLoginModel.getPassword().replaceAll("%2B", "\\+")).trim();//密码解密
//update-begin--Author:scott Date:20190805 for暂时注释掉密码加密逻辑有点问题
//update-begin-author:taoyan date:20190828 for:校验验证码
// step.1 验证码check
String captcha = sysLoginModel.getCaptcha();
if(captcha==null){
result.error500("验证码无效");
return result;
}
String lowerCaseCaptcha = captcha.toLowerCase();
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
String realKey = Md5Util.md5Encode(origin, "utf-8");
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
Object checkCode = redisUtil.get(realKey);
//当进入登录页时,有一定几率出现验证码错误 #1714
if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
@ -126,40 +119,36 @@ public class LoginController {
result.setCode(HttpStatus.PRECONDITION_FAILED.value());
return result;
}
//update-end-author:taoyan date:20190828 for:校验验证码
//1. 校验用户是否有效
//update-begin-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bugif条件永远为false
// step.2 校验用户是否存在且有效
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUser::getUsername,username);
SysUser sysUser = sysUserService.getOne(queryWrapper);
//update-end-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bugif条件永远为false
result = sysUserService.checkUserIsEffective(sysUser);
if(!result.isSuccess()) {
return result;
}
//2. 校验用户名或密码是否正确
// step.3 校验用户名或密码是否正确
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
String syspassword = sysUser.getPassword();
if (!syspassword.equals(userpassword)) {
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
addLoginFailOvertimes(username);
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
result.error500("用户名或密码错误");
return result;
}
//用户登录信息
userInfo(sysUser, result);
//update-begin--Author:liusq Date:20210126 for登录成功删除redis中的验证码
// step.4 登录成功获取用户信息
userInfo(sysUser, result, request);
// step.5 登录成功删除验证码
redisUtil.del(realKey);
//update-begin--Author:liusq Date:20210126 for登录成功删除redis中的验证码
redisUtil.del(CommonConstant.LOGIN_FAIL + username);
// step.6 记录用户登录日志
LoginUser loginUser = new LoginUser();
BeanUtils.copyProperties(sysUser, loginUser);
baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null,loginUser);
//update-end--Author:wangshuai Date:20200714 for登录日志没有记录人员
return result;
}
@ -169,18 +158,20 @@ public class LoginController {
*/
@GetMapping("/user/getUserInfo")
public Result<JSONObject> getUserInfo(HttpServletRequest request){
long start = System.currentTimeMillis();
Result<JSONObject> result = new Result<JSONObject>();
String username = JwtUtil.getUserNameByToken(request);
if(oConvertUtils.isNotEmpty(username)) {
// 根据用户名查询用户信息
SysUser sysUser = sysUserService.getUserByName(username);
JSONObject obj=new JSONObject();
log.info("1 获取用户信息耗时(用户基础信息)" + (System.currentTimeMillis() - start) + "毫秒");
//update-begin---author:scott ---date:2022-06-20 forvue3前端支持自定义首页-----------
String version = request.getHeader(CommonConstant.VERSION);
String vue3Version = request.getHeader(CommonConstant.VERSION);
//update-begin---author:liusq ---date:2022-06-29 for接口返回值修改同步修改这里的判断逻辑-----------
SysRoleIndex roleIndex = sysUserService.getDynamicIndexByUserRole(username, version);
if (oConvertUtils.isNotEmpty(version) && roleIndex != null && oConvertUtils.isNotEmpty(roleIndex.getUrl())) {
SysRoleIndex roleIndex = sysUserService.getDynamicIndexByUserRole(username, vue3Version);
if (oConvertUtils.isNotEmpty(vue3Version) && roleIndex != null && oConvertUtils.isNotEmpty(roleIndex.getUrl())) {
String homePath = roleIndex.getUrl();
if (!homePath.startsWith(SymbolConstant.SINGLE_SLASH)) {
homePath = SymbolConstant.SINGLE_SLASH + homePath;
@ -189,12 +180,14 @@ public class LoginController {
}
//update-begin---author:liusq ---date:2022-06-29 for接口返回值修改同步修改这里的判断逻辑-----------
//update-end---author:scott ---date::2022-06-20 forvue3前端支持自定义首页--------------
log.info("2 获取用户信息耗时 (首页面配置)" + (System.currentTimeMillis() - start) + "毫秒");
obj.put("userInfo",sysUser);
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
result.setResult(obj);
result.success("");
}
log.info("end 获取用户信息耗时 " + (System.currentTimeMillis() - start) + "毫秒");
return result;
}
@ -276,7 +269,7 @@ public class LoginController {
* 获取访问量
* @return
*/
@GetMapping("visitInfo")
@GetMapping("/visitInfo")
public Result<List<Map<String,Object>>> visitInfo() {
Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
Calendar calendar = new GregorianCalendar();
@ -328,12 +321,14 @@ public class LoginController {
* @return
*/
@PostMapping(value = "/sms")
public Result<String> sms(@RequestBody JSONObject jsonObject) {
public Result<String> sms(@RequestBody JSONObject jsonObject,HttpServletRequest request) {
Result<String> result = new Result<String>();
String clientIp = IpUtils.getIpAddr(request);
String mobile = jsonObject.get("mobile").toString();
//手机号模式 登录模式: "2" 注册模式: "1"
String smsmode=jsonObject.get("smsmode").toString();
log.info(mobile);
log.info("-------- IP:{}, 手机号:{},获取绑定验证码", clientIp, mobile);
if(oConvertUtils.isEmpty(mobile)){
result.setMessage("手机号不允许为空!");
result.setSuccess(false);
@ -351,6 +346,17 @@ public class LoginController {
return result;
}
//-------------------------------------------------------------------------------------
//增加 check防止恶意刷短信接口
if(!DySmsLimit.canSendSms(clientIp)){
log.warn("--------[警告] IP地址:{}, 短信接口请求太多-------", clientIp);
result.setMessage("短信接口请求太多,请稍后再试!");
result.setCode(CommonConstant.PHONE_SMS_FAIL_CODE);
result.setSuccess(false);
return result;
}
//-------------------------------------------------------------------------------------
//随机数
String captcha = RandomUtil.randomNumbers(6);
JSONObject obj = new JSONObject();
@ -424,7 +430,7 @@ public class LoginController {
*/
@Operation(summary ="手机号登录接口")
@PostMapping("/phoneLogin")
public Result<JSONObject> phoneLogin(@RequestBody JSONObject jsonObject) {
public Result<JSONObject> phoneLogin(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
Result<JSONObject> result = new Result<JSONObject>();
String phone = jsonObject.getString("mobile");
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
@ -450,11 +456,10 @@ public class LoginController {
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
addLoginFailOvertimes(phone);
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
result.setMessage("手机验证码错误");
return result;
return Result.error("手机验证码错误");
}
//用户信息
userInfo(sysUser, result);
userInfo(sysUser, result, request);
//添加日志
baseCommonService.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
@ -469,7 +474,7 @@ public class LoginController {
* @param result
* @return
*/
private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result, HttpServletRequest request) {
String username = sysUser.getUsername();
String syspassword = sysUser.getPassword();
// 获取用户部门信息
@ -509,7 +514,15 @@ public class LoginController {
// update-end--Author:wangshuai Date:20200805 for如果用戶为选择部门数据库为存在上一次登录部门则取一条存进去
obj.put("multi_depart", 2);
}
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
//update-begin---author:scott ---date:2024-01-05 for【QQYUN-7802】前端在登录时加载了两次数据字典建议优化下避免数据字典太多时可能产生的性能问题 #956---
// login接口在vue3前端下不加载字典数据vue2下加载字典
String vue3Version = request.getHeader(CommonConstant.VERSION);
if(oConvertUtils.isEmpty(vue3Version)){
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
}
//end-begin---author:scott ---date:2024-01-05 for【QQYUN-7802】前端在登录时加载了两次数据字典建议优化下避免数据字典太多时可能产生的性能问题 #956---
result.setResult(obj);
result.success("登录成功");
return result;
@ -570,7 +583,7 @@ public class LoginController {
@PreAuthorize("@jps.requiresRoles('admin')")
@GetMapping(value = "/switchVue3Menu")
public Result<String> switchVue3Menu(HttpServletResponse response) {
Result<String> res = new Result<String>();
Result<String> res = new Result<String>();
sysPermissionService.switchVue3Menu();
return res;
}
@ -615,10 +628,12 @@ public class LoginController {
String orgCode = sysUser.getOrgCode();
if(oConvertUtils.isEmpty(orgCode)) {
//如果当前用户无选择部门 查看部门关联信息
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
//update-begin-author:taoyan date:20220117 for: JTC-1068【app】新建用户没有设置部门及角色点击登录提示暂未归属部一直在登录页面 使用手机号登录 可正常
if (departs == null || departs.size() == 0) {
/*result.error500("用户暂未归属部门,不可登录!");
return result;*/
}else{
orgCode = departs.get(0).getOrgCode();
@ -754,8 +769,86 @@ public class LoginController {
if(failTime!=null){
val = Integer.parseInt(failTime.toString());
}
// 10分钟
redisUtil.set(key, ++val, 10);
// 10分钟一分钟为60s
redisUtil.set(key, ++val, 600);
}
/**
* 发送短信验证码接口(修改密码)
*
* @param jsonObject
* @return
*/
@PostMapping(value = "/sendChangePwdSms")
public Result<String> sendSms(@RequestBody JSONObject jsonObject) {
Result<String> result = new Result<>();
String mobile = jsonObject.get("mobile").toString();
if (oConvertUtils.isEmpty(mobile)) {
result.setMessage("手机号不允许为空!");
result.setSuccess(false);
return result;
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String username = sysUser.getUsername();
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
query.eq(SysUser::getUsername, username).eq(SysUser::getPhone, mobile);
SysUser user = sysUserService.getOne(query);
if (null == user) {
return Result.error("当前登录用户和绑定的手机号不匹配,无法修改密码!");
}
String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
Object object = redisUtil.get(redisKey);
if (object != null) {
result.setMessage("验证码10分钟内仍然有效");
result.setSuccess(false);
return result;
}
//随机数
String captcha = RandomUtil.randomNumbers(6);
JSONObject obj = new JSONObject();
obj.put("code", captcha);
try {
boolean b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.CHANGE_PASSWORD_TEMPLATE_CODE);
if (!b) {
result.setMessage("短信验证码发送失败,请稍后重试");
result.setSuccess(false);
return result;
}
//验证码5分钟内有效
redisUtil.set(redisKey, captcha, 300);
result.setSuccess(true);
} catch (ClientException e) {
e.printStackTrace();
result.error500(" 短信接口未配置,请联系管理员!");
return result;
}
return result;
}
/**
* 图形验证码
* @param sysLoginModel
* @return
*/
@RequestMapping(value = "/smsCheckCaptcha", method = RequestMethod.POST)
public Result<?> smsCheckCaptcha(@RequestBody SysLoginModel sysLoginModel, HttpServletRequest request){
String captcha = sysLoginModel.getCaptcha();
String checkKey = sysLoginModel.getCheckKey();
if(captcha==null){
return Result.error("验证码无效");
}
String lowerCaseCaptcha = captcha.toLowerCase();
String realKey = Md5Util.md5Encode(lowerCaseCaptcha+checkKey+jeecgBaseConfig.getSignatureSecret(), "utf-8");
Object checkCode = redisUtil.get(realKey);
if(checkCode==null || !checkCode.equals(lowerCaseCaptcha)) {
return Result.error("验证码错误");
}
String clientIp = IpUtils.getIpAddr(request);
//清空短信记录数量
DySmsLimit.clearSendSmsCount(clientIp);
redisUtil.removeAll(realKey);
return Result.ok();
}
}

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeecg.dingtalk.api.core.response.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
@ -18,10 +19,7 @@ import org.jeecg.common.constant.WebsocketConst;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.common.util.*;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.security.utils.SecureUtil;
import org.jeecg.modules.message.enums.RangeDateEnum;
@ -41,6 +39,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.CollectionUtils;
@ -88,7 +87,9 @@ public class SysAnnouncementController {
@Autowired
@Lazy
private RedisUtil redisUtil;
@Autowired
public RedisTemplate redisTemplate;
/**
* QQYUN-5072【性能优化】线上通知消息打开有点慢
*/
@ -334,11 +335,19 @@ public class SysAnnouncementController {
* @return
*/
@RequestMapping(value = "/listByUser", method = RequestMethod.GET)
public Result<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
public Result<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize, HttpServletRequest request) {
long start = System.currentTimeMillis();
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> sysMsgMap = new HashMap(5);
LoginUser sysUser = SecureUtil.currentUser();
String userId = sysUser.getId();
//update-begin---author:scott ---date:2024-05-11 for【性能优化】优化系统通知只查近2个月的通知---
// 获取上个月的第一天(只查近两个月的通知)
Date lastMonthStartDay = DateRangeUtils.getLastMonthStartDay();
log.info("-----查询近两个月收到的未读通知-----近2月的第一天{}", lastMonthStartDay);
//update-end---author:scott ---date::2024-05-11 for【性能优化】优化系统通知只查近2个月的通知---
// //补推送数据(用户和通知的关系表)
// completeNoteThreadPool.execute(()->{
@ -348,15 +357,19 @@ public class SysAnnouncementController {
// 2.查询用户未读的系统消息
Page<SysAnnouncement> anntMsgList = new Page<SysAnnouncement>(0, pageSize);
//通知公告消息
anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList,userId,"1");
anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList,userId,"1",null, lastMonthStartDay);
sysMsgMap.put("anntMsgList", anntMsgList.getRecords());
sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());
log.info("begin 获取用户近2个月的系统公告 (通知)" + (System.currentTimeMillis() - start) + "毫秒");
//系统消息
Page<SysAnnouncement> sysMsgList = new Page<SysAnnouncement>(0, pageSize);
sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList,userId,"2");
sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList,userId,"2",null, lastMonthStartDay);
sysMsgMap.put("sysMsgList", sysMsgList.getRecords());
sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());
log.info("end 获取用户2个月的系统公告 (系统消息)" + (System.currentTimeMillis() - start) + "毫秒");
result.setSuccess(true);
result.setResult(sysMsgMap);
@ -364,6 +377,24 @@ public class SysAnnouncementController {
}
/**
* 获取未读消息通知数量
*
* @return
*/
@RequestMapping(value = "/getUnreadMessageCount", method = RequestMethod.GET)
public Result<Integer> getUnreadMessageCount(@RequestParam(required = false, defaultValue = "5") Integer pageSize, HttpServletRequest request) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
// 获取上个月的第一天(只查近两个月的通知)
Date lastMonthStartDay = DateRangeUtils.getLastMonthStartDay();
log.info(" ------查询近两个月收到的未读通知消息数量------近2月的第一天{}", lastMonthStartDay);
Integer unreadMessageCount = sysAnnouncementService.getUnreadMessageCountByUserId(userId, lastMonthStartDay);
return Result.ok(unreadMessageCount);
}
/**
* 导出excel
*
@ -567,15 +598,37 @@ public class SysAnnouncementController {
*/
@GetMapping("/getLastAnnountTime")
public Result<Page<SysAnnouncementSend>> getLastAnnountTime(@RequestParam(name = "userId") String userId){
Result<Page<SysAnnouncementSend>> result = new Result<>();
Page<SysAnnouncementSend> page = new Page<>(1,1);
Result<Page<SysAnnouncementSend>> result = new Result<>();
//----------------------------------------------------------------------------------------
// step.1 此接口过慢,可以采用缓存一小时方案
String keyString = String.format(CommonConstant.CACHE_KEY_USER_LAST_ANNOUNT_TIME_1HOUR, userId);
if (redisTemplate.hasKey(keyString)) {
log.info("[SysAnnouncementSend Redis] 通过Redis缓存查询用户最后一次收到系统通知时间userId={}", userId);
Page<SysAnnouncementSend> pageList = (Page<SysAnnouncementSend>) redisTemplate.opsForValue().get(keyString);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
//----------------------------------------------------------------------------------------
Page<SysAnnouncementSend> page = new Page<>(1,1);
LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>();
query.eq(SysAnnouncementSend::getUserId,userId);
query.select(SysAnnouncementSend::getCreateTime);
//只查询上个月和本月,的通知的数据
query.ne(SysAnnouncementSend::getCreateTime, DateRangeUtils.getLastMonthStartDay());
query.select(SysAnnouncementSend::getCreateTime); // 提高查询效率
query.orderByDesc(SysAnnouncementSend::getCreateTime);
Page<SysAnnouncementSend> pageList = sysAnnouncementSendService.page(page, query);
result.setSuccess(true);
result.setResult(pageList);
//----------------------------------------------------------------------------------------
if (pageList != null && pageList.getSize() > 0) {
// step.3 保留1小时redis缓存
redisTemplate.opsForValue().set(keyString, pageList, 3600, TimeUnit.SECONDS);
}
//----------------------------------------------------------------------------------------
result.setSuccess(true);
result.setResult(pageList);
return result;
}

View File

@ -25,6 +25,7 @@ import org.jeecg.modules.system.model.SysDepartTreeModel;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.vo.SysDepartExportVo;
import org.jeecg.modules.system.vo.lowapp.ExportDepartVo;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@ -352,25 +353,35 @@ public class SysDepartController {
}
//------------------------------------------------------------------------------------------------
// Step.1 组装查询条件
QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<SysDepart> pageList = sysDepartService.list(queryWrapper);
//update-begin---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
//// Step.1 组装查询条件
//QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
//Step.1 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//List<SysDepart> pageList = sysDepartService.list(queryWrapper);
//按字典排序
Collections.sort(pageList, new Comparator<SysDepart>() {
@Override
public int compare(SysDepart arg0, SysDepart arg1) {
return arg0.getOrgCode().compareTo(arg1.getOrgCode());
}
});
//Collections.sort(pageList, new Comparator<SysDepart>() {
//@Override
//public int compare(SysDepart arg0, SysDepart arg1) {
//return arg0.getOrgCode().compareTo(arg1.getOrgCode());
//}
//});
//step.2 组装导出数据
Integer tenantId = sysDepart == null ? null : sysDepart.getTenantId();
List<SysDepartExportVo> sysDepartExportVos = sysDepartService.getExportDepart(tenantId);
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
mv.addObject(NormalExcelConstants.CLASS, SysDepartExportVo.class);
LoginUser user = SecureUtil.currentUser();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("导入规则:\n" +
"1、标题为第三行部门路径和部门名称的标题不允许修改否则会匹配失败第四行为数据填写范围;\n" +
"2、部门路径用英文字符/分割,部门名称为部门路径的最后一位;\n" +
"3、部门从一级名称开始创建如果有同级就需要多添加一行如研发部/研发一部;研发部/研发二部;\n" +
"4、自定义的部门编码需要满足规则才能导入。如一级部门编码为A01,那么子部门为A01A01,同级子部门为A01A02,编码固定为三位首字母为A-Z,后两位为数字0-99依次递增;", "导出人:"+user.getRealname(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, sysDepartExportVos);
//update-end---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
return mv;
}
/**
@ -388,7 +399,8 @@ public class SysDepartController {
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
List<String> errorMessageList = new ArrayList<>();
List<SysDepart> listSysDeparts = null;
//List<SysDepart> listSysDeparts = null;
List<SysDepartExportVo> listSysDeparts = null;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
@ -398,51 +410,59 @@ public class SysDepartController {
params.setHeadRows(1);
params.setNeedSave(true);
try {
// orgCode编码长度
int codeLength = YouBianCodeUtil.ZHANWEI_LENGTH;
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
//按长度排序
Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
@Override
public int compare(SysDepart arg0, SysDepart arg1) {
return arg0.getOrgCode().length() - arg1.getOrgCode().length();
}
});
int num = 0;
for (SysDepart sysDepart : listSysDeparts) {
String orgCode = sysDepart.getOrgCode();
if(orgCode.length() > codeLength) {
String parentCode = orgCode.substring(0, orgCode.length()-codeLength);
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<SysDepart>();
queryWrapper.eq("org_code", parentCode);
try {
SysDepart parentDept = sysDepartService.getOne(queryWrapper);
if(!parentDept.equals(null)) {
sysDepart.setParentId(parentDept.getId());
//更新父级部门不是叶子结点
sysDepartService.updateIzLeaf(parentDept.getId(),CommonConstant.NOT_LEAF);
} else {
sysDepart.setParentId("");
}
}catch (Exception e) {
//没有查找到parentDept
}
}else{
sysDepart.setParentId("");
}
//update-begin---author:liusq Date:20210223 for批量导入部门以后不能追加下一级部门 #2245------------
sysDepart.setOrgType(sysDepart.getOrgCode().length()/codeLength+"");
//update-end---author:liusq Date:20210223 for批量导入部门以后不能追加下一级部门 #2245------------
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
//update-begin---author:wangshuai ---date:20220105 for[JTC-363]部门导入 机构类别没有时导入失败,赋默认值------------
if(oConvertUtils.isEmpty(sysDepart.getOrgCategory())){
sysDepart.setOrgCategory("1");
}
//update-end---author:wangshuai ---date:20220105 for[JTC-363]部门导入 机构类别没有时导入失败,赋默认值------------
ImportExcelUtil.importDateSaveOne(sysDepart, ISysDepartService.class, errorMessageList, num, CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE);
num++;
}
//update-begin---author:wangshuai---date:2023-10-20---for: 注释掉原来的导入部门的逻辑---
// // orgCode编码长度
// int codeLength = YouBianCodeUtil.ZHANWEI_LENGTH;
// listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
// //按长度排序
// Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
// @Override
// public int compare(SysDepart arg0, SysDepart arg1) {
// return arg0.getOrgCode().length() - arg1.getOrgCode().length();
// }
// });
//
// int num = 0;
// for (SysDepart sysDepart : listSysDeparts) {
// String orgCode = sysDepart.getOrgCode();
// if(orgCode.length() > codeLength) {
// String parentCode = orgCode.substring(0, orgCode.length()-codeLength);
// QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<SysDepart>();
// queryWrapper.eq("org_code", parentCode);
// try {
// SysDepart parentDept = sysDepartService.getOne(queryWrapper);
// if(!parentDept.equals(null)) {
// sysDepart.setParentId(parentDept.getId());
// //更新父级部门不是叶子结点
// sysDepartService.updateIzLeaf(parentDept.getId(),CommonConstant.NOT_LEAF);
// } else {
// sysDepart.setParentId("");
// }
// }catch (Exception e) {
// //没有查找到parentDept
// }
// }else{
// sysDepart.setParentId("");
// }
// //update-begin---author:liusq Date:20210223 for批量导入部门以后不能追加下一级部门 #2245------------
// sysDepart.setOrgType(sysDepart.getOrgCode().length()/codeLength+"");
// //update-end---author:liusq Date:20210223 for批量导入部门以后不能追加下一级部门 #2245------------
// sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
// //update-begin---author:wangshuai ---date:20220105 for[JTC-363]部门导入 机构类别没有时导入失败,赋默认值------------
// if(oConvertUtils.isEmpty(sysDepart.getOrgCategory())){
// sysDepart.setOrgCategory("1");
// }
// //update-end---author:wangshuai ---date:20220105 for[JTC-363]部门导入 机构类别没有时导入失败,赋默认值------------
// ImportExcelUtil.importDateSaveOne(sysDepart, ISysDepartService.class, errorMessageList, num, CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE);
// num++;
// }
//update-end---author:wangshuai---date:2023-10-20---for: 注释掉原来的导入部门的逻辑---
//update-begin---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepartExportVo.class, params);
sysDepartService.importSysDepart(listSysDeparts,errorMessageList);
//update-end---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
//清空部门缓存
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
@ -546,7 +566,7 @@ public class SysDepartController {
* @return
*/
@RequestMapping(value = "/queryByIds", method = RequestMethod.GET)
public Result<Collection<SysDepart>> queryByIds(@RequestParam String deptIds) {
public Result<Collection<SysDepart>> queryByIds(@RequestParam(name = "deptIds") String deptIds) {
Result<Collection<SysDepart>> result = new Result<>();
String[] ids = deptIds.split(",");
Collection<String> idList = Arrays.asList(ids);

View File

@ -94,7 +94,10 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
// queryWrapper.in("depart_id",deptIds);
//我的部门,选中部门只能看当前部门下的角色
queryWrapper.eq("depart_id",deptId);
if(oConvertUtils.isNotEmpty(deptId)){
queryWrapper.eq("depart_id",deptId);
}
IPage<SysDepartRole> pageList = sysDepartRoleService.page(page, queryWrapper);
return Result.ok(pageList);
}

View File

@ -18,6 +18,7 @@ import org.jeecg.common.system.vo.DictQuery;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.security.JeecgPermissionService;
import org.jeecg.config.security.utils.SecureUtil;
import org.jeecg.modules.system.entity.SysDict;
import org.jeecg.modules.system.entity.SysDictItem;
@ -70,7 +71,9 @@ public class SysDictController {
public RedisTemplate<String, Object> redisTemplate;
@Autowired
private RedisUtil redisUtil;
@Autowired
private JeecgPermissionService jeecgPermissionService;
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
@ -327,6 +330,13 @@ public class SysDictController {
@RequestParam(name="condition") String condition,
@RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
// 【QQYUN-9207】防止参数为空导致报错
if (oConvertUtils.isEmpty(tableName) || oConvertUtils.isEmpty(text) || oConvertUtils.isEmpty(code)) {
result.error500("字典Code格式不正确");
return result;
}
// 1.获取查询条件参数
Map<String, String> query = null;
if(oConvertUtils.isNotEmpty(condition)) {
@ -476,6 +486,11 @@ public class SysDictController {
redisUtil.removeAll("jmreport:cache:dict");
redisUtil.removeAll("jmreport:cache:dictTable");
//update-end-author:liusq date:20230404 for: [issue/4358]springCache中的清除缓存的操作使用了“keys”
//update-begin---author:scott ---date:2024-06-18 for【TV360X-1320】分配权限必须退出重新登录才生效造成很多用户困扰---
// 清除权限缓存
jeecgPermissionService.clearCache();
//update-end---author:scott ---date::2024-06-18 for【TV360X-1320】分配权限必须退出重新登录才生效造成很多用户困扰---
return result;
}
@ -497,6 +512,10 @@ public class SysDictController {
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
String selections = request.getParameter("selections");
if(!oConvertUtils.isEmpty(selections)){
queryWrapper.in("id",selections.split(","));
}
List<SysDictPage> pageList = new ArrayList<SysDictPage>();
List<SysDict> sysDictList = sysDictService.list(queryWrapper);
@ -601,9 +620,10 @@ public class SysDictController {
* @return
*/
@RequestMapping(value = "/deleteList", method = RequestMethod.GET)
public Result<List<SysDict>> deleteList() {
public Result<List<SysDict>> deleteList(HttpServletRequest request) {
Result<List<SysDict>> result = new Result<List<SysDict>>();
List<SysDict> list = this.sysDictService.queryDeleteList();
String tenantId = TokenUtils.getTenantIdByRequest(request);
List<SysDict> list = this.sysDictService.queryDeleteList(tenantId);
result.setSuccess(true);
result.setResult(list);
return result;

View File

@ -1,152 +0,0 @@
package org.jeecg.modules.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.system.entity.SysFiles;
import org.jeecg.modules.system.service.ISysFilesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
/**
* @Description: 知识库-文档管理
* @Author: jeecg-boot
* @Date: 2022-07-21
* @Version: V1.0
*/
@Slf4j
@Tag(name = "知识库-文档管理")
@RestController
@RequestMapping("/sys/files")
public class SysFilesController extends JeecgController<SysFiles, ISysFilesService> {
@Autowired
private ISysFilesService sysFilesService;
/**
* 分页列表查询
*
* @param sysFiles
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "知识库-文档管理-分页列表查询")
@Operation(summary = "知识库-文档管理-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysFiles sysFiles,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<SysFiles> queryWrapper = QueryGenerator.initQueryWrapper(sysFiles, req.getParameterMap());
Page<SysFiles> page = new Page<SysFiles>(pageNo, pageSize);
IPage<SysFiles> pageList = sysFilesService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param sysFiles
* @return
*/
@AutoLog(value = "知识库-文档管理-添加")
@Operation(summary = "知识库-文档管理-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysFiles sysFiles) {
sysFilesService.save(sysFiles);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param sysFiles
* @return
*/
@AutoLog(value = "知识库-文档管理-编辑")
@Operation(summary = "知识库-文档管理-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<?> edit(@RequestBody SysFiles sysFiles) {
sysFilesService.updateById(sysFiles);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "知识库-文档管理-通过id删除")
@Operation(summary = "知识库-文档管理-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
sysFilesService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "知识库-文档管理-批量删除")
@Operation(summary = "知识库-文档管理-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.sysFilesService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "知识库-文档管理-通过id查询")
@Operation(summary = "知识库-文档管理-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
SysFiles sysFiles = sysFilesService.getById(id);
return Result.OK(sysFiles);
}
/**
* 导出excel
*
* @param request
* @param sysFiles
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysFiles sysFiles) {
return super.exportXls(request, sysFiles, SysFiles.class, "知识库-文档管理");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, SysFiles.class);
}
}

View File

@ -6,7 +6,6 @@ import java.util.Arrays;
import jakarta.servlet.http.HttpServletRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysLog;
@ -54,6 +53,7 @@ public class SysLogController {
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
//@RequiresPermissions("system:log:list")
public Result<IPage<SysLog>> queryPageList(SysLog syslog,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
Result<IPage<SysLog>> result = new Result<IPage<SysLog>>();
@ -84,6 +84,7 @@ public class SysLogController {
* @return
*/
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
//@RequiresPermissions("system:log:delete")
public Result<SysLog> delete(@RequestParam(name="id",required=true) String id) {
Result<SysLog> result = new Result<SysLog>();
SysLog sysLog = sysLogService.getById(id);
@ -104,6 +105,7 @@ public class SysLogController {
* @return
*/
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
//@RequiresPermissions("system:log:deleteBatch")
public Result<SysRole> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
Result<SysRole> result = new Result<SysRole>();
if(ids==null || "".equals(ids.trim())) {

View File

@ -18,6 +18,7 @@ import org.jeecg.config.JeecgBaseConfig;
import org.jeecg.config.security.JeecgPermissionService;
import org.jeecg.config.security.utils.SecureUtil;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.system.constant.DefIndexConst;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.model.SysPermissionTree;
import org.jeecg.modules.system.model.TreeModel;
@ -249,38 +250,66 @@ public class SysPermissionController {
if (oConvertUtils.isEmpty(loginUser)) {
return Result.error("请登录系统!");
}
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getId());
//添加首页路由
//update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
if(!PermissionDataUtil.hasIndexPage(metaList)){
SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0);
metaList.add(0,indexMenu);
}
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
//update-begin--Author:zyf Date:20220425 for:自定义首页地址 LOWCOD-1578
String version = request.getHeader(CommonConstant.VERSION);
//update-begin---author:liusq ---date:2022-06-29 for接口返回值修改同步修改这里的判断逻辑-----------
SysRoleIndex roleIndex= sysUserService.getDynamicIndexByUserRole(loginUser.getUsername(),version);
//update-end---author:liusq ---date:2022-06-29 for接口返回值修改同步修改这里的判断逻辑-----------
SysRoleIndex defIndexCfg = sysUserService.getDynamicIndexByUserRole(loginUser.getUsername(), version);
if (defIndexCfg == null) {
defIndexCfg = sysRoleIndexService.initDefaultIndex();
}
//update-end--Author:zyf Date:20220425 for自定义首页地址 LOWCOD-1578
if(roleIndex!=null){
List<SysPermission> menus = metaList.stream().filter(sysPermission -> "首页".equals(sysPermission.getName())).collect(Collectors.toList());
//update-begin---author:liusq ---date:2022-06-29 for设置自定义首页地址和组件----------
String component = roleIndex.getComponent();
String routeUrl = roleIndex.getUrl();
boolean route = roleIndex.isRoute();
if(oConvertUtils.isNotEmpty(routeUrl)){
// 如果没有授权角色首页,则自动添加首页路由
if (!PermissionDataUtil.hasIndexPage(metaList, defIndexCfg)) {
LambdaQueryWrapper<SysPermission> indexQueryWrapper = new LambdaQueryWrapper<>();
indexQueryWrapper.eq(SysPermission::getUrl, defIndexCfg.getUrl());
SysPermission indexMenu = sysPermissionService.getOne(indexQueryWrapper);
if (indexMenu == null) {
indexMenu = new SysPermission();
indexMenu.setUrl(defIndexCfg.getUrl());
indexMenu.setComponent(defIndexCfg.getComponent());
indexMenu.setRoute(defIndexCfg.isRoute());
indexMenu.setName(DefIndexConst.DEF_INDEX_NAME);
indexMenu.setMenuType(0);
}
// 如果没有授权一级菜单,则自身变为一级菜单
if (indexMenu.getParentId() != null && !PermissionDataUtil.hasMenuById(metaList, indexMenu.getParentId())) {
indexMenu.setMenuType(0);
indexMenu.setParentId(null);
}
if (oConvertUtils.isEmpty(indexMenu.getIcon())) {
indexMenu.setIcon("ant-design:home");
}
metaList.add(0, indexMenu);
}
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
/* TODO 注: 这段代码的主要作用是:把首页菜单的组件替换成角色菜单的组件,由于现在的逻辑如果角色菜单不存在则自动插入一条,所以这段代码暂时不需要
List<SysPermission> menus = metaList.stream().filter(sysPermission -> {
if (defIndexCfg.getUrl().equals(sysPermission.getUrl())) {
return true;
}
return defIndexCfg.getUrl().equals(sysPermission.getUrl());
}).collect(Collectors.toList());
//update-begin---author:liusq ---date:2022-06-29 for设置自定义首页地址和组件----------
if (menus.size() == 1) {
String component = defIndexCfg.getComponent();
String routeUrl = defIndexCfg.getUrl();
boolean route = defIndexCfg.isRoute();
if (oConvertUtils.isNotEmpty(routeUrl)) {
menus.get(0).setComponent(component);
menus.get(0).setRoute(route);
menus.get(0).setUrl(routeUrl);
}else{
} else {
menus.get(0).setComponent(component);
}
//update-end---author:liusq ---date:2022-06-29 for设置自定义首页地址和组件-----------
}
//update-end---author:liusq ---date:2022-06-29 for设置自定义首页地址和组件-----------
*/
JSONObject json = new JSONObject();
JSONArray menujsonArray = new JSONArray();
this.getPermissionJsonArray(menujsonArray, metaList, null);
@ -290,7 +319,7 @@ public class SysPermissionController {
JSONArray authjsonArray = new JSONArray();
this.getAuthJsonArray(authjsonArray, metaList);
//查询所有的权限
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>().select( SysPermission::getName, SysPermission::getPermsType, SysPermission::getPerms, SysPermission::getStatus);
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2);
//query.eq(SysPermission::getStatus, "1");
@ -301,6 +330,12 @@ public class SysPermissionController {
json.put("menu", menujsonArray);
//按钮权限(用户拥有的权限集合)
json.put("auth", authjsonArray);
// 按钮权限(用户拥有的权限集合)
List<String> codeList = metaList.stream()
.filter((permission) -> CommonConstant.MENU_TYPE_2.equals(permission.getMenuType()) && CommonConstant.STATUS_1.equals(permission.getStatus()))
.collect(ArrayList::new, (list, permission) -> list.add(permission.getPerms()), ArrayList::addAll);
// 所拥有的权限编码(vue3专用)
json.put("codeList", codeList);
//全部权限配置集合(按钮权限,访问权限)
json.put("allAuth", allauthjsonArray);
//数据源安全模式
@ -328,7 +363,7 @@ public class SysPermissionController {
return Result.error("请登录系统!");
}
// 获取当前用户的权限集合
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getId());
// 按钮权限(用户拥有的权限集合)
List<String> codeList = metaList.stream()
.filter((permission) -> CommonConstant.MENU_TYPE_2.equals(permission.getMenuType()) && CommonConstant.STATUS_1.equals(permission.getStatus()))
@ -337,7 +372,7 @@ public class SysPermissionController {
JSONArray authArray = new JSONArray();
this.getAuthJsonArray(authArray, metaList);
// 查询所有的权限
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>().select( SysPermission::getName, SysPermission::getPermsType, SysPermission::getPerms, SysPermission::getStatus);
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2);
List<SysPermission> allAuthList = sysPermissionService.list(query);

View File

@ -15,9 +15,11 @@ import jakarta.servlet.http.HttpServletResponse;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.base.BaseMap;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.modules.redis.client.JeecgRedisClient;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
@ -83,6 +85,8 @@ public class SysRoleController {
private ISysUserRoleService sysUserRoleService;
@Autowired
private BaseCommonService baseCommonService;
@Autowired
private JeecgRedisClient jeecgRedisClient;
/**
* 分页列表查询 【系统角色,不做租户隔离】
@ -123,9 +127,10 @@ public class SysRoleController {
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
//------------------------------------------------------------------------------------------------
//此接口必须通过租户来隔离查询
role.setTenantId(oConvertUtils.getInt(!"0".equals(TenantContext.getTenant()) ? TenantContext.getTenant() : "", -1));
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
role.setTenantId(oConvertUtils.getInt(!"0".equals(TenantContext.getTenant()) ? TenantContext.getTenant() : "", -1));
}
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
Page<SysRole> page = new Page<SysRole>(pageNo, pageSize);
@ -146,7 +151,9 @@ public class SysRoleController {
Result<SysRole> result = new Result<SysRole>();
try {
//开启多租户隔离,角色id自动生成10位
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
//update-begin---author:wangshuai---date:2024-05-23---for:【TV360X-42】角色新增时设置的编码保存后不一致---
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL && oConvertUtils.isEmpty(role.getRoleCode())){
//update-end---author:wangshuai---date:2024-05-23---for:【TV360X-42】角色新增时设置的编码保存后不一致---
role.setRoleCode(RandomUtil.randomString(10));
}
role.setCreateTime(new Date());
@ -213,10 +220,17 @@ public class SysRoleController {
String username = "admin";
if(getRoleCount == 0 && !username.equals(sysUser.getUsername())){
baseCommonService.addLog("未经授权删除非本租户下的角色ID" + id + ",操作人:" + sysUser.getUsername(), CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_4);
return Result.error("删除角色失败,当前角色不在此租户中。");
return Result.error("删除角色失败,删除角色不属于登录租户!");
}
}
//update-begin---author:wangshuai---date:2024-01-16---for:【QQYUN-7974】禁止删除 admin 角色---
//是否存在admin角色
sysRoleService.checkAdminRoleRejectDel(id);
//update-end---author:wangshuai---date:2024-01-16---for:【QQYUN-7974】禁止删除 admin 角色---
sysRoleService.deleteRole(id);
return Result.ok("删除角色成功");
}
@ -248,6 +262,8 @@ public class SysRoleController {
}
}
}
//验证是否为admin角色
sysRoleService.checkAdminRoleRejectDel(ids);
sysRoleService.deleteBatchRole(ids.split(","));
result.success("删除角色成功!");
}
@ -527,7 +543,6 @@ public class SysRoleController {
}
/**
* TODO 权限未完成(敲敲云接口,租户应用)
* 分页获取全部角色列表(包含每个角色的数量)
* @return
*/
@ -564,4 +579,5 @@ public class SysRoleController {
result.setResult(sysRoleCountPage);
return result;
}
}

View File

@ -172,4 +172,32 @@ public class SysRoleIndexController extends JeecgController<SysRoleIndex, ISysRo
SysRoleIndex sysRoleIndex = sysRoleIndexService.getOne(new LambdaQueryWrapper<SysRoleIndex>().eq(SysRoleIndex::getRoleCode, roleCode));
return Result.OK(sysRoleIndex);
}
/**
* 查询默认首页配置
*/
@GetMapping("/queryDefIndex")
public Result<SysRoleIndex> queryDefIndex() {
SysRoleIndex defIndexCfg = sysRoleIndexService.queryDefaultIndex();
return Result.OK(defIndexCfg);
}
/**
* 更新默认首页配置
*/
@PreAuthorize("@jps.requiresPermissions('system:permission:setDefIndex')")
@PutMapping("/updateDefIndex")
public Result<?> updateDefIndex(
@RequestParam("url") String url,
@RequestParam("component") String component,
@RequestParam("isRoute") Boolean isRoute
) {
boolean success = sysRoleIndexService.updateDefaultIndex(url, component, isRoute);
if (success) {
return Result.OK("设置成功");
} else {
return Result.error("设置失败");
}
}
}

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.RolesAllowed;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.system.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.config.TenantContext;
@ -353,10 +355,10 @@ public class SysTenantController {
* @param ids
* @return
*/
@DeleteMapping("/deletePackPermissions")
@DeleteMapping("/deleteTenantPack")
@PreAuthorize("@jps.requiresPermissions('system:tenant:delete:pack')")
public Result<String> deletePackPermissions(@RequestParam(value = "ids") String ids) {
sysTenantPackService.deletePackPermissions(ids);
public Result<String> deleteTenantPack(@RequestParam(value = "ids") String ids) {
sysTenantPackService.deleteTenantPack(ids);
return Result.ok("删除租户产品包成功");
}
@ -502,7 +504,7 @@ public class SysTenantController {
Integer tenantId = sysTenantService.joinTenantByHouseNumber(sysTenant, sysUser.getId());
Result<Integer> result = new Result<>();
if(tenantId != 0){
result.setMessage("申请租户成功");
result.setMessage("申请加入组织成功");
result.setSuccess(true);
result.setResult(tenantId);
return result;
@ -860,16 +862,19 @@ public class SysTenantController {
@GetMapping("/getTenantCount")
public Result<Map<String,Long>> getTenantCount(HttpServletRequest request){
Map<String,Long> map = new HashMap<>();
Integer tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request),0);
LambdaQueryWrapper<SysUserTenant> userTenantQuery = new LambdaQueryWrapper<>();
userTenantQuery.eq(SysUserTenant::getTenantId,tenantId);
userTenantQuery.eq(SysUserTenant::getStatus,CommonConstant.USER_TENANT_NORMAL);
long userCount = relationService.count(userTenantQuery);
//update-begin---author:wangshuai---date:2023-11-24---for:【QQYUN-7177】用户数量显示不正确---
if(oConvertUtils.isEmpty(TokenUtils.getTenantIdByRequest(request))){
return Result.error("当前租户为空,禁止访问!");
}
Integer tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request));
Long userCount = relationService.getUserCount(tenantId,CommonConstant.USER_TENANT_NORMAL);
//update-end---author:wangshuai---date:2023-11-24---for:【QQYUN-7177】用户数量显示不正确---
map.put("userCount",userCount);
LambdaQueryWrapper<SysDepart> departQuery = new LambdaQueryWrapper<>();
departQuery.eq(SysDepart::getDelFlag,String.valueOf(CommonConstant.DEL_FLAG_0));
departQuery.eq(SysDepart::getTenantId,tenantId);
departQuery.eq(SysDepart::getStatus,CommonConstant.STATUS_1);
//部门状态暂时没用,先注释掉
//departQuery.eq(SysDepart::getStatus,CommonConstant.STATUS_1);
long departCount = sysDepartService.count(departQuery);
map.put("departCount",departCount);
return Result.ok(map);
@ -934,4 +939,39 @@ public class SysTenantController {
return Result.error("类型不匹配,禁止修改数据");
}
/**
* 目前只给敲敲云租户下删除用户使用
*
* 根据密码删除用户
*/
@DeleteMapping("/deleteUserByPassword")
public Result<String> deleteUserByPassword(@RequestBody SysUser sysUser,HttpServletRequest request){
Integer tenantId = oConvertUtils.getInteger(TokenUtils.getTenantIdByRequest(request), null);
sysTenantService.deleteUserByPassword(sysUser, tenantId);
return Result.ok("删除用户成功");
}
/**
* 查询当前用户的所有有效租户【知识库专用接口】
* @return
*/
@RequestMapping(value = "/getCurrentUserTenantForFile", method = RequestMethod.GET)
public Result<Map<String,Object>> getCurrentUserTenantForFile() {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
try {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<SysTenant> tenantList = sysTenantService.getTenantListByUserId(sysUser.getId());
Map<String,Object> map = new HashMap<>(5);
//在开启saas租户隔离的时候并且租户数据不为空则返回租户信息
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL && CollectionUtil.isNotEmpty(tenantList)) {
map.put("list", tenantList);
}
result.setSuccess(true);
result.setResult(map);
}catch(Exception e) {
log.error(e.getMessage(), e);
result.error500("查询失败!");
}
return result;
}
}

View File

@ -13,16 +13,20 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.base.BaseMap;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.security.utils.SecureUtil;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.common.modules.redis.client.JeecgRedisClient;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.model.DepartIdModel;
import org.jeecg.modules.system.model.SysUserSysDepartModel;
@ -99,6 +103,9 @@ public class SysUserController {
@Autowired
private ISysUserTenantService userTenantService;
@Autowired
private JeecgRedisClient jeecgRedisClient;
/**
* 获取租户下用户数据(支持租户隔离)
* @param user
@ -242,6 +249,7 @@ public class SysUserController {
Result<SysUser> result = new Result<SysUser>();
try {
String ids = jsonObject.getString("ids");
sysUserService.checkUserAdminRejectDel(ids);
String status = jsonObject.getString("status");
String[] arr = ids.split(",");
for (String id : arr) {
@ -435,12 +443,13 @@ public class SysUserController {
@RequestParam(name = "departId", required = false) String departId,
@RequestParam(name="realname",required=false) String realname,
@RequestParam(name="username",required=false) String username,
@RequestParam(name="isMultiTranslate",required=false) String isMultiTranslate,
@RequestParam(name="id",required = false) String id) {
//update-begin-author:taoyan date:2022-7-14 for: VUEN-1702【禁止问题】sql注入漏洞
String[] arr = new String[]{departId, realname, username, id};
SqlInjectionUtil.filterContent(arr, SymbolConstant.SINGLE_QUOTATION_MARK);
//update-end-author:taoyan date:2022-7-14 for: VUEN-1702【禁止问题】sql注入漏洞
IPage<SysUser> pageList = sysUserDepartService.queryDepartUserPageList(departId, username, realname, pageSize, pageNo,id);
IPage<SysUser> pageList = sysUserDepartService.queryDepartUserPageList(departId, username, realname, pageSize, pageNo,id,isMultiTranslate);
return Result.OK(pageList);
}
@ -566,7 +575,7 @@ public class SysUserController {
* @return
*/
@RequestMapping(value = "/queryByIds", method = RequestMethod.GET)
public Result<Collection<SysUser>> queryByIds(@RequestParam String userIds) {
public Result<Collection<SysUser>> queryByIds(@RequestParam(name = "userIds") String userIds) {
Result<Collection<SysUser>> result = new Result<>();
String[] userId = userIds.split(",");
Collection<String> idList = Arrays.asList(userId);
@ -583,7 +592,7 @@ public class SysUserController {
* @return
*/
@RequestMapping(value = "/queryByNames", method = RequestMethod.GET)
public Result<Collection<SysUser>> queryByNames(@RequestParam String userNames) {
public Result<Collection<SysUser>> queryByNames(@RequestParam(name = "userNames") String userNames) {
Result<Collection<SysUser>> result = new Result<>();
String[] names = userNames.split(",");
QueryWrapper<SysUser> queryWrapper=new QueryWrapper();
@ -1125,7 +1134,7 @@ public class SysUserController {
}
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username).eq(SysUser::getPhone,phone));
if (sysUser == null) {
result.setMessage("未找到用户");
result.setMessage("当前登录用户和绑定的手机号不匹配,无法修改密码");
result.setSuccess(false);
return result;
} else {
@ -1139,6 +1148,8 @@ public class SysUserController {
//update-end---author:wangshuai ---date:20220316 for[VUEN-234]密码重置添加敏感日志------------
result.setSuccess(true);
result.setMessage("密码重置完成!");
//修改完密码后清空redis
redisUtil.removeAll(redisKey);
return result;
}
}
@ -1425,7 +1436,7 @@ public class SysUserController {
//------------------------------------------------------------------------------------------------
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
String tenantId = TokenUtils.getTenantIdByRequest(request);
String tenantId = oConvertUtils.getString(TokenUtils.getTenantIdByRequest(request),"-1");
//update-begin---author:wangshuai ---date:20221223 for[QQYUN-3371]租户逻辑改造,改成关系表------------
List<String> userIds = userTenantService.getUserIdsByTenantId(Integer.valueOf(tenantId));
if (oConvertUtils.listIsNotEmpty(userIds)) {
@ -1546,18 +1557,19 @@ public class SysUserController {
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name = "departId", required = false) String departId,
@RequestParam(name = "roleId", required = false) String roleId,
@RequestParam(name="keyword",required=false) String keyword) {
@RequestParam(name="keyword",required=false) String keyword,
@RequestParam(name="excludeUserIdList",required = false) String excludeUserIdList,
HttpServletRequest req) {
//------------------------------------------------------------------------------------------------
Integer tenantId = null;
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
String tenantStr = TenantContext.getTenant();
if(oConvertUtils.isNotEmpty(tenantStr)){
tenantId = Integer.parseInt(tenantStr);
}
tenantId = oConvertUtils.getInteger(tenantStr, oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(req), -1));
log.info("---------简流中选择用户接口通过租户筛选租户ID={}", tenantId);
}
//------------------------------------------------------------------------------------------------
IPage<SysUser> pageList = sysUserDepartService.getUserInformation(tenantId, departId,roleId, keyword, pageSize, pageNo);
IPage<SysUser> pageList = sysUserDepartService.getUserInformation(tenantId, departId,roleId, keyword, pageSize, pageNo,excludeUserIdList);
return Result.OK(pageList);
}

View File

@ -68,7 +68,7 @@ public class SysUserOnlineController {
online.setToken(token);
//TODO 改成一次性查询
LoginUser loginUser = sysBaseApi.getUserByName(JwtUtil.getUsername(token));
if (loginUser != null) {
if (loginUser != null && !"_reserve_user_external".equals(loginUser.getUsername())) {
//update-begin---author:wangshuai ---date:20220104 for[JTC-382]在线用户查询无效------------
//验证用户名是否与传过来的用户名相同
boolean isMatchUsername=true;

View File

@ -14,6 +14,7 @@ import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.constant.enums.MessageTypeEnum;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.security.utils.SecureUtil;
@ -23,6 +24,8 @@ import org.jeecg.modules.system.service.ISysThirdAccountService;
import org.jeecg.modules.system.service.ISysThirdAppConfigService;
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
import org.jeecg.modules.system.vo.thirdapp.JwSysUserDepartVo;
import org.jeecg.modules.system.vo.thirdapp.JwUserDepartVo;
import org.jeecg.modules.system.vo.thirdapp.SyncInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
@ -60,8 +63,13 @@ public class ThirdAppController {
@GetMapping("/getEnabledType")
public Result getEnabledType() {
Map<String, Boolean> enabledMap = new HashMap(5);
//update-begin---author:wangshuai ---date:20230224 for[QQYUN-3440]通过租户模式隔离 ------------
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
int tenantId;
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
tenantId = oConvertUtils.getInt(TenantContext.getTenant(), -1);
} else {
tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
}
//查询当前租户下的第三方配置
List<SysThirdAppConfig> list = appConfigService.getThirdConfigListByThirdType(tenantId);
//钉钉是否已配置
@ -426,10 +434,6 @@ public class ThirdAppController {
@GetMapping("/getThirdConfigByTenantId")
public Result<SysThirdAppConfig> getThirdAppByTenantId(@RequestParam(name = "tenantId", required = false) Integer tenantId,
@RequestParam(name = "thirdType") String thirdType) {
Result<SysThirdAppConfig> result = new Result<>();
LambdaQueryWrapper<SysThirdAppConfig> query = new LambdaQueryWrapper<>();
query.eq(SysThirdAppConfig::getThirdType,thirdType);
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
if (tenantId == null) {
return Result.error("开启多租户模式租户ID参数不允许为空");
@ -440,7 +444,9 @@ public class ThirdAppController {
tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
}
}
Result<SysThirdAppConfig> result = new Result<>();
LambdaQueryWrapper<SysThirdAppConfig> query = new LambdaQueryWrapper<>();
query.eq(SysThirdAppConfig::getThirdType,thirdType);
query.eq(SysThirdAppConfig::getTenantId,tenantId);
SysThirdAppConfig sysThirdAppConfig = appConfigService.getOne(query);
result.setSuccess(true);
@ -522,4 +528,46 @@ public class ThirdAppController {
return Result.ok("解绑成功");
}
//========================end 应用低代码账号设置第三方账号绑定 ================================
/**
* 获取企业微信绑定的用户信息
* @param request
* @return
*/
@GetMapping("/getThirdUserByWechat")
public Result<JwSysUserDepartVo> getThirdUserByWechat(HttpServletRequest request){
//获取企业微信配置
Integer tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request),0);
SysThirdAppConfig config = appConfigService.getThirdConfigByThirdType(tenantId, MessageTypeEnum.QYWX.getType());
if (null != config) {
JwSysUserDepartVo list = wechatEnterpriseService.getThirdUserByWechat(tenantId);
return Result.ok(list);
}
return Result.error("企业微信尚未配置,请配置企业微信");
}
/**
* 同步企业微信部门和用户到本地
* @param jwUserDepartJson
* @param request
* @return
*/
@GetMapping("/sync/wechatEnterprise/departAndUser/toLocal")
public Result<SyncInfoVo> syncWechatEnterpriseDepartAndUserToLocal(@RequestParam(name = "jwUserDepartJson") String jwUserDepartJson,HttpServletRequest request){
int tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request), 0);
SyncInfoVo syncInfoVo = wechatEnterpriseService.syncWechatEnterpriseDepartAndUserToLocal(jwUserDepartJson,tenantId);
return Result.ok(syncInfoVo);
}
/**
* 查询被绑定的企业微信用户
* @param request
* @return
*/
@GetMapping("/getThirdUserBindByWechat")
public Result<List<JwUserDepartVo>> getThirdUserBindByWechat(HttpServletRequest request){
int tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request), 0);
List<JwUserDepartVo> jwSysUserDepartVos = wechatEnterpriseService.getThirdUserBindByWechat(tenantId);
return Result.ok(jwSysUserDepartVos);
}
}

View File

@ -74,6 +74,8 @@ public class SysDepart implements Serializable {
private String delFlag;
/**对接企业微信的ID*/
private String qywxIdentifier;
/**对接钉钉的部门ID*/
private String dingIdentifier;
/**创建人*/
private String createBy;
/**创建日期*/

View File

@ -1,142 +0,0 @@
package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @Description: 知识库-文档管理
* @Author: jeecg-boot
* @Date: 2022-07-21
* @Version: V1.0
*/
@Data
@TableName("sys_files")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="sys_files对象")
public class SysFiles {
/**主键id*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键id")
private String id;
/**文件名称*/
@Excel(name = "文件名称", width = 15)
@Schema(description = "文件名称")
private String fileName;
/**文件地址*/
@Excel(name = "文件地址", width = 15)
@Schema(description = "文件地址")
private String url;
/**创建人登录名称*/
@Excel(name = "创建人登录名称", width = 15)
@Dict(dicCode = "username",dicText = "realname",dictTable = "sys_user")
@Schema(description = "创建人登录名称")
private String createBy;
/**创建日期*/
@Excel(name = "创建日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人登录名称*/
@Excel(name = "更新人登录名称", width = 15)
@Schema(description = "更新人登录名称")
private String updateBy;
/**更新日期*/
@Excel(name = "更新日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频)*/
@Excel(name = "文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频)", width = 15)
@Schema(description = "文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频)")
private String fileType;
/**文件上传类型(temp/本地上传(临时文件) manage/知识库 comment)*/
@Excel(name = "文件上传类型(temp/本地上传(临时文件) manage/知识库 common(通用上传))", width = 15)
@Schema(description = "文件上传类型(temp/本地上传(临时文件) manage/知识库)")
private String storeType;
/**父级id*/
@Excel(name = "父级id", width = 15)
@Schema(description = "父级id")
private String parentId;
/**租户id*/
@Excel(name = "租户id", width = 15)
@Schema(description = "租户id")
private String tenantId;
/**文件大小kb*/
@Excel(name = "文件大小kb", width = 15)
@Schema(description = "文件大小kb")
private Double fileSize;
/**是否文件夹(1是 0否)*/
@Excel(name = "是否文件夹(1是 0否)", width = 15)
@Schema(description = "是否文件夹(1是 0否)")
private String izFolder;
/**是否为1级文件夹允许为空 (1是 )*/
@Excel(name = "是否为1级文件夹允许为空 (1是 )", width = 15)
@Schema(description = "是否为1级文件夹允许为空 (1是 )")
private String izRootFolder;
/**是否标星(1是 0否)*/
@Excel(name = "是否标星(1是 0否)", width = 15)
@Schema(description = "是否标星(1是 0否)")
private String izStar;
/**下载次数*/
@Excel(name = "下载次数", width = 15)
@Schema(description = "下载次数")
private Integer downCount;
/**阅读次数*/
@Excel(name = "阅读次数", width = 15)
@Schema(description = "阅读次数")
private Integer readCount;
/**分享链接*/
@Excel(name = "分享链接", width = 15)
@Schema(description = "分享链接")
private String shareUrl;
/**分享权限(1.关闭分享 2.允许所有联系人查看 3.允许任何人查看)*/
@Excel(name = "分享权限(1.关闭分享 2.允许所有联系人查看 3.允许任何人查看)", width = 15)
@Schema(description = "分享权限(1.关闭分享 2.允许所有联系人查看 3.允许任何人查看)")
private String sharePerms;
/**是否允许下载(1是 0否)*/
@Excel(name = "是否允许下载(1是 0否)", width = 15)
@Schema(description = "是否允许下载(1是 0否)")
private String enableDown;
/**是否允许修改(1是 0否)*/
@Excel(name = "是否允许修改(1是 0否)", width = 15)
@Schema(description = "是否允许修改(1是 0否)")
private String enableUpdat;
/**删除状态(0-正常,1-删除至回收站)*/
@Excel(name = "删除状态(0-正常,1-删除至回收站)", width = 15)
@Schema(description = "删除状态(0-正常,1-删除至回收站)")
private String delFlag;
/**
* 文件表不存在的字段:用户数据集合
*/
@TableField(exist=false)
private String userData;
/**
* 文件表不存在的字段:用户真实姓名
*/
@TableField(exist=false)
private String realname;
/**
* 文件表不存在的字段:压缩名称
*/
@TableField(exist=false)
private String zipName;
}

View File

@ -108,6 +108,12 @@ public class SysLog implements Serializable {
*/
@Dict(dicCode = "operate_type")
private Integer operateType;
/**
* 客户终端类型 pc:电脑端 app:手机端 h5:移动网页端
*/
@Dict(dicCode = "client_type")
private String clientType;
/**
* 租户ID

View File

@ -9,7 +9,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.modules.system.constant.DefIndexConst;
/**
* <p>
@ -166,11 +166,11 @@ public class SysPermission implements Serializable {
}
public SysPermission(boolean index) {
if(index) {
this.id = "9502685863ab87f0ad1134142788a385";
this.name="首页";
this.component="dashboard/Analysis";
this.componentName="dashboard-analysis";
this.url="/dashboard/analysis";
this.id = "9502685863ab87f0ad1134142788a385";
this.name = DefIndexConst.DEF_INDEX_NAME;
this.component = DefIndexConst.DEF_INDEX_COMPONENT;
this.componentName = "dashboard-analysis";
this.url = DefIndexConst.DEF_INDEX_URL;
this.icon="home";
this.menuType=0;
this.sortNo=0.0;

View File

@ -67,7 +67,7 @@ public class SysTenantPackUser implements Serializable {
private transient String packCode;
/**
* 状态(1 正常 2 离职 3 待审核 4 拒绝 5 邀请加入)
* 状态(申请状态0 正常状态1)
*/
private Integer status;

View File

@ -48,6 +48,4 @@ public class SysUserRole implements Serializable {
this.roleId = roleId;
}
}

View File

@ -26,7 +26,16 @@ public interface SysAnnouncementMapper extends BaseMapper<SysAnnouncement> {
* @param msgCategory 消息类型
* @return
*/
List<SysAnnouncement> querySysCementListByUserId(Page<SysAnnouncement> page, @Param("userId")String userId,@Param("msgCategory")String msgCategory);
List<SysAnnouncement> querySysCementListByUserId(Page<SysAnnouncement> page, @Param("userId")String userId,@Param("msgCategory")String msgCategory,
@Param("tenantId")Integer tenantId, @Param("beginDate")Date beginDate);
/**
* 获取用户未读消息数量
*
* @param userId 用户id
* @return
*/
Integer getUnreadMessageCountByUserId(@Param("userId") String userId, @Param("beginDate") Date beginDate);
/**
* 分页查询全部消息列表

View File

@ -9,6 +9,7 @@ import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.model.SysDepartTreeModel;
import org.jeecg.modules.system.model.TreeModel;
import org.jeecg.modules.system.vo.SysDepartExportVo;
import org.jeecg.modules.system.vo.SysUserDepVo;
import org.jeecg.modules.system.vo.lowapp.ExportDepartVo;
import org.springframework.data.repository.query.Param;
@ -39,6 +40,14 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
* @return
*/
public List<SysDepart> queryDepartsByUsername(@Param("username") String username);
/**
* 根据用户名查询部门
*
* @param userId
* @return
*/
public List<String> queryDepartsByUserId(@Param("userId") String userId);
/**
* 通过部门编码获取部门id
@ -161,4 +170,12 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
* @return
*/
List<SysDepart> getDepartPageByName(@Param("page") Page<SysDepart> page, @Param("departName") String departName, @Param("tenantId") Integer tenantId, @Param("parentId") String parentId);
/**
* 获取租户id和部门父id获取的部门数据
* @param tenantId
* @param parentId
* @return
*/
List<SysDepartExportVo> getSysDepartList(@Param("parentId") String parentId,@Param("tenantId") Integer tenantId);
}

View File

@ -82,6 +82,12 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
*/
List<DictModelMany> queryManyDictByKeys(@Param("dictCodeList") List<String> dictCodeList, @Param("keys") List<String> keys);
/**
* 查询系统所有字典项
* @return
*/
public List<DictModelMany> queryAllDictItems(List<Integer> tenantIdList);
/**
* 查询所有部门 作为字典信息 id -->value,departName -->text
* @return
@ -187,4 +193,11 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
*/
@InterceptorIgnore(tenantLine = "true")
List<SysDict> getDictListByLowAppId(@Param("lowAppId") String lowAppId, @Param("tenantId") Integer tenantId);
/**
* 查询被逻辑删除的数据根据租户id
* @return
*/
@Select("select * from sys_dict where del_flag = 1 and tenant_id = #{tenantId}")
List<SysDict> queryDeleteListBtTenantId(@Param("tenantId") Integer tenantId);
}

View File

@ -1,14 +0,0 @@
package org.jeecg.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.system.entity.SysFiles;
/**
* @Description: 知识库-文档管理
* @Author: jeecg-boot
* @Date: 2022-07-21
* @Version: V1.0
*/
public interface SysFilesMapper extends BaseMapper<SysFiles> {
}

View File

@ -20,4 +20,12 @@ public interface SysPackPermissionMapper extends BaseMapper<SysPackPermission> {
* @return
*/
List<String> getPermissionsByPackId(@Param("packId") String packId);
/**
* 删除产品包对应的菜单权限
*
* @param tenantIdList
*/
void deletePackPermByTenantIds(@Param("tenantIdList") List<Integer> tenantIdList);
}

View File

@ -29,10 +29,10 @@ public interface SysPermissionMapper extends BaseMapper<SysPermission> {
/**
* 根据用户查询用户权限
* @param username 用户账户名称
* @param userId 用户ID
* @return List<SysPermission>
*/
public List<SysPermission> queryByUser(@Param("username") String username);
public List<SysPermission> queryByUser(@Param("userId") String userId);
/**
* 修改菜单状态字段: 是否子节点

View File

@ -37,7 +37,16 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
*/
@InterceptorIgnore(tenantLine = "true")
SysRole getRoleNoTenant(@Param("roleCode") String roleCode);
/**
* 根据用户id查询用户拥有的角色Code
*
* @param userId
* @param tenantId
* @return
*/
List<SysRole> getRoleCodeListByUserId(@Param("userId") String userId, @Param("tenantId") Integer tenantId);
/**
* 删除角色与用户关系
* @Author scott

View File

@ -119,5 +119,19 @@ public interface SysTenantMapper extends BaseMapper<SysTenant> {
* @return
*/
Long getApplySuperAdminCount(@Param("userId") String userId, @Param("tenantId") Integer tenantId);
/**
* 租户是否存在
* @param tenantId
* @return
*/
@Select("select count(1) from sys_tenant where id = #{tenantId} and del_flag = 0")
Long tenantIzExist(@Param("tenantId") Integer tenantId);
/**
* 根据用户id获取租户
* @param userId
* @return
*/
List<SysTenant> getTenantListByUserId(@Param("userId") String userId);
}

View File

@ -14,4 +14,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface SysTenantPackMapper extends BaseMapper<SysTenantPack> {
/**
* 删除租户产品包
*
* @param tenantIdList
*/
void deletePackByTenantIds(@Param("tenantIdList") List<Integer> tenantIdList);
}

View File

@ -25,4 +25,23 @@ public interface SysTenantPackUserMapper extends BaseMapper<SysTenantPackUser> {
@InterceptorIgnore(tenantLine = "true")
List<String> queryTenantPackUserNameList(@Param("tenantId") Integer tenantId, @Param("packCodeList") List<String> packCodeList);
/**
* 判断当前用户在该租户下是否拥有管理员的权限
* @param userId
* @param tenantId
* @return
*/
Long izHaveBuyAuth(@Param("userId") String userId, @Param("tenantId") Integer tenantId);
/**
* 根据租户id 删除租户产品包下的 用户
* @param tenantId
*/
void deletePackUserByTenantId(@Param("tenantId") Integer tenantId, @Param("userIds") List<String> userIds);
/**
* 根据多个租户id 删除租户产品包下的 用户
* @param
*/
void deletePackUserByTenantIds(@Param("tenantIds") List<Integer> tenantIds);
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.system.entity.SysThirdAccount;
import org.jeecg.modules.system.vo.thirdapp.JwUserDepartVo;
import java.util.List;
@ -22,5 +23,12 @@ public interface SysThirdAccountMapper extends BaseMapper<SysThirdAccount> {
* @return
*/
List<SysThirdAccount> selectThirdIdsByUsername(@Param("sysUsernameArr") String[] sysUsernameArr, @Param("thirdType") String thirdType, @Param("tenantId") Integer tenantId);
/**
* 查询被绑定的用户
* @param tenantId
* @param thirdType
* @return
*/
List<JwUserDepartVo> getThirdUserBindByWechat(@Param("tenantId") int tenantId, @Param("thirdType") String thirdType);
}

View File

@ -57,7 +57,7 @@ public interface SysUserDepartMapper extends BaseMapper<SysUserDepart>{
* @param keyword
* @return
*/
IPage<SysUser> getProcessUserList(Page<SysUser> page, @Param("orgCode") String orgCode, @Param("keyword") String keyword, @Param("tenantId") Integer tenantId);
IPage<SysUser> getProcessUserList(Page<SysUser> page, @Param("orgCode") String orgCode, @Param("keyword") String keyword, @Param("tenantId") Integer tenantId, @Param("excludeUserIdList") List<String> excludeUserIdList);
/**
* 获取租户下的部门通过前台传过来的部门id

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.system.model.SysUserSysDepartModel;
@ -27,6 +28,13 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return
*/
public SysUser getUserByName(@Param("username") String username);
/**
* 通过用户账号查询用户Id
* @param username
* @return
*/
public String getUserIdByName(@Param("username") String username);
/**
* 根据部门Id查询用户信息
@ -171,9 +179,10 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @param page
* @param roleId
* @param keyword
* @param userIdList
* @return
*/
IPage<SysUser> selectUserListByRoleId(Page<SysUser> page, @Param("roleId") String roleId, @Param("keyword") String keyword, @Param("tenantId") Integer tenantId);
IPage<SysUser> selectUserListByRoleId(Page<SysUser> page, @Param("roleId") String roleId, @Param("keyword") String keyword, @Param("tenantId") Integer tenantId, @Param("excludeUserIdList") List<String> excludeUserIdList);
/**
* 更新刪除状态和离职状态
@ -204,4 +213,13 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return
*/
List<SysUser> getUserByDepartsTenantId(@Param("departIds") List<String> departIds,@Param("tenantId") Integer tenantId);
/**
* 根据用户名和手机号获取用户
* @param phone
* @param username
* @return
*/
@Select("select id,phone from sys_user where phone = #{phone} and username = #{username}")
SysUser getUserByNameAndPhone(@Param("phone") String phone, @Param("username") String username);
}

View File

@ -1,17 +1,17 @@
package org.jeecg.modules.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.entity.SysUserPosition;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.system.vo.SysUserPositionVo;
import java.util.List;
/**
* @Description: 用户职位关系表
* @Author: jeecg-boot
@ -66,7 +66,7 @@ public interface SysUserPositionMapper extends BaseMapper<SysUserPosition> {
* @return
*/
@InterceptorIgnore(tenantLine = "true")
List<String> getPositionIdByUserTenantId(@Param("userId") String userId, @Param("tenantId") Integer tenantId);
List<String> getPositionIdByUserTenantId(@Param("userId")String userId, @Param("tenantId")Integer tenantId);
/**
* 根据用户id获取用户职位

View File

@ -23,6 +23,14 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
*/
@Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
List<String> getRoleByUserName(@Param("username") String username);
/**
* 通过用户账号查询角色集合
* @param userId 用户id
* @return List<String>
*/
@Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = #{userId})")
List<String> getRoleCodeByUserId(@Param("userId") String userId);
/**
* 通过用户账号查询角色Id集合

View File

@ -12,6 +12,7 @@ import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.entity.SysUserTenant;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.system.vo.SysUserTenantVo;
import org.jeecg.modules.system.vo.thirdapp.JwUserDepartVo;
/**
* @Description: sys_user_tenant_relation
@ -149,4 +150,28 @@ public interface SysUserTenantMapper extends BaseMapper<SysUserTenant> {
* @param tenantIds
*/
void deleteUserByTenantId(@Param("tenantIds") List<Integer> tenantIds);
/**
* 获取租户下的成员数量
*
* @param tenantId
* @param tenantStatus
* @return
*/
Long getUserCount(Integer tenantId, String tenantStatus);
/**
* 根据租户id和名称获取用户数据
* @param tenantId
* @return
*/
List<JwUserDepartVo> getUsersByTenantIdAndName(@Param("tenantId") Integer tenantId);
/**
* 根据多个用户id获取租户id
*
* @param userIds
* @return
*/
List<Integer> getTenantIdsByUserIds(@Param("userIds") List<String> userIds);
}

View File

@ -33,15 +33,23 @@
<select id="querySysCementListByUserId" parameterType="String" resultMap="SysAnnouncement">
select * from sys_announcement
select id,titile,create_time,priority,bus_id,open_type,open_page,sender,send_time,msg_content from sys_announcement
where send_status = '1'
and del_flag = '0'
and msg_category = #{msgCategory}
and id IN ( select annt_id from sys_announcement_send where user_id = #{userId} and read_flag = 0)
and create_time &gt;= #{beginDate}
<if test="tenantId!=null and tenantId != 0">
and tenant_id = #{tenantId}
</if>
and id IN ( select annt_id from sys_announcement_send where user_id = #{userId} and read_flag = 0 and create_time &gt;= #{beginDate})
order by create_time DESC
</select>
<!-- 获取用户未读消息数量 -->
<select id="getUnreadMessageCountByUserId" resultType="java.lang.Integer">
select count(1) from sys_announcement_send where user_id = #{userId} and read_flag = 0 and create_time &gt;= #{beginDate}
</select>
<!-- 查询消息记录 -->
<select id="queryAllMessageList" resultMap="SysAnnouncement">
select
@ -72,6 +80,7 @@
<if test="beginDate!=null">
and a.create_time &gt;= #{beginDate}
and b.create_time &gt;= #{beginDate}
</if>
<if test="endDate!=null">
and a.create_time &lt;= #{endDate}

View File

@ -20,6 +20,17 @@
)
)
</select>
<!-- 根据username查询所拥有的部门 -->
<select id="queryDepartsByUserId" parameterType="String" resultType="java.lang.String">
SELECT id
FROM sys_depart
WHERE id IN (
SELECT dep_id
FROM sys_user_depart
WHERE user_id = #{userId}
)
</select>
<!-- 根据部门Id查询,当前和下级所有部门IDS -->
<select id="getSubDepIdsByDepId" resultType="java.lang.String">
@ -114,7 +125,9 @@
SELECT id,depart_name,org_code,parent_id FROM sys_depart
where
depart_name = #{departName}
and tenant_id = #{tenantId}
<if test="null != tenantId and 0 != tenantId">
and tenant_id = #{tenantId}
</if>
<if test="parentId != null and parentId != ''">
and parent_id = #{parentId}
</if>
@ -154,4 +167,24 @@
</foreach>
)
</select>
<!--系统后台导出根据父级id和租户id查询部门数据-->
<select id="getSysDepartList" resultType="org.jeecg.modules.system.vo.SysDepartExportVo">
SELECT id,depart_name,parent_id,depart_name_en,depart_order,description,org_category,org_code,mobile,fax,address,memo FROM sys_depart
WHERE
1=1
<if test="null != tenantId and 0 != tenantId">
AND tenant_id = #{tenantId}
</if>
AND
<choose>
<when test="parentId != null and parentId != ''">
parent_id = #{parentId}
</when>
<otherwise>
parent_id IS NULL OR parent_id=''
</otherwise>
</choose>
ORDER BY depart_order DESC
</select>
</mapper>

View File

@ -63,6 +63,28 @@
</foreach>
)
</select>
<!-- 获取全部字典项 -->
<select id="queryAllDictItems" resultType="org.jeecg.common.system.vo.DictModelMany">
SELECT
dict.dict_code,
item.item_text AS "text",
item.item_value AS "value",
item.item_color AS "color"
FROM
sys_dict_item item
INNER JOIN sys_dict dict ON dict.id = item.dict_id
WHERE dict.del_flag = 0
<if test="tenantIdList!=null and tenantIdList.size()>0">
AND dict.tenant_id IN (
<foreach item="tenantId" collection="tenantIdList" separator=",">
#{tenantId}
</foreach>
)
</if>
AND item.status =1
order by dict.dict_code, item.sort_order
</select>
<!-- 查询部门信息 作为字典数据 -->
<select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">

View File

@ -7,5 +7,15 @@
where
pack_id = #{packId}
</select>
<!--删除产品包对应的菜单权限-->
<delete id="deletePackPermByTenantIds">
delete from sys_tenant_pack_perms
where pack_id in(
select id from sys_tenant_pack where tenant_id in
<foreach collection="tenantIdList" index="index" item="tenantId" open="(" separator="," close=")">
#{tenantId}
</foreach>
)
</delete>
</mapper>

View File

@ -42,46 +42,105 @@
<!-- 获取登录用户拥有的权限 -->
<select id="queryByUser" parameterType="Object" resultMap="SysPermission">
SELECT * FROM (
SELECT p.*
SELECT p.id,
p.parent_id,
p.name,
p.url,
p.component,
p.is_route,
p.component_name,
p.redirect,
p.menu_type,
p.perms,
p.perms_type,
p.sort_no,
p.always_show,
p.icon,
p.is_leaf,
p.keep_alive,
p.hidden,
p.hide_tab,
p.rule_flag,
p.status,
p.internal_or_external
FROM sys_permission p
WHERE (exists(
select a.id from sys_role_permission a
join sys_role b on a.role_id = b.id
join sys_user_role c on c.role_id = b.id
join sys_user d on d.id = c.user_id
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
WHERE p.del_flag = 0
AND ( p.id in (
SELECT DISTINCT a.permission_id
FROM sys_role_permission a
JOIN sys_role b ON a.role_id = b.id
JOIN sys_user_role c ON c.role_id = b.id AND c.user_id = #{userId,jdbcType=VARCHAR}
)
or (p.url like '%:code' and p.url like '/online%' and p.hidden = 1)
or (p.url like '%:id' and p.url like '/online%' and p.hidden = 1)
or p.url = '/online')
and p.del_flag = 0
or p.url = '/online'
)
<!--update begin Author:lvdandan Date:20200213 for加入部门权限 -->
UNION
SELECT p.*
FROM sys_permission p
WHERE exists(
select a.id from sys_depart_role_permission a
join sys_depart_role b on a.role_id = b.id
join sys_depart_role_user c on c.drole_id = b.id
join sys_user d on d.id = c.user_id
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
)
SELECT p.id,
p.parent_id,
p.name,
p.url,
p.component,
p.is_route,
p.component_name,
p.redirect,
p.menu_type,
p.perms,
p.perms_type,
p.sort_no,
p.always_show,
p.icon,
p.is_leaf,
p.keep_alive,
p.hidden,
p.hide_tab,
p.rule_flag,
p.status,
p.internal_or_external
FROM sys_permission p
WHERE p.id in(
SELECT DISTINCT a.permission_id
FROM sys_depart_role_permission a
INNER JOIN sys_depart_role b ON a.role_id = b.id
INNER JOIN sys_depart_role_user c ON c.drole_id = b.id AND c.user_id = #{userId,jdbcType=VARCHAR}
)
and p.del_flag = 0
<!--update end Author:lvdandan Date:20200213 for加入部门权限 -->
<!-- update begin Author: taoyan Date:20200213 forQQYUN-4303 【low app】 用户登录的时候 加载low app的套餐权限 加到用户信息 -->
UNION
SELECT p.*
FROM sys_permission p
WHERE exists(
select a.id from sys_tenant_pack_perms a
join sys_tenant_pack b on a.pack_id = b.id
join sys_tenant_pack_user c on c.pack_id = b.id
join sys_user d on d.id = c.user_id
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
)
and p.del_flag = 0
<!-- update end Author: taoyan Date:20200213 forQQYUN-4303 【low app】 用户登录的时候 加载low app的套餐权限 加到用户信息 -->
UNION
SELECT p.id,
p.parent_id,
p.name,
p.url,
p.component,
p.is_route,
p.component_name,
p.redirect,
p.menu_type,
p.perms,
p.perms_type,
p.sort_no,
p.always_show,
p.icon,
p.is_leaf,
p.keep_alive,
p.hidden,
p.hide_tab,
p.rule_flag,
p.status,
p.internal_or_external
FROM sys_permission p
WHERE p.id in (
SELECT distinct a.permission_id
FROM sys_tenant_pack_perms a
INNER JOIN sys_tenant_pack b ON a.pack_id = b.id AND b.STATUS = '1'
INNER JOIN sys_tenant st ON st.id = b.tenant_id and st.del_flag = 0
INNER JOIN sys_tenant_pack_user c ON c.pack_id = b.id AND c.STATUS = '1' AND c.user_id = #{userId,jdbcType=VARCHAR}
)
and p.del_flag = 0
<!-- update end Author: taoyan Date:20200213 forQQYUN-4303 【low app】 用户登录的时候 加载low app的套餐权限 加到用户信息 -->
) h order by h.sort_no ASC
</select>

View File

@ -20,5 +20,14 @@
SELECT * from sys_role
WHERE role_code = #{roleCode}
</select>
<!-- 根据用户id查询用户拥有的角色 -->
<select id="getRoleCodeListByUserId" resultType="org.jeecg.modules.system.entity.SysRole">
SELECT id, role_code from sys_role
WHERE id in (SELECT role_id from sys_user_role WHERE user_id = #{userId})
<if test="tenantId != null">
AND tenant_id = #{tenantId}
</if>
</select>
</mapper>

View File

@ -43,6 +43,7 @@
<select id="queryTenantPackUserCount" resultType="org.jeecg.modules.system.vo.tenant.TenantPackUserCount">
SELECT pack_code, count(*) as user_count FROM sys_tenant_pack a
join sys_tenant_pack_user b on a.id = b.pack_id
join sys_user_tenant sut on a.tenant_id = sut.tenant_id and b.user_id = sut.user_id and sut.status = 1
where a.tenant_id = #{tenantId}
and a.pack_code in ('superAdmin', 'accountAdmin', 'appAdmin')
and b.status = 1
@ -74,6 +75,7 @@
SELECT c.id, c.username, c.realname, c.phone, c.avatar, a.pack_name, a.id as pack_id FROM sys_user c
join sys_tenant_pack_user b on c.id = b.user_id
join sys_tenant_pack a on a.id = b.pack_id
join sys_user_tenant sut on a.tenant_id = sut.tenant_id and b.user_id = sut.user_id and sut.status = 1
where c.status = 1
and c.del_flag = 0
and b.status = #{packUserStatus}
@ -130,5 +132,12 @@
and a.tenant_id = #{tenantId}
and b.user_id = #{userId}
</select>
<!--根据用户id获取租户信息-->
<select id="getTenantListByUserId" resultType="org.jeecg.modules.system.entity.SysTenant">
SELECT st.id,st.name FROM sys_tenant st
LEFT JOIN sys_user_tenant sut on st.id= sut.tenant_id and st.status = 1 and sut.status='1'
WHERE sut.user_id = #{userId}
</select>
</mapper>

View File

@ -2,4 +2,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.system.mapper.SysTenantPackMapper">
<!--删除租户产品包-->
<delete id="deletePackByTenantIds">
delete from sys_tenant_pack
where tenant_id in
<foreach collection="tenantIdList" index="index" item="tenantId" open="(" separator="," close=")">
#{tenantId}
</foreach>
</delete>
</mapper>

View File

@ -15,4 +15,30 @@
)
</select>
<!-- 判断当前用户在该租户下是否拥有管理员的权限 -->
<select id="izHaveBuyAuth" resultType="java.lang.Long">
SELECT count(1) from sys_tenant_pack_user stpu
left join sys_tenant_pack stp on stpu.pack_id = stp.id
WHERE stpu.tenant_id = #{tenantId}
and stpu.user_id = #{userId}
and stp.pack_code in('superAdmin','accountAdmin')
</select>
<!--根据租户id 删除租户产品包下的 用户-->
<delete id="deletePackUserByTenantId">
delete from sys_tenant_pack_user where tenant_id = #{tenantId}
and user_id in
<foreach collection="userIds" index="index" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<!--根据多个租户id 删除租户产品包下的 用户-->
<delete id="deletePackUserByTenantIds">
delete from sys_tenant_pack_user
where tenant_id in
<foreach collection="tenantIds" index="index" item="tenantId" open="(" separator="," close=")">
#{tenantId}
</foreach>
</delete>
</mapper>

View File

@ -14,5 +14,14 @@
<!-- TODO in 查询数据量大的时候可能会报错 -->
<foreach collection="sysUsernameArr" item="item" open=" sys_user.username IN (" close=")" separator=",">#{item}</foreach>
</select>
<!--查询被绑定的用户-->
<select id="getThirdUserBindByWechat" resultType="org.jeecg.modules.system.vo.thirdapp.JwUserDepartVo">
SELECT su.id userId, su.realname, su.avatar, sta.realname as wechatRealName, sta.third_user_id as wechatUserId, sta.id as thirdId
FROM sys_third_account sta
LEFT JOIN sys_user su on sta.sys_user_id = su.id
WHERE sta.tenant_id = #{tenantId}
AND sta.third_type = #{thirdType}
</select>
</mapper>

View File

@ -74,6 +74,13 @@
select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
)
</if>
<!--【QQYUN-8239】用户角色添加用户 返回2页数据实际只显示一页 需要将不符合的用户id排除-->
<if test="excludeUserIdList!=null and excludeUserIdList.size()>0">
and a.id not in
<foreach collection="excludeUserIdList" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>
</select>
<!--获取租户下的部门-通过前台传过来的部门id-->

View File

@ -6,6 +6,11 @@
<select id="getUserByName" resultType="org.jeecg.modules.system.entity.SysUser">
select * from sys_user where username = #{username} and del_flag = 0
</select>
<!-- 根据用户名查询用户ID -->
<select id="getUserIdByName" resultType="String">
select id from sys_user where username = #{username} and del_flag = 0
</select>
<!-- 根据部门Id查询 -->
<select id="getUserByDepId" resultType="org.jeecg.modules.system.entity.SysUser">
@ -219,11 +224,19 @@
select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
)
</if>
<!--【QQYUN-8239】用户角色添加用户 返回2页数据实际只显示一页 需要将不符合的用户id排除-->
<if test="excludeUserIdList!=null and excludeUserIdList.size()>0">
and a.id not in
<foreach collection="excludeUserIdList" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>
</select>
<!--获取租户下的用户离职列表信息-->
<select id="getTenantQuitList" resultType="org.jeecg.modules.system.entity.SysUser">
select su.id,su.username,su.realname,su.sex,su.avatar from sys_user su
select su.id,su.username,su.realname,su.sex,su.avatar,su.create_time,sut.create_by from sys_user su
join sys_user_tenant sut on sut.user_id = su.id and sut.status = '2'
where
su.status = 1

View File

@ -39,9 +39,9 @@
<!--通过用户id获取租户列表-->
<select id="getTenantListByUserId" resultType="org.jeecg.modules.system.vo.SysUserTenantVo">
SELECT st.id as tenantUserId,st.name,st.trade,st.house_number,st.create_by,sut.status as userTenantStatus
SELECT st.id as tenantUserId,st.name,st.trade,st.house_number,st.create_by,sut.status as userTenantStatus,sut.user_id as id
FROM sys_user_tenant sut
JOIN sys_tenant st ON sut.tenant_id = st.id
LEFT JOIN sys_tenant st ON sut.tenant_id = st.id
WHERE st.status = 1
AND st.del_flag = 0
AND sut.user_id = #{userId}
@ -164,4 +164,22 @@
#{tenantId}
</foreach>
</delete>
<!-- 获取租户下的成员数量 -->
<select id="getUserCount" resultType="java.lang.Long">
SELECT count(1) FROM sys_user_tenant sut JOIN sys_user su on sut.user_id = su.id and su.del_flag = 0 and su.status = 1
WHERE sut.status = #{tenantStatus}
AND sut.tenant_id = #{tenantId}
</select>
<!--根据租户id和名称获取用户数据-->
<select id="getUsersByTenantIdAndName" resultType="org.jeecg.modules.system.vo.thirdapp.JwUserDepartVo">
SELECT su.id userId,su.realname,su.avatar
FROM sys_user_tenant sut
JOIN sys_tenant st ON sut.tenant_id = st.id and st.status = 1 and st.del_flag = 0
JOIN sys_user su ON sut.user_id = su.id and su.status = 1 and su.del_flag = 0
WHERE
sut.status = 1
AND sut.tenant_id = #{tenantId}
</select>
</mapper>

View File

@ -43,7 +43,15 @@ public interface ISysAnnouncementService extends IService<SysAnnouncement> {
* @param msgCategory 消息类型
* @return Page<SysAnnouncement>
*/
public Page<SysAnnouncement> querySysCementPageByUserId(Page<SysAnnouncement> page, String userId, String msgCategory);
public Page<SysAnnouncement> querySysCementPageByUserId(Page<SysAnnouncement> page, String userId, String msgCategory, Integer tenantId, Date beginDate);
/**
* 获取用户未读消息数量
*
* @param userId 用户id
* @return
*/
public Integer getUnreadMessageCountByUserId(String userId, Date beginDate);
/**

View File

@ -89,4 +89,13 @@ public interface ISysCategoryService extends IService<SysCategory> {
*/
List<String> loadDictItem(String ids, boolean delNotExist);
/**
* 【仅导入使用】分类字典控件反向翻译
*
* @param names
* @param delNotExist 是否移除不存在的项设为false如果某个key不存在数据库中则直接返回key本身
* @return
*/
List<String> loadDictItemByNames(String names, boolean delNotExist);
}

View File

@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUserDepart;
import org.jeecg.modules.system.model.DepartIdModel;
import org.jeecg.modules.system.model.SysDepartTreeModel;
import org.jeecg.modules.system.vo.SysDepartExportVo;
import org.jeecg.modules.system.vo.lowapp.ExportDepartVo;
import jakarta.servlet.http.HttpServletRequest;
@ -101,6 +103,14 @@ public interface ISysDepartService extends IService<SysDepart>{
* @return
*/
List<SysDepart> queryDepartsByUsername(String username);
/**
* 根据用户ID查询部门
*
* @param userId
* @return
*/
List<String> queryDepartsByUserId(String userId);
/**
* 根据部门id批量删除并删除其可能存在的子级部门
@ -215,5 +225,18 @@ public interface ISysDepartService extends IService<SysDepart>{
List<ExportDepartVo> getExcelDepart(int tenantId);
void importExcel(List<ExportDepartVo> listSysDeparts, List<String> errorMessageList);
/**
* 根据租户id导出部门
* @param tenantId
* @return
*/
List<SysDepartExportVo> getExportDepart(Integer tenantId);
/**
* 导出系统部门excel
* @param listSysDeparts
* @param errorMessageList
*/
void importSysDepart(List<SysDepartExportVo> listSysDeparts, List<String> errorMessageList);
}

View File

@ -107,6 +107,7 @@ public interface ISysDictService extends IService<SysDict> {
@Deprecated
String queryTableDictTextByKey(String table, String text, String code, String key);
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/**
* 通过查询指定table的 text code key 获取字典值,可批量查询
*
@ -114,9 +115,11 @@ public interface ISysDictService extends IService<SysDict> {
* @param text
* @param code
* @param keys
* @param dataSource 数据源
* @return
*/
List<DictModel> queryTableDictTextByKeys(String table, String text, String code, List<String> keys);
List<DictModel> queryTableDictTextByKeys(String table, String text, String code, List<String> keys, String dataSource);
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/**
* 通过查询指定table的 text code key 获取字典值包含value
@ -235,7 +238,7 @@ public interface ISysDictService extends IService<SysDict> {
* 查询被逻辑删除的数据
* @return
*/
public List<SysDict> queryDeleteList();
public List<SysDict> queryDeleteList(String tenantId);
/**
* 分页查询

View File

@ -1,14 +0,0 @@
package org.jeecg.modules.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.system.entity.SysFiles;
/**
* @Description: 知识库-文档管理
* @Author: jeecg-boot
* @Date: 2022-07-21
* @Version: V1.0
*/
public interface ISysFilesService extends IService<SysFiles> {
}

View File

@ -1,14 +1,43 @@
package org.jeecg.modules.system.service;
import org.jeecg.modules.system.entity.SysRoleIndex;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.system.entity.SysRoleIndex;
/**
* @Description: 角色首页配置
* @Author: jeecg-boot
* @Date: 2022-03-25
* @Date: 2022-03-25
* @Version: V1.0
*/
public interface ISysRoleIndexService extends IService<SysRoleIndex> {
/**
* 查询默认首页
*
* @return
*/
SysRoleIndex queryDefaultIndex();
/**
* 更新默认首页
*
* @param url
* @param component
* @param isRoute 是否是路由页面
* @return
*/
boolean updateDefaultIndex(String url, String component, boolean isRoute);
/**
* 创建最原始的默认首页配置
*
* @return
*/
SysRoleIndex initDefaultIndex();
/**
* 清理默认首页的redis缓存
*/
void cleanDefaultIndexCache();
}

View File

@ -67,4 +67,11 @@ public interface ISysRoleService extends IService<SysRole> {
* @return
*/
Long getRoleCountByTenantId(String id, Integer tenantId);
/**
* 验证是否为admin角色
*
* @param ids
*/
void checkAdminRoleRejectDel(String ids);
}

View File

@ -37,7 +37,7 @@ public interface ISysTenantPackService extends IService<SysTenantPack> {
* 删除租户产品包
* @param ids
*/
void deletePackPermissions(String ids);
void deleteTenantPack(String ids);
/**
* 退出租户

View File

@ -217,4 +217,19 @@ public interface ISysTenantService extends IService<SysTenant> {
* @param content
*/
void sendMsgForAgreeAndRefuseJoin(SysUser user, String content);
/**
* 根据密码删除当前用户
*
* @param sysUser
* @param tenantId
*/
void deleteUserByPassword(SysUser sysUser, Integer tenantId);
/**
* 根据用户id获取租户信息
* @param userId
* @return
*/
List<SysTenant> getTenantListByUserId(String userId);
}

View File

@ -75,7 +75,8 @@ public interface ISysThirdAccountService extends IService<SysThirdAccount> {
* @param unionid
* @param thirdType
* @param tenantId
* @param thirdUserId
* @return
*/
SysThirdAccount getOneByUuidAndThirdType(String unionid, String thirdType,Integer tenantId);
SysThirdAccount getOneByUuidAndThirdType(String unionid, String thirdType,Integer tenantId,String thirdUserId);
}

View File

@ -51,9 +51,10 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
* @param pageNo
* @param realname
* @param id
* @param isMultiTranslate 是否多字段翻译
* @return
*/
IPage<SysUser> queryDepartUserPageList(String departId, String username, String realname, int pageSize, int pageNo,String id);
IPage<SysUser> queryDepartUserPageList(String departId, String username, String realname, int pageSize, int pageNo,String id,String isMultiTranslate);
/**
* 获取用户信息
@ -76,7 +77,7 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
* @param pageNo
* @return
*/
IPage<SysUser> getUserInformation(Integer tenantId,String departId,String roleId, String keyword, Integer pageSize, Integer pageNo);
IPage<SysUser> getUserInformation(Integer tenantId,String departId,String roleId, String keyword, Integer pageSize, Integer pageNo, String excludeUserIdList);
/**
* 通过部门id和租户id获取多个用户

View File

@ -89,7 +89,7 @@ public interface ISysUserService extends IService<SysUser> {
* @param user
* @param roles
*/
public void addUserWithRole(SysUser user,String roles);
public void addUserWithRole(SysUser user, String roles);
/**
@ -97,7 +97,7 @@ public interface ISysUserService extends IService<SysUser> {
* @param user
* @param roles
*/
public void editUserWithRole(SysUser user,String roles);
public void editUserWithRole(SysUser user, String roles);
/**
* 获取用户的授权角色
@ -113,7 +113,7 @@ public interface ISysUserService extends IService<SysUser> {
* @param version 前端UI版本
* @return
*/
public SysRoleIndex getDynamicIndexByUserRole(String username,String version);
public SysRoleIndex getDynamicIndexByUserRole(String username, String version);
/**
* 查询用户信息包括 部门信息
@ -177,7 +177,7 @@ public interface ISysUserService extends IService<SysUser> {
* @param username 用户账户名称
* @return
*/
public IPage<SysUser> getUserByRoleId(Page<SysUser> page,String roleId, String username);
public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username);
/**
* 通过用户名获取用户角色集合
@ -186,14 +186,22 @@ public interface ISysUserService extends IService<SysUser> {
* @return 角色集合
*/
Set<String> getUserRolesSet(String username);
/**
* 通过用户名获取用户角色集合
*
* @param userId 用户id
* @return 角色集合
*/
Set<String> getUserRoleSetById(String userId);
/**
* 通过用户名获取用户权限集合
*
* @param username 用户
* @param userId 用户id
* @return 权限集合
*/
Set<String> getUserPermissionsSet(String username);
Set<String> getUserPermissionsSet(String userId);
/**
* 根据用户名设置部门ID
@ -347,7 +355,7 @@ public interface ISysUserService extends IService<SysUser> {
* @param sysUser
* @return
*/
Result<JSONObject> setLoginTenant(SysUser sysUser, JSONObject obj, String username, Result<JSONObject> result);
Result<JSONObject> setLoginTenant(SysUser sysUser, JSONObject obj, String username, Result<JSONObject> result);
//--- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能细节实现 ---
/**
@ -411,4 +419,27 @@ public interface ISysUserService extends IService<SysUser> {
* @return
*/
Result<?> importAppUser(HttpServletRequest request);
/**
* 验证用户是否为管理员
* @param ids
*/
void checkUserAdminRejectDel(String ids);
/**
* 修改手机号
*
* @param json
* @param username
*/
void changePhone(JSONObject json, String username);
/**
* 发送短信验证码
*
* @param jsonObject
* @param username 用户名
* @param ipAddress ip地址
*/
void sendChangePhoneSms(JSONObject jsonObject, String username, String ipAddress);
}

View File

@ -35,7 +35,7 @@ public interface ISysUserTenantService extends IService<SysUserTenant> {
List<SysUser> setUserTenantIds(List<SysUser> records);
/**
* 获取户id根据用户id
* 获取户id获取用户ids
* @param tenantId
* @return
*/
@ -120,4 +120,12 @@ public interface ISysUserTenantService extends IService<SysUserTenant> {
* @return
*/
SysUserTenant getUserTenantByTenantId(String userId, Integer tenantId);
/**
* 获取租户下的成员数量
* @param tenantId
* @param tenantStatus
* @return
*/
Long getUserCount(Integer tenantId, String tenantStatus);
}

View File

@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateRangeUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.security.utils.SecureUtil;
@ -63,7 +65,12 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe
sysAnnouncementMapper.insert(sysAnnouncement);
// 2.插入用户通告阅读标记表记录
String userId = sysAnnouncement.getUserIds();
String[] userIds = userId.substring(0, (userId.length()-1)).split(",");
//update-begin-author:liusq---date:2023-10-31--for:[issues/5503]【公告】通知无法接收
if(StringUtils.isNotBlank(userId) && userId.endsWith(",")){
userId = userId.substring(0, (userId.length()-1));
}
String[] userIds = userId.split(",");
//update-end-author:liusq---date:2023-10-31--for:[issues/5503]【公告】通知无法接收
String anntId = sysAnnouncement.getId();
Date refDate = new Date();
for(int i=0;i<userIds.length;i++) {
@ -135,14 +142,19 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe
}
@Override
public Page<SysAnnouncement> querySysCementPageByUserId(Page<SysAnnouncement> page, String userId, String msgCategory) {
public Page<SysAnnouncement> querySysCementPageByUserId(Page<SysAnnouncement> page, String userId, String msgCategory, Integer tenantId, Date beginDate) {
if (page.getSize() == -1) {
return page.setRecords(sysAnnouncementMapper.querySysCementListByUserId(null, userId, msgCategory));
return page.setRecords(sysAnnouncementMapper.querySysCementListByUserId(null, userId, msgCategory,tenantId,beginDate));
} else {
return page.setRecords(sysAnnouncementMapper.querySysCementListByUserId(page, userId, msgCategory));
return page.setRecords(sysAnnouncementMapper.querySysCementListByUserId(page, userId, msgCategory,tenantId,beginDate));
}
}
@Override
public Integer getUnreadMessageCountByUserId(String userId, Date beginDate) {
return sysAnnouncementMapper.getUnreadMessageCountByUserId(userId, beginDate);
}
@Override
public void completeAnnouncementSendInfo() {
LoginUser sysUser = SecureUtil.currentUser();

View File

@ -22,7 +22,6 @@ import org.jeecg.common.api.dto.OnlineAuthDTO;
import org.jeecg.common.api.dto.message.*;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.UrlMatchEnum;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.EmailTemplateEnum;
import org.jeecg.common.constant.enums.MessageTypeEnum;
@ -34,7 +33,8 @@ import org.jeecg.common.system.query.QueryCondition;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.system.vo.*;
import org.jeecg.common.util.*;
import org.jeecg.common.util.HTMLUtils;
import org.jeecg.common.util.YouBianCodeUtil;
import org.jeecg.common.util.dynamic.db.FreemarkerParseFactory;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.firewall.SqlInjection.IDictTableWhiteListHandler;
@ -59,6 +59,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.CollectionUtils;
import org.springframework.util.PathMatcher;
import jakarta.annotation.Resource;
@ -125,8 +126,6 @@ public class SysBaseApiImpl implements ISysBaseAPI {
@Autowired
private ISysDataLogService sysDataLogService;
@Autowired
private ISysFilesService sysFilesService;
@Autowired
private ISysRoleService sysRoleService;
@Autowired
private ISysUserTenantService sysUserTenantService;
@ -160,6 +159,18 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return user;
}
@Override
@Cacheable(cacheNames=CommonConstant.SYS_USER_ID_MAPPING_CACHE, key="#username")
public String getUserIdByName(String username) {
if (oConvertUtils.isEmpty(username)) {
return null;
}
String userId = userMapper.getUserIdByName(username);
return userId;
}
@Override
public LoginUser getUserByPhone(String phone) {
if (oConvertUtils.isEmpty(phone)) {
@ -281,9 +292,12 @@ public class SysBaseApiImpl implements ISysBaseAPI {
// }
if(user!=null) {
info.setSysUserId(user.getId());
info.setSysUserCode(user.getUsername());
info.setSysUserName(user.getRealname());
info.setSysOrgCode(user.getOrgCode());
info.setSysOrgId(user.getOrgId());
info.setSysRoleCode(user.getRoleCode());
}else{
return null;
}
@ -327,6 +341,11 @@ public class SysBaseApiImpl implements ISysBaseAPI {
public List<String> getRolesByUsername(String username) {
return sysUserRoleMapper.getRoleByUserName(username);
}
@Override
public List<String> getRolesByUserId(String userId) {
return sysUserRoleMapper.getRoleCodeByUserId(userId);
}
@Override
public List<String> getDepartIdsByUsername(String username) {
@ -337,6 +356,35 @@ public class SysBaseApiImpl implements ISysBaseAPI {
}
return result;
}
@Override
public List<String> getDepartIdsByUserId(String userId) {
return sysDepartService.queryDepartsByUserId(userId);
}
@Override
public Set<String> getDepartParentIdsByUsername(String username) {
List<SysDepart> list = sysDepartService.queryDepartsByUsername(username);
Set<String> result = new HashSet<>(list.size());
for (SysDepart depart : list) {
result.add(depart.getParentId());
}
return result;
}
@Override
public Set<String> getDepartParentIdsByDepIds(Set<String> depIds) {
LambdaQueryWrapper<SysDepart> departQuery = new LambdaQueryWrapper<SysDepart>().in(SysDepart::getId, depIds);
List<SysDepart> departList = departMapper.selectList(departQuery);
if(CollectionUtils.isEmpty(departList)){
return null;
}
Set<String> parentIds = departList.stream()
.map(SysDepart::getParentId)
.collect(Collectors.toSet());
return parentIds;
}
@Override
public List<String> getDepartNamesByUsername(String username) {
@ -1084,16 +1132,30 @@ public class SysBaseApiImpl implements ISysBaseAPI {
log.info("-------通过数据库读取用户拥有的角色Rules------username " + username + ",Roles size: " + (roles == null ? 0 : roles.size()));
return new HashSet<>(roles);
}
/**
* 查询用户拥有的权限集合
* @param username
* 查询用户拥有的角色集合
* @param useId
* @return
*/
@Override
public Set<String> getUserPermissionSet(String username) {
public Set<String> getUserRoleSetById(String useId) {
// 查询用户拥有的角色集合
List<String> roles = sysUserRoleMapper.getRoleCodeByUserId(useId);
log.info("-------通过数据库读取用户拥有的角色Rules------useId " + useId + ",Roles size: " + (roles == null ? 0 : roles.size()));
return new HashSet<>(roles);
}
/**
* 查询用户拥有的权限集合
* @param userId
* @return
*/
@Override
public Set<String> getUserPermissionSet(String userId) {
Set<String> permissionSet = new HashSet<>();
List<SysPermission> permissionList = sysPermissionMapper.queryByUser(username);
List<SysPermission> permissionList = sysPermissionMapper.queryByUser(userId);
//================= begin 开启租户的时候 如果没有test角色默认加入test角色================
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
if (permissionList == null) {
@ -1112,7 +1174,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
permissionSet.add(po.getPerms());
}
}
log.info("-------通过数据库读取用户拥有的权限Perms------username "+ username+",Perms size: "+ (permissionSet==null?0:permissionSet.size()) );
log.info("-------通过数据库读取用户拥有的权限Perms------userId "+ userId+",Perms size: "+ (permissionSet==null?0:permissionSet.size()) );
return permissionSet;
}
@ -1137,7 +1199,13 @@ public class SysBaseApiImpl implements ISysBaseAPI {
sysPermission.setUrl(onlineFormUrl);
int count = sysPermissionMapper.queryCountByUsername(username, sysPermission);
if(count<=0){
return false;
//update-begin---author:chenrui ---date:20240123 for[QQYUN-7992]【online】工单申请下的online表单未配置online表单开发菜单操作报错无权限------------
sysPermission.setUrl(onlineAuthDTO.getOnlineWorkOrderUrl());
count = sysPermissionMapper.queryCountByUsername(username, sysPermission);
if(count<=0) {
return false;
}
//update-end---author:chenrui ---date:20240123 for[QQYUN-7992]【online】工单申请下的online表单未配置online表单开发菜单操作报错无权限------------
}
} else {
//找到菜单了
@ -1161,14 +1229,19 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return getUserRoleSet(username);
}
@Override
public Set<String> queryUserRolesById(String userId) {
return getUserRoleSetById(userId);
}
/**
* 查询用户拥有的权限集合 common api 里面的接口实现
* @param username
* @param userId
* @return
*/
@Override
public Set<String> queryUserAuths(String username) {
return getUserPermissionSet(username);
public Set<String> queryUserAuths(String userId) {
return getUserPermissionSet(userId);
}
/**
@ -1403,6 +1476,11 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return sysCategoryService.loadDictItem(ids, false);
}
@Override
public List<String> loadCategoryDictItemByNames(String names, boolean delNotExist) {
return sysCategoryService.loadDictItemByNames(names, delNotExist);
}
/**
* 根据字典code加载字典text
*
@ -1476,13 +1554,17 @@ public class SysBaseApiImpl implements ISysBaseAPI {
public Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys) {
List<String> dictCodeList = Arrays.asList(dictCodes.split(","));
List<String> values = Arrays.asList(keys.split(","));
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
return sysDictService.queryManyDictByKeys(dictCodeList, values);
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
}
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
@Override
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys) {
return sysDictService.queryTableDictTextByKeys(table, text, code, Arrays.asList(keys.split(",")));
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys, String dataSource) {
return sysDictService.queryTableDictTextByKeys(table, text, code, Arrays.asList(keys.split(",")), dataSource);
}
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
@Override
public Map<String, List<DictModel>> queryAllDictItems() {
@ -1586,41 +1668,33 @@ public class SysBaseApiImpl implements ISysBaseAPI {
@Override
public void saveDataLog(DataLogDTO dataLogDto) {
SysDataLog entity = new SysDataLog();
entity.setDataTable(dataLogDto.getTableName());
entity.setDataId(dataLogDto.getDataId());
entity.setDataContent(dataLogDto.getContent());
entity.setType(dataLogDto.getType());
entity.setDataVersion("1");
entity.autoSetCreateName();
sysDataLogService.save(entity);
try {
SysDataLog entity = new SysDataLog();
entity.setDataTable(dataLogDto.getTableName());
entity.setDataId(dataLogDto.getDataId());
entity.setDataContent(dataLogDto.getContent());
entity.setType(dataLogDto.getType());
entity.setDataVersion("1");
if (oConvertUtils.isNotEmpty(dataLogDto.getCreateName())) {
entity.setCreateBy(dataLogDto.getCreateName());
} else {
entity.autoSetCreateName();
}
sysDataLogService.save(entity);
} catch (Exception e) {
log.warn(e.getMessage(), e);
//e.printStackTrace();
}
}
@Override
public void addSysFiles(SysFilesModel sysFilesModel) {
SysFiles sysFiles = new SysFiles();
BeanUtils.copyProperties(sysFilesModel,sysFiles);
String defaultValue = "0";
sysFiles.setIzStar(defaultValue);
sysFiles.setIzFolder(defaultValue);
sysFiles.setIzRootFolder(defaultValue);
sysFiles.setDelFlag(defaultValue);
String tenantId = oConvertUtils.getString(TenantContext.getTenant());
sysFiles.setTenantId(tenantId);
sysFilesService.save(sysFiles);
}
@Override
public String getFileUrl(String fileId) {
SysFiles sysFiles = sysFilesService.getById(fileId);
return sysFiles.getUrl();
}
@Override
public void updateAvatar(LoginUser loginUser) {
SysUser sysUser = new SysUser();
BeanUtils.copyProperties(loginUser, sysUser);
sysUserService.updateById(sysUser);
SysUser sysUser = new SysUser();
// 创建UpdateWrapper对象
UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", loginUser.getId()); // 设置更新条件
sysUser.setAvatar(loginUser.getAvatar()); // 设置要更新的字段
sysUserService.update(sysUser, updateWrapper);
}
@Override

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.FillRuleConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.exception.JeecgBootException;
@ -18,10 +17,7 @@ import org.jeecg.modules.system.service.ISysCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -235,4 +231,22 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
return textList;
}
@Override
public List<String> loadDictItemByNames(String names, boolean delNotExist) {
List<String> nameList = Arrays.asList(names.split(SymbolConstant.COMMA));
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
query.select(SysCategory::getId, SysCategory::getName);
query.in(SysCategory::getName, nameList);
// 查询数据
List<SysCategory> list = super.list(query);
// 取出id并返回
return nameList.stream().map(name -> {
SysCategory res = list.stream().filter(i -> name.equals(i.getName())).findFirst().orElse(null);
if (res == null) {
return delNotExist ? null : name;
}
return res.getId();
}).filter(Objects::nonNull).collect(Collectors.toList());
}
}

View File

@ -12,14 +12,13 @@ import org.jeecg.common.constant.enums.FileTypeEnum;
import org.jeecg.common.constant.enums.MessageTypeEnum;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.SysFilesModel;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysComment;
import org.jeecg.modules.system.entity.SysFiles;
import org.jeecg.modules.system.entity.SysFormFile;
import org.jeecg.modules.system.mapper.SysCommentMapper;
import org.jeecg.modules.system.mapper.SysFilesMapper;
import org.jeecg.modules.system.mapper.SysFormFileMapper;
import org.jeecg.modules.system.service.ISysCommentService;
import org.jeecg.modules.system.vo.SysCommentFileVo;
@ -55,8 +54,8 @@ public class SysCommentServiceImpl extends ServiceImpl<SysCommentMapper, SysComm
@Autowired
private SysFormFileMapper sysFormFileMapper;
@Autowired
private SysFilesMapper sysFilesMapper;
// @Autowired
// private IEasyOaBaseApi easyOaBseApi;
@Autowired
private RedisUtil redisUtil;
@ -158,7 +157,7 @@ public class SysCommentServiceImpl extends ServiceImpl<SysCommentMapper, SysComm
FileTypeEnum fileType = FileTypeEnum.getByType(type);
//保存至 SysFiles
SysFiles sysFiles = new SysFiles();
SysFilesModel sysFiles = new SysFilesModel();
sysFiles.setFileName(orgName);
sysFiles.setUrl(savePath);
sysFiles.setFileType(fileType.getValue());
@ -166,16 +165,13 @@ public class SysCommentServiceImpl extends ServiceImpl<SysCommentMapper, SysComm
if (size > 0) {
sysFiles.setFileSize(Double.parseDouble(String.valueOf(size)));
}
String defaultValue = "0";
sysFiles.setIzStar(defaultValue);
sysFiles.setIzFolder(defaultValue);
sysFiles.setIzRootFolder(defaultValue);
sysFiles.setDelFlag(defaultValue);
String fileId = String.valueOf(IdWorker.getId());
sysFiles.setId(fileId);
String tenantId = oConvertUtils.getString(TenantContext.getTenant());
sysFiles.setTenantId(tenantId);
sysFilesMapper.insert(sysFiles);
// //update-begin---author:wangshuai---date:2024-01-04---for:【QQYUN-7821】知识库后端迁移---
// easyOaBseApi.addSysFiles(sysFiles);
// //update-end---author:wangshuai---date:2024-01-04---for:【QQYUN-7821】知识库后端迁移---
//保存至 SysFormFile
String tableName = SYS_FORM_FILE_TABLE_NAME;
@ -188,18 +184,20 @@ public class SysCommentServiceImpl extends ServiceImpl<SysCommentMapper, SysComm
sysFormFileMapper.insert(sysFormFile);
}else{
SysFiles sysFiles = sysFilesMapper.selectById(existFileId);
if(sysFiles!=null){
// //update-begin---author:wangshuai---date:2024-01-04---for:【QQYUN-7821】知识库后端迁移---
// SysFilesModel sysFiles = easyOaBseApi.getFileById(existFileId);
// //update-end---author:wangshuai---date:2024-01-04---for:【QQYUN-7821】知识库后端迁移---
// if(sysFiles!=null){
//保存至 SysFormFile
String tableName = SYS_FORM_FILE_TABLE_NAME;
String tableDataId = request.getParameter("commentId");
SysFormFile sysFormFile = new SysFormFile();
sysFormFile.setTableName(tableName);
sysFormFile.setFileType(sysFiles.getFileType());
sysFormFile.setFileType("");
sysFormFile.setTableDataId(tableDataId);
sysFormFile.setFileId(existFileId);
sysFormFileMapper.insert(sysFormFile);
}
// }
}
//update-end-author:taoyan date:2023-6-12 for: QQYUN-4310【文件】从文件库选择文件功能未做
}
@ -224,7 +222,7 @@ public class SysCommentServiceImpl extends ServiceImpl<SysCommentMapper, SysComm
FileTypeEnum fileType = FileTypeEnum.getByType(type);
//保存至 SysFiles
SysFiles sysFiles = new SysFiles();
SysFilesModel sysFiles = new SysFilesModel();
sysFiles.setFileName(orgName);
sysFiles.setUrl(savePath);
sysFiles.setFileType(fileType.getValue());
@ -233,16 +231,13 @@ public class SysCommentServiceImpl extends ServiceImpl<SysCommentMapper, SysComm
sysFiles.setFileSize(Double.parseDouble(String.valueOf(size)));
}
String defaultValue = "0";
sysFiles.setIzStar(defaultValue);
sysFiles.setIzFolder(defaultValue);
sysFiles.setIzRootFolder(defaultValue);
sysFiles.setDelFlag(defaultValue);
String fileId = String.valueOf(IdWorker.getId());
sysFiles.setId(fileId);
String tenantId = oConvertUtils.getString(TenantContext.getTenant());
sysFiles.setTenantId(tenantId);
sysFilesMapper.insert(sysFiles);
// //update-begin---author:wangshuai---date:2024-01-04---for:【QQYUN-7821】知识库后端迁移---
// easyOaBseApi.addSysFiles(sysFiles);
// //update-end---author:wangshuai---date:2024-01-04---for:【QQYUN-7821】知识库后端迁移---
//保存至 SysFormFile
String tableName = SYS_FORM_FILE_TABLE_NAME;
String tableDataId = request.getParameter("commentId");

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -29,6 +30,7 @@ import org.jeecg.modules.system.model.DepartIdModel;
import org.jeecg.modules.system.model.SysDepartTreeModel;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.util.FindsDepartsChildrenUtil;
import org.jeecg.modules.system.vo.SysDepartExportVo;
import org.jeecg.modules.system.vo.lowapp.ExportDepartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
@ -71,6 +73,11 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
//根据部门id获取所负责部门
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
String[] codeArr = this.getMyDeptParentOrgCode(departIds);
//update-begin---author:wangshuai---date:2023-12-01---for:【QQYUN-7320】查询部门没数据导致报错空指针---
if(ArrayUtil.isEmpty(codeArr)){
return null;
}
//update-end---author:wangshuai---date:2023-12-01---for:【QQYUN-7320】查询部门没数据导致报错空指针---
for(int i=0;i<codeArr.length;i++){
query.or().likeRight(SysDepart::getOrgCode,codeArr[i]);
}
@ -199,6 +206,14 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
//新添加的部门是叶子节点
sysDepart.setIzLeaf(CommonConstant.IS_LEAF);
// 【QQYUN-7172】数据库默认值兼容
if (oConvertUtils.isEmpty(sysDepart.getOrgCategory())) {
if (oConvertUtils.isEmpty(sysDepart.getParentId())) {
sysDepart.setOrgCategory("1");
} else {
sysDepart.setOrgCategory("2");
}
}
this.save(sysDepart);
//update-begin---author:wangshuai ---date:20220307 for[JTC-119]在部门管理菜单下设置部门负责人 创建用户的时候不需要处理
//新增部门的时候新增负责部门
@ -477,6 +492,12 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
public List<SysDepart> queryDepartsByUsername(String username) {
return baseMapper.queryDepartsByUsername(username);
}
@Override
public List<String> queryDepartsByUserId(String userId) {
List<String> list = baseMapper.queryDepartsByUserId(userId);
return list;
}
/**
* 根据用户所负责部门ids获取父级部门编码
@ -487,7 +508,10 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
//根据部门id查询所负责部门
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
query.in(SysDepart::getId, Arrays.asList(departIds.split(",")));
if(oConvertUtils.isNotEmpty(departIds)){
query.in(SysDepart::getId, Arrays.asList(departIds.split(",")));
}
//------------------------------------------------------------------------------------------------
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
@ -1197,4 +1221,169 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
}
}
}
//========================begin 系统下部门与人员导入 ==================================================================
/**
* 系统部门导出
* @param tenantId
* @return
*/
@Override
public List<SysDepartExportVo> getExportDepart(Integer tenantId) {
//获取父级部门
List<SysDepartExportVo> parentDepart = departMapper.getSysDepartList("", tenantId);
//子部门
List<SysDepartExportVo> childrenDepart = new ArrayList<>();
//把一级部门名称放在里面
List<SysDepartExportVo> exportDepartVoList = new ArrayList<>();
//存放部门一级id避免重复
List<String> departIdList = new ArrayList<>();
for (SysDepartExportVo sysDepart : parentDepart) {
//step 1.添加第一级部门
departIdList.add(sysDepart.getId());
sysDepart.setDepartNameUrl(sysDepart.getDepartName());
exportDepartVoList.add(sysDepart);
//step 2.添加自己部门路径,用/分离
//创建路径
List<String> path = new ArrayList<>();
path.add(sysDepart.getDepartName());
//创建子部门路径
findSysDepartPath(sysDepart, path, tenantId, childrenDepart, departIdList);
path.clear();
}
exportDepartVoList.addAll(childrenDepart);
childrenDepart.clear();
departIdList.clear();
return exportDepartVoList;
}
/**
* 系统部门导入
* @param listSysDeparts
* @param errorMessageList
*/
@Override
public void importSysDepart(List<SysDepartExportVo> listSysDeparts, List<String> errorMessageList) {
int num = 0;
int tenantId = 0;
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
}
//部门路径排序
Collections.sort(listSysDeparts, new Comparator<SysDepartExportVo>() {
@Override
public int compare(SysDepartExportVo o1, SysDepartExportVo o2) {
if(oConvertUtils.isNotEmpty(o1.getDepartNameUrl()) && oConvertUtils.isNotEmpty(o2.getDepartNameUrl())){
int oldLength = o1.getDepartNameUrl().split(SymbolConstant.SINGLE_SLASH).length;
int newLength = o2.getDepartNameUrl().split(SymbolConstant.SINGLE_SLASH).length;
return oldLength - newLength;
}else{
return 0;
}
}
});
//存放部门数据的map
Map<String,SysDepart> departMap = new HashMap<>();
// orgCode编码长度
int codeLength = YouBianCodeUtil.ZHANWEI_LENGTH;
//循环第二遍导入数据
for (SysDepartExportVo departExportVo : listSysDeparts) {
SysDepart sysDepart = new SysDepart();
boolean izExport = false;
try {
izExport = this.addDepartByName(departExportVo.getDepartNameUrl(),departExportVo.getDepartName(),sysDepart,errorMessageList,tenantId,departMap,num);
} catch (Exception e) {
//没有查找到parentDept
}
//没有错误的时候才会导入数据
if(izExport){
if(oConvertUtils.isNotEmpty(departExportVo.getOrgCode())){
SysDepart depart = this.baseMapper.queryCompByOrgCode(departExportVo.getOrgCode());
if(null != depart){
if(oConvertUtils.isNotEmpty(sysDepart.getParentId())){
//更新上级部门为叶子节点
this.updateIzLeaf(sysDepart.getParentId(),CommonConstant.IS_LEAF);
}
//部门名称已存在
errorMessageList.add("" + num + " 行:记录部门名称“"+departExportVo.getDepartName()+"”部门编码重复,请检查!");
continue;
}
String departNameUrl = departExportVo.getDepartNameUrl();
//包含/说明是多级
if(departNameUrl.contains(SymbolConstant.SINGLE_SLASH)){
//判断添加部门的规则是否和生成的一致
if(!sysDepart.getOrgCode().equals(departExportVo.getOrgCode())){
if(oConvertUtils.isNotEmpty(sysDepart.getParentId())){
//更新上级部门为叶子节点
this.updateIzLeaf(sysDepart.getParentId(),CommonConstant.IS_LEAF);
}
//部门名称已存在
errorMessageList.add("" + num + " 行:记录部门名称“"+departExportVo.getDepartName()+"”部门编码规则不匹配,请检查!");
continue;
}
}
sysDepart.setOrgCode(departExportVo.getOrgCode());
if(oConvertUtils.isNotEmpty(sysDepart.getParentId())){
//上级
sysDepart.setOrgType("2");
}else{
//下级
sysDepart.setOrgType("1");
}
}else{
sysDepart.setOrgType(sysDepart.getOrgCode().length()/codeLength+"");
}
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
sysDepart.setDepartNameEn(departExportVo.getDepartNameEn());
sysDepart.setDepartOrder(departExportVo.getDepartOrder());
sysDepart.setOrgCategory(oConvertUtils.getString(departExportVo.getOrgCategory(),"1"));
sysDepart.setMobile(departExportVo.getMobile());
sysDepart.setFax(departExportVo.getFax());
sysDepart.setAddress(departExportVo.getAddress());
sysDepart.setMemo(departExportVo.getMemo());
ImportExcelUtil.importDateSaveOne(sysDepart, ISysDepartService.class, errorMessageList, num, CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE);
departMap.put(departExportVo.getDepartNameUrl(),sysDepart);
}
num++;
}
}
/**
* 寻找部门路径
*
* @param departVo 部门vo
* @param path 部门路径
* @param tenantId 租户id
* @param childrenDepart 子部门
* @param departIdList 部门id集合
*/
private void findSysDepartPath(SysDepartExportVo departVo, List<String> path, Integer tenantId, List<SysDepartExportVo> childrenDepart, List<String> departIdList) {
//step 1.查询子部门的数据
//获取租户id和部门父id获取的部门数据
List<SysDepartExportVo> departList = departMapper.getSysDepartList(departVo.getId(), tenantId);
//部门为空判断
if (departList == null || departList.size() <= 0) {
//判断最后一个子部门是否已拼接
if (!departIdList.contains(departVo.getId())) {
departVo.setDepartNameUrl(String.join(SymbolConstant.SINGLE_SLASH, path));
childrenDepart.add(departVo);
}
return;
}
for (SysDepartExportVo exportDepartVo : departList) {
//存放子级路径
List<String> cPath = new ArrayList<>(path);
cPath.add(exportDepartVo.getDepartName());
//step 2.拼接子部门路径
if (!departIdList.contains(departVo.getId())) {
departIdList.add(departVo.getId());
departVo.setDepartNameUrl(String.join(SymbolConstant.SINGLE_SLASH, path));
childrenDepart.add(departVo);
}
//step 3.递归查询子路径,直到找不到为止
findSysDepartPath(exportDepartVo, cPath, tenantId, childrenDepart, departIdList);
}
}
//========================end 系统下部门与人员导入 ==================================================================
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.system.service.impl;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -20,6 +21,7 @@ import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.DictModelMany;
import org.jeecg.common.system.vo.DictQuery;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.SqlInjectionUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
@ -66,6 +68,9 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Lazy
@Autowired
private ISysBaseAPI sysBaseAPI;
@Lazy
@Autowired
private RedisUtil redisUtil;
@Override
public boolean duplicateCheckData(DuplicateCheckVo duplicateCheckVo) {
@ -79,7 +84,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
// 2.SQL注入check只限制非法串改数据库
//关联表字典举例sys_user,realname,id
SqlInjectionUtil.filterContent(table, fieldName);
SqlInjectionUtil.filterContentMulti(table, fieldName);
String checkSql = table + SymbolConstant.COMMA + fieldName + SymbolConstant.COMMA;
// 【QQYUN-6533】表字典白名单check
@ -151,37 +156,36 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
public Map<String, List<DictModel>> queryAllDictItems() {
Map<String, List<DictModel>> res = new HashMap(5);
LambdaQueryWrapper<SysDict> sysDictQueryWrapper = new LambdaQueryWrapper<SysDict>();
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
long start = System.currentTimeMillis();
Map<String, List<DictModel>> sysAllDictItems = new HashMap(5);
List<Integer> tenantIds = null;
//------------------------------------------------------------------------------------------------
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
sysDictQueryWrapper.eq(SysDict::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0))
.or().eq(SysDict::getTenantId,0);
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
tenantIds = new ArrayList<>();
tenantIds.add(0);
if (TenantContext.getTenant() != null) {
tenantIds.add(oConvertUtils.getInt(TenantContext.getTenant()));
}
}
//------------------------------------------------------------------------------------------------
List<SysDict> ls = sysDictMapper.selectList(sysDictQueryWrapper);
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
queryWrapper.eq(SysDictItem::getStatus, 1);
queryWrapper.orderByAsc(SysDictItem::getSortOrder);
List<SysDictItem> sysDictItemList = sysDictItemMapper.selectList(queryWrapper);
List<DictModelMany> sysDictItemList = sysDictMapper.queryAllDictItems(tenantIds);
// 使用groupingBy根据dictCode分组
sysAllDictItems = sysDictItemList.stream()
.collect(Collectors.groupingBy(DictModelMany::getDictCode,
Collectors.mapping(d -> new DictModel(d.getValue(), d.getText(), d.getColor()), Collectors.toList())));
log.info(" >>> 1 获取系统字典项耗时SQL" + (System.currentTimeMillis() - start) + "毫秒");
for (SysDict d : ls) {
List<DictModel> dictModelList = sysDictItemList.stream().filter(s -> d.getId().equals(s.getDictId())).map(item -> {
DictModel dictModel = new DictModel();
dictModel.setText(item.getItemText());
dictModel.setValue(item.getItemValue());
return dictModel;
}).collect(Collectors.toList());
res.put(d.getDictCode(), dictModelList);
}
//update-begin-author:taoyan date:2022-7-8 for: 系统字典数据应该包括自定义的java类-枚举
Map<String, List<DictModel>> enumRes = ResourceUtil.getEnumDictData();
res.putAll(enumRes);
//update-end-author:taoyan date:2022-7-8 for: 系统字典数据应该包括自定义的java类-枚举
log.debug("-------登录加载系统字典-----" + res.toString());
return res;
sysAllDictItems.putAll(enumRes);
log.info(" >>> 2 获取系统字典项耗时Enum" + (System.currentTimeMillis() - start) + "毫秒");
log.info(" >>> end 获取系统字典库总耗时:" + (System.currentTimeMillis() - start) + "毫秒");
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
//log.info("-------登录加载系统字典-----" + sysAllDictItems.toString());
return sysAllDictItems;
}
/**
@ -246,7 +250,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
// 3.SQL注入check
SqlInjectionUtil.filterContent(table, text, code);
SqlInjectionUtil.filterContentMulti(table, text, code);
SqlInjectionUtil.specialFilterContentForDictSql(filterSql);
// 4.针对采用 ${}写法的表名和字段进行转义和check
@ -265,7 +269,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
// 1.SQL注入校验只限制非法串改数据库
SqlInjectionUtil.specialFilterContentForDictSql(table);
SqlInjectionUtil.filterContent(text, code);
SqlInjectionUtil.filterContentMulti(text, code);
SqlInjectionUtil.specialFilterContentForDictSql(filterSql);
String str = table+","+text+","+code;
@ -308,7 +312,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
return null;
}
// 2.sql注入check
SqlInjectionUtil.filterContent(table, text, code, key);
SqlInjectionUtil.filterContentMulti(table, text, code, key);
// 3.针对采用 ${}写法的表名和字段进行转义和check
table = SqlInjectionUtil.getSqlInjectTableName(table);
@ -327,15 +331,22 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
@Override
public List<DictModel> queryTableDictTextByKeys(String table, String text, String code, List<String> codeValues) {
public List<DictModel> queryTableDictTextByKeys(String table, String text, String code, List<String> codeValues, String dataSource) {
String str = table+","+text+","+code;
// 【QQYUN-6533】表字典白名单check
sysBaseAPI.dictTableWhiteListCheckByDict(table, text, code);
// 1.表字典黑名单check
if(!dictQueryBlackListHandler.isPass(str)){
log.error(dictQueryBlackListHandler.getError());
return null;
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
// 是否自定义数据源
boolean isCustomDataSource = oConvertUtils.isNotEmpty(dataSource);
// 如果是自定义数据源就不检查表字典白名单
if (!isCustomDataSource) {
// 【QQYUN-6533】表字典白名单check
sysBaseAPI.dictTableWhiteListCheckByDict(table, text, code);
// 1.表字典黑名单check
if (!dictQueryBlackListHandler.isPass(str)) {
log.error(dictQueryBlackListHandler.getError());
return null;
}
}
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
// 2.分割SQL获取表名和条件
String filterSql = null;
@ -346,15 +357,26 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
// 3.SQL注入check
SqlInjectionUtil.filterContent(table, text, code);
SqlInjectionUtil.filterContentMulti(table, text, code);
SqlInjectionUtil.specialFilterContentForDictSql(filterSql);
// 4.针对采用 ${}写法的表名和字段进行转义和check
table = SqlInjectionUtil.getSqlInjectTableName(table);
text = SqlInjectionUtil.getSqlInjectField(text);
code = SqlInjectionUtil.getSqlInjectField(code);
return sysDictMapper.queryTableDictByKeysAndFilterSql(table, text, code, filterSql, codeValues);
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
// 切换为字典表的数据源
if (isCustomDataSource) {
DynamicDataSourceContextHolder.push(dataSource);
}
List<DictModel> restData = sysDictMapper.queryTableDictByKeysAndFilterSql(table, text, code, filterSql, codeValues);
// 清理自定义的数据源
if (isCustomDataSource) {
DynamicDataSourceContextHolder.clear();
}
return restData;
//update-end---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
//update-end-author:taoyan date:20220113 for: @dict注解支持 dicttable 设置where条件
}
@ -397,7 +419,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
// 2.SQL注入check
SqlInjectionUtil.filterContent(table, text, code);
SqlInjectionUtil.filterContentMulti(table, text, code);
SqlInjectionUtil.specialFilterContentForDictSql(filterSql);
String str = table+","+text+","+code;
@ -513,10 +535,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
String filterSql = "";
String keywordSql = null;
String sqlWhere = "where ";
String sqlAnd = " and ";
//【JTC-631】判断如果 table 携带了 where 条件,那么就使用 and 查询,防止报错
if (tableSql.toLowerCase().contains(sqlWhere)) {
sqlWhere = CommonUtils.getFilterSqlByTableSql(tableSql) + " and ";
boolean tableHasWhere = tableSql.toLowerCase().contains(sqlWhere);
if (tableHasWhere) {
sqlWhere = CommonUtils.getFilterSqlByTableSql(tableSql);
}
// 下拉搜索组件 支持传入排序信息 查询排序
@ -546,14 +570,17 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
//下拉搜索组件 支持传入排序信息 查询排序
if(oConvertUtils.isNotEmpty(condition) && oConvertUtils.isNotEmpty(keywordSql)){
filterSql+= sqlWhere + condition + " and " + keywordSql;
}else if(oConvertUtils.isNotEmpty(condition)){
filterSql+= sqlWhere + condition;
}else if(oConvertUtils.isNotEmpty(keywordSql)){
filterSql+= sqlWhere + keywordSql;
}
//update-begin---author:chenrui ---date:20240327 for[QQYUN-8514]Online表单中 下拉搜索框 搜索时报sql错误生成的SQL多了一个 “and" ------------
if (oConvertUtils.isNotEmpty(condition) && oConvertUtils.isNotEmpty(keywordSql)) {
filterSql += sqlWhere + (tableHasWhere ? sqlAnd : " ") + condition + sqlAnd + keywordSql;
} else if (oConvertUtils.isNotEmpty(condition)) {
filterSql += sqlWhere + (tableHasWhere ? sqlAnd : " ") + condition;
} else if (oConvertUtils.isNotEmpty(keywordSql)) {
filterSql += sqlWhere + (tableHasWhere ? sqlAnd : " ") + keywordSql;
} else if (tableHasWhere) {
filterSql += sqlWhere;
}
//update-end---author:chenrui ---date:20240327 for[QQYUN-8514]Online表单中 下拉搜索框 搜索时报sql错误生成的SQL多了一个 “and" ------------
// 增加排序逻辑
if (oConvertUtils.isNotEmpty(orderField)) {
filterSql += " order by " + orderField + " " + orderType;
@ -598,9 +625,15 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
pidField = SqlInjectionUtil.getSqlInjectField(pidField);
hasChildField = SqlInjectionUtil.getSqlInjectField(hasChildField);
if(oConvertUtils.isEmpty(text) || oConvertUtils.isEmpty(code)){
log.warn("text={}code={}", text, code);
log.warn("加载树字典参数有误text和code不允许为空");
return null;
}
// 2.检测最终SQL是否存在SQL注入风险
String dictCode = table + "," + text + "," + code;
SqlInjectionUtil.filterContent(dictCode);
SqlInjectionUtil.filterContentMulti(dictCode);
// 【QQYUN-6533】表字典白名单check
sysBaseAPI.dictTableWhiteListCheckByDict(table, text, code);
@ -634,7 +667,15 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
@Override
public List<SysDict> queryDeleteList() {
public List<SysDict> queryDeleteList(String tenantId) {
//update-begin---author:wangshuai---date:2024-02-27---for:【QQYUN-8340】回收站查找软删除记录时没有判断是否启用多租户造成可以查找并回收其他租户的数据 #5907---
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
if(oConvertUtils.isEmpty(tenantId)){
return new ArrayList<>();
}
return baseMapper.queryDeleteListBtTenantId(oConvertUtils.getInt(tenantId));
}
//update-end---author:wangshuai---date:2024-02-27---for:【QQYUN-8340】回收站查找软删除记录时没有判断是否启用多租户造成可以查找并回收其他租户的数据 #5907---
return baseMapper.queryDeleteList();
}
@ -661,7 +702,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
// 3.SQL注入check
SqlInjectionUtil.filterContent(dictCode);
SqlInjectionUtil.filterContentMulti(dictCode);
Page<DictModel> pageList = baseMapper.queryDictTablePageList(page, query);
return pageList.getRecords();
@ -789,6 +830,8 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
sysDict.setId(id);
baseMapper.updateById(sysDict);
this.updateDictItem(id,sysDictVo.getDictItemsList());
// 删除字典缓存
redisUtil.removeAll(CacheConstant.SYS_DICT_CACHE + "::" + dict.getDictCode());
}
/**

View File

@ -1,19 +0,0 @@
package org.jeecg.modules.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.system.entity.SysFiles;
import org.jeecg.modules.system.mapper.SysFilesMapper;
import org.jeecg.modules.system.service.ISysFilesService;
import org.springframework.stereotype.Service;
/**
* @Description: 知识库-文档管理
* @Author: jeecg-boot
* @Date: 2022-07-21
* @Version: V1.0
*/
@Service
public class SysFilesServiceImpl extends ServiceImpl<SysFilesMapper, SysFiles> implements ISysFilesService {
}

View File

@ -1,9 +1,8 @@
package org.jeecg.modules.system.service.impl;
import java.util.*;
import jakarta.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
@ -11,6 +10,7 @@ import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.modules.system.entity.SysPermission;
import org.jeecg.modules.system.entity.SysPermissionDataRule;
import org.jeecg.modules.system.entity.SysRoleIndex;
import org.jeecg.modules.system.mapper.SysDepartPermissionMapper;
import org.jeecg.modules.system.mapper.SysDepartRolePermissionMapper;
import org.jeecg.modules.system.mapper.SysPermissionMapper;
@ -18,14 +18,15 @@ import org.jeecg.modules.system.mapper.SysRolePermissionMapper;
import org.jeecg.modules.system.model.TreeModel;
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
import org.jeecg.modules.system.service.ISysPermissionService;
import org.jeecg.modules.system.service.ISysRoleIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import java.util.*;
/**
* <p>
@ -53,6 +54,9 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
@Resource
private SysDepartRolePermissionMapper sysDepartRolePermissionMapper;
@Autowired
private ISysRoleIndexService roleIndexService;
@Override
public void switchVue3Menu() {
sysPermissionMapper.backupVue2Menu();
@ -217,13 +221,21 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
}
}
// 同步更改默认菜单
SysRoleIndex defIndexCfg = this.roleIndexService.queryDefaultIndex();
boolean isDefIndex = defIndexCfg.getUrl().equals(p.getUrl());
if (isDefIndex) {
this.roleIndexService.updateDefaultIndex(sysPermission.getUrl(), sysPermission.getComponent(), sysPermission.isRoute());
}
}
}
@Override
public List<SysPermission> queryByUser(String username) {
List<SysPermission> permissionList = this.sysPermissionMapper.queryByUser(username);
public List<SysPermission> queryByUser(String userId) {
List<SysPermission> permissionList = this.sysPermissionMapper.queryByUser(userId);
//================= begin 开启租户的时候 如果没有test角色默认加入test角色================
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
if (permissionList == null) {

View File

@ -1,19 +1,91 @@
package org.jeecg.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.system.constant.DefIndexConst;
import org.jeecg.modules.system.entity.SysRoleIndex;
import org.jeecg.modules.system.mapper.SysRoleIndexMapper;
import org.jeecg.modules.system.service.ISysRoleIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 角色首页配置
* @Author: jeecg-boot
* @Date: 2022-03-25
* @Date: 2022-03-25
* @Version: V1.0
*/
@Service
@Service("sysRoleIndexServiceImpl")
public class SysRoleIndexServiceImpl extends ServiceImpl<SysRoleIndexMapper, SysRoleIndex> implements ISysRoleIndexService {
@Autowired
private RedisUtil redisUtil;
@Override
@Cacheable(cacheNames = DefIndexConst.CACHE_KEY, key = "'" + DefIndexConst.DEF_INDEX_ALL + "'")
public SysRoleIndex queryDefaultIndex() {
LambdaQueryWrapper<SysRoleIndex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysRoleIndex::getRoleCode, DefIndexConst.DEF_INDEX_ALL);
SysRoleIndex entity = super.getOne(queryWrapper);
// 保证不为空
if (entity == null) {
entity = this.initDefaultIndex();
}
return entity;
}
@Override
public boolean updateDefaultIndex(String url, String component, boolean isRoute) {
// 1. 先查询出配置信息
LambdaQueryWrapper<SysRoleIndex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysRoleIndex::getRoleCode, DefIndexConst.DEF_INDEX_ALL);
SysRoleIndex entity = super.getOne(queryWrapper);
boolean success = false;
// 2. 如果不存在则新增
if (entity == null) {
entity = this.newDefIndexConfig(url, component, isRoute);
success = super.save(entity);
} else {
// 3. 如果存在则更新
entity.setUrl(url);
entity.setComponent(component);
entity.setRoute(isRoute);
success = super.updateById(entity);
}
// 4. 清理缓存
if (success) {
this.cleanDefaultIndexCache();
}
return success;
}
@Override
public SysRoleIndex initDefaultIndex() {
return this.newDefIndexConfig(DefIndexConst.DEF_INDEX_URL, DefIndexConst.DEF_INDEX_COMPONENT, true);
}
/**
* 创建默认首页配置
*
* @param indexComponent
* @return
*/
private SysRoleIndex newDefIndexConfig(String indexUrl, String indexComponent, boolean isRoute) {
SysRoleIndex entity = new SysRoleIndex();
entity.setRoleCode(DefIndexConst.DEF_INDEX_ALL);
entity.setUrl(indexUrl);
entity.setComponent(indexComponent);
entity.setRoute(isRoute);
entity.setStatus(CommonConstant.STATUS_1);
return entity;
}
@Override
public void cleanDefaultIndexCache() {
redisUtil.del(DefIndexConst.CACHE_KEY + "::" + DefIndexConst.DEF_INDEX_ALL);
}
}

View File

@ -1,9 +1,12 @@
package org.jeecg.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.mapper.SysRoleMapper;
@ -102,4 +105,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
public Long getRoleCountByTenantId(String id, Integer tenantId) {
return sysRoleMapper.getRoleCountByTenantId(id,tenantId);
}
@Override
public void checkAdminRoleRejectDel(String ids) {
LambdaQueryWrapper<SysRole> query = new LambdaQueryWrapper<>();
query.in(SysRole::getId,Arrays.asList(ids.split(SymbolConstant.COMMA)));
query.eq(SysRole::getRoleCode,"admin");
Long adminRoleCount = sysRoleMapper.selectCount(query);
if(adminRoleCount>0){
throw new JeecgBootException("admin角色不允许删除");
}
}
}

View File

@ -115,10 +115,12 @@ public class SysTenantPackServiceImpl extends ServiceImpl<SysTenantPackMapper, S
@Override
@Transactional(rollbackFor = Exception.class)
public void deletePackPermissions(String ids) {
public void deleteTenantPack(String ids) {
String[] idsArray = ids.split(SymbolConstant.COMMA);
for (String id : idsArray) {
this.deletePackPermission(id,null);
//删除产品包下面的用户
this.deletePackUser(id);
sysTenantPackMapper.deleteById(id);
}
}
@ -130,25 +132,47 @@ public class SysTenantPackServiceImpl extends ServiceImpl<SysTenantPackMapper, S
@Override
public void addDefaultTenantPack(Integer tenantId) {
// 创建超级管理员
SysTenantPack superAdminPack = new SysTenantPack(tenantId, "超级管理员", TenantConstant.SUPER_ADMIN);
ISysTenantPackService currentService = SpringContextUtils.getApplicationContext().getBean(ISysTenantPackService.class);
String packId = currentService.saveOne(superAdminPack);
// 创建租户超级管理员
SysTenantPack superAdminPack = new SysTenantPack(tenantId, "超级管理员", TenantConstant.SUPER_ADMIN);
//step.1 创建租户套餐包(超级管理员)
LambdaQueryWrapper<SysTenantPack> query = new LambdaQueryWrapper<>();
query.eq(SysTenantPack::getTenantId,tenantId);
query.eq(SysTenantPack::getPackCode, TenantConstant.SUPER_ADMIN);
SysTenantPack sysTenantPackSuperAdmin = currentService.getOne(query);
String packId = "";
if(null == sysTenantPackSuperAdmin){
packId = currentService.saveOne(superAdminPack);
}else{
packId = sysTenantPackSuperAdmin.getId();
}
//step.1.2 补充人员与套餐包的关系数据
LoginUser sysUser = SecureUtil.currentUser();
SysTenantPackUser packUser = new SysTenantPackUser(tenantId, packId, sysUser.getId());
packUser.setRealname(sysUser.getRealname());
packUser.setPackName(superAdminPack.getPackName());
//添加人员和管理员的关系数据
currentService.savePackUser(packUser);
//step.2 创建租户套餐包(组织账户管理员)和 添加人员关系数据
query.eq(SysTenantPack::getTenantId,tenantId);
query.eq(SysTenantPack::getPackCode, TenantConstant.ACCOUNT_ADMIN);
SysTenantPack sysTenantPackAccountAdmin = currentService.getOne(query);
if(null == sysTenantPackAccountAdmin){
// 创建超级管理员
SysTenantPack accountAdminPack = new SysTenantPack(tenantId, "组织账户管理员", TenantConstant.ACCOUNT_ADMIN);
currentService.saveOne(accountAdminPack);
}
// 创建超级管理员
SysTenantPack accountAdminPack = new SysTenantPack(tenantId, "组织账户管理员", TenantConstant.ACCOUNT_ADMIN);
currentService.saveOne(accountAdminPack);
// 创建超级管理员
SysTenantPack appAdminPack = new SysTenantPack(tenantId, "组织应用管理员", TenantConstant.APP_ADMIN);
currentService.saveOne(appAdminPack);
//step.3 创建租户套餐包(组织应用管理员)
query.eq(SysTenantPack::getTenantId,tenantId);
query.eq(SysTenantPack::getPackCode, TenantConstant.APP_ADMIN);
SysTenantPack sysTenantPackAppAdmin = currentService.getOne(query);
if(null == sysTenantPackAppAdmin){
// 创建超级管理员
SysTenantPack appAdminPack = new SysTenantPack(tenantId, "组织应用管理员", TenantConstant.APP_ADMIN);
currentService.saveOne(appAdminPack);
}
}
@ -231,4 +255,13 @@ public class SysTenantPackServiceImpl extends ServiceImpl<SysTenantPackMapper, S
}
}
/**
* 删除产品包下面的用户
* @param packId
*/
private void deletePackUser(String packId) {
LambdaQueryWrapper<SysTenantPackUser> query = new LambdaQueryWrapper<>();
query.eq(SysTenantPackUser::getPackId, packId);
sysTenantPackUserMapper.delete(query);
}
}

View File

@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.message.BusMessageDTO;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.api.vo.Result;
@ -14,19 +16,19 @@ import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.exception.JeecgBootBizTipException;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.security.utils.SecureUtil;
import org.jeecg.modules.aop.TenantLog;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.mapper.SysTenantMapper;
import org.jeecg.modules.system.mapper.SysTenantPackUserMapper;
import org.jeecg.modules.system.mapper.SysUserDepartMapper;
import org.jeecg.modules.system.mapper.SysUserTenantMapper;
import org.jeecg.modules.system.mapper.*;
import org.jeecg.modules.system.service.ISysTenantPackService;
import org.jeecg.modules.system.service.ISysTenantService;
import org.jeecg.modules.system.service.ISysUserService;
@ -66,6 +68,12 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
@Autowired
private SysUserDepartMapper sysUserDepartMapper;
@Autowired
private SysTenantPackMapper sysTenantPackMapper;
@Autowired
private SysPackPermissionMapper sysPackPermissionMapper;
@Override
public List<SysTenant> queryEffectiveTenant(Collection<Integer> idList) {
if(oConvertUtils.listIsEmpty(idList)){
@ -142,6 +150,8 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
userTenantMapper.delete(query);
//update-end---author:wangshuai ---date:20221223 for[QQYUN-3371]租户逻辑改造,改成关系表------------
}
//租户移除用户,直接删除用户租户产品包
sysTenantPackUserMapper.deletePackUserByTenantId(Integer.valueOf(tenantId),Arrays.asList(userIds.split(SymbolConstant.COMMA)));
}
@Override
@ -155,7 +165,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
sysTenantPackService.addDefaultTenantPack(tenantId);
//添加租户到关系表
return this.saveTenantRelation(sysTenant.getId(), userId);
return tenantId;
}
@Override
@ -163,6 +173,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
//获取租户id
sysTenant.setId(this.tenantIdGenerate());
sysTenant.setHouseNumber(RandomUtil.randomStringUpper(6));
sysTenant.setDelFlag(CommonConstant.DEL_FLAG_0);
this.save(sysTenant);
//update-begin---author:wangshuai ---date:20230710 for【QQYUN-5723】1、把当前创建人加入到租户关系里面------------
//当前登录人的id
@ -190,11 +201,11 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
if(CommonConstant.USER_TENANT_UNDER_REVIEW.equals(relation.getStatus())){
msg = ",状态:审核中";
}else if(CommonConstant.USER_TENANT_REFUSE.equals(relation.getStatus())){
throw new JeecgBootException("管理员已拒绝您加入租户,请联系租户管理员");
throw new JeecgBootBizTipException("管理员已拒绝您加入租户,请联系租户管理员");
}else if(CommonConstant.USER_TENANT_QUIT.equals(relation.getStatus())){
msg = ",状态:已离职";
}
throw new JeecgBootException("您已是该租户成员"+msg);
throw new JeecgBootBizTipException("您已是该租户成员"+msg);
}
//用户加入门牌号审核中状态
SysUserTenant tenant = new SysUserTenant();
@ -234,6 +245,11 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
//删除租户下的用户
userTenantMapper.deleteUserByTenantId(list);
//update-ennd---author:wangshuai ---date:20230710 for【QQYUN-5723】3、租户彻底删除用户租户关系表也需要删除------------
//update-begin---author:wangshuai ---date:20230710 for【QQYUN-5723】3、租户彻底删除用户租户关系表也需要删除------------
//删除租户下的产品包
this.deleteTenantPackByTenantId(list);
//update-ennd---author:wangshuai ---date:20230710 for【QQYUN-5723】3、租户彻底删除用户租户关系表也需要删除------------
}
@Override
@ -679,6 +695,9 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
messageDTO.setData(data);
messageDTO.setContent(title);
messageDTO.setType("system");
//update-begin---author:wangshuai---date:2023-11-24---for:【QQYUN-7168】邀请成员时会报错但实际已经邀请成功了---
messageDTO.setCategory(CommonConstant.MSG_CATEGORY_1);
//update-end---author:wangshuai---date:2023-11-24---for:【QQYUN-7168】邀请成员时会报错但实际已经邀请成功了---
//update-begin---author:wangshuai ---date:20230721 for【QQYUN-5726】邀请加入租户加个按钮直接跳转过去------------
messageDTO.setBusType(SysAnnmentTypeEnum.TENANT_INVITE.getType());
sysBaseApi.sendBusAnnouncement(messageDTO);
@ -828,4 +847,67 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
}
return content;
}
/**
* 删除租户下的产品包
*
* @param tenantIdList
*/
private void deleteTenantPackByTenantId(List<Integer> tenantIdList) {
//1.删除产品包下的用户
sysTenantPackUserMapper.deletePackUserByTenantIds(tenantIdList);
//2.删除产品包对应的菜单权限
sysPackPermissionMapper.deletePackPermByTenantIds(tenantIdList);
//3.删除产品包
sysTenantPackMapper.deletePackByTenantIds(tenantIdList);
}
@Override
public void deleteUserByPassword(SysUser sysUser, Integer tenantId) {
//被删除人的用户id
String userId = sysUser.getId();
//被删除人的密码
String password = sysUser.getPassword();
//当前登录用户
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//step1 判断当前用户是否为当前租户的管理员(只有超级管理员和账号管理员可以删除)
Long isHaveAdmin = sysTenantPackUserMapper.izHaveBuyAuth(user.getId(), tenantId);
if(null == isHaveAdmin || 0 == isHaveAdmin){
throw new JeecgBootException("您不是当前组织的管理员,无法删除用户!");
}
//step2 离职状态下,并且无其他组织情况下,可以删除
SysUserTenant sysUserTenant = userTenantMapper.getUserTenantByTenantId(userId, tenantId);
if(null == sysUserTenant || !CommonConstant.USER_TENANT_QUIT.equals(sysUserTenant.getStatus())){
throw new JeecgBootException("用户没有离职,不允许删除!");
}
List<Integer> tenantIdsByUserId = userTenantMapper.getTenantIdsByUserId(userId);
if(CollectionUtils.isNotEmpty(tenantIdsByUserId) && tenantIdsByUserId.size()>0){
throw new JeecgBootException("用户尚有未退出的组织,无法删除!");
}
//step3 当天创建的用户和创建人可以删除
SysUser sysUserData = userService.getById(userId);
if(!sysUserData.getCreateBy().equals(user.getUsername())){
throw new JeecgBootException("您不是该用户的创建人,无法删除!");
}
Date createTime = sysUserData.getCreateTime();
boolean sameDay = DateUtils.isSameDay(createTime, new Date());
if(!sameDay){
throw new JeecgBootException("用户不是今天创建的,无法删除!");
}
//step4 验证密码
String passwordEncode = PasswordUtil.encrypt(sysUserData.getUsername(), password, sysUserData.getSalt());
if(!passwordEncode.equals(sysUserData.getPassword())){
throw new JeecgBootException("您输入的密码不正确,无法删除该用户!");
}
//step5 逻辑删除用户
userService.deleteUser(userId);
//step6 真实删除用户
userService.removeLogicDeleted(Collections.singletonList(userId));
}
@Override
public List<SysTenant> getTenantListByUserId(String userId) {
return tenantMapper.getTenantListByUserId(userId);
}
}

View File

@ -64,6 +64,8 @@ public class SysThirdAccountServiceImpl extends ServiceImpl<SysThirdAccountMappe
//修改第三方登录账户表使其进行添加用户id
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
query.eq(SysThirdAccount::getThirdUserUuid,thirdUserUuid);
//扫码登录更新用户创建的时候存的是默认租户更新的时候也需要根据默认租户来查询同一个公司下UUID是一样的不同应用需要区分租户。
query.eq(SysThirdAccount::getTenantId,CommonConstant.TENANT_ID_DEFAULT_VALUE);
SysThirdAccount account = sysThirdAccountMapper.selectOne(query);
SysThirdAccount sysThirdAccount = new SysThirdAccount();
sysThirdAccount.setSysUserId(sysUser.getId());
@ -72,6 +74,7 @@ public class SysThirdAccountServiceImpl extends ServiceImpl<SysThirdAccountMappe
thirdQuery.eq(SysThirdAccount::getSysUserId,sysUser.getId());
thirdQuery.eq(SysThirdAccount::getThirdType,account.getThirdType());
thirdQuery.eq(SysThirdAccount::getThirdUserUuid,thirdUserUuid);
thirdQuery.eq(SysThirdAccount::getTenantId,CommonConstant.TENANT_ID_DEFAULT_VALUE);
SysThirdAccount sysThirdAccounts = sysThirdAccountMapper.selectOne(thirdQuery);
if(sysThirdAccounts!=null){
sysThirdAccount.setThirdUserId(sysThirdAccounts.getThirdUserId());
@ -191,7 +194,7 @@ public class SysThirdAccountServiceImpl extends ServiceImpl<SysThirdAccountMappe
//获取当前登录用户
LoginUser sysUser = SecureUtil.currentUser();
//当前第三方用户已被其他用户所绑定
SysThirdAccount oneByThirdUserId = this.getOneByUuidAndThirdType(thirdUserUuid, thirdType,CommonConstant.TENANT_ID_DEFAULT_VALUE);
SysThirdAccount oneByThirdUserId = this.getOneByUuidAndThirdType(thirdUserUuid, thirdType,CommonConstant.TENANT_ID_DEFAULT_VALUE, null);
if(null != oneByThirdUserId){
//如果不为空,并且第三方表和当前登录的用户一致,直接返回
if(oConvertUtils.isNotEmpty(oneByThirdUserId.getSysUserId()) && oneByThirdUserId.getSysUserId().equals(sysUser.getId())){
@ -212,10 +215,16 @@ public class SysThirdAccountServiceImpl extends ServiceImpl<SysThirdAccountMappe
}
@Override
public SysThirdAccount getOneByUuidAndThirdType(String unionid, String thirdType,Integer tenantId) {
public SysThirdAccount getOneByUuidAndThirdType(String unionid, String thirdType,Integer tenantId,String thirdUserId) {
LambdaQueryWrapper<SysThirdAccount> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysThirdAccount::getThirdUserUuid, unionid);
queryWrapper.eq(SysThirdAccount::getThirdType, thirdType);
//update-begin---author:wangshuai---date:2023-12-04---for: 如果第三方用户id为空那么就不走第三方用户查询逻辑因为扫码登录third_user_id是唯一的没有重复的情况---
if(oConvertUtils.isNotEmpty(thirdUserId)){
queryWrapper.and((wrapper) ->wrapper.eq(SysThirdAccount::getThirdUserUuid,unionid).or().eq(SysThirdAccount::getThirdUserId,thirdUserId));
}else{
queryWrapper.eq(SysThirdAccount::getThirdUserUuid, unionid);
}
//update-end---author:wangshuai---date:2023-12-04---for:如果第三方用户id为空那么就不走第三方用户查询逻辑因为扫码登录third_user_id是唯一的没有重复的情况---
queryWrapper.eq(SysThirdAccount::getTenantId, tenantId);
return super.getOne(queryWrapper);
}

Some files were not shown because too many files have changed in this diff Show More