Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-usercenter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 248721da
authored
Jun 19, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加通过用户ID获取所在租户ID接口
1 parent
8ea9aa7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
src/main/java/cn/com/glsx/shield/modules/api/FeignUserController.java
src/main/java/cn/com/glsx/shield/modules/converter/TenantConverter.java
src/main/java/cn/com/glsx/shield/modules/service/UserService.java
src/main/java/cn/com/glsx/shield/modules/api/FeignUserController.java
View file @
248721d
package
cn
.
com
.
glsx
.
shield
.
modules
.
api
;
import
cn.com.glsx.shield.modules.converter.TenantConverter
;
import
cn.com.glsx.shield.modules.converter.UserConverter
;
import
cn.com.glsx.shield.modules.entity.Tenant
;
import
cn.com.glsx.shield.modules.service.UserService
;
import
cn.com.glsx.usercenter.api.dto.request.FindUserRequest
;
import
cn.com.glsx.usercenter.api.dto.response.TenantDto
;
import
cn.com.glsx.usercenter.api.dto.response.User
;
import
com.glsx.plat.core.web.R
;
import
com.google.common.collect.Lists
;
...
...
@@ -109,4 +112,12 @@ public class FeignUserController implements cn.com.glsx.usercenter.api.feign.Use
return
R
.
ok
().
data
(
userList
);
}
@Override
@ApiOperation
(
value
=
"根据用户ID获取该用户所在租户"
)
@GetMapping
(
value
=
"/getTenantByUserId"
)
public
R
<
TenantDto
>
getTenantByUserId
(
@RequestParam
(
"userId"
)
Long
userId
)
{
Tenant
tenant
=
userService
.
getTenantByUserId
(
userId
);
TenantDto
tenantDto
=
TenantConverter
.
INSTANCE
.
do2dtoApi
(
tenant
);
return
R
.
ok
().
data
(
tenantDto
);
}
}
src/main/java/cn/com/glsx/shield/modules/converter/TenantConverter.java
View file @
248721d
...
...
@@ -2,6 +2,7 @@ package cn.com.glsx.shield.modules.converter;
import
cn.com.glsx.shield.modules.entity.Tenant
;
import
cn.com.glsx.shield.modules.model.view.TenantDTO
;
import
cn.com.glsx.usercenter.api.dto.response.TenantDto
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.Mappings
;
...
...
@@ -15,4 +16,5 @@ public interface TenantConverter {
@Mappings
({
@Mapping
(
source
=
"id"
,
target
=
"tenantId"
)})
TenantDTO
do2dto
(
Tenant
tenant
);
TenantDto
do2dtoApi
(
Tenant
tenant
);
}
src/main/java/cn/com/glsx/shield/modules/service/UserService.java
View file @
248721d
...
...
@@ -1078,4 +1078,15 @@ public class UserService {
}
return
userDto
;
}
/**
* 通过用户ID获取租户数据
*
* @param userId 用户
* @return
*/
public
Tenant
getTenantByUserId
(
Long
userId
)
{
User
user
=
userMapper
.
selectById
(
userId
);
return
tenantMapper
.
selectById
(
user
.
getTenantId
());
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment