Browse Source

【3.6.3版本发布】性能优化部分代码

pull/5955/head^2
zhangdaiscott 9 months ago
parent
commit
a9dba08a8d
  1. 4
      jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java
  2. 4
      jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
  3. 22
      jeecg-module-system/jeecg-system-api/jeecg-system-cloud-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java
  4. 17
      jeecg-module-system/jeecg-system-api/jeecg-system-cloud-api/src/main/java/org/jeecg/common/system/api/fallback/SysBaseAPIFallback.java
  5. 19
      jeecg-module-system/jeecg-system-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java
  6. 14
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java
  7. 22
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml
  8. 104
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysPermissionMapper.xml

4
jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java

@ -22,10 +22,10 @@ public interface CommonAPI {
/**
* 2查询用户权限信息
* @param username
* @param userId
* @return
*/
Set<String> queryUserAuths(String username);
Set<String> queryUserAuths(String userId);
/**
* 3根据 id 查询数据库中存储的 DynamicDataSourceModel

4
jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java

@ -62,9 +62,11 @@ public class ShiroRealm extends AuthorizingRealm {
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
log.debug("===============Shiro权限认证开始============ [ roles、permissions]==========");
String username = null;
String userId = null;
if (principals != null) {
LoginUser sysUser = (LoginUser) principals.getPrimaryPrincipal();
username = sysUser.getUsername();
userId = sysUser.getId();
}
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
@ -74,7 +76,7 @@ public class ShiroRealm extends AuthorizingRealm {
info.setRoles(roleSet);
// 设置用户拥有的权限集合,比如“sys:role:add,sys:user:add”
Set<String> permissionSet = commonApi.queryUserAuths(username);
Set<String> permissionSet = commonApi.queryUserAuths(userId);
info.addStringPermissions(permissionSet);
//System.out.println(permissionSet);
log.info("===============Shiro权限认证成功==============");

22
jeecg-module-system/jeecg-system-api/jeecg-system-cloud-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java

@ -307,11 +307,11 @@ public interface ISysBaseAPI extends CommonAPI {
/**
* 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访问的权限
@ -351,12 +351,12 @@ public interface ISysBaseAPI extends CommonAPI {
/**
* 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
@ -611,20 +611,6 @@ public interface ISysBaseAPI extends CommonAPI {
@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);
/**
* 更新头像
* @param loginUser

17
jeecg-module-system/jeecg-system-api/jeecg-system-cloud-api/src/main/java/org/jeecg/common/system/api/fallback/SysBaseAPIFallback.java

@ -71,7 +71,7 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public Set<String> getDepartParentIdsByDepIds(Set depIds) {
public Set<String> getDepartParentIdsByDepIds(Set<String> depIds) {
return null;
}
@ -194,7 +194,7 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public Set<String> getUserPermissionSet(String username) {
public Set<String> getUserPermissionSet(String userId) {
return null;
}
@ -219,7 +219,7 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
}
@Override
public Set<String> queryUserAuths(String username) {
public Set<String> queryUserAuths(String userId) {
return null;
}
@ -361,17 +361,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) { }

19
jeecg-module-system/jeecg-system-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java

@ -101,7 +101,7 @@ public interface ISysBaseAPI extends CommonAPI {
* @param depIds
* @return 部门 parentIds
*/
Set<String> getDepartParentIdsByDepIds(Set depIds);
Set<String> getDepartParentIdsByDepIds(Set<String> depIds);
/**
* 9通过用户账号查询部门 name
@ -302,10 +302,10 @@ public interface ISysBaseAPI extends CommonAPI {
/**
* 32获取用户的权限集合
* @param username
* @param userId
* @return
*/
Set<String> getUserPermissionSet(String username);
Set<String> getUserPermissionSet(String userId);
/**
* 33判断是否有online访问的权限
@ -445,19 +445,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

14
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java

@ -156,7 +156,7 @@ public class SystemApiController {
* @return 部门 id
*/
@GetMapping("/getDepartParentIdsByDepIds")
Set<String> getDepartParentIdsByDepIds(@RequestParam("depIds") Set depIds){
Set<String> getDepartParentIdsByDepIds(@RequestParam("depIds") Set<String> depIds){
return sysBaseApi.getDepartParentIdsByDepIds(depIds);
}
@ -386,12 +386,12 @@ public class SystemApiController {
/**
* 获取用户的权限集合
* @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);
}
//-----
@ -419,12 +419,12 @@ public class SystemApiController {
/**
* 查询用户权限信息
* @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);
}
/**

22
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml

@ -64,6 +64,28 @@
)
</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">
select id as "value",depart_name as "text" from sys_depart where del_flag = '0'

104
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysPermissionMapper.xml

@ -42,43 +42,101 @@
<!-- 获取登录用户拥有的权限 -->
<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.*
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_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}
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 for:QQYUN-4303 【low app】 用户登录的时候 加载low app的套餐权限 加到用户信息 -->
UNION
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_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}
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_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 for:QQYUN-4303 【low app】 用户登录的时候 加载low app的套餐权限 加到用户信息 -->

Loading…
Cancel
Save