Commit a0e8d2f3 by 水库浪子 Committed by Gitee

Merge branch 'multi-tenant-lw' of gitee.com:LinkWeChat/link-wechat into back_end_dev

2 parents 7f4af205 4530fae1
Showing 27 changed files with 490 additions and 122 deletions
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
<div align="center"> <div align="center">
![GVP Stars](http://img.shields.io/badge/GPV%20Stars-700+-yellow) [![star](https://gitee.com/LinkWeChat/link-wechat/badge/star.svg?theme=gvp)](https://gitee.com/LinkWeChat/link-wechat/stargazers)
![GVP Forks](http://img.shields.io/badge/GPV%20Forks-200+-yellow) [![fork](https://gitee.com/LinkWeChat/link-wechat/badge/fork.svg?theme=gvp)](https://gitee.com/LinkWeChat/link-wechat/members)
![license](http://img.shields.io/badge/license-GPL%203.0-green) [![license](http://img.shields.io/badge/license-GPL%203.0-green)](https://gitee.com/LinkWeChat/link-wechat/blob/master/LICENSE)
</div> </div>
...@@ -18,9 +18,20 @@ ...@@ -18,9 +18,20 @@
<p></p> <p></p>
<p></p> <p></p>
<p></p> <p></p>
<p></p>
<p></p>
<p></p>
<p></p>
![输入图片说明](https://images.gitee.com/uploads/images/2020/1231/233450_65d03349_1480777.png "LinkWeChat 企业微信私域流量营销专家-V1.0.4_00.png") ![输入图片说明](https://images.gitee.com/uploads/images/2020/1231/233450_65d03349_1480777.png "LinkWeChat 企业微信私域流量营销专家-V1.0.4_00.png")
---
**如果您觉得我们的开源项目很有帮助,请帮忙点击右上方的 :star: Star ,您的认可就是我们最大的动力,谢谢支持!:heart:**
---
### 平台简介 ### 平台简介
> LinkWeChat, Link to WeChat > LinkWeChat, Link to WeChat
...@@ -213,13 +224,13 @@ com.linkwechat ...@@ -213,13 +224,13 @@ com.linkwechat
#### 在线体验 #### 在线体验
演示地址:http://106.13.201.219/ 演示地址:http://demo.linkwechat.cn
演示账号/密码:test/123456 演示账号/密码:Wecome/123456
#### 开发进度 #### 开发进度
![输入图片说明](https://images.gitee.com/uploads/images/2020/1231/233603_09dc4ac4_1480777.png "LinkWeChat 1.0.png") ![输入图片说明](https://images.gitee.com/uploads/images/2021/0315/205221_36f5b3f3_1480777.png "LinkWeChat 1.0.png")
### 联系作者加入群 ### 联系作者加入群
...@@ -247,3 +258,63 @@ com.linkwechat ...@@ -247,3 +258,63 @@ com.linkwechat
### 版权声明 ### 版权声明
LinkWeChat 开源版遵循 [GPL-3.0](https://gitee.com/LinkWeChat/link-wechat/blob/master/LICENSE) 开源协议发布,并提供免费使用,但 **绝不允许修改后和衍生的代码做为闭源的商业软件发布和销售!** LinkWeChat 开源版遵循 [GPL-3.0](https://gitee.com/LinkWeChat/link-wechat/blob/master/LICENSE) 开源协议发布,并提供免费使用,但 **绝不允许修改后和衍生的代码做为闭源的商业软件发布和销售!**
### 捐赠支持
#### 来一杯卡布奇诺
如果您觉得我们的开源项目 `LinkWeChat` 对您有帮助,那就请项目开发者们来一杯卡布奇诺吧!当前我们接受来自于**微信**、**支付宝**或者**码云**的捐赠,请在捐赠时备注自己的昵称或附言。
您的捐赠将用于支付该项目的一些费用支出,并激励开发者们以便更好的推动项目的发展,同时欢迎捐赠**公网服务器**用于提高在线演示系统体验。
![输入图片说明](https://images.gitee.com/uploads/images/2021/0222/221344_727a0e80_1480777.png "image-20210222214357456.png")
#### 长期捐赠
如果您是企业的经营者并且有计划将 `LinkWeChat` 用在公司的经营产品中,欢迎进行长期捐赠。长期捐赠有商业上的益处有:
* 积极响应,快速维护,及时更新;
* 企业名称、Logo 及官网链接将长期展示在开源仓库、`LinkWeChat` 官网及宣发材料中;
* 捐赠金额同比例抵扣未来 `LinkWeChat` 的付费产品价格。
如果您对长期赞助 `LinkWeChat` 团队感兴趣,或者有其他好想法,欢迎联系开发团队微信 `sxjiangdongqin`,或发送邮件到 iamxiarui@foxmail.com。
#### 捐赠记录
`LinkWeChat` 全体开发团队感谢以下全部小伙伴们的赞助(排名不分先后):
| 昵称 | 金额 | 渠道 | 时间 | 附言 |
| :------: | :-----: | :--: | :-----------------: | :----------------: |
| yang | ¥10.00 | 码云 | 2021-02-22 22:08:59 | 感谢您的开源项目! |
| 水库浪子 | ¥1.00 | 码云 | 2021-02-22 22:09:03 | 感谢您的开源项目! |
| 楼* | ¥166.60 | 微信 | 2021-02-22 22:27:25 | 希望这个好项目能长久发展 |
| joygezxp | ¥66.60 | 微信 | 2021-02-22 22:39:41 | 愿项目一路666 |
| iamxiarui | ¥10.00 | 微信 | 2021-02-22 22:37:52 | 坚持开源不容易 |
| godricV | ¥10.00 | 微信 | 2021-02-22 22:28:55 | 感谢您的开源项目! |
| *标 | ¥20.00 | 微信 | 2021-03-05 16:03:19 | 感谢您的开源项目! |
| *涯 | ¥30.00 | 微信 | 2021-03-09 12:14:02 | 加油,感谢开源! |
| *魂 | ¥30.00 | 微信 | 2021-03-11 10:52:47 | 感谢开源供大家学习 |
| *J | ¥10.00 | 微信 | 2021-03-12 14:20:22 | 感谢开源供大家学习 |
| 杨*源 | ¥10.00 | 码云 | 2021-03-23 11:07:22 | 期待月底的大更新 |
| 骆*升 | ¥66.66 | 支付宝 | 2021-03-23 11:31:58 | 感谢开源供大家学习 |
| 曲*旭 | ¥20.00 | 码云 | 2021-03-23 11:31:58 | 感谢您的开源项目! |
| 郑* | ¥ 50.00 | 码云 | 2021-03-23 11:31:58 | 虽然之前做过类似的,还是感谢下开源和分享的奉献精神 |
| *喵 | ¥ 66.00 | 微信 | 2021-03-24 11:06:31 | 感谢您的开源项目! |
| q*s | ¥ 50.00 | 微信 | 2021-03-29 19:57:49 | 感谢您的开源项目! |
| *海 | ¥ 1.00 | 微信 | 2021-03-30 10:47:03 | 感谢您的开源项目! |
| m*r | ¥ 50.00 | 微信 | 2021-03-30 17:55:30 | 感谢您的开源项目! |
| *祺 | ¥ 20.00 | 支付宝 | 2021-03-30 19:03:59 | 感谢您的开源项目! |
| *桥 | ¥ 66.66 | 支付宝 | 2021-04-07 16:38:31 | 祝项目一路 666 |
| *力 | ¥ 66.00 | 微信 | 2021-04-09 10:30:11 | 支持开源 |
`LinkWeChat` 全体开发团队感谢以下全部合作伙伴的服务器赞助(排名不分先后):
| 公司/个人名称 | 服务器 |
| :------: | :-----: |
| 上海六感科技有限公司 | 八核 16G 服务器一台 |
| Happy | 两核 8G 服务器一台 |
| 平山阑槛倚晴空 | 两核 4G 服务器一台 |
---
**如果您觉得我们的开源项目很有帮助,请帮忙点击右上方的 :star: Star ,您的认可就是我们最大的动力,谢谢支持!:heart:**
\ No newline at end of file \ No newline at end of file
package com.linkwechat.web.controller.system; package com.linkwechat.web.controller.system;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.domain.entity.SysMenu; import com.linkwechat.common.core.domain.entity.SysMenu;
...@@ -12,7 +13,7 @@ import com.linkwechat.framework.web.service.SysPermissionService; ...@@ -12,7 +13,7 @@ import com.linkwechat.framework.web.service.SysPermissionService;
import com.linkwechat.framework.web.service.TokenService; import com.linkwechat.framework.web.service.TokenService;
import com.linkwechat.system.service.ISysMenuService; import com.linkwechat.system.service.ISysMenuService;
import com.linkwechat.wecom.client.WeAccessTokenClient; import com.linkwechat.wecom.client.WeAccessTokenClient;
import com.linkwechat.wecom.domain.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.domain.dto.WeLoginUserInfoDto; import com.linkwechat.wecom.domain.dto.WeLoginUserInfoDto;
import com.linkwechat.wecom.service.IWeCorpAccountService; import com.linkwechat.wecom.service.IWeCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -53,6 +54,12 @@ public class SysLoginController ...@@ -53,6 +54,12 @@ public class SysLoginController
private WeAccessTokenClient weAccessTokenClient; private WeAccessTokenClient weAccessTokenClient;
// @Autowired
// private IWeGroupCodeService weGroupCodeService;
/** /**
* 登录方法 * 登录方法
* *
...@@ -86,12 +93,14 @@ public class SysLoginController ...@@ -86,12 +93,14 @@ public class SysLoginController
Set<String> roles = permissionService.getRolePermission(user); Set<String> roles = permissionService.getRolePermission(user);
// 权限集合 // 权限集合
Set<String> permissions = permissionService.getMenuPermission(user); Set<String> permissions = permissionService.getMenuPermission(user);
//校验用户是否拥有可用corpid //校验用户是否拥有可用corpid
WeCorpAccount wxCorpAccount // WeCorpAccount wxCorpAccount
= iWxCorpAccountService.findValidWeCorpAccount(); // = iWxCorpAccountService.findValidWeCorpAccount();
if(null != wxCorpAccount){ // if(null != wxCorpAccount){
user.setValidCropId(true); // user.setValidCropId(true);
} // }
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("user", user); ajax.put("user", user);
ajax.put("roles", roles); ajax.put("roles", roles);
...@@ -121,15 +130,15 @@ public class SysLoginController ...@@ -121,15 +130,15 @@ public class SysLoginController
@GetMapping("/findWxQrLoginInfo") @GetMapping("/findWxQrLoginInfo")
public AjaxResult findQrLoginParm(){ public AjaxResult findQrLoginParm(){
WeCorpAccount validWeCorpAccount // WeCorpAccount validWeCorpAccount
= iWxCorpAccountService.findValidWeCorpAccount(); // = iWxCorpAccountService.findValidWeCorpAccount();
if(null != validWeCorpAccount){ // if(null != validWeCorpAccount){
validWeCorpAccount.setContactSecret(null); // validWeCorpAccount.setContactSecret(null);
validWeCorpAccount.setCorpSecret(null); // validWeCorpAccount.setCorpSecret(null);
validWeCorpAccount.setProviderSecret(null); // validWeCorpAccount.setProviderSecret(null);
} // }
return AjaxResult.success(validWeCorpAccount); return AjaxResult.success();
} }
...@@ -155,18 +164,26 @@ public class SysLoginController ...@@ -155,18 +164,26 @@ public class SysLoginController
/** /**
* 租户登录 * 通过企业id和企业密钥登录
* @param corpId * @param corpId
* @param corpSecret * @param corpSecret
* @return * @return
*/ */
@GetMapping("/tenantLogin") @GetMapping("/corpLogin")
public AjaxResult tenantLogin(String corpId,String corpSecret){ public AjaxResult corpLogin(String corpId,String corpSecret){
AjaxResult ajax = AjaxResult.success(); List<WeCorpAccount> weCorpAccounts = iWxCorpAccountService.selectWeCorpAccountList(WeCorpAccount.builder()
.corpId(corpId)
.corpSecret(corpSecret)
.delFlag(Constants.NORMAL_CODE)
.build());
if(CollectionUtil.isEmpty(weCorpAccounts)){
return AjaxResult.error("当前企业id与企业密码不匹配或不存在");
}
return ajax; return AjaxResult.success(
loginService.noPwdLogin(weCorpAccounts.get(0).getCropAccount())
);
} }
} }
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.service.IWeCorpAccountService; import com.linkwechat.wecom.service.IWeCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
......
#spring.cloud.nacos.config.server-addr=
#spring.cloud.nacos.config.namespace=
#spring.application.name=
#spring.cloud.nacos.config.file-extension=
\ No newline at end of file \ No newline at end of file
spring.cloud.nacos.config.server-addr=${NACOS_SERVER:119.45.28.29:10848}
spring.cloud.nacos.config.namespace=f3edcb53-b0f8-42c3-8c5f-37c263deb60e
spring.application.name=link-wechat
spring.cloud.nacos.config.file-extension=yaml
\ No newline at end of file \ No newline at end of file
...@@ -39,12 +39,6 @@ ...@@ -39,12 +39,6 @@
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>pagehelper-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- 自定义验证注解 --> <!-- 自定义验证注解 -->
...@@ -260,6 +254,12 @@ ...@@ -260,6 +254,12 @@
<artifactId>bcpkix-jdk15on</artifactId> <artifactId>bcpkix-jdk15on</artifactId>
<version>1.68</version> <version>1.68</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.jsqlparser</groupId>-->
<!-- <artifactId>jsqlparser</artifactId>-->
<!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -36,4 +36,7 @@ public class WeComeConfig { ...@@ -36,4 +36,7 @@ public class WeComeConfig {
/** 第三方自建应用得url*/ /** 第三方自建应用得url*/
private String[] thirdAppUrl; private String[] thirdAppUrl;
/**多租户相关表*/
private String[] needTenant=new String[]{};
} }
...@@ -151,18 +151,17 @@ public class Constants ...@@ -151,18 +151,17 @@ public class Constants
public static final String USER_TYPE_WECOME="11"; public static final String USER_TYPE_WECOME="11";
/** 企业管理 */
public static final String USER_TYOE_CORP_ADMIN="22";
/** 企业微信用户系统中默认用户 */ /** 企业微信用户系统中默认用户 */
public static final String DEFAULT_WECOME_ROLE_KEY="WeCome"; public static final String DEFAULT_WECOME_ROLE_KEY="WeCome";
/** 企业微信用户系统中默认用户 */
public static final String DEFAULT_WECOME_CORP_ADMIN="CROP_ADMIN_ROLE";
/**完成待办*/ /**完成待办*/
public static final String HANDLE_SUCCESS="1"; public static final String HANDLE_SUCCESS="1";
} }
...@@ -105,6 +105,9 @@ public class SysUser extends BaseEntity ...@@ -105,6 +105,9 @@ public class SysUser extends BaseEntity
/** 是否具有有效得cropId */ /** 是否具有有效得cropId */
private boolean validCropId=false; private boolean validCropId=false;
private WeCorpAccount weCorpAccount;
public SysUser() public SysUser()
{ {
......
package com.linkwechat.wecom.domain; package com.linkwechat.common.core.domain.entity;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
...@@ -76,4 +76,8 @@ public class WeCorpAccount extends BaseEntity ...@@ -76,4 +76,8 @@ public class WeCorpAccount extends BaseEntity
@ApiModelProperty("客户流失通知开关 0:关闭 1:开启") @ApiModelProperty("客户流失通知开关 0:关闭 1:开启")
private String customerChurnNoticeSwitch = new String("0"); private String customerChurnNoticeSwitch = new String("0");
@ApiModelProperty("企业管理员账号")
private String cropAccount;
} }
...@@ -87,4 +87,7 @@ public class SecurityUtils ...@@ -87,4 +87,7 @@ public class SecurityUtils
{ {
return userId != null && 1L == userId; return userId != null && 1L == userId;
} }
} }
package com.linkwechat.framework.config; package com.linkwechat.framework.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
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.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.utils.SecurityUtils;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.plugin.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
/** /**
* Mybatis支持*匹配扫描包 * Mybatis支持*匹配扫描包
...@@ -14,9 +27,103 @@ import org.springframework.context.annotation.Configuration; ...@@ -14,9 +27,103 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class MyBatisPlusConfig public class MyBatisPlusConfig
{ {
@Autowired
WeComeConfig weComeConfig;
//
// @Bean
// public MybatisPlusInterceptor mybatisPlusInterceptor() {
// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// // 如果用了分页插件注意先 add TenantLineInnerInterceptor 再 add PaginationInnerInterceptor
// // 用了分页插件必须设置 MybatisConfiguration#useDeprecatedExecutor = false
// // interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
//
// interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(
// new TenantLineHandler() {
// // 获取租户 ID 值表达式,只支持单个 ID 值
// @Override
// public Expression getTenantId() {
//
// WeCorpAccount weCorpAccount
// = SecurityUtils.getLoginUser().getUser().getWeCorpAccount();
// if(null != weCorpAccount){
// return new StringValue(weCorpAccount.getCorpId());
// }
//
// return null;
// }
// // 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件,
// // 这里设置 role表不需要该条件
// @Override
// public boolean ignoreTable(String tableName) {
//
// if (Arrays.asList(weComeConfig.getNeedTenant())
// .contains(tableName)){
// return false;
// }
// return true;
// }
//
// @Override
// public String getTenantIdColumn() {
// return "corp_id";
// }
// }));
// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// return interceptor;
// }
// @Bean
// public ConfigurationCustomizer configurationCustomizer() {
// return configuration -> configuration.setUseDeprecatedExecutor(false);
// }
@Bean @Bean
public Interceptor[] plugins() { public Interceptor[] plugins() {
return new Interceptor[]{new PageInterceptor()}; MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(
new TenantLineHandler() {
// 获取租户 ID 值表达式,只支持单个 ID 值
@Override
public Expression getTenantId() {
WeCorpAccount weCorpAccount
= SecurityUtils.getLoginUser().getUser().getWeCorpAccount();
if(null != weCorpAccount){
return new StringValue(weCorpAccount.getCorpId());
}
return null;
}
// 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件,
// 这里设置 role表不需要该条件
@Override
public boolean ignoreTable(String tableName) {
if (Arrays.asList(weComeConfig.getNeedTenant())
.contains(tableName)){
return false;
}
return true;
}
@Override
public String getTenantIdColumn() {
return "corp_id";
}
}));
//
return new Interceptor[]{interceptor,new PageInterceptor()
};
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -130,6 +130,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -130,6 +130,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/wecom/community/h5/**").anonymous() .antMatchers("/wecom/community/h5/**").anonymous()
//微信授权接口 //微信授权接口
.antMatchers("/weixin/auth/**").anonymous() .antMatchers("/weixin/auth/**").anonymous()
// .antMatchers("/common/uploadFile2Cos").anonymous()
.antMatchers("/wecom/material/temporaryMaterialMediaId").anonymous()
.antMatchers("/wecom/portrait/**").anonymous()
.antMatchers("/wecom/findAddaddEmployes").anonymous()
.antMatchers("/corpLogin").anonymous()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
......
package com.linkwechat.framework.web.service; package com.linkwechat.framework.web.service;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.core.domain.entity.SysRole; import com.linkwechat.common.core.domain.entity.SysRole;
import com.linkwechat.common.core.domain.entity.SysUser; import com.linkwechat.common.core.domain.entity.SysUser;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.core.domain.model.LoginUser; import com.linkwechat.common.core.domain.model.LoginUser;
import com.linkwechat.common.enums.UserStatus; import com.linkwechat.common.enums.UserStatus;
import com.linkwechat.common.exception.BaseException; import com.linkwechat.common.exception.BaseException;
...@@ -12,7 +14,7 @@ import com.linkwechat.common.utils.SecurityUtils; ...@@ -12,7 +14,7 @@ import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.system.mapper.SysRoleMapper; import com.linkwechat.system.mapper.SysRoleMapper;
import com.linkwechat.system.service.ISysUserService; import com.linkwechat.system.service.ISysUserService;
import com.linkwechat.wecom.domain.WeUser; import com.linkwechat.wecom.service.IWeCorpAccountService;
import com.linkwechat.wecom.service.IWeUserService; import com.linkwechat.wecom.service.IWeUserService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -51,35 +53,58 @@ public class UserDetailsServiceImpl implements UserDetailsService ...@@ -51,35 +53,58 @@ public class UserDetailsServiceImpl implements UserDetailsService
private SysRoleMapper roleMapper; private SysRoleMapper roleMapper;
@Autowired
private IWeCorpAccountService iWeCorpAccountService;
@Override @Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
{ {
SysUser user = userService.selectUserByUserName(username); SysUser user = userService.selectUserByUserName(username);
System.out.println(user.getUserType());
if (StringUtils.isNull(user)) if (StringUtils.isNull(user))
{ {
//we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中 //企业管理登录
WeUser weUser //查询企业管理相关账号
= iWeUserService.getById(username); WeCorpAccount weCorpByAccount = iWeCorpAccountService.findWeCorpByAccount(username);
if(null == weUser){ if(null != weCorpByAccount){
log.info("登录用户:{} 不存在.", username);
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
}
//注册到we_user表中 //注册到we_user表中
user=SysUser.builder() user= SysUser.builder()
.userName(weUser.getUserId()) .userName(weCorpByAccount.getCropAccount())
.nickName(weUser.getName()) .nickName(weCorpByAccount.getCompanyName())
.userType(Constants.USER_TYPE_WECOME) .userType(Constants.USER_TYOE_CORP_ADMIN)
.email(weUser.getEmail())
.phonenumber(weUser.getMobile())
.sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString())
.avatar(weUser.getAvatarMediaid())
.roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder() .roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
.roleKey(Constants.DEFAULT_WECOME_ROLE_KEY) .roleKey(Constants.DEFAULT_WECOME_CORP_ADMIN)
.build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class)) .build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class))
.password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd())) .password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd()))
.build(); .build();
}
// else{
//
// //we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中
// WeUser weUser
// = iWeUserService.getById(username);
// if(null == weUser){
// log.info("登录用户:{} 不存在.", username);
// throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
// }
//
// //注册到we_user表中
// user=SysUser.builder()
// .userName(weUser.getUserId())
// .nickName(weUser.getName())
// .userType(Constants.USER_TYPE_WECOME)
// .email(weUser.getEmail())
// .phonenumber(weUser.getMobile())
// .sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString())
// .avatar(weUser.getAvatarMediaid())
// .roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
// .roleKey(Constants.DEFAULT_WECOME_ROLE_KEY)
// .build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class))
// .password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd()))
// .build();
// }
userService.insertUser( userService.insertUser(
user user
); );
...@@ -95,6 +120,13 @@ public class UserDetailsServiceImpl implements UserDetailsService ...@@ -95,6 +120,13 @@ public class UserDetailsServiceImpl implements UserDetailsService
throw new BaseException("对不起,您的账号:" + username + " 已停用"); throw new BaseException("对不起,您的账号:" + username + " 已停用");
} }
//当前登录用户为企业管理,设置corpId和密钥相关
if(Constants.USER_TYOE_CORP_ADMIN.equals(user.getUserType())){
user.setWeCorpAccount(
iWeCorpAccountService.findWeCorpByAccount(username)
);
}
return createLoginUser(user); return createLoginUser(user);
} }
......
...@@ -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
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
<version>5.2.9.RELEASE</version> <version>5.2.9.RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>com.linkwechat</groupId>
<artifactId>linkwe-system</artifactId>
</dependency>
</dependencies> </dependencies>
......
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.factory.impl.customer; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.factory.impl.customer;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.MessageType; import com.linkwechat.common.enums.MessageType;
import com.linkwechat.wecom.client.WeMessagePushClient; import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.*; import com.linkwechat.wecom.domain.*;
......
...@@ -8,6 +8,7 @@ import com.dtflys.forest.interceptor.Interceptor; ...@@ -8,6 +8,7 @@ import com.dtflys.forest.interceptor.Interceptor;
import com.dtflys.forest.utils.ForestDataType; import com.dtflys.forest.utils.ForestDataType;
import com.linkwechat.common.config.WeComeConfig; import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.wecom.domain.dto.WeResultDto; import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.service.IWeAccessTokenService; import com.linkwechat.wecom.service.IWeAccessTokenService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import java.util.List; import java.util.List;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.baomidou.mybatisplus.annotation.SqlParser;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
...@@ -18,6 +20,7 @@ public interface WeCorpAccountMapper ...@@ -18,6 +20,7 @@ public interface WeCorpAccountMapper
* @param id 企业id相关配置ID * @param id 企业id相关配置ID
* @return 企业id相关配置 * @return 企业id相关配置
*/ */
@SqlParser(filter = true)
public WeCorpAccount selectWeCorpAccountById(Long id); public WeCorpAccount selectWeCorpAccountById(Long id);
/** /**
...@@ -26,6 +29,7 @@ public interface WeCorpAccountMapper ...@@ -26,6 +29,7 @@ public interface WeCorpAccountMapper
* @param wxCorpAccount 企业id相关配置 * @param wxCorpAccount 企业id相关配置
* @return 企业id相关配置集合 * @return 企业id相关配置集合
*/ */
@SqlParser(filter = true)
public List<WeCorpAccount> selectWeCorpAccountList(WeCorpAccount wxCorpAccount); public List<WeCorpAccount> selectWeCorpAccountList(WeCorpAccount wxCorpAccount);
/** /**
...@@ -34,6 +38,7 @@ public interface WeCorpAccountMapper ...@@ -34,6 +38,7 @@ public interface WeCorpAccountMapper
* @param wxCorpAccount 企业id相关配置 * @param wxCorpAccount 企业id相关配置
* @return 结果 * @return 结果
*/ */
@SqlParser(filter = true)
public int insertWeCorpAccount(WeCorpAccount wxCorpAccount); public int insertWeCorpAccount(WeCorpAccount wxCorpAccount);
/** /**
...@@ -42,6 +47,7 @@ public interface WeCorpAccountMapper ...@@ -42,6 +47,7 @@ public interface WeCorpAccountMapper
* @param wxCorpAccount 企业id相关配置 * @param wxCorpAccount 企业id相关配置
* @return 结果 * @return 结果
*/ */
@SqlParser(filter = true)
public int updateWeCorpAccount(WeCorpAccount wxCorpAccount); public int updateWeCorpAccount(WeCorpAccount wxCorpAccount);
...@@ -50,6 +56,7 @@ public interface WeCorpAccountMapper ...@@ -50,6 +56,7 @@ public interface WeCorpAccountMapper
* 获取有效cropid * 获取有效cropid
* @return * @return
*/ */
@SqlParser(filter = true)
public WeCorpAccount findValidWeCorpAccount(); public WeCorpAccount findValidWeCorpAccount();
...@@ -58,5 +65,15 @@ public interface WeCorpAccountMapper ...@@ -58,5 +65,15 @@ public interface WeCorpAccountMapper
* @param corpId * @param corpId
* @return * @return
*/ */
@SqlParser(filter = true)
public int startVailWeCorpAccount(@Param("corpId") String corpId); public int startVailWeCorpAccount(@Param("corpId") String corpId);
/**
* 根据企业账号获取企业相关配置
* @param corpAccount
* @return
*/
@SqlParser(filter = true)
WeCorpAccount findWeCorpByAccount(@Param("corpAccount") String corpAccount);
} }
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
/** /**
* @description: 微信token相关接口 * @description: 微信token相关接口
* @author: My * @author: My
...@@ -21,5 +23,5 @@ public interface IWeAccessTokenService { ...@@ -21,5 +23,5 @@ public interface IWeAccessTokenService {
public String findThirdAppAccessToken(String agentId); public String findThirdAppAccessToken(String agentId);
public void removeToken(); public void removeToken(WeCorpAccount wxCorpAccount);
} }
\ No newline at end of file \ No newline at end of file
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import java.util.List; import java.util.List;
import com.linkwechat.wecom.domain.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import org.apache.ibatis.annotations.Param;
/** /**
* 企业id相关配置Service接口 * 企业id相关配置Service接口
...@@ -71,4 +70,6 @@ public interface IWeCorpAccountService ...@@ -71,4 +70,6 @@ public interface IWeCorpAccountService
* 客户流失通知开关查询 * 客户流失通知开关查询
*/ */
public String getCustomerChurnNoticeSwitch(); public String getCustomerChurnNoticeSwitch();
WeCorpAccount findWeCorpByAccount(String corpAccount);
} }
...@@ -3,12 +3,15 @@ package com.linkwechat.wecom.service.impl; ...@@ -3,12 +3,15 @@ package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.entity.SysUser;
import com.linkwechat.common.core.domain.model.LoginUser;
import com.linkwechat.common.core.redis.RedisCache; import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeAccessTokenClient; import com.linkwechat.wecom.client.WeAccessTokenClient;
import com.linkwechat.wecom.domain.WeApp; import com.linkwechat.wecom.domain.WeApp;
import com.linkwechat.wecom.domain.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.domain.dto.WeAccessTokenDtoDto; import com.linkwechat.wecom.domain.dto.WeAccessTokenDtoDto;
import com.linkwechat.wecom.service.IWeAccessTokenService; import com.linkwechat.wecom.service.IWeAccessTokenService;
import com.linkwechat.wecom.service.IWeAppService; import com.linkwechat.wecom.service.IWeAppService;
...@@ -133,16 +136,25 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService { ...@@ -133,16 +136,25 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
private String findAccessToken(String accessTokenKey){ private String findAccessToken(String accessTokenKey){
String weAccessToken =redisCache.getCacheObject(accessTokenKey);
//为空,请求微信服务器同时缓存到redis中
if(StringUtils.isEmpty(weAccessToken)){
WeCorpAccount wxCorpAccount WeCorpAccount wxCorpAccount
= iWxCorpAccountService.findValidWeCorpAccount(); = SecurityUtils.getLoginUser().getUser().getWeCorpAccount();
if(null == wxCorpAccount){ if(null == wxCorpAccount){
//返回错误异常,让用户绑定企业id相关信息 //返回错误异常,让用户绑定企业id相关信息
throw new WeComException("无可用的corpid和secret"); throw new WeComException("无可用的corpid和secret");
} }
String weAccessToken =redisCache.getCacheObject(accessTokenKey+"::"+wxCorpAccount.getCorpId());
//为空,请求微信服务器同时缓存到redis中
if(StringUtils.isEmpty(weAccessToken)){
String token=""; String token="";
Long expires_in=null; Long expires_in=null;
if(WeConstans.WE_COMMON_ACCESS_TOKEN.equals(accessTokenKey) || WeConstans.WE_CONTACT_ACCESS_TOKEN.equals(accessTokenKey)){ if(WeConstans.WE_COMMON_ACCESS_TOKEN.equals(accessTokenKey) || WeConstans.WE_CONTACT_ACCESS_TOKEN.equals(accessTokenKey)){
...@@ -166,7 +178,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService { ...@@ -166,7 +178,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
} }
if(StringUtils.isNotEmpty(token)){ if(StringUtils.isNotEmpty(token)){
redisCache.setCacheObject(accessTokenKey,token,expires_in.intValue(), TimeUnit.SECONDS); redisCache.setCacheObject(accessTokenKey+"::"+wxCorpAccount.getCorpId(),token,expires_in.intValue(), TimeUnit.SECONDS);
weAccessToken = token; weAccessToken = token;
} }
...@@ -180,10 +192,10 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService { ...@@ -180,10 +192,10 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
* 清空redis中的相关token * 清空redis中的相关token
*/ */
@Override @Override
public void removeToken() { public void removeToken(WeCorpAccount wxCorpAccount) {
redisCache.deleteObject(WeConstans.WE_COMMON_ACCESS_TOKEN); redisCache.deleteObject(WeConstans.WE_COMMON_ACCESS_TOKEN+"::"+wxCorpAccount.getAgentId());
redisCache.deleteObject(WeConstans.WE_CONTACT_ACCESS_TOKEN); redisCache.deleteObject(WeConstans.WE_CONTACT_ACCESS_TOKEN+"::"+wxCorpAccount.getAgentId());
redisCache.deleteObject(WeConstans.WE_PROVIDER_ACCESS_TOKEN); redisCache.deleteObject(WeConstans.WE_PROVIDER_ACCESS_TOKEN+"::"+wxCorpAccount.getAgentId());
} }
......
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import java.util.List; import cn.hutool.core.collection.CollectionUtil;
import java.util.Optional; import cn.hutool.core.util.ArrayUtil;
import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.core.domain.entity.SysRole;
import com.linkwechat.common.core.domain.entity.SysUser;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.system.mapper.SysRoleMapper;
import com.linkwechat.system.service.ISysUserService;
import com.linkwechat.wecom.mapper.WeCorpAccountMapper;
import com.linkwechat.wecom.service.IWeAccessTokenService; import com.linkwechat.wecom.service.IWeAccessTokenService;
import com.linkwechat.wecom.service.IWeCorpAccountService; import com.linkwechat.wecom.service.IWeCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeCorpAccountMapper;
import com.linkwechat.wecom.domain.WeCorpAccount; import java.util.List;
import org.springframework.transaction.annotation.Transactional; import java.util.Optional;
import java.util.stream.Collectors;
//import com.linkwechat.system.mapper.SysRoleMapper;
//import com.linkwechat.system.service.ISysUserService;
/** /**
* 企业id相关配置Service业务层处理 * 企业id相关配置Service业务层处理
...@@ -23,13 +33,28 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -23,13 +33,28 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class WeCorpAccountServiceImpl implements IWeCorpAccountService { public class WeCorpAccountServiceImpl implements IWeCorpAccountService {
@Autowired
private WeCorpAccountMapper weCorpAccountMapper;
@Autowired @Autowired
private IWeAccessTokenService iWeAccessTokenService; private IWeAccessTokenService iWeAccessTokenService;
@Autowired
private ISysUserService iSysUserService;
@Autowired
private RuoYiConfig ruoYiConfig;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private WeCorpAccountMapper weCorpAccountMapper;
/** /**
* 查询企业id相关配置 * 查询企业id相关配置
* *
...@@ -63,8 +88,23 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService { ...@@ -63,8 +88,23 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService {
@Override @Override
public int insertWeCorpAccount(WeCorpAccount wxCorpAccount) public int insertWeCorpAccount(WeCorpAccount wxCorpAccount)
{ {
int returnCode = weCorpAccountMapper.insertWeCorpAccount(wxCorpAccount);
if(Constants.SERVICE_STATUS_ERROR<returnCode){
iSysUserService.insertUser(
SysUser.builder()
.userName(wxCorpAccount.getCropAccount())
.nickName(wxCorpAccount.getCompanyName())
.userType(Constants.USER_TYOE_CORP_ADMIN)
.roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
.roleKey(Constants.DEFAULT_WECOME_CORP_ADMIN)
.build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class))
.password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd()))
.build()
);
}
return weCorpAccountMapper.insertWeCorpAccount(wxCorpAccount); return returnCode;
} }
/** /**
...@@ -81,7 +121,7 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService { ...@@ -81,7 +121,7 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService {
if(Constants.SERVICE_RETURN_SUCCESS_CODE<returnCode){ if(Constants.SERVICE_RETURN_SUCCESS_CODE<returnCode){
iWeAccessTokenService.removeToken(); iWeAccessTokenService.removeToken(wxCorpAccount);
} }
...@@ -108,17 +148,30 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService { ...@@ -108,17 +148,30 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService {
@Override @Override
public int startVailWeCorpAccount(String corpId) { public int startVailWeCorpAccount(String corpId) {
int returnCode = weCorpAccountMapper.startVailWeCorpAccount(corpId); // List<WeCorpAccount> weCorpAccounts = weCorpAccountMapper.selectWeCorpAccountList(
// WeCorpAccount.builder()
if(Constants.SERVICE_RETURN_SUCCESS_CODE<returnCode){ // .corpId(corpId)
// .delFlag(Constants.NORMAL_CODE)
// .build()
iWeAccessTokenService.removeToken(); // );
// if(CollectionUtil.isNotEmpty(weCorpAccounts)){
} //
// WeCorpAccount weCorpAccount = weCorpAccounts.get(0);
//
return returnCode; // }
//
// int returnCode = weCorpAccountMapper.startVailWeCorpAccount(corpId);
//
// if(Constants.SERVICE_RETURN_SUCCESS_CODE<returnCode){
//
//
// iWeAccessTokenService.removeToken();
//
// }
//
//
// return returnCode;
return 1;
} }
@Override @Override
...@@ -137,4 +190,10 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService { ...@@ -137,4 +190,10 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService {
} }
@Override
public WeCorpAccount findWeCorpByAccount(String corpAccount) {
return weCorpAccountMapper.findWeCorpByAccount(corpAccount);
}
} }
...@@ -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();
} }
......
...@@ -13,7 +13,7 @@ import com.linkwechat.common.utils.DateUtils; ...@@ -13,7 +13,7 @@ import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeMessagePushClient; import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.domain.WeSensitive; import com.linkwechat.wecom.domain.WeSensitive;
import com.linkwechat.wecom.domain.WeSensitiveAuditScope; import com.linkwechat.wecom.domain.WeSensitiveAuditScope;
import com.linkwechat.wecom.domain.WeUser; import com.linkwechat.wecom.domain.WeUser;
......
...@@ -22,10 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -22,10 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="providerSecret" column="provider_secret" /> <result property="providerSecret" column="provider_secret" />
<result property="customerChurnNoticeSwitch" column="customer_churn_notice_switch" /> <result property="customerChurnNoticeSwitch" column="customer_churn_notice_switch" />
<result property="wxQrLoginRedirectUri" column="wx_qr_login_redirect_uri"/> <result property="wxQrLoginRedirectUri" column="wx_qr_login_redirect_uri"/>
<result property="cropAccount" column="corp_account"/>
</resultMap> </resultMap>
<sql id="selectWeCorpAccountVo"> <sql id="selectWeCorpAccountVo">
select id,chat_secret,provider_secret,company_name, corp_id, corp_secret,agent_id, agent_secret, status, del_flag, create_by, create_time, update_by, update_time,contact_secret, customer_churn_notice_switch,wx_qr_login_redirect_uri from we_corp_account select id,chat_secret,corp_account,provider_secret,company_name, corp_id, corp_secret,agent_id, agent_secret, status, del_flag, create_by, create_time, update_by, update_time,contact_secret, customer_churn_notice_switch,wx_qr_login_redirect_uri from we_corp_account
</sql> </sql>
<select id="selectWeCorpAccountList" parameterType="WeCorpAccount" resultMap="WeCorpAccountResult"> <select id="selectWeCorpAccountList" parameterType="WeCorpAccount" resultMap="WeCorpAccountResult">
...@@ -62,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -62,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerChurnNoticeSwitch != null ">customer_churn_notice_switch,</if> <if test="customerChurnNoticeSwitch != null ">customer_churn_notice_switch,</if>
<if test="providerSecret != null ">provider_secret,</if> <if test="providerSecret != null ">provider_secret,</if>
<if test="wxQrLoginRedirectUri != null ">wx_qr_login_redirect_uri,</if> <if test="wxQrLoginRedirectUri != null ">wx_qr_login_redirect_uri,</if>
<if test="cropAccount != null">corp_account,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyName != null">#{companyName},</if> <if test="companyName != null">#{companyName},</if>
...@@ -80,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -80,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerChurnNoticeSwitch != null ">#{customerChurnNoticeSwitch},</if> <if test="customerChurnNoticeSwitch != null ">#{customerChurnNoticeSwitch},</if>
<if test="providerSecret != null ">#{providerSecret},</if> <if test="providerSecret != null ">#{providerSecret},</if>
<if test="wxQrLoginRedirectUri != null ">#{wxQrLoginRedirectUri},</if> <if test="wxQrLoginRedirectUri != null ">#{wxQrLoginRedirectUri},</if>
<if test="cropAccount != null">#{cropAccount},</if>
</trim> </trim>
</insert> </insert>
...@@ -100,11 +103,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -100,11 +103,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="agentId != null ">agent_id = #{agentId},</if> <if test="agentId != null ">agent_id = #{agentId},</if>
<if test="agentSecret != null ">agent_secret =#{agentSecret},</if> <if test="agentSecret != null ">agent_secret =#{agentSecret},</if>
<if test="customerChurnNoticeSwitch != null ">customer_churn_notice_switch = #{customerChurnNoticeSwitch},</if> <if test="customerChurnNoticeSwitch != null ">customer_churn_notice_switch = #{customerChurnNoticeSwitch},</if>
<if test="providerSecret != null ">provider_secret = #{providerSecret},</if> <if test="providerSecret != null ">provider_secret = #{providerSecret},</if>
<if test="wxQrLoginRedirectUri != null ">wx_qr_login_redirect_uri = #{wxQrLoginRedirectUri},</if> <if test="wxQrLoginRedirectUri != null ">wx_qr_login_redirect_uri = #{wxQrLoginRedirectUri},</if>
<if test="cropAccount != null">corp_account = #{cropAccount},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
...@@ -125,6 +126,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -125,6 +126,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<select id="findWeCorpByAccount" resultMap="WeCorpAccountResult">
<include refid="selectWeCorpAccountVo"/>
WHERE
del_flag = 0
AND corp_account = #{corpAccount}
</select>
......
...@@ -83,6 +83,16 @@ ...@@ -83,6 +83,16 @@
<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>-->
<exclusion>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- 获取系统信息 --> <!-- 获取系统信息 -->
...@@ -245,6 +255,12 @@ ...@@ -245,6 +255,12 @@
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version> <version>${mybatis-plus.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
...@@ -271,6 +287,9 @@ ...@@ -271,6 +287,9 @@
<version>${nacos.version}</version> <version>${nacos.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.xml.bind</groupId> <groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId> <artifactId>jaxb-api</artifactId>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!