Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
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 446aeec2
authored
Apr 13, 2021
by
1539136324@qq.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完成组织架构员工数据隔离
1 parent
41270f85
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
19 deletions
linkwe-framework/src/main/java/com/linkwechat/framework/config/MyBatisPlusConfig.java
linkwe-system/src/main/resources/mapper/system/SysUserMapper.xml
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAccessTokenServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeDepartmentServiceImpl.java
pom.xml
linkwe-framework/src/main/java/com/linkwechat/framework/config/MyBatisPlusConfig.java
View file @
446aeec
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerIntercept
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerIntercept
import
com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor
;
import
com.github.pagehelper.PageInterceptor
;
import
com.github.pagehelper.PageInterceptor
;
import
com.linkwechat.common.config.WeComeConfig
;
import
com.linkwechat.common.config.WeComeConfig
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
net.sf.jsqlparser.expression.Expression
;
import
net.sf.jsqlparser.expression.Expression
;
import
net.sf.jsqlparser.expression.StringValue
;
import
net.sf.jsqlparser.expression.StringValue
;
...
@@ -48,7 +49,13 @@ public class MyBatisPlusConfig
...
@@ -48,7 +49,13 @@ public class MyBatisPlusConfig
@Override
@Override
public
Expression
getTenantId
()
{
public
Expression
getTenantId
()
{
return
new
StringValue
(
SecurityUtils
.
getLoginUser
().
getUser
().
getWeCorpAccount
().
getCorpId
());
WeCorpAccount
weCorpAccount
=
SecurityUtils
.
getLoginUser
().
getUser
().
getWeCorpAccount
();
if
(
null
!=
weCorpAccount
){
return
new
StringValue
(
weCorpAccount
.
getCorpId
());
}
return
null
;
}
}
// 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件,
// 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件,
// 这里设置 role表不需要该条件
// 这里设置 role表不需要该条件
...
...
linkwe-system/src/main/resources/mapper/system/SysUserMapper.xml
View file @
446aeec
...
@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"userType"
column=
"user_type"
/>
<association
property=
"dept"
column=
"dept_id"
javaType=
"SysDept"
resultMap=
"deptResult"
/>
<association
property=
"dept"
column=
"dept_id"
javaType=
"SysDept"
resultMap=
"deptResult"
/>
<collection
property=
"roles"
javaType=
"java.util.List"
resultMap=
"RoleResult"
/>
<collection
property=
"roles"
javaType=
"java.util.List"
resultMap=
"RoleResult"
/>
</resultMap>
</resultMap>
...
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql
id=
"selectUserVo"
>
<sql
id=
"selectUserVo"
>
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
u.user_type,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_dept d on u.dept_id = d.dept_id
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAccessTokenServiceImpl.java
View file @
446aeec
...
@@ -136,8 +136,6 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -136,8 +136,6 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
private
String
findAccessToken
(
String
accessTokenKey
){
private
String
findAccessToken
(
String
accessTokenKey
){
// WeCorpAccount wxCorpAccount
// = iWxCorpAccountService.findValidWeCorpAccount();
WeCorpAccount
wxCorpAccount
WeCorpAccount
wxCorpAccount
...
@@ -149,7 +147,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -149,7 +147,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
}
String
weAccessToken
=
redisCache
.
getCacheObject
(
accessTokenKey
+
"::"
+
wxCorpAccount
.
get
Agent
Id
());
String
weAccessToken
=
redisCache
.
getCacheObject
(
accessTokenKey
+
"::"
+
wxCorpAccount
.
get
Corp
Id
());
...
@@ -180,7 +178,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -180,7 +178,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
}
if
(
StringUtils
.
isNotEmpty
(
token
)){
if
(
StringUtils
.
isNotEmpty
(
token
)){
redisCache
.
setCacheObject
(
accessTokenKey
+
"::"
+
wxCorpAccount
.
get
Agent
Id
(),
token
,
expires_in
.
intValue
(),
TimeUnit
.
SECONDS
);
redisCache
.
setCacheObject
(
accessTokenKey
+
"::"
+
wxCorpAccount
.
get
Corp
Id
(),
token
,
expires_in
.
intValue
(),
TimeUnit
.
SECONDS
);
weAccessToken
=
token
;
weAccessToken
=
token
;
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeDepartmentServiceImpl.java
View file @
446aeec
...
@@ -63,19 +63,19 @@ public class WeDepartmentServiceImpl extends ServiceImpl<WeDepartmentMapper,WeDe
...
@@ -63,19 +63,19 @@ public class WeDepartmentServiceImpl extends ServiceImpl<WeDepartmentMapper,WeDe
{
{
//校验数据中中是否存在根节点,如果不存在,从微信端获取,同时入库
//校验数据中中是否存在根节点,如果不存在,从微信端获取,同时入库
WeDepartment
weDepartment
=
this
.
baseMapper
.
selectWeDepartmentById
(
WeConstans
.
WE_ROOT_DEPARMENT_ID
);
//
WeDepartment weDepartment=this.baseMapper.selectWeDepartmentById(WeConstans.WE_ROOT_DEPARMENT_ID);
if
(
null
==
weDepartment
){
//
if(null == weDepartment){
WeDepartMentDto
weDepartMentDto
=
weDepartMentClient
.
weDepartMents
(
WeConstans
.
WE_ROOT_DEPARMENT_ID
);
//
WeDepartMentDto weDepartMentDto=weDepartMentClient.weDepartMents(WeConstans.WE_ROOT_DEPARMENT_ID);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
weDepartMentDto
.
getErrcode
())
//
if(WeConstans.WE_SUCCESS_CODE.equals(weDepartMentDto.getErrcode())
&&
CollectionUtils
.
isNotEmpty
(
weDepartMentDto
.
getDepartment
())){
//
&& CollectionUtils.isNotEmpty(weDepartMentDto.getDepartment())){
this
.
baseMapper
.
insertWeDepartment
(
//
this.baseMapper.insertWeDepartment(
WeDepartment
.
transformWeDepartment
(
//
WeDepartment.transformWeDepartment(
weDepartMentDto
.
getDepartment
().
stream
().
filter
(
item
->
item
.
getId
().
equals
(
WeConstans
.
WE_ROOT_DEPARMENT_ID
)).
findFirst
().
get
()
//
weDepartMentDto.getDepartment().stream().filter(item->item.getId().equals(WeConstans.WE_ROOT_DEPARMENT_ID)).findFirst().get()
)
//
)
);
//
);
//
}
//
}
}
//
}
return
this
.
baseMapper
.
selectWeDepartmentList
();
return
this
.
baseMapper
.
selectWeDepartmentList
();
}
}
...
...
pom.xml
View file @
446aeec
...
@@ -83,6 +83,12 @@
...
@@ -83,6 +83,12 @@
<groupId>
com.github.pagehelper
</groupId>
<groupId>
com.github.pagehelper
</groupId>
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<version>
${pagehelper.boot.version}
</version>
<version>
${pagehelper.boot.version}
</version>
<exclusions>
<exclusion>
<groupId>
com.github.jsqlparser
</groupId>
<artifactId>
jsqlparser
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<!-- 获取系统信息 -->
<!-- 获取系统信息 -->
...
...
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