Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auth-master
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
吴超
auth-master
Commits
5fc73721
Commit
5fc73721
authored
Dec 03, 2025
by
周海峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
c21f6a50
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
91 行增加
和
85 行删除
+91
-85
src/main/java/com/metro/auth/platform/controller/PlatformApplicationsController.java
+6
-0
src/main/java/com/metro/auth/platform/domain/auth/PlatformApplications.java
+18
-19
src/main/java/com/metro/auth/platform/mapper/PlatformApplicationsMapper.xml
+1
-9
src/main/java/com/metro/auth/platform/service/PlatformApplicationsServiceImpl.java
+66
-57
没有找到文件。
src/main/java/com/metro/auth/platform/controller/PlatformApplicationsController.java
View file @
5fc73721
...
...
@@ -57,6 +57,12 @@ public class PlatformApplicationsController {
List
<
PlatformApplications
>
list
=
platformApplicationsService
.
getPlatformApplicationsListByRole
(
roleid
);
return
ResultJson
.
ok
(
list
);
}
/**
* 根据用户ID获取应用列表
* @param userid 用户ID
* @return 应用列表
*/
@GetMapping
(
"/platformapplications/listbyuserid/{userid}"
)
public
ResultJson
listbyuserid
(
@PathVariable
String
userid
){
List
<
PlatformApplications
>
list
=
platformApplicationsService
.
getPlatformApplicationsListByUserid
(
userid
);
...
...
src/main/java/com/metro/auth/platform/domain/auth/PlatformApplications.java
View file @
5fc73721
...
...
@@ -5,7 +5,6 @@ import org.springframework.data.annotation.Transient;
import
java.io.Serializable
;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table platform_applications
*
...
...
@@ -13,7 +12,6 @@ import java.io.Serializable;
*/
public
class
PlatformApplications
implements
Serializable
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.id
*
...
...
@@ -24,7 +22,7 @@ public class PlatformApplications implements Serializable {
/**
* Database Column Remarks:
* 名称
*
*
<p>
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.title
*
...
...
@@ -35,7 +33,7 @@ public class PlatformApplications implements Serializable {
/**
* Database Column Remarks:
* 图标
*
*
<p>
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.img
*
...
...
@@ -46,7 +44,7 @@ public class PlatformApplications implements Serializable {
/**
* Database Column Remarks:
* 连接
*
*
<p>
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.href
*
...
...
@@ -57,7 +55,7 @@ public class PlatformApplications implements Serializable {
/**
* Database Column Remarks:
* 添加时间
*
*
<p>
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.addtime
*
...
...
@@ -68,7 +66,7 @@ public class PlatformApplications implements Serializable {
/**
* Database Column Remarks:
* 是否提示
*
*
<p>
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.tishi
*
...
...
@@ -107,6 +105,19 @@ public class PlatformApplications implements Serializable {
*/
private
String
wechatUrl
;
/**
* 应用排序编号
*/
private
String
num
;
public
String
getNum
()
{
return
num
;
}
public
void
setNum
(
String
num
)
{
this
.
num
=
num
;
}
public
String
getWechatUrl
()
{
return
wechatUrl
;
}
...
...
@@ -160,7 +171,6 @@ public class PlatformApplications implements Serializable {
* This method returns the value of the database column platform_applications.id
*
* @return the value of platform_applications.id
*
* @mbg.generated
*/
public
Integer
getId
()
{
...
...
@@ -172,7 +182,6 @@ public class PlatformApplications implements Serializable {
* This method sets the value of the database column platform_applications.id
*
* @param id the value for platform_applications.id
*
* @mbg.generated
*/
public
void
setId
(
Integer
id
)
{
...
...
@@ -184,7 +193,6 @@ public class PlatformApplications implements Serializable {
* This method returns the value of the database column platform_applications.title
*
* @return the value of platform_applications.title
*
* @mbg.generated
*/
public
String
getTitle
()
{
...
...
@@ -196,7 +204,6 @@ public class PlatformApplications implements Serializable {
* This method sets the value of the database column platform_applications.title
*
* @param title the value for platform_applications.title
*
* @mbg.generated
*/
public
void
setTitle
(
String
title
)
{
...
...
@@ -208,7 +215,6 @@ public class PlatformApplications implements Serializable {
* This method returns the value of the database column platform_applications.img
*
* @return the value of platform_applications.img
*
* @mbg.generated
*/
public
String
getImg
()
{
...
...
@@ -220,7 +226,6 @@ public class PlatformApplications implements Serializable {
* This method sets the value of the database column platform_applications.img
*
* @param img the value for platform_applications.img
*
* @mbg.generated
*/
public
void
setImg
(
String
img
)
{
...
...
@@ -232,7 +237,6 @@ public class PlatformApplications implements Serializable {
* This method returns the value of the database column platform_applications.href
*
* @return the value of platform_applications.href
*
* @mbg.generated
*/
public
String
getHref
()
{
...
...
@@ -244,7 +248,6 @@ public class PlatformApplications implements Serializable {
* This method sets the value of the database column platform_applications.href
*
* @param href the value for platform_applications.href
*
* @mbg.generated
*/
public
void
setHref
(
String
href
)
{
...
...
@@ -256,7 +259,6 @@ public class PlatformApplications implements Serializable {
* This method returns the value of the database column platform_applications.addtime
*
* @return the value of platform_applications.addtime
*
* @mbg.generated
*/
public
String
getAddtime
()
{
...
...
@@ -268,7 +270,6 @@ public class PlatformApplications implements Serializable {
* This method sets the value of the database column platform_applications.addtime
*
* @param addtime the value for platform_applications.addtime
*
* @mbg.generated
*/
public
void
setAddtime
(
String
addtime
)
{
...
...
@@ -280,7 +281,6 @@ public class PlatformApplications implements Serializable {
* This method returns the value of the database column platform_applications.tishi
*
* @return the value of platform_applications.tishi
*
* @mbg.generated
*/
public
Integer
getTishi
()
{
...
...
@@ -292,7 +292,6 @@ public class PlatformApplications implements Serializable {
* This method sets the value of the database column platform_applications.tishi
*
* @param tishi the value for platform_applications.tishi
*
* @mbg.generated
*/
public
void
setTishi
(
Integer
tishi
)
{
...
...
src/main/java/com/metro/auth/platform/mapper/PlatformApplicationsMapper.xml
View file @
5fc73721
...
...
@@ -105,19 +105,11 @@
</where>
</sql>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, title, img, href, addtime, tishi, databasename, databasepassword, databasecon, qyflag, appid, secret,
openmail, mailtype, group_code, wechat_url
openmail, mailtype, group_code, wechat_url
, num
</sql>
<select
id=
"selectByExample"
parameterType=
"com.metro.auth.platform.domain.auth.PlatformApplicationsExample"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if
test=
"distinct"
>
distinct
...
...
src/main/java/com/metro/auth/platform/service/PlatformApplicationsServiceImpl.java
View file @
5fc73721
...
...
@@ -16,10 +16,8 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
PlatformApplicationsServiceImpl
implements
PlatformApplicationsService
{
...
...
@@ -28,13 +26,14 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
PlatformApplicationsMapper
platformApplicationsMapper
;
@Resource
PlatformSysRoleMapper
platformSysRoleMapper
;
@Override
public
PageInfo
<
PlatformApplications
>
pagedlist
(
PlatformApplications
platformApplications
,
int
pageNum
,
int
pageSize
){
public
PageInfo
<
PlatformApplications
>
pagedlist
(
PlatformApplications
platformApplications
,
int
pageNum
,
int
pageSize
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
PlatformApplicationsExample
platformApplicationsExample
=
new
PlatformApplicationsExample
();
if
(
platformApplications
!=
null
&&!
EmptyUtilHelper
.
isEmpty
(
platformApplications
.
getTitle
()))
{
platformApplicationsExample
.
createCriteria
().
andTitleLike
(
"%"
+
platformApplications
.
getTitle
()+
"%"
);
if
(
platformApplications
!=
null
&&
!
EmptyUtilHelper
.
isEmpty
(
platformApplications
.
getTitle
()))
{
platformApplicationsExample
.
createCriteria
().
andTitleLike
(
"%"
+
platformApplications
.
getTitle
()
+
"%"
);
}
List
<
PlatformApplications
>
list
=
platformApplicationsMapper
.
selectByExample
(
platformApplicationsExample
);
...
...
@@ -51,7 +50,7 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
if
(
"1"
.
equals
(
platformApplications
.
getOpenmail
())
&&
StringUtils
.
isEmpty
(
platformApplications
.
getMailtype
()))
{
throw
new
Exception
(
"启用待办标识不能为空"
);
}
if
(
StringUtils
.
isNotEmpty
(
platformApplications
.
getMailtype
()))
{
if
(
StringUtils
.
isNotEmpty
(
platformApplications
.
getMailtype
()))
{
//所有应用
List
<
PlatformApplications
>
attlist
=
platformApplicationsMapper
.
selectListByMailType
(
platformApplications
.
getMailtype
(),
platformApplications
.
getId
());
if
(
attlist
.
size
()
>
0
)
{
...
...
@@ -60,19 +59,19 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
}
int
count
=
0
;
if
(
platformApplications
!=
null
&&
!
EmptyUtilHelper
.
isEmpty
(
platformApplications
.
getId
()))
{
int
count
=
0
;
if
(
platformApplications
!=
null
&&
!
EmptyUtilHelper
.
isEmpty
(
platformApplications
.
getId
()))
{
//更新
PlatformApplicationsExample
platformApplicationsExample
=
new
PlatformApplicationsExample
();
PlatformApplicationsExample
platformApplicationsExample
=
new
PlatformApplicationsExample
();
platformApplicationsExample
.
createCriteria
().
andIdEqualTo
(
platformApplications
.
getId
());
count
=
platformApplicationsMapper
.
updateByExample
(
platformApplications
,
platformApplicationsExample
);
}
else
{
count
=
platformApplicationsMapper
.
updateByExample
(
platformApplications
,
platformApplicationsExample
);
}
else
{
//主键
// platformApplications.setId(StrUtil.makePramykey());
// platformApplications.setAppid(StrUtil.makePramykey());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
platformApplications
.
setAddtime
(
sdf
.
format
(
new
Date
()));
count
=
platformApplicationsMapper
.
insert
(
platformApplications
);
count
=
platformApplicationsMapper
.
insert
(
platformApplications
);
}
return
count
;
...
...
@@ -85,66 +84,76 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
}
@Override
public
List
<
PlatformApplications
>
getPlatformApplicationsList
(){
public
List
<
PlatformApplications
>
getPlatformApplicationsList
()
{
return
platformApplicationsMapper
.
getPlatformApplicationsList
();
}
@Override
public
List
<
PlatformApplications
>
getPlatformApplicationsListByUserid
(
String
userid
){
PlatformApplicationsExample
platformApplicationsExample
=
new
PlatformApplicationsExample
();
PlatformApplicationsExample
.
Criteria
criteria
=
platformApplicationsExample
.
createCriteria
();
criteria
.
andQyflagEqualTo
(
"1"
);
//所有应用
List
<
PlatformApplications
>
attlist
=
platformApplicationsMapper
.
selectByExample
(
platformApplicationsExample
);
//根据userid查询用户所有角色
String
roleidlist
=
""
;
List
<
String
>
names
=
new
ArrayList
<>();
try
{
int
intuser
=
Integer
.
parseInt
(
userid
);
List
<
PlatformSysRole
>
idealist
=
platformSysRoleMapper
.
selectByUserId
(
intuser
);
for
(
int
i
=
0
;
i
<
idealist
.
size
();
i
++){
names
.
add
(
idealist
.
get
(
i
).
getId
());
public
List
<
PlatformApplications
>
getPlatformApplicationsListByUserid
(
String
userid
)
{
// 1. 查询所有启用的应用
PlatformApplicationsExample
example
=
new
PlatformApplicationsExample
();
example
.
createCriteria
().
andQyflagEqualTo
(
"1"
);
List
<
PlatformApplications
>
allApplications
=
platformApplicationsMapper
.
selectByExample
(
example
);
// 2. 将所有应用转换为以ID为Key的Map,方便后续快速查找
// 使用 Collectors.toMap 是一个高效且清晰的做法
Map
<
Integer
,
PlatformApplications
>
appMap
=
allApplications
.
stream
()
.
collect
(
Collectors
.
toMap
(
PlatformApplications:
:
getId
,
app
->
app
));
// 3. 安全地解析userid并查询用户角色
Set
<
String
>
roleIds
=
new
HashSet
<>();
int
userIdInt
=
Integer
.
parseInt
(
userid
);
// 直接查询出角色ID列表,避免在Java代码中循环提取
roleIds
=
platformSysRoleMapper
.
selectByUserId
(
userIdInt
)
.
stream
().
map
(
PlatformSysRole:
:
getId
)
.
collect
(
Collectors
.
toSet
());
// 4. 根据角色ID列表查询可见应用
List
<
PlatformApplications
>
visibleApplications
;
if
(
roleIds
.
isEmpty
())
{
visibleApplications
=
Collections
.
emptyList
();
// 如果没有角色,则可见应用列表为空
}
else
{
visibleApplications
=
platformApplicationsMapper
.
getPlatformApplicationsListByRoleList
(
new
ArrayList
<>(
roleIds
));
}
// 提取可见应用的ID集合,用于快速判断
Set
<
Integer
>
visibleAppIds
=
visibleApplications
.
stream
()
.
map
(
PlatformApplications:
:
getId
)
.
collect
(
Collectors
.
toSet
());
// 遍历所有应用,根据其ID是否在可见应用ID集合中来更新状态
allApplications
.
forEach
(
app
->
{
if
(
visibleAppIds
.
contains
(
app
.
getId
()))
{
app
.
setRoleUseStatue
(
app
.
getId
());
// 可见
}
else
{
app
.
setRoleUseStatue
(
0
);
// 不可见
}
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
}
//当前角色可见应用
List
<
PlatformApplications
>
rolelist
=
platformApplicationsMapper
.
getPlatformApplicationsListByRoleList
(
names
);
if
(
rolelist
!=
null
&&
rolelist
.
size
()>
0
){
for
(
int
i
=
0
;
i
<
rolelist
.
size
();
i
++){
int
finalI
=
i
;
attlist
.
stream
().
forEach
(
t
->{
if
(
t
.
getId
().
equals
(
rolelist
.
get
(
finalI
).
getId
())){
t
.
setRoleUseStatue
(
t
.
getId
());
}
});
}
}
else
{
attlist
.
stream
().
forEach
(
t
->{
t
.
setRoleUseStatue
(
0
);
});
return
allApplications
.
stream
()
.
sorted
(
Comparator
.
comparing
(
app
->
StringUtils
.
isEmpty
(
app
.
getNum
())
?
0
:
Integer
.
parseInt
(
app
.
getNum
())))
.
collect
(
Collectors
.
toList
());
}
return
attlist
;
}
@Override
public
List
<
PlatformApplications
>
getPlatformApplicationsListByRole
(
String
roleid
){
public
List
<
PlatformApplications
>
getPlatformApplicationsListByRole
(
String
roleid
)
{
PlatformApplicationsExample
platformApplicationsExample
=
new
PlatformApplicationsExample
();
//所有应用
List
<
PlatformApplications
>
alllist
=
platformApplicationsMapper
.
selectByExample
(
platformApplicationsExample
);
//当前角色可见应用
List
<
PlatformApplications
>
rolelist
=
platformApplicationsMapper
.
getPlatformApplicationsListByRole
(
roleid
);
if
(
rolelist
!=
null
&&
rolelist
.
size
()>
0
)
{
for
(
int
i
=
0
;
i
<
rolelist
.
size
();
i
++)
{
List
<
PlatformApplications
>
rolelist
=
platformApplicationsMapper
.
getPlatformApplicationsListByRole
(
roleid
);
if
(
rolelist
!=
null
&&
rolelist
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
rolelist
.
size
();
i
++)
{
int
finalI
=
i
;
alllist
.
stream
().
forEach
(
t
->
{
if
(
t
.
getId
().
equals
(
rolelist
.
get
(
finalI
).
getId
())){
alllist
.
stream
().
forEach
(
t
->
{
if
(
t
.
getId
().
equals
(
rolelist
.
get
(
finalI
).
getId
()))
{
t
.
setRoleUseStatue
(
t
.
getId
());
}
});
}
}
else
{
alllist
.
stream
().
forEach
(
t
->
{
}
else
{
alllist
.
stream
().
forEach
(
t
->
{
t
.
setRoleUseStatue
(
0
);
});
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论