记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
371d22d3
Commit
371d22d3
authored
Aug 21, 2025
by
姜秀龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LostFoundAdmin redis del and unq
parent
174aa13c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
5 deletions
+116
-5
SweetLostFoundAdminServiceImpl.java
...ce/sweet/service/impl/SweetLostFoundAdminServiceImpl.java
+101
-5
LostFoundRedisUtils.java
...om/liquidnet/service/sweet/utils/LostFoundRedisUtils.java
+15
-0
No files found.
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/service/impl/SweetLostFoundAdminServiceImpl.java
View file @
371d22d3
...
...
@@ -30,25 +30,115 @@ public class SweetLostFoundAdminServiceImpl extends ServiceImpl<SweetLostFoundAd
@Override
public
boolean
addAdmin
(
SweetLostFoundAdminParam
admin
)
{
String
phone
=
admin
.
getPhone
().
trim
();
String
performanceId
=
admin
.
getPerformanceId
().
trim
();
Integer
authScope
=
admin
.
getAuthScope
();
if
(
phone
==
null
||
phone
.
trim
().
isEmpty
())
{
throw
new
IllegalArgumentException
(
"手机号不能为空"
);
}
if
(
performanceId
==
null
||
performanceId
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"演出ID不能为空"
);
}
// 规则1: 检查在当前演出下是否已创建过管理员
QueryWrapper
<
SweetLostFoundAdmin
>
existWrapper
=
new
QueryWrapper
<>();
existWrapper
.
eq
(
"phone"
,
phone
)
.
eq
(
"performance_id"
,
performanceId
)
.
eq
(
"is_deleted"
,
0
);
if
(
baseMapper
.
selectCount
(
existWrapper
)
>
0
)
{
throw
new
IllegalStateException
(
"该手机号在当前演出下已存在管理员记录"
);
}
// 规则2: 如果创建的是全站管理员,检查该手机号是否已在其他演出下创建过全站管理员
if
(
authScope
!=
null
&&
authScope
==
2
)
{
QueryWrapper
<
SweetLostFoundAdmin
>
globalWrapper
=
new
QueryWrapper
<>();
globalWrapper
.
eq
(
"phone"
,
phone
)
.
eq
(
"auth_scope"
,
2
)
.
ne
(
"performance_id"
,
performanceId
)
.
eq
(
"is_deleted"
,
0
);
if
(
baseMapper
.
selectCount
(
globalWrapper
)
>
0
)
{
throw
new
IllegalStateException
(
"该手机号已作为全站管理员存在,不能再次创建"
);
}
}
SweetLostFoundAdmin
foundAdmin
=
SweetLostFoundAdmin
.
getNew
();
foundAdmin
.
setAdminId
(
IDGenerator
.
nextSnowId
());
foundAdmin
.
setPhone
(
admin
.
getPhone
()
);
foundAdmin
.
setPhone
(
phone
);
foundAdmin
.
setName
(
admin
.
getName
());
foundAdmin
.
setPermissionType
(
admin
.
getPermissionType
());
foundAdmin
.
setAuthScope
(
admin
.
getAuthScope
());
foundAdmin
.
setPerformanceId
(
admin
.
getPerformanceId
()
);
foundAdmin
.
setPerformanceId
(
performanceId
);
return
baseMapper
.
insert
(
foundAdmin
)
>
0
;
}
@Override
public
boolean
editAdmin
(
SweetLostFoundAdminParam
admin
)
{
Long
id
=
admin
.
getId
();
String
phone
=
admin
.
getPhone
().
trim
();
String
performanceId
=
admin
.
getPerformanceId
().
trim
();
Integer
authScope
=
admin
.
getAuthScope
();
if
(
id
==
null
)
{
throw
new
IllegalArgumentException
(
"管理员ID不能为空"
);
}
if
(
phone
==
null
||
phone
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"手机号不能为空"
);
}
if
(
performanceId
==
null
||
performanceId
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"演出ID不能为空"
);
}
// 检查要修改的管理员是否存在
SweetLostFoundAdmin
existingAdmin
=
baseMapper
.
selectById
(
id
);
if
(
existingAdmin
==
null
||
existingAdmin
.
getIsDeleted
()
==
1
)
{
throw
new
IllegalStateException
(
"管理员记录不存在或已删除"
);
}
// 规则1: 检查修改后的手机号在当前演出下是否已存在(排除自身)
QueryWrapper
<
SweetLostFoundAdmin
>
existWrapper
=
new
QueryWrapper
<>();
existWrapper
.
eq
(
"phone"
,
phone
)
.
eq
(
"performance_id"
,
performanceId
)
.
ne
(
"id"
,
id
)
.
eq
(
"is_deleted"
,
0
);
if
(
baseMapper
.
selectCount
(
existWrapper
)
>
0
)
{
throw
new
IllegalStateException
(
"该手机号在当前演出下已存在管理员记录"
);
}
// 规则2: 如果修改为全站管理员,检查该手机号是否已在其他演出下创建过全站管理员(排除自身)
if
(
authScope
!=
null
&&
authScope
==
2
)
{
QueryWrapper
<
SweetLostFoundAdmin
>
globalWrapper
=
new
QueryWrapper
<>();
globalWrapper
.
eq
(
"phone"
,
phone
)
.
eq
(
"auth_scope"
,
2
)
.
ne
(
"id"
,
id
)
.
ne
(
"performance_id"
,
performanceId
)
.
eq
(
"is_deleted"
,
0
);
if
(
baseMapper
.
selectCount
(
globalWrapper
)
>
0
)
{
throw
new
IllegalStateException
(
"该手机号已作为全站管理员存在,不能再次创建"
);
}
}
SweetLostFoundAdmin
foundAdmin
=
SweetLostFoundAdmin
.
getNew
();
foundAdmin
.
setId
(
admin
.
getId
()
);
foundAdmin
.
setPhone
(
admin
.
getPhone
()
);
foundAdmin
.
setId
(
id
);
foundAdmin
.
setPhone
(
phone
);
foundAdmin
.
setName
(
admin
.
getName
());
foundAdmin
.
setPermissionType
(
admin
.
getPermissionType
());
foundAdmin
.
setAuthScope
(
admin
.
getAuthScope
());
foundAdmin
.
setPerformanceId
(
admin
.
getPerformanceId
());
foundAdmin
.
setPerformanceId
(
performanceId
);
// 更新缓存
lostFoundRedisUtils
.
deleteAdminCache
(
phone
,
performanceId
);
if
(!
phone
.
trim
().
equals
(
existingAdmin
.
getPhone
()))
{
lostFoundRedisUtils
.
deleteAdminCache
(
existingAdmin
.
getPhone
(),
performanceId
);
}
return
baseMapper
.
updateById
(
foundAdmin
)
>
0
;
}
...
...
@@ -62,6 +152,9 @@ public class SweetLostFoundAdminServiceImpl extends ServiceImpl<SweetLostFoundAd
// 逻辑删除:更新is_deleted字段为1
admin
.
setIsDeleted
(
1
);
lostFoundRedisUtils
.
deleteAdminCache
(
admin
.
getPhone
(),
admin
.
getPerformanceId
());
return
baseMapper
.
updateById
(
admin
)
>
0
;
}
...
...
@@ -123,6 +216,9 @@ public class SweetLostFoundAdminServiceImpl extends ServiceImpl<SweetLostFoundAd
.
eq
(
"auth_scope"
,
2
)
);
SweetLostFoundAdmin
admin
=
baseMapper
.
selectOne
(
queryWrapper
);
if
(
admin
==
null
)
{
return
null
;
}
SweetLostFoundAdminVo
vo
=
new
SweetLostFoundAdminVo
();
BeanUtils
.
copyProperties
(
admin
,
vo
);
lostFoundRedisUtils
.
setAdminCache
(
phone
,
performanceId
,
vo
);
...
...
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/utils/LostFoundRedisUtils.java
View file @
371d22d3
...
...
@@ -188,4 +188,19 @@ public class LostFoundRedisUtils {
log
.
error
(
"设置管理员缓存失败"
,
e
);
}
}
/**
* 删除管理员缓存
*
* @param phone 手机号
* @param performanceId 演出ID
*/
public
void
deleteAdminCache
(
String
phone
,
String
performanceId
)
{
try
{
String
key
=
ADMIN_DETAIL_KEY
+
phone
+
":"
+
performanceId
;
redisUtil
.
del
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
"删除管理员缓存失败"
,
e
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment