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 452d2327
authored
Dec 19, 2020
by
sunxiwang
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
会话存档相关接口
1 parent
7cf17f42
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
308 additions
and
26 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeConversationArchiveController.java
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
linkwe-common/src/main/java/com/linkwechat/common/enums/BusinessType.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMsgAuditClient.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMsgauditClient.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/msgaudit/WeMsgAuditDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/msgaudit/MsgauditDto.java → linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/WeMsgAuditVo.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeConversationArchiveService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeUserService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeConversationArchiveServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeUserServiceImpl.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeConversationArchiveController.java
0 → 100644
View file @
452d232
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.wecom.service.IWeConversationArchiveService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* @author sxw
* @description 会话存档controller
* @date 2020/12/19 13:51
**/
@Slf4j
@RestController
@RequestMapping
(
"/wecom/finance"
)
public
class
WeConversationArchiveController
{
@Autowired
private
IWeConversationArchiveService
weConversationArchiveService
;
/**
* 获取内部联系人列表
*
* @return
*/
@PreAuthorize
(
"@ss.hasPermi('conversationArchive:InternalContact:list')"
)
@Log
(
title
=
"获取内部联系人列表"
,
businessType
=
BusinessType
.
SELECT
)
@GetMapping
(
"/getInternalContactList"
)
public
R
<
List
<
JSONObject
>>
getInternalContactList
(
String
userId
,
int
pageSize
,
int
pageNum
)
{
return
R
.
ok
(
weConversationArchiveService
.
getInternalContactList
(
userId
,
pageSize
,
pageNum
));
}
}
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
View file @
452d232
...
@@ -269,4 +269,7 @@ public class WeConstans {
...
@@ -269,4 +269,7 @@ public class WeConstans {
}
}
public
static
final
String
WECOM_FINANCE_INDEX
=
"finance"
;
public
static
final
String
WECOM_FINANCE_INDEX
=
"finance"
;
/** 开启会话存档成员列表 **/
public
static
final
String
weMsgAuditKey
=
"wecom_msg_audit:user:ids"
;
}
}
linkwe-common/src/main/java/com/linkwechat/common/enums/BusinessType.java
View file @
452d232
...
@@ -56,4 +56,8 @@ public enum BusinessType
...
@@ -56,4 +56,8 @@ public enum BusinessType
* 清空数据
* 清空数据
*/
*/
CLEAN
,
CLEAN
,
/**
* 查询
*/
SELECT
,
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMsgAuditClient.java
0 → 100644
View file @
452d232
package
com
.
linkwechat
.
wecom
.
client
;
import
com.dtflys.forest.annotation.DataObject
;
import
com.dtflys.forest.annotation.Request
;
import
com.linkwechat.wecom.domain.dto.msgaudit.WeMsgAuditDto
;
/**
* @author sxw
* @description 会话存档接口
* @date 2020/12/2 16:45
**/
public
interface
WeMsgAuditClient
{
/**
* 获取会话内容存档开启成员列表
*/
@Request
(
url
=
"/msgaudit/get_permit_user_list"
,
type
=
"POST"
)
WeMsgAuditDto
getPermitUserList
(
@DataObject
WeMsgAuditDto
msgAuditDto
);
/**
* 单聊 获取会话中外部成员的同意情况
* @param msgAuditDto
* @return
*/
@Request
(
url
=
"/msgaudit/check_single_agree"
,
type
=
"POST"
)
WeMsgAuditDto
checkSingleAgree
(
@DataObject
WeMsgAuditDto
msgAuditDto
);
/**
* 群聊 获取群会话中外部成员的同意情况
* @param msgAuditDto
* @return
*/
@Request
(
url
=
"/msgaudit/check_room_agree"
,
type
=
"POST"
)
WeMsgAuditDto
checkRoomAgree
(
@DataObject
WeMsgAuditDto
msgAuditDto
);
/**
* 获取会话内容存档内部群信息
* @param msgAuditDto
* @return
*/
@Request
(
url
=
"/msgaudit/groupchat/get"
,
type
=
"POST"
)
WeMsgAuditDto
getGroupChat
(
@DataObject
WeMsgAuditDto
msgAuditDto
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMsgauditClient.java
deleted
100644 → 0
View file @
7cf17f4
package
com
.
linkwechat
.
wecom
.
client
;
import
com.dtflys.forest.annotation.DataObject
;
import
com.dtflys.forest.annotation.Request
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushResultDto
;
import
com.linkwechat.wecom.domain.dto.msgaudit.MsgauditDto
;
/**
* @author sxw
* @description 会话存档接口
* @date 2020/12/2 16:45
**/
public
interface
WeMsgauditClient
{
/**
* 获取会话内容存档开启成员列表
*/
@Request
(
url
=
"/msgaudit/get_permit_user_list"
,
type
=
"POST"
)
WeMessagePushResultDto
sendMessageToUser
(
@DataObject
MsgauditDto
msgauditDto
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/msgaudit/WeMsgAuditDto.java
0 → 100644
View file @
452d232
package
com
.
linkwechat
.
wecom
.
domain
.
dto
.
msgaudit
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.linkwechat.wecom.domain.dto.WeResultDto
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author sxw
* @description 会话存档
* @date 2020/12/2 16:47
**/
@Data
public
class
WeMsgAuditDto
extends
WeResultDto
{
/**
* 设置在开启范围内的成员的userid列表
*/
private
List
<
String
>
ids
;
/**
* 同意情况
*/
private
List
<
AgreeInfo
>
agreeInfo
;
/**
* roomid对应的群名称
*/
private
String
roomName
;
/**
* roomid对应的群创建者,userid
*/
private
String
creator
;
/**
* roomid对应的群创建时间
*/
@JSONField
(
format
=
"unixtime"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
Date
roomCreateTime
;
/**
* roomid对应的群公告
*/
private
String
notice
;
/**
* roomid对应的群成员列表
*/
private
List
<
Member
>
members
;
private
class
Member
{
/**
* roomid群成员的id,userid
*/
private
String
memberId
;
/**
* roomid群成员的入群时间
*/
private
String
joinTime
;
}
private
class
AgreeInfo
{
/**
* 同意状态改变的具体时间,utc时间
*/
private
String
statusChangeTime
;
/**
* 成员Id
*/
private
String
userId
;
/**
* 群内外部联系人的externalopenid
*/
private
String
exteranaLopenId
;
/**
* 同意:”Agree”,不同意:”Disagree”,默认同意:”Default_Agree”
*/
private
String
agreeSagreeStatustatus
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/
dto/msgaudit/MsgauditDt
o.java
→
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/
vo/WeMsgAuditV
o.java
View file @
452d232
package
com
.
linkwechat
.
wecom
.
domain
.
dto
.
msgaudit
;
package
com
.
linkwechat
.
wecom
.
domain
.
vo
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
/**
/**
* @author sxw
* @author sxw
* @description 会话存档
* @description 会话存档
入参实体
* @date 2020/12/
2 16:47
* @date 2020/12/
19 12:38
**/
**/
@Data
@Data
public
class
MsgauditDt
o
{
public
class
WeMsgAuditV
o
{
/**
/**
* 拉取对应版本的开启成员列表。1表示办公版;2表示服务版;3表示企业版。
* 拉取对应版本的开启成员列表。1表示办公版;2表示服务版;3表示企业版。
* 非必填,不填写的时候返回全量成员列表
* 非必填,不填写的时候返回全量成员列表
*/
*/
private
Integer
type
;
private
Integer
type
;
/** 待查询的roomid */
private
String
roomid
;
/** 待查询的会话信息,数组 */
private
List
<
Info
>
info
;
@Data
private
class
Info
{
/**
* 内部成员的userid
*/
private
String
userid
;
/**
* 外部成员的externalopenid
*/
private
String
exteranalopenid
;
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeConversationArchiveService.java
0 → 100644
View file @
452d232
package
com
.
linkwechat
.
wecom
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.List
;
/**
* @author sxw
* @description 会话存档业务接口
* @date 2020/12/19 13:59
**/
public
interface
IWeConversationArchiveService
{
/**
* 根据用户ID 获取对应内部联系人列表
*
* @param userId
* @return
*/
List
<
JSONObject
>
getInternalContactList
(
String
userId
,
int
pageSize
,
int
pageNum
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeUserService.java
View file @
452d232
...
@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
...
@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.dto.msgaudit.WeMsgAuditDto
;
import
com.linkwechat.wecom.domain.vo.WeAllocateCustomersVo
;
import
com.linkwechat.wecom.domain.vo.WeAllocateCustomersVo
;
import
com.linkwechat.wecom.domain.vo.WeAllocateGroupsVo
;
import
com.linkwechat.wecom.domain.vo.WeAllocateGroupsVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
...
@@ -108,4 +109,11 @@ public interface IWeUserService extends IService<WeUser>
...
@@ -108,4 +109,11 @@ public interface IWeUserService extends IService<WeUser>
*/
*/
List
<
WeAllocateGroupsVo
>
getAllocateGroups
(
WeAllocateGroupsVo
weAllocateGroupsVo
);
List
<
WeAllocateGroupsVo
>
getAllocateGroups
(
WeAllocateGroupsVo
weAllocateGroupsVo
);
/**
* 获取会话内容存档开启成员列表
* @param msgAuditDto
* @return
*/
List
<
WeUser
>
getPermitUserList
(
WeMsgAuditDto
msgAuditDto
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeConversationArchiveServiceImpl.java
0 → 100644
View file @
452d232
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.elasticsearch.ElasticSearch
;
import
com.linkwechat.wecom.service.IWeConversationArchiveService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author sxw
* @description 会话存档业务实现类
* @date 2020/12/19 14:00
**/
@Slf4j
@Service
public
class
WeConversationArchiveServiceImpl
implements
IWeConversationArchiveService
{
@Autowired
private
ElasticSearch
elasticSearch
;
/**
* 根据用户ID 获取对应内部联系人列表
*
* @param userId
* @return
*/
@Override
public
List
<
JSONObject
>
getInternalContactList
(
String
userId
,
int
pageSize
,
int
pageNum
)
{
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
size
(
pageSize
);
builder
.
from
(
pageNum
);
builder
.
sort
(
"msgtime"
,
SortOrder
.
ASC
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termsQuery
(
"tolist.keyword"
,
userId
))
.
must
(
QueryBuilders
.
termQuery
(
"roomid"
,
""
));
builder
.
query
(
boolQueryBuilder
);
List
<
JSONObject
>
search
=
elasticSearch
.
search
(
WeConstans
.
WECOM_FINANCE_INDEX
,
builder
,
JSONObject
.
class
);
return
search
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeUserServiceImpl.java
View file @
452d232
...
@@ -3,9 +3,12 @@ package com.linkwechat.wecom.service.impl;
...
@@ -3,9 +3,12 @@ package com.linkwechat.wecom.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.wecom.client.WeMsgAuditClient
;
import
com.linkwechat.wecom.client.WeUserClient
;
import
com.linkwechat.wecom.client.WeUserClient
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.dto.msgaudit.WeMsgAuditDto
;
import
com.linkwechat.wecom.domain.vo.WeAllocateCustomersVo
;
import
com.linkwechat.wecom.domain.vo.WeAllocateCustomersVo
;
import
com.linkwechat.wecom.domain.vo.WeAllocateGroupsVo
;
import
com.linkwechat.wecom.domain.vo.WeAllocateGroupsVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
...
@@ -22,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -22,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* 通讯录相关客户Service业务层处理
* 通讯录相关客户Service业务层处理
...
@@ -35,10 +40,15 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
...
@@ -35,10 +40,15 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
@Autowired
@Autowired
private
WeUserMapper
weUserMapper
;
private
WeUserMapper
weUserMapper
;
@Autowired
private
RedisCache
redisCache
;
@Autowired
@Autowired
private
WeUserClient
weUserClient
;
private
WeUserClient
weUserClient
;
@Autowired
private
WeMsgAuditClient
weMsgAuditClient
;
@Autowired
@Autowired
private
IWeCustomerService
iWeCustomerService
;
private
IWeCustomerService
iWeCustomerService
;
...
@@ -245,5 +255,17 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
...
@@ -245,5 +255,17 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
return
this
.
baseMapper
.
getAllocateGroups
(
weAllocateGroupsVo
);
return
this
.
baseMapper
.
getAllocateGroups
(
weAllocateGroupsVo
);
}
}
@Override
public
List
<
WeUser
>
getPermitUserList
(
WeMsgAuditDto
msgAuditDto
)
{
List
<
String
>
userIds
=
redisCache
.
getCacheList
(
WeConstans
.
weMsgAuditKey
);
if
(
CollectionUtil
.
isNotEmpty
(
userIds
)){
WeMsgAuditDto
permitUserList
=
weMsgAuditClient
.
getPermitUserList
(
msgAuditDto
);
userIds
=
Optional
.
ofNullable
(
userIds
).
orElse
(
permitUserList
.
getIds
());
redisCache
.
setCacheList
(
WeConstans
.
weMsgAuditKey
,
userIds
);
redisCache
.
expire
(
WeConstans
.
weMsgAuditKey
,
10
,
TimeUnit
.
MILLISECONDS
);
}
return
weUserMapper
.
selectBatchIds
(
userIds
);
}
}
}
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