提交 ba355860 编写于 作者: 1 1539136324@qq.com

完成组织架构员工数据隔离

上级 8b506f47
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerIntercept
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.github.pagehelper.PageInterceptor;
import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.utils.SecurityUtils;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
......@@ -48,7 +49,13 @@ public class MyBatisPlusConfig
@Override
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 表示所有表都需要拼多租户条件,
// 这里设置 role表不需要该条件
......
......@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="userType" column="user_type" />
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
......@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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,
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
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
......
......@@ -136,8 +136,6 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
private String findAccessToken(String accessTokenKey){
// WeCorpAccount wxCorpAccount
// = iWxCorpAccountService.findValidWeCorpAccount();
WeCorpAccount wxCorpAccount
......@@ -149,7 +147,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
String weAccessToken =redisCache.getCacheObject(accessTokenKey+"::"+wxCorpAccount.getAgentId());
String weAccessToken =redisCache.getCacheObject(accessTokenKey+"::"+wxCorpAccount.getCorpId());
......@@ -180,7 +178,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
if(StringUtils.isNotEmpty(token)){
redisCache.setCacheObject(accessTokenKey+"::"+wxCorpAccount.getAgentId(),token,expires_in.intValue(), TimeUnit.SECONDS);
redisCache.setCacheObject(accessTokenKey+"::"+wxCorpAccount.getCorpId(),token,expires_in.intValue(), TimeUnit.SECONDS);
weAccessToken = token;
}
......
......@@ -63,19 +63,19 @@ public class WeDepartmentServiceImpl extends ServiceImpl<WeDepartmentMapper,WeDe
{
//校验数据中中是否存在根节点,如果不存在,从微信端获取,同时入库
WeDepartment weDepartment=this.baseMapper.selectWeDepartmentById(WeConstans.WE_ROOT_DEPARMENT_ID);
if(null == weDepartment){
WeDepartMentDto weDepartMentDto=weDepartMentClient.weDepartMents(WeConstans.WE_ROOT_DEPARMENT_ID);
if(WeConstans.WE_SUCCESS_CODE.equals(weDepartMentDto.getErrcode())
&& CollectionUtils.isNotEmpty(weDepartMentDto.getDepartment())){
this.baseMapper.insertWeDepartment(
WeDepartment.transformWeDepartment(
weDepartMentDto.getDepartment().stream().filter(item->item.getId().equals(WeConstans.WE_ROOT_DEPARMENT_ID)).findFirst().get()
)
);
}
}
// WeDepartment weDepartment=this.baseMapper.selectWeDepartmentById(WeConstans.WE_ROOT_DEPARMENT_ID);
// if(null == weDepartment){
// WeDepartMentDto weDepartMentDto=weDepartMentClient.weDepartMents(WeConstans.WE_ROOT_DEPARMENT_ID);
// if(WeConstans.WE_SUCCESS_CODE.equals(weDepartMentDto.getErrcode())
// && CollectionUtils.isNotEmpty(weDepartMentDto.getDepartment())){
// this.baseMapper.insertWeDepartment(
// WeDepartment.transformWeDepartment(
// weDepartMentDto.getDepartment().stream().filter(item->item.getId().equals(WeConstans.WE_ROOT_DEPARMENT_ID)).findFirst().get()
// )
// );
//
// }
// }
return this.baseMapper.selectWeDepartmentList();
}
......
......@@ -83,6 +83,12 @@
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 获取系统信息 -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册