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 77c652af
authored
Nov 16, 2021
by
linkwechat8856@163.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
企微配置相关接口提交
1 parent
c0624ada
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
279 additions
and
624 deletions
linkwe-admin/pom.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeAppController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCorpAccountController.java
linkwe-common/src/main/java/com/linkwechat/common/core/domain/entity/WeCorpAccount.java
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeApp.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeAppMapper.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeCorpAccountMapper.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAccessTokenService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAppService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCorpAccountService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAccessTokenServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAppServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCorpAccountServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeAppMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCorpAccountMapper.xml
pom.xml
linkwe-admin/pom.xml
View file @
77c652a
...
@@ -89,6 +89,8 @@
...
@@ -89,6 +89,8 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
javax.xml.bind
</groupId>
<groupId>
javax.xml.bind
</groupId>
<artifactId>
jaxb-api
</artifactId>
<artifactId>
jaxb-api
</artifactId>
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java
View file @
77c652a
...
@@ -135,76 +135,76 @@ public class SysLoginController
...
@@ -135,76 +135,76 @@ public class SysLoginController
return
AjaxResult
.
success
(
menuService
.
buildMenus
(
menus
));
return
AjaxResult
.
success
(
menuService
.
buildMenus
(
menus
));
}
}
/**
//
/**
* 获取企业扫码登录相关参数
//
* 获取企业扫码登录相关参数
* @return
//
* @return
*/
//
*/
@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(validWeCorpAccount);
}
//
}
/**
//
/**
* 扫码登录微信端回调
//
* 扫码登录微信端回调
* @param auth_code 授权code
//
* @param auth_code 授权code
* @param agentId 应用id
//
* @param agentId 应用id
* @return
//
* @return
*/
//
*/
@GetMapping
(
"/wxQrLogin"
)
//
@GetMapping("/wxQrLogin")
public
AjaxResult
wxQrLogin
(
String
auth_code
,
String
agentId
){
//
public AjaxResult wxQrLogin(String auth_code, String agentId){
//
AjaxResult
ajax
=
AjaxResult
.
success
();
//
AjaxResult ajax = AjaxResult.success();
//
WeUserInfoDto
userInfo
=
weUserClient
.
getUserInfo
(
auth_code
,
agentId
);
//
WeUserInfoDto userInfo = weUserClient.getUserInfo(auth_code, agentId);
if
(
null
!=
userInfo
){
//
if( null != userInfo){
SysUser
sysUser
=
sysUserService
.
selectUserByCorpUserId
(
userInfo
.
getUserId
());
//
SysUser sysUser = sysUserService.selectUserByCorpUserId(userInfo.getUserId());
if
(
null
!=
sysUser
){
//
if (null != sysUser){
String
token
=
loginService
.
noPwdLogin
(
sysUser
.
getUserName
());
//
String token = loginService.noPwdLogin(sysUser.getUserName());
ajax
.
put
(
Constants
.
TOKEN
,
token
);
//
ajax.put(Constants.TOKEN, token);
}
else
{
//
}else {
return
AjaxResult
.
error
(
"请绑定后再登录"
);
//
return AjaxResult.error("请绑定后再登录");
}
//
}
}
//
}
return
ajax
;
//
return ajax;
}
//
}
/**
//
/**
* 通过企业id和企业密钥登录
//
* 通过企业id和企业密钥登录
* @param corpId
//
* @param corpId
* @param corpSecret
//
* @param corpSecret
* @return
//
* @return
*/
//
*/
@GetMapping
(
"/corpLogin"
)
//
@GetMapping("/corpLogin")
public
AjaxResult
corpLogin
(
String
corpId
,
String
corpSecret
){
//
public AjaxResult corpLogin(String corpId,String corpSecret){
//
WeCorpAccount
weCorpAccount
=
iWxCorpAccountService
.
getOne
(
new
LambdaQueryWrapper
<
WeCorpAccount
>()
//
WeCorpAccount weCorpAccount = iWxCorpAccountService.getOne(new LambdaQueryWrapper<WeCorpAccount>()
.
eq
(
WeCorpAccount:
:
getCorpId
,
corpId
)
//
.eq(WeCorpAccount::getCorpId, corpId)
.
eq
(
WeCorpAccount:
:
getCorpSecret
,
corpSecret
)
//
.eq(WeCorpAccount::getCorpSecret, corpSecret)
.
eq
(
WeCorpAccount:
:
getDelFlag
,
Constants
.
NORMAL_CODE
));
//
.eq(WeCorpAccount::getDelFlag, Constants.NORMAL_CODE));
//
//
if
(
weCorpAccount
==
null
){
//
if(weCorpAccount == null){
//
return
AjaxResult
.
error
(
"当前企业id与企业密码不匹配或不存在"
);
//
return AjaxResult.error("当前企业id与企业密码不匹配或不存在");
}
//
}
//
return
AjaxResult
.
success
(
//
return AjaxResult.success(
loginService
.
noPwdLogin
(
weCorpAccount
.
getCorpAccount
())
//
loginService.noPwdLogin(weCorpAccount.getCorpAccount())
);
//
);
}
//
}
}
}
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeAppController.java
deleted
100644 → 0
View file @
c0624ad
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.wecom.domain.WeApp
;
import
com.linkwechat.wecom.service.IWeAppService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"/wecom/weapp"
)
public
class
WeAppController
extends
BaseController
{
@Autowired
IWeAppService
iWeAppService
;
@GetMapping
(
"/list"
)
public
AjaxResult
list
()
{
return
AjaxResult
.
success
(
iWeAppService
.
list
()
);
}
@PostMapping
(
"/addWeApp"
)
public
AjaxResult
addWeApp
(
@RequestBody
WeApp
weApp
){
iWeAppService
.
addWeApp
(
weApp
);
return
AjaxResult
.
success
();
}
@PutMapping
(
"/updateWeApp"
)
public
AjaxResult
updateWeApp
(
@RequestBody
WeApp
weApp
){
iWeAppService
.
updateWeApp
(
weApp
);
return
AjaxResult
.
success
();
}
}
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCorpAccountController.java
View file @
77c652a
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.constant.Constants
;
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.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 企业id相关配置Controller
*
* @author ruoyi
* @date 2020-08-24
*/
@RestController
@RestController
@RequestMapping
(
"/wecom/corp"
)
@RequestMapping
(
value
=
"/wecom/corp"
)
@Api
(
"企业id配置接口"
)
public
class
WeCorpAccountController
{
public
class
WeCorpAccountController
extends
BaseController
{
@Autowired
@Autowired
private
IWeCorpAccountService
weCorpAccountService
;
private
IWeCorpAccountService
iWeCorpAccountService
;
// @PreAuthorize("@ss.hasPermi('wechat:corp:list')")
@GetMapping
(
"/list"
)
@ApiOperation
(
"查询企业id相关配置列表"
)
public
TableDataInfo
list
(
WeCorpAccount
weCorpAccount
)
{
startPage
();
List
<
WeCorpAccount
>
list
=
weCorpAccountService
.
list
(
new
LambdaQueryWrapper
<
WeCorpAccount
>()
.
eq
(
WeCorpAccount:
:
getDelFlag
,
Constants
.
NORMAL_CODE
)
.
like
(
WeCorpAccount:
:
getCompanyName
,
weCorpAccount
.
getCompanyName
()));
return
getDataTable
(
list
);
}
/**
* 获取当前企业可用密钥
* @return
*/
@GetMapping
(
"/findCurrentCorpAccount"
)
public
AjaxResult
findCurrentCorpAccount
(){
// @PreAuthorize("@ss.hasPermi('wechat:corp:add')")
return
AjaxResult
.
success
(
@Log
(
title
=
"新增企业id相关配置"
,
businessType
=
BusinessType
.
INSERT
)
iWeCorpAccountService
.
findValidWeCorpAccount
()
@PostMapping
);
@ApiOperation
(
"新增企业id相关配置"
)
public
AjaxResult
add
(
@Validated
@RequestBody
WeCorpAccount
weCorpAccount
)
{
weCorpAccountService
.
save
(
weCorpAccount
);
return
AjaxResult
.
success
();
}
// @PreAuthorize("@ss.hasPermi('wechat:corp:edit')")
@Log
(
title
=
"修改企业id相关配置"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
@ApiOperation
(
"修改企业id相关配置"
)
public
AjaxResult
edit
(
@Validated
@RequestBody
WeCorpAccount
weCorpAccount
)
{
weCorpAccountService
.
updateById
(
weCorpAccount
);
return
AjaxResult
.
success
();
}
}
// @PreAuthorize("@ss.hasPermi('wechat:corp:startVailWeCorpAccount')")
/**
@Log
(
title
=
"启用有效企业微信账号"
,
businessType
=
BusinessType
.
DELETE
)
* 新增或更新企业配置相关
@PutMapping
(
"/startVailWeCorpAccount/{corpId}"
)
* @param weCorpAccount
@ApiOperation
(
"启用有效企业微信账号"
)
* @return
public
AjaxResult
startWeCorpAccount
(
@PathVariable
String
corpId
)
*/
@Log
(
title
=
"新增或更新企业配置相关"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"/addOrUpdate"
)
public
AjaxResult
addOrUpdate
(
@RequestBody
WeCorpAccount
weCorpAccount
)
{
{
return
toAjax
(
weCorpAccountService
.
startVailWeCorpAccount
(
corpId
));
iWeCorpAccountService
.
saveOrUpdate
(
weCorpAccount
);
return
AjaxResult
.
success
();
}
}
// @PreAuthorize("@ss.hasPermi('wechat:corp:startCustomerChurnNoticeSwitch')")
/**
* 客户流失通知开关
* @param status
* @return
*/
@Log
(
title
=
"客户流失通知开关"
,
businessType
=
BusinessType
.
UPDATE
)
@Log
(
title
=
"客户流失通知开关"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
(
"/startCustomerChurnNoticeSwitch/{status}"
)
@PutMapping
(
"/startCustomerChurnNoticeSwitch/{status}"
)
@ApiOperation
(
"客户流失通知开关"
)
public
AjaxResult
startCustomerChurnNoticeSwitch
(
@PathVariable
String
status
)
public
AjaxResult
startCustomerChurnNoticeSwitch
(
@PathVariable
String
status
)
{
{
w
eCorpAccountService
.
startCustomerChurnNoticeSwitch
(
status
);
iW
eCorpAccountService
.
startCustomerChurnNoticeSwitch
(
status
);
return
AjaxResult
.
success
();
return
AjaxResult
.
success
();
}
}
// @PreAuthorize("@ss.hasPermi('wechat:corp:getCustomerChurnNoticeSwitch')")
/**
* 客户流失通知开关查询
* @return
*/
@Log
(
title
=
"客户流失通知开关查询"
,
businessType
=
BusinessType
.
OTHER
)
@Log
(
title
=
"客户流失通知开关查询"
,
businessType
=
BusinessType
.
OTHER
)
@GetMapping
(
"/getCustomerChurnNoticeSwitch"
)
@GetMapping
(
"/getCustomerChurnNoticeSwitch"
)
@ApiOperation
(
"客户流失通知开关查询"
)
public
AjaxResult
getCustomerChurnNoticeSwitch
()
public
AjaxResult
getCustomerChurnNoticeSwitch
()
{
{
return
AjaxResult
.
success
(
"操作成功"
,
w
eCorpAccountService
.
getCustomerChurnNoticeSwitch
());
return
AjaxResult
.
success
(
"操作成功"
,
iW
eCorpAccountService
.
getCustomerChurnNoticeSwitch
());
}
}
}
}
linkwe-common/src/main/java/com/linkwechat/common/core/domain/entity/WeCorpAccount.java
View file @
77c652a
...
@@ -24,7 +24,6 @@ import javax.validation.constraints.NotBlank;
...
@@ -24,7 +24,6 @@ import javax.validation.constraints.NotBlank;
@SuperBuilder
@SuperBuilder
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@ApiModel
(
"企业id配置相关实体"
)
@TableName
(
"we_corp_account"
)
@TableName
(
"we_corp_account"
)
public
class
WeCorpAccount
extends
BaseEntity
public
class
WeCorpAccount
extends
BaseEntity
{
{
...
@@ -32,59 +31,109 @@ public class WeCorpAccount extends BaseEntity
...
@@ -32,59 +31,109 @@ public class WeCorpAccount extends BaseEntity
/** $column.columnComment */
/** $column.columnComment */
@TableId
@TableId
@ApiModelProperty
(
"主键"
)
private
Long
id
;
private
Long
id
=
SnowFlakeUtil
.
nextId
();
/** 企业名称 */
/***********************************************
@ApiModelProperty
(
"企业名称"
)
*******************企业配置start****************
@NotBlank
(
message
=
"企业名称不能为空"
)
**********************************************/
private
String
companyName
;
/** 企业ID */
/** 企业ID */
@ApiModelProperty
(
"企业corpId"
)
@NotBlank
(
message
=
"企业ID不能为空"
)
@NotBlank
(
message
=
"企业ID不能为空"
)
private
String
corpId
;
private
String
corpId
;
/** 应用的密钥凭证 */
@ApiModelProperty
(
"企业为corpSecret"
)
/** 企业名称 */
@NotBlank
(
message
=
"应用的密钥凭证不能为空"
)
@NotBlank
(
message
=
"企业名称不能为空"
)
private
String
companyName
;
/***********************************************
*******************企业配置end****************
**********************************************/
/***********************************************
*******************通讯录配置start**************
**********************************************/
/** 通讯录Secret */
@NotBlank
(
message
=
"通讯录Secret不可为空"
)
private
String
corpSecret
;
private
String
corpSecret
;
/** 帐号状态(0正常 1停用) */
/***********************************************
@ApiModelProperty
(
"帐号状态(0正常 1停用)"
)
*******************通讯录配置end****************
private
String
status
;
**********************************************/
/***********************************************
*******************客户联系配置start*************
**********************************************/
@NotBlank
(
message
=
"客户联系Secret不可为空"
)
private
String
contactSecret
;
/***********************************************
*******************客户联系配置end***************
**********************************************/
/***********************************************
*******************应用配置start****************
**********************************************/
/**消息应用ID*/
@NotBlank
(
message
=
"消息应用ID不可为空"
)
private
String
agentId
;
/**消息应用Secret*/
@NotBlank
(
message
=
"消息应用Secret不可为空"
)
private
String
agentSecret
;
/**会话私钥Secret*/
private
String
chatSecret
;
/**会话存档密钥*/
private
String
financePrivateKey
;
/***********************************************
*******************应用配置end****************
**********************************************/
/***********************************************
*******************接收事件服务器start***********
**********************************************/
/**回调url*/
private
String
backOffUrl
;
/** 删除标志(0代表存在 2代表删除) */
/**回调token*/
@ApiModelProperty
(
"删除标志(0代表存在 2代表删除)"
)
private
String
token
;
private
String
delFlag
=
new
String
(
"0"
);
/**回调EncodingAESKey*/
private
String
encodingAesKey
;
@ApiModelProperty
(
"外部联系人密钥"
)
@NotBlank
(
message
=
"外部联系人密钥凭证不能为空"
)
private
String
contactSecret
;
@ApiModelProperty
(
"应用id"
)
/***********************************************
private
String
agentId
;
*******************接收事件服务器end*************
**********************************************/
@ApiModelProperty
(
"应用密钥"
)
private
String
agentSecret
;
@ApiModelProperty
(
"服务商密钥"
)
private
String
providerSecret
;
@ApiModelProperty
(
"会话存档密钥"
)
/**客服密钥*/
private
String
chat
Secret
;
private
String
kf
Secret
;
/** 删除标志(0代表存在 1代表删除) */
private
Integer
delFlag
;
@ApiModelProperty
(
"企业微信扫码登陆回调地址"
)
private
String
wxQrLoginRedirectUri
;
@ApiModelProperty
(
"客户流失通知开关 0:关闭 1:开启"
)
/**客户流失通知开关 0:关闭 1:开启*/
private
String
customerChurnNoticeSwitch
=
Constants
.
NORMAL_CODE
;
private
String
customerChurnNoticeSwitch
=
Constants
.
NORMAL_CODE
;
@ApiModelProperty
(
"会话存档私钥"
)
private
String
financePrivateKey
;
@ApiModelProperty
(
"企业管理员账号"
)
private
String
corpAccount
;
}
}
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java
View file @
77c652a
package
com
.
linkwechat
.
framework
.
web
.
service
;
package
com
.
linkwechat
.
framework
.
web
.
service
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
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.constant.WeConstans
;
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.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
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.system.service.ISysRoleService
;
import
com.linkwechat.system.service.ISysRoleService
;
import
com.linkwechat.system.service.ISysUserService
;
import
com.linkwechat.system.service.ISysUserService
;
...
@@ -27,9 +23,6 @@ import org.springframework.security.core.userdetails.UserDetailsService;
...
@@ -27,9 +23,6 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* 用户验证处理
* 用户验证处理
*
*
...
@@ -73,54 +66,65 @@ public class UserDetailsServiceImpl implements UserDetailsService
...
@@ -73,54 +66,65 @@ public class UserDetailsServiceImpl implements UserDetailsService
if
(
StringUtils
.
isNull
(
user
))
if
(
StringUtils
.
isNull
(
user
))
{
{
//查询企业管理相关账号
//we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中
WeCorpAccount
weCorpByAccount
=
iWeCorpAccountService
.
getOne
(
new
LambdaQueryWrapper
<
WeCorpAccount
>().
eq
(
WeCorpAccount:
:
getCorpAccount
,
username
)
WeUser
weUser
=
iWeUserService
.
getOne
(
new
LambdaQueryWrapper
<
WeUser
>()
.
eq
(
WeCorpAccount:
:
getDelFlag
,
Constants
.
NORMAL_CODE
));
.
eq
(
WeUser:
:
getMobile
,
username
)
if
(
null
!=
weCorpByAccount
){
.
ne
(
WeUser:
:
getIsActivate
,
new
Integer
(
6
)));
//注册到we_user表中
if
(
null
==
weUser
){
user
=
SysUser
.
builder
()
throw
new
BaseException
(
"对不起,您的账号:"
+
username
+
" 不存在"
);
.
userName
(
weCorpByAccount
.
getCorpAccount
())
.
nickName
(
weCorpByAccount
.
getCompanyName
())
.
userType
(
Constants
.
USER_TYOE_CORP_ADMIN
)
.
roleIds
(
ArrayUtil
.
toArray
(
iSysRoleService
.
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
();
}
else
{
//we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中
WeUser
weUser
=
iWeUserService
.
getOne
(
new
LambdaQueryWrapper
<
WeUser
>()
.
eq
(
WeUser:
:
getMobile
,
username
)
.
ne
(
WeUser:
:
getIsActivate
,
new
Integer
(
6
)));
if
(
null
==
weUser
){
throw
new
BaseException
(
"对不起,您的账号:"
+
username
+
" 不存在"
);
}
if
(
StrUtil
.
isBlank
(
weUser
.
getMobile
())){
throw
new
BaseException
(
"请填写当前企业员工的手机号:"
+
username
+
" 然后再登录"
);
}
//注册到we_user表中
user
=
SysUser
.
builder
()
.
userName
(
username
)
.
nickName
(
weUser
.
getName
())
.
userType
(
Constants
.
USER_TYPE_WECOME
)
.
email
(
weUser
.
getEmail
())
.
phonenumber
(
weUser
.
getMobile
())
.
sex
(
weUser
.
getGender
()
==
0
?
"1"
:
weUser
.
getGender
()
.
toString
())
.
avatar
(
weUser
.
getHeadImageUrl
())
.
weUserId
(
weUser
.
getUserId
())
.
roleIds
(
ArrayUtil
.
toArray
(
iSysRoleService
.
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
();
}
if
(
user
!=
null
){
userService
.
insertUser
(
user
);
}
}
// if(StrUtil.isBlank(weUser.getMobile())){
// throw new BaseException("请填写当前企业员工的手机号:" + username + " 然后再登录");
// }
// //查询企业管理相关账号
// WeCorpAccount weCorpByAccount = iWeCorpAccountService.getOne(new LambdaQueryWrapper<WeCorpAccount>().eq(WeCorpAccount::getCorpAccount, username)
// .eq(WeCorpAccount::getDelFlag, Constants.NORMAL_CODE));
// if(null != weCorpByAccount){
// //注册到we_user表中
// user=SysUser.builder()
// .userName(weCorpByAccount.getCorpAccount())
// .nickName(weCorpByAccount.getCompanyName())
// .userType(Constants.USER_TYOE_CORP_ADMIN)
// .roleIds(ArrayUtil.toArray(iSysRoleService.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();
// } else{
// //we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中
// WeUser weUser=iWeUserService.getOne(new LambdaQueryWrapper<WeUser>()
// .eq(WeUser::getMobile,username)
// .ne(WeUser::getIsActivate,new Integer(6)));
// if(null == weUser){
// throw new BaseException("对不起,您的账号:" + username + " 不存在");
// }
// if(StrUtil.isBlank(weUser.getMobile())){
// throw new BaseException("请填写当前企业员工的手机号:" + username + " 然后再登录");
// }
// //注册到we_user表中
// user=SysUser.builder()
// .userName(username)
// .nickName(weUser.getName())
// .userType(Constants.USER_TYPE_WECOME)
// .email(weUser.getEmail())
// .phonenumber(weUser.getMobile())
// .sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString())
// .avatar(weUser.getHeadImageUrl())
// .weUserId(weUser.getUserId())
// .roleIds(ArrayUtil.toArray(iSysRoleService.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();
//
// }
//
// if(user != null){
// userService.insertUser(
// user
// );
// }
}
}
else
if
(
UserStatus
.
DELETED
.
getCode
().
equals
(
user
.
getDelFlag
()))
else
if
(
UserStatus
.
DELETED
.
getCode
().
equals
(
user
.
getDelFlag
()))
{
{
...
@@ -134,13 +138,13 @@ public class UserDetailsServiceImpl implements UserDetailsService
...
@@ -134,13 +138,13 @@ public class UserDetailsServiceImpl implements UserDetailsService
}
}
//当前登录用户为企业管理,设置corpId和密钥相关
//
//当前登录用户为企业管理,设置corpId和密钥相关
if
(
Constants
.
USER_TYOE_CORP_ADMIN
.
equals
(
user
.
getUserType
())){
//
if(Constants.USER_TYOE_CORP_ADMIN.equals(user.getUserType())){
user
.
setWeCorpAccount
(
//
user.setWeCorpAccount(
iWeCorpAccountService
.
getOne
(
new
LambdaQueryWrapper
<
WeCorpAccount
>().
eq
(
WeCorpAccount:
:
getCorpAccount
,
username
)
//
iWeCorpAccountService.getOne(new LambdaQueryWrapper<WeCorpAccount>().eq(WeCorpAccount::getCorpAccount, username)
.
eq
(
WeCorpAccount:
:
getDelFlag
,
Constants
.
NORMAL_CODE
))
//
.eq(WeCorpAccount::getDelFlag, Constants.NORMAL_CODE))
);
//
);
}
//
}
return
createLoginUser
(
user
);
return
createLoginUser
(
user
);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeApp.java
deleted
100644 → 0
View file @
c0624ad
package
com
.
linkwechat
.
wecom
.
domain
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
lombok.AllArgsConstructor
;
import
lombok.experimental.SuperBuilder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
import
java.util.List
;
/**
* @description: 自建应用相关
* @author: HaoN
* @create: 2021-01-26 18:38
**/
@Data
@TableName
(
"we_app"
)
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public
class
WeApp
{
private
static
final
long
serialVersionUID
=
1L
;
/** $column.columnComment */
private
Long
id
=
SnowFlakeUtil
.
nextId
();
/**应用id**/
private
String
agentId
;
/**应用密钥**/
private
String
agentSecret
;
/**应用类型(1:自建应用;2:小程序)**/
private
Integer
appType
;
/**应用创建时间**/
private
Date
createTime
;
/**删除标志(0代表存在 2代表删除)**/
private
String
delFlag
;
/**帐号状态(0正常 1停用)**/
private
String
status
;
/**可见范围部门id,使用逗号隔开**/
private
String
allowPartys
;
/**可见范围人员id,使用逗号隔开**/
private
String
allowUserinfos
;
/**应用名称**/
private
String
agentName
;
/**企业应用描述**/
private
String
description
;
/**应用头像**/
private
String
squareLogoUrl
;
@TableField
(
exist
=
false
)
private
String
logoMediaid
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeAppMapper.java
deleted
100644 → 0
View file @
c0624ad
package
com
.
linkwechat
.
wecom
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.linkwechat.wecom.domain.WeApp
;
/**
* @description: 自建应用相关
* @author: HaoN
* @create: 2021-01-26 18:43
**/
public
interface
WeAppMapper
extends
BaseMapper
<
WeApp
>
{
}
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeCorpAccountMapper.java
View file @
77c652a
...
@@ -14,12 +14,6 @@ public interface WeCorpAccountMapper extends BaseMapper<WeCorpAccount>
...
@@ -14,12 +14,6 @@ public interface WeCorpAccountMapper extends BaseMapper<WeCorpAccount>
{
{
/**
* 启用有效的企业微信账号
* @param corpId
* @return
*/
int
startVailWeCorpAccount
(
@Param
(
"corpId"
)
String
corpId
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAccessTokenService.java
View file @
77c652a
package
com
.
linkwechat
.
wecom
.
service
;
package
com
.
linkwechat
.
wecom
.
service
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.wecom.domain.WeApp
;
/**
/**
* @description: 微信token相关接口
* @description: 微信token相关接口
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAppService.java
deleted
100644 → 0
View file @
c0624ad
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeApp
;
/**
* @description:
* @author: HaoN
* @create: 2021-01-26 18:44
**/
public
interface
IWeAppService
extends
IService
<
WeApp
>
{
void
addWeApp
(
WeApp
weApp
);
void
updateWeApp
(
WeApp
weApp
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCorpAccountService.java
View file @
77c652a
...
@@ -13,13 +13,7 @@ public interface IWeCorpAccountService extends IService<WeCorpAccount>
...
@@ -13,13 +13,7 @@ public interface IWeCorpAccountService extends IService<WeCorpAccount>
{
{
/**
* 修改企业id相关配置
*
* @param wxCorpAccount 企业id相关配置
* @return 结果
*/
void
updateWeCorpAccount
(
WeCorpAccount
wxCorpAccount
);
...
@@ -31,11 +25,7 @@ public interface IWeCorpAccountService extends IService<WeCorpAccount>
...
@@ -31,11 +25,7 @@ public interface IWeCorpAccountService extends IService<WeCorpAccount>
WeCorpAccount
findValidWeCorpAccount
();
WeCorpAccount
findValidWeCorpAccount
();
/**
* 启用有效的企业微信账号
* @param corpId
*/
int
startVailWeCorpAccount
(
String
corpId
);
/**
/**
* 客户流失通知开关
* 客户流失通知开关
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAccessTokenServiceImpl.java
View file @
77c652a
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
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.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.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.wecom.domain.dto.WeAccessTokenDto
;
import
com.linkwechat.wecom.domain.dto.WeAccessTokenDto
;
import
com.linkwechat.wecom.service.IWeAccessTokenService
;
import
com.linkwechat.wecom.service.IWeAccessTokenService
;
import
com.linkwechat.wecom.service.IWeAppService
;
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
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
...
@@ -40,8 +35,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -40,8 +35,7 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@Autowired
private
IWeAppService
iWeAppService
;
@Autowired
@Autowired
...
@@ -97,57 +91,33 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -97,57 +91,33 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
public
String
findThirdAppAccessToken
()
{
public
String
findThirdAppAccessToken
()
{
WeApp
weApp
=
null
;
//首先表中查询提醒的appid
//首先表中查询提醒的appid
WeCorpAccount
weCorpAccount
=
iWxCorpAccountService
.
findValidWeCorpAccount
();
WeCorpAccount
weCorpAccount
=
iWxCorpAccountService
.
findValidWeCorpAccount
();
if
(
weCorpAccount
!=
null
&&
StringUtils
.
isNotEmpty
(
weCorpAccount
.
getAgentId
())){
if
(
null
==
weCorpAccount
){
throw
new
WeComException
(
"无可用的corpid和secret"
);
String
token
=
redisCache
.
getCacheObject
(
WeConstans
.
WE_THIRD_APP_TOKEN
+
"::"
+
weCorpAccount
.
getAgentId
());
}
if
(
StringUtils
.
isNotEmpty
(
token
)){
return
token
;
}
else
{
weApp
=
WeApp
.
builder
()
.
agentId
(
weCorpAccount
.
getAgentId
())
.
agentSecret
(
weCorpAccount
.
getAgentSecret
())
.
build
();
}
// if(weCorpAccount.getAgentId().equals(agentId)){
if
(
StringUtils
.
isEmpty
(
weCorpAccount
.
getAgentId
())&&
StringUtils
.
isEmpty
(
weCorpAccount
.
getAgentSecret
())){
//
throw
new
WeComException
(
"请确保应用id与应用密钥可用"
);
// }
}
}
// if(weApp==null){
String
token
=
redisCache
.
getCacheObject
(
WeConstans
.
WE_THIRD_APP_TOKEN
+
"::"
+
weCorpAccount
.
getAgentId
());
// weApp = iWeAppService.getOne(new LambdaQueryWrapper<WeApp>()
// .eq(WeApp::getAgentId, agentId)
// .eq(WeApp::getDelFlag, Constants.NORMAL_CODE)
// .eq(WeApp::getStatus, Constants.NORMAL_CODE));
// }
return
findThirdAppAccessToken
(
weApp
);
return
StringUtils
.
isNotEmpty
(
token
)
?
token:
findThirdAppAccessToken
(
weCorpAccount
);
}
}
private
String
findThirdAppAccessToken
(
WeApp
weApp
){
private
String
findThirdAppAccessToken
(
WeCorpAccount
weCorpAccount
){
if
(
weApp
==
null
){
throw
new
WeComException
(
"当前agentId不可用或不存在"
);
}
WeCorpAccount
wxCorpAccount
=
iWxCorpAccountService
.
findValidWeCorpAccount
();
if
(
wxCorpAccount
==
null
){
throw
new
WeComException
(
"无可用的corpid和secret"
);
}
WeAccessTokenDto
weAccessTokenDto
WeAccessTokenDto
weAccessTokenDto
=
accessTokenClient
.
getToken
(
w
xCorpAccount
.
getCorpId
(),
weApp
.
getAgentSecret
());
=
accessTokenClient
.
getToken
(
w
eCorpAccount
.
getCorpId
(),
weCorpAccount
.
getAgentSecret
());
if
(
StringUtils
.
isNotEmpty
(
weAccessTokenDto
.
getAccessToken
())){
if
(
StringUtils
.
isNotEmpty
(
weAccessTokenDto
.
getAccessToken
())){
redisCache
.
setCacheObject
(
WeConstans
.
WE_THIRD_APP_TOKEN
+
"::"
+
we
App
.
getAgentId
(),
weAccessTokenDto
.
getAccessToken
(),
weAccessTokenDto
.
getExpiresIn
().
intValue
(),
TimeUnit
.
SECONDS
);
redisCache
.
setCacheObject
(
WeConstans
.
WE_THIRD_APP_TOKEN
+
"::"
+
we
CorpAccount
.
getAgentId
(),
weAccessTokenDto
.
getAccessToken
(),
weAccessTokenDto
.
getExpiresIn
().
intValue
(),
TimeUnit
.
SECONDS
);
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAppServiceImpl.java
deleted
100644 → 0
View file @
c0624ad
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeAppClient
;
import
com.linkwechat.wecom.domain.WeApp
;
import
com.linkwechat.wecom.domain.dto.WeAppDetailDto
;
import
com.linkwechat.wecom.mapper.WeAppMapper
;
import
com.linkwechat.wecom.service.IWeAccessTokenService
;
import
com.linkwechat.wecom.service.IWeAppService
;
import
com.linkwechat.wecom.service.IWeDepartmentService
;
import
com.linkwechat.wecom.service.IWeUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
/**
* @description:
* @author: HaoN
* @create: 2021-01-26 18:44
**/
@Service
public
class
WeAppServiceImpl
extends
ServiceImpl
<
WeAppMapper
,
WeApp
>
implements
IWeAppService
{
@Autowired
WeAppClient
weAppClient
;
@Autowired
IWeDepartmentService
iWeDepartmentService
;
@Autowired
IWeUserService
iWeUserService
;
@Autowired
IWeAccessTokenService
iWeAccessTokenService
;
/**
* 保存应用
* @param weApp
*/
@Override
@Transactional
public
void
addWeApp
(
WeApp
weApp
)
{
if
(
null
!=
this
.
getOne
(
new
LambdaQueryWrapper
<
WeApp
>()
.
eq
(
WeApp:
:
getAgentId
,
weApp
.
getAgentId
())
.
eq
(
WeApp:
:
getDelFlag
,
Constants
.
SUCCESS
))){
throw
new
WeComException
(
"AgentId已经存在"
);
}
weApp
.
setCreateTime
(
new
Date
());
if
(
this
.
save
(
weApp
)){
WeAppDetailDto
weAppDetailDto
=
weAppClient
.
findAgentById
(
weApp
.
getAgentId
());
if
(
null
!=
weAppDetailDto
){
weApp
.
setAgentName
(
weAppDetailDto
.
getName
());
weApp
.
setCreateTime
(
new
Date
());
weApp
.
setSquareLogoUrl
(
weAppDetailDto
.
getSquare_logo_url
());
weApp
.
setDescription
(
weAppDetailDto
.
getDescription
());
weApp
.
setAllowPartys
(
StringUtils
.
join
(
weAppDetailDto
.
getAllow_partys
().
getPartyid
(),
","
));
weApp
.
setAllowUserinfos
(
StringUtils
.
join
(
weAppDetailDto
.
getAllow_userinfos
().
getUser
(),
","
));
this
.
updateById
(
weApp
);
}
}
}
@Override
@Transactional
public
void
updateWeApp
(
WeApp
weApp
)
{
if
(
this
.
updateById
(
weApp
)){
weAppClient
.
updateAgentById
(
WeAppDetailDto
.
builder
()
.
agentid
(
weApp
.
getAgentId
())
.
logo_mediaid
(
weApp
.
getLogoMediaid
())
.
description
(
weApp
.
getDescription
())
.
name
(
weApp
.
getAgentName
())
.
build
(),
weApp
.
getAgentId
()
);
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCorpAccountServiceImpl.java
View file @
77c652a
...
@@ -2,16 +2,12 @@ package com.linkwechat.wecom.service.impl;
...
@@ -2,16 +2,12 @@ package com.linkwechat.wecom.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
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.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.wecom.mapper.WeCorpAccountMapper
;
import
com.linkwechat.wecom.mapper.WeCorpAccountMapper
;
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.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Optional
;
import
java.util.Optional
;
/**
/**
...
@@ -25,34 +21,11 @@ public class WeCorpAccountServiceImpl extends ServiceImpl<WeCorpAccountMapper,We
...
@@ -25,34 +21,11 @@ public class WeCorpAccountServiceImpl extends ServiceImpl<WeCorpAccountMapper,We
public
WeCorpAccountServiceImpl
(){
@Autowired
System
.
out
.
println
(
"nihaoya"
);
private
IWeAccessTokenService
iWeAccessTokenService
;
@Autowired
private
RuoYiConfig
ruoYiConfig
;
/**
* 修改企业id相关配置
*
* @param wxCorpAccount 企业id相关配置
* @return 结果
*/
@Override
public
void
updateWeCorpAccount
(
WeCorpAccount
wxCorpAccount
)
{
if
(
this
.
updateById
(
wxCorpAccount
)){
iWeAccessTokenService
.
removeToken
(
wxCorpAccount
);
}
}
}
/**
/**
* 获取有效的企业id
* 获取有效的企业id
*
*
...
@@ -61,36 +34,20 @@ public class WeCorpAccountServiceImpl extends ServiceImpl<WeCorpAccountMapper,We
...
@@ -61,36 +34,20 @@ public class WeCorpAccountServiceImpl extends ServiceImpl<WeCorpAccountMapper,We
@Override
@Override
public
WeCorpAccount
findValidWeCorpAccount
()
{
public
WeCorpAccount
findValidWeCorpAccount
()
{
return
ruoYiConfig
.
isStartTenant
()?
WeCorpAccount
.
builder
().
build
():
this
.
getOne
(
new
LambdaQueryWrapper
<
WeCorpAccount
>()
WeCorpAccount
weCorpAccount
=
this
.
getOne
(
new
LambdaQueryWrapper
<
WeCorpAccount
>()
.
eq
(
WeCorpAccount:
:
getDelFlag
,
Constants
.
NORMAL_CODE
)
.
eq
(
WeCorpAccount:
:
getDelFlag
,
Constants
.
NORMAL_CODE
));
.
eq
(
WeCorpAccount:
:
getStatus
,
Constants
.
NORMAL_CODE
));
}
/**
* 启用有效的企业微信账号
* @param corpId
*/
@Override
public
int
startVailWeCorpAccount
(
String
corpId
)
{
int
returnCode
=
this
.
baseMapper
.
startVailWeCorpAccount
(
corpId
);
if
(
Constants
.
SERVICE_RETURN_SUCCESS_CODE
<
returnCode
){
return
weCorpAccount
!=
null
?
weCorpAccount:
WeCorpAccount
.
builder
().
build
();
}
iWeAccessTokenService
.
removeToken
(
WeCorpAccount
.
builder
().
build
());
}
return
returnCode
;
}
@Override
@Override
public
void
startCustomerChurnNoticeSwitch
(
String
status
)
{
public
void
startCustomerChurnNoticeSwitch
(
String
status
)
{
WeCorpAccount
validWeCorpAccount
=
findValidWeCorpAccount
();
WeCorpAccount
validWeCorpAccount
=
findValidWeCorpAccount
();
validWeCorpAccount
.
setCustomerChurnNoticeSwitch
(
status
);
validWeCorpAccount
.
setCustomerChurnNoticeSwitch
(
status
);
this
.
update
WeCorpAccount
(
validWeCorpAccount
);
this
.
update
ById
(
validWeCorpAccount
);
}
}
@Override
@Override
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeAppMapper.xml
deleted
100644 → 0
View file @
c0624ad
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.linkwechat.wecom.mapper.WeAppMapper"
>
</mapper>
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/resources/mapper/wecom/WeCorpAccountMapper.xml
View file @
77c652a
...
@@ -6,11 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -6,11 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update
id=
"startVailWeCorpAccount"
>
UPDATE we_corp_account
SET `status` = (CASE WHEN corp_id = #{corpId} THEN 0 ELSE 1 END)
</update>
...
...
pom.xml
View file @
77c652a
...
@@ -300,6 +300,7 @@
...
@@ -300,6 +300,7 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.google.protobuf
</groupId>
<groupId>
com.google.protobuf
</groupId>
<artifactId>
protobuf-java
</artifactId>
<artifactId>
protobuf-java
</artifactId>
...
...
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