Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
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
wangpeng
dinky
Commits
16f1aac5
Unverified
Commit
16f1aac5
authored
May 16, 2024
by
Zzm0809
Committed by
GitHub
May 16, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] When Add Tenant Automatically Add Admin User Association (#3503)
Signed-off-by:
Zzm0809
<
934230207@qq.com
>
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
266dba30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
TenantServiceImpl.java
...c/main/java/org/dinky/service/impl/TenantServiceImpl.java
+19
-0
No files found.
dinky-admin/src/main/java/org/dinky/service/impl/TenantServiceImpl.java
View file @
16f1aac5
...
...
@@ -45,13 +45,16 @@ 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.conditions.query.LambdaQueryChainWrapper
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
cn.hutool.core.collection.CollectionUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@RequiredArgsConstructor
@Slf4j
public
class
TenantServiceImpl
extends
SuperServiceImpl
<
TenantMapper
,
Tenant
>
implements
TenantService
{
@Resource
...
...
@@ -71,6 +74,22 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant> im
}
tenant
.
setIsDelete
(
false
);
if
(
save
(
tenant
))
{
// When adding a new tenant, the admin user will be added to the tenant by default
Long
count
=
new
LambdaQueryChainWrapper
<>(
userTenantService
.
getBaseMapper
())
.
eq
(
UserTenant:
:
getUserId
,
BaseConstant
.
ADMIN_ID
)
.
eq
(
UserTenant:
:
getTenantId
,
tenant
.
getId
())
.
count
();
if
(
count
==
0
)
{
UserTenant
userTenant
=
new
UserTenant
();
userTenant
.
setUserId
(
BaseConstant
.
ADMIN_ID
);
userTenant
.
setTenantId
(
tenant
.
getId
());
userTenant
.
setTenantAdminFlag
(
true
);
// set an admin flag to true,because the admin user is the tenant admin
userTenantService
.
save
(
userTenant
);
log
.
info
(
"You have added tenant {}, and the system will automatically add the admin user to that tenant."
,
tenant
.
getTenantCode
());
}
TenantContextHolder
.
set
(
tenant
.
getId
());
return
Result
.
succeed
(
Status
.
ADDED_SUCCESS
);
}
...
...
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