Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
c4195da7
Commit
c4195da7
authored
Feb 22, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
好友关系逻辑调整
parent
46cc0362
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
99 additions
and
86 deletions
+99
-86
core/src/main/java/com/wecloud/im/friend/controller/ImFriendController.java
+1
-1
core/src/main/java/com/wecloud/im/friend/entity/ImFriend.java
+3
-3
core/src/main/java/com/wecloud/im/friend/entity/ImFriendRecommend.java
+2
-2
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendMapper.java
+13
-7
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendRecommendMapper.java
+7
-1
core/src/main/java/com/wecloud/im/friend/param/ImFriendApplyParam.java
+2
-1
core/src/main/java/com/wecloud/im/friend/param/ImFriendBaseParam.java
+1
-1
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
+35
-35
core/src/main/java/com/wecloud/im/service/ImClientService.java
+2
-2
core/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
+4
-4
core/src/main/resources/mapper/ImFriendMapper.xml
+14
-14
core/src/main/resources/mapper/ImFriendRecommendMapper.xml
+9
-9
docs/db/feature-cluster增量.sql
+6
-6
No files found.
core/src/main/java/com/wecloud/im/friend/controller/ImFriendController.java
View file @
c4195da7
...
...
@@ -66,7 +66,7 @@ public class ImFriendController extends BaseController {
if
(
friendClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
ImFriendApplyDto
friendInfo
=
imFriendService
.
getFriendInfo
(
currentClient
.
get
Id
(),
friendClient
.
ge
tId
());
ImFriendApplyDto
friendInfo
=
imFriendService
.
getFriendInfo
(
currentClient
.
get
ClientId
(),
friendClient
.
getClien
tId
());
return
ApiResult
.
ok
(
friendInfo
);
}
...
...
core/src/main/java/com/wecloud/im/friend/entity/ImFriend.java
View file @
c4195da7
...
...
@@ -29,13 +29,13 @@ public class ImFriend extends BaseEntity {
private
Long
id
;
@ApiModelProperty
(
"我的client-id"
)
private
Long
fkC
lientId
;
private
String
c
lientId
;
@ApiModelProperty
(
"好友的client-id"
)
private
Long
fkC
lientIdFriend
;
private
String
c
lientIdFriend
;
@ApiModelProperty
(
"申请者"
)
private
Long
fkC
lientIdClaimer
;
private
String
c
lientIdClaimer
;
@ApiModelProperty
(
"好友的昵称备注"
)
private
String
friendName
;
...
...
core/src/main/java/com/wecloud/im/friend/entity/ImFriendRecommend.java
View file @
c4195da7
...
...
@@ -29,10 +29,10 @@ public class ImFriendRecommend extends BaseEntity {
private
Long
id
;
@ApiModelProperty
(
"我的client-id"
)
private
Long
fkC
lientId
;
private
String
c
lientId
;
@ApiModelProperty
(
"好友的client-id"
)
private
Long
fkC
lientIdFriend
;
private
String
c
lientIdFriend
;
@ApiModelProperty
(
"推荐来源"
)
private
Integer
source
;
...
...
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendMapper.java
View file @
c4195da7
...
...
@@ -21,23 +21,29 @@ public interface ImFriendMapper extends BaseMapper<ImFriend> {
IPage
<
ImFriendBaseDto
>
getImFriendPageList
(
@Param
(
"page"
)
Page
<
ImFriendBaseDto
>
page
,
@Param
(
"clientId"
)
Long
fkClientId
);
IPage
<
ImFriendApplyDto
>
getUnsureFriendPageList
(
@Param
(
"page"
)
Page
<
ImFriendApplyDto
>
page
,
@Param
(
"clientId"
)
Long
fkClientId
);
/**
* 获取待验证的好友列表
* @param page
* @param clientId
* @return
*/
IPage
<
ImFriendApplyDto
>
getUnsureFriendPageList
(
@Param
(
"page"
)
Page
<
ImFriendApplyDto
>
page
,
@Param
(
"clientId"
)
String
clientId
);
ImFriendApplyDto
getFriendInfo
(
@Param
(
"clientId"
)
Long
fkClientId
,
@Param
(
"friendClientId"
)
Long
fkF
riendClientId
);
ImFriendApplyDto
getFriendInfo
(
@Param
(
"clientId"
)
String
clientId
,
@Param
(
"friendClientId"
)
String
f
riendClientId
);
/**
* 过滤得到真的好友,非好友的friendId将被它忽略
* @param
fkC
lientId
* @param f
kF
riendClientIds
* @param
c
lientId
* @param friendClientIds
* @return
*/
List
<
Long
>
filterNegativeFriends
(
@Param
(
"clientId"
)
Long
fkClientId
,
@Param
(
"friendClientIds"
)
List
<
Long
>
fkF
riendClientIds
);
List
<
String
>
filterNegativeFriends
(
@Param
(
"clientId"
)
String
clientId
,
@Param
(
"friendClientIds"
)
List
<
String
>
f
riendClientIds
);
/**
* 批量删除好友
* @param
fkC
lientId 删除人的clientId
* @param
c
lientId 删除人的clientId
* @param fkAppId
* @param friendClientIds 被删除人的clientId列表
*/
void
batchDeleteFriend
(
@Param
(
"clientId"
)
Long
fkC
lientId
,
@Param
(
"fkAppId"
)
Long
fkAppId
,
@Param
(
"friendClientIds"
)
List
<
String
>
friendClientIds
);
void
batchDeleteFriend
(
@Param
(
"clientId"
)
String
c
lientId
,
@Param
(
"fkAppId"
)
Long
fkAppId
,
@Param
(
"friendClientIds"
)
List
<
String
>
friendClientIds
);
}
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendRecommendMapper.java
View file @
c4195da7
...
...
@@ -22,7 +22,13 @@ public interface ImFriendRecommendMapper extends BaseMapper<ImFriendRecommend> {
IPage
<
ImFriendRecommendDto
>
getImFriendRecommendPageList
(
@Param
(
"page"
)
Page
pageParam
,
@Param
(
"clientId"
)
Long
clientId
);
void
batchDeleteRecommend
(
@Param
(
"clientId"
)
Long
clientId
,
@Param
(
"fkAppId"
)
Long
fkAppId
,
@Param
(
"friendClientIds"
)
List
<
String
>
friendClientIds
);
/**
* 批量删除好友推荐
* @param clientId
* @param fkAppId
* @param friendClientIds
*/
void
batchDeleteRecommend
(
@Param
(
"clientId"
)
String
clientId
,
@Param
(
"fkAppId"
)
Long
fkAppId
,
@Param
(
"friendClientIds"
)
List
<
String
>
friendClientIds
);
void
batchCreateRecommend
(
@Param
(
"list"
)
List
<
ImFriendRecommend
>
list
);
}
core/src/main/java/com/wecloud/im/friend/param/ImFriendApplyParam.java
View file @
c4195da7
...
...
@@ -6,7 +6,7 @@ import lombok.Data;
import
java.io.Serializable
;
/**
* @Description
TODO
* @Description
申请好友入参
* @Author lixiaozhong
* @Date 2022/1/13 4:24 下午
*/
...
...
@@ -16,6 +16,7 @@ public class ImFriendApplyParam extends ImFriendBaseParam {
@ApiModelProperty
(
"备注好友名称"
)
private
String
friendName
;
@ApiModelProperty
(
"请求备注"
)
private
String
requestRemark
;
}
core/src/main/java/com/wecloud/im/friend/param/ImFriendBaseParam.java
View file @
c4195da7
...
...
@@ -6,7 +6,7 @@ import lombok.Data;
import
java.io.Serializable
;
/**
* @Description
TODO
* @Description
好友相关base入参
* @Author lixiaozhong
* @Date 2022/1/13 4:24 下午
*/
...
...
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
View file @
c4195da7
...
...
@@ -55,12 +55,12 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
/**
* 查看朋友详情
* @param curentClientId
* @param cur
r
entClientId
* @param friendClientId
* @return
*/
public
ImFriendApplyDto
getFriendInfo
(
Long
curentClientId
,
Lo
ng
friendClientId
)
{
return
imFriendMapper
.
getFriendInfo
(
curentClientId
,
friendClientId
);
public
ImFriendApplyDto
getFriendInfo
(
String
currentClientId
,
Stri
ng
friendClientId
)
{
return
imFriendMapper
.
getFriendInfo
(
cur
r
entClientId
,
friendClientId
);
}
/**
...
...
@@ -72,7 +72,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
ImFriendPageParam
pageParam
=
new
ImFriendPageParam
();
pageParam
.
setPageSize
(
1000L
);
Page
<
ImFriendApplyDto
>
page
=
new
PageInfo
(
pageParam
,
OrderItem
.
desc
(
getLambdaColumn
(
ImFriend:
:
getCreateTime
)));
IPage
<
ImFriendApplyDto
>
pageList
=
imFriendMapper
.
getUnsureFriendPageList
(
page
,
currentClient
.
getId
());
IPage
<
ImFriendApplyDto
>
pageList
=
imFriendMapper
.
getUnsureFriendPageList
(
page
,
currentClient
.
get
Client
Id
());
return
pageList
.
getRecords
();
}
...
...
@@ -88,13 +88,13 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
public
Boolean
applyFriend
(
ImClient
currentClient
,
ImClient
friendClient
,
String
friendName
,
String
requestRemark
)
{
//好友关系有维护两条,我和他,他和我
ImFriend
my
=
new
ImFriend
();
my
.
set
FkClientId
(
currentClient
.
ge
tId
());
my
.
set
FkClientIdFriend
(
friendClient
.
ge
tId
());
my
.
set
FkClientIdClaimer
(
currentClient
.
ge
tId
());
my
.
set
ClientId
(
currentClient
.
getClien
tId
());
my
.
set
ClientIdFriend
(
friendClient
.
getClien
tId
());
my
.
set
ClientIdClaimer
(
currentClient
.
getClien
tId
());
my
.
setFriendName
(
friendName
);
my
.
setRequestRemark
(
requestRemark
);
my
.
setState
(
FriendStateEnum
.
UNSURE
.
getCode
());
if
(
getByKey
(
currentClient
.
get
Id
(),
friendClient
.
ge
tId
())
!=
null
)
{
if
(
getByKey
(
currentClient
.
get
ClientId
(),
friendClient
.
getClien
tId
())
!=
null
)
{
if
(
StringUtils
.
isNotEmpty
(
requestRemark
))
{
my
.
setRequestRemark
(
requestRemark
);
}
...
...
@@ -109,12 +109,12 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
}
ImFriend
friend
=
new
ImFriend
();
friend
.
set
FkClientId
(
friendClient
.
ge
tId
());
friend
.
set
FkClientIdFriend
(
currentClient
.
ge
tId
());
friend
.
set
FkClientIdClaimer
(
currentClient
.
ge
tId
());
friend
.
set
ClientId
(
friendClient
.
getClien
tId
());
friend
.
set
ClientIdFriend
(
currentClient
.
getClien
tId
());
friend
.
set
ClientIdClaimer
(
currentClient
.
getClien
tId
());
friend
.
setRequestRemark
(
requestRemark
);
friend
.
setState
(
FriendStateEnum
.
UNSURE
.
getCode
());
if
(
getByKey
(
friendClient
.
get
Id
(),
currentClient
.
ge
tId
())
!=
null
)
{
if
(
getByKey
(
friendClient
.
get
ClientId
(),
currentClient
.
getClien
tId
())
!=
null
)
{
if
(
StringUtils
.
isNotEmpty
(
requestRemark
))
{
friend
.
setRequestRemark
(
requestRemark
);
}
...
...
@@ -142,10 +142,10 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
* @param friendClientId
* @return
*/
public
ImFriend
getByKey
(
Long
clientId
,
Lo
ng
friendClientId
)
{
public
ImFriend
getByKey
(
String
clientId
,
Stri
ng
friendClientId
)
{
return
this
.
getOne
(
new
QueryWrapper
<
ImFriend
>().
lambda
()
.
eq
(
ImFriend:
:
get
Fk
ClientId
,
clientId
)
.
eq
(
ImFriend:
:
get
Fk
ClientIdFriend
,
friendClientId
));
.
eq
(
ImFriend:
:
getClientId
,
clientId
)
.
eq
(
ImFriend:
:
getClientIdFriend
,
friendClientId
));
}
/**
...
...
@@ -157,9 +157,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
imFriend
.
setId
(
null
);
imFriend
.
setCreateTime
(
null
);
return
this
.
update
(
imFriend
,
new
QueryWrapper
<
ImFriend
>().
lambda
()
.
eq
(
ImFriend:
:
get
FkClientId
,
imFriend
.
getFk
ClientId
())
.
eq
(
ImFriend:
:
get
FkClientIdFriend
,
imFriend
.
getFk
ClientIdFriend
())
.
eq
(
ImFriend:
:
get
FkClientIdClaimer
,
imFriend
.
getFk
ClientIdClaimer
()));
.
eq
(
ImFriend:
:
get
ClientId
,
imFriend
.
get
ClientId
())
.
eq
(
ImFriend:
:
get
ClientIdFriend
,
imFriend
.
get
ClientIdFriend
())
.
eq
(
ImFriend:
:
get
ClientIdClaimer
,
imFriend
.
get
ClientIdClaimer
()));
}
/**
...
...
@@ -177,9 +177,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
//好友关系有维护两条,我和他,他和我
//好友的先更新
ImFriend
friend
=
new
ImFriend
();
friend
.
set
FkClientId
(
friendClient
.
ge
tId
());
friend
.
set
FkClientIdFriend
(
currentClient
.
ge
tId
());
friend
.
set
FkClientIdClaimer
(
friendClient
.
ge
tId
());
friend
.
set
ClientId
(
friendClient
.
getClien
tId
());
friend
.
set
ClientIdFriend
(
currentClient
.
getClien
tId
());
friend
.
set
ClientIdClaimer
(
friendClient
.
getClien
tId
());
friend
.
setState
(
agree
?
FriendStateEnum
.
CONFORM
.
getCode
()
:
FriendStateEnum
.
REJECT
.
getCode
());
if
(
StringUtils
.
isNotEmpty
(
rejectRemark
))
{
friend
.
setRejectRemark
(
rejectRemark
);
...
...
@@ -187,9 +187,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
boolean
ok1
=
this
.
updateByKeyAndClaimer
(
friend
);
// 同时更新我的
ImFriend
my
=
new
ImFriend
();
my
.
set
FkClientId
(
currentClient
.
ge
tId
());
my
.
set
FkClientIdFriend
(
friendClient
.
ge
tId
());
my
.
set
FkClientIdClaimer
(
friendClient
.
ge
tId
());
my
.
set
ClientId
(
currentClient
.
getClien
tId
());
my
.
set
ClientIdFriend
(
friendClient
.
getClien
tId
());
my
.
set
ClientIdClaimer
(
friendClient
.
getClien
tId
());
my
.
setState
(
agree
?
FriendStateEnum
.
CONFORM
.
getCode
()
:
FriendStateEnum
.
REJECT
.
getCode
());
if
(
StringUtils
.
isNotEmpty
(
rejectRemark
))
{
my
.
setRejectRemark
(
rejectRemark
);
...
...
@@ -205,7 +205,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
if
(
CollectionUtils
.
isEmpty
(
friendClientIds
))
{
return
;
}
imFriendMapper
.
batchDeleteFriend
(
currentClient
.
getId
(),
currentClient
.
getFkAppid
(),
friendClientIds
);
imFriendMapper
.
batchDeleteFriend
(
currentClient
.
get
Client
Id
(),
currentClient
.
getFkAppid
(),
friendClientIds
);
}
public
Paging
<
ImFriendBaseDto
>
getImFriendPageList
(
Long
currentClientId
,
ImFriendPageParam
pageParam
)
{
...
...
@@ -224,7 +224,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
if
(
CollectionUtils
.
isEmpty
(
friendClientIds
))
{
return
;
}
imFriendRecommendMapper
.
batchDeleteRecommend
(
currentClient
.
getId
(),
currentClient
.
getFkAppid
(),
friendClientIds
);
imFriendRecommendMapper
.
batchDeleteRecommend
(
currentClient
.
get
Client
Id
(),
currentClient
.
getFkAppid
(),
friendClientIds
);
}
/**
...
...
@@ -242,28 +242,28 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
return
;
}
//对已经存在的好友过滤掉
List
<
Long
>
maybeFriendIds
=
simpleFriendClients
.
stream
().
map
(
ImClientSimpleDto:
:
ge
tId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
alreadyFriendIds
=
imFriendMapper
.
filterNegativeFriends
(
currentClient
.
getId
(),
maybeFriend
Ids
);
List
<
String
>
maybeFriendClientIds
=
simpleFriendClients
.
stream
().
map
(
ImClientSimpleDto:
:
getClien
tId
).
collect
(
Collectors
.
toList
());
List
<
String
>
alreadyFriendClientIds
=
imFriendMapper
.
filterNegativeFriends
(
currentClient
.
getClientId
(),
maybeFriendClient
Ids
);
Map
<
String
,
Long
>
friend
IdMap
=
simpleFriendClients
.
stream
().
collect
(
Collectors
.
toMap
(
ImClientSimpleDto:
:
getClientId
,
ImClientSimpleDto:
:
getId
,
(
a
,
b
)
->
a
));
Map
<
String
,
String
>
friendClient
IdMap
=
simpleFriendClients
.
stream
().
collect
(
Collectors
.
toMap
(
ImClientSimpleDto:
:
getClientId
,
ImClientSimpleDto:
:
get
Client
Id
,
(
a
,
b
)
->
a
));
List
<
ImFriendRecommend
>
list
=
new
ArrayList
<>();
for
(
ImFriendRecommendDto
p
:
friends
)
{
Long
fkFriendCliendId
=
friend
IdMap
.
get
(
p
.
getFriendClientId
());
String
friendClientId
=
friendClient
IdMap
.
get
(
p
.
getFriendClientId
());
// 只有client存在的数据才是真数据
if
(
f
kFriendCliend
Id
==
null
)
{
if
(
f
riendClient
Id
==
null
)
{
continue
;
}
// 如果推荐的人已经是好友,则忽略。
if
(
alreadyFriend
Ids
.
contains
(
fkFriendCliend
Id
))
{
if
(
alreadyFriend
ClientIds
.
contains
(
friendClient
Id
))
{
continue
;
}
ImFriendRecommend
recommend
=
new
ImFriendRecommend
();
recommend
.
setId
(
SnowflakeUtil
.
getId
());
recommend
.
set
FkClientId
(
currentClient
.
ge
tId
());
recommend
.
set
ClientId
(
currentClient
.
getClien
tId
());
recommend
.
set
FkClientIdFriend
(
fkFriendCliend
Id
);
recommend
.
set
ClientIdFriend
(
friendClient
Id
);
recommend
.
setSource
(
p
.
getSource
());
recommend
.
setDelFlag
(
false
);
list
.
add
(
recommend
);
...
...
core/src/main/java/com/wecloud/im/service/ImClientService.java
View file @
c4195da7
...
...
@@ -138,10 +138,10 @@ public interface ImClientService extends BaseService<ImClient> {
/**
* 获取client的简单对象,减少开销
* @param applicationId
* @param clientId
* @param clientId
s
* @return
*/
List
<
ImClientSimpleDto
>
getSimpleClients
(
Long
applicationId
,
List
<
String
>
clientId
);
List
<
ImClientSimpleDto
>
getSimpleClients
(
Long
applicationId
,
List
<
String
>
clientId
s
);
List
<
ImClientSimpleDto
>
getSimpleClients
(
List
<
Long
>
ids
);
}
core/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
View file @
c4195da7
...
...
@@ -167,7 +167,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
BeanUtils
.
copyProperties
(
infoList
.
get
(
0
),
clientInfoVo
);
clientInfoVo
.
setRelation
(
RelationEnum
.
STRANGER
.
getCode
());
// 查询该好友与自己关系: 陌生人、好友、被拉黑名单
ImFriend
imFriend
=
imFriendService
.
getByKey
(
currentClient
.
get
Id
(),
clientInfoVo
.
ge
tId
());
ImFriend
imFriend
=
imFriendService
.
getByKey
(
currentClient
.
get
ClientId
(),
clientInfoVo
.
getClien
tId
());
if
(
imFriend
!=
null
&&
FriendStateEnum
.
CONFORM
.
getCode
().
equals
(
imFriend
.
getState
()))
{
clientInfoVo
.
setRelation
(
RelationEnum
.
FRIEND
.
getCode
());
}
...
...
@@ -303,14 +303,14 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
}
@Override
//
@Cacheable(key = "#p0")
@Cacheable
(
key
=
"#p0"
)
public
ImClient
getCacheImClient
(
Long
id
)
{
return
imClientMapper
.
selectById
(
id
);
}
@Override
public
List
<
ImClientSimpleDto
>
getSimpleClients
(
Long
applicationId
,
List
<
String
>
clientId
)
{
return
imClientMapper
.
getSimpleClients
(
applicationId
,
clientId
);
public
List
<
ImClientSimpleDto
>
getSimpleClients
(
Long
applicationId
,
List
<
String
>
clientId
s
)
{
return
imClientMapper
.
getSimpleClients
(
applicationId
,
clientId
s
);
}
@Override
...
...
core/src/main/resources/mapper/ImFriendMapper.xml
View file @
c4195da7
...
...
@@ -4,47 +4,47 @@
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id,
fk_client_id, fk_
client_id_friend, friend_name,reject_remark,request_remark,state,create_time, update_time
id,
client_id,
client_id_friend, friend_name,reject_remark,request_remark,state,create_time, update_time
</sql>
<select
id=
"getFriendInfo"
resultType=
"com.wecloud.im.friend.param.ImFriendApplyDto"
>
select
friend.id, client.client_id as friendClientId, friend.friend_name, claimer.client_id as claimerClientId,
friend.reject_remark, friend.request_remark, friend.state, friend.create_time
from im_friend friend inner join im_client client on friend.
fk_client_id_friend = client.
id
inner join im_client claimer on friend.
fk_client_id_claimer = claimer.
id
where friend.
fk_client_id = #{clientId} and fk_
client_id_friend = #{friendClientId} and friend.state = 2
from im_friend friend inner join im_client client on friend.
client_id_friend = client.client_
id
inner join im_client claimer on friend.
client_id_claimer = claimer.client_
id
where friend.
client_id = #{clientId} and
client_id_friend = #{friendClientId} and friend.state = 2
</select>
<select
id=
"getImFriendPageList"
resultType=
"com.wecloud.im.friend.param.ImFriendBaseDto"
>
select
friend.id, client.client_id as friendClientId, friend.friend_name, friend.state
from im_friend friend inner join im_client client on friend.
fk_client_id_friend = client.
id
where friend.
fk_
client_id = #{clientId} and friend.state = 2
from im_friend friend inner join im_client client on friend.
client_id_friend = client.client_
id
where friend.client_id = #{clientId} and friend.state = 2
</select>
<select
id=
"getUnsureFriendPageList"
resultType=
"com.wecloud.im.friend.param.ImFriendApplyDto"
>
select
friend.id, client.client_id as friendClientId, friend.friend_name, claimer.client_id as claimerClientId,
friend.reject_remark, friend.request_remark, friend.state, friend.create_time
from im_friend friend inner join im_client client on friend.
fk_client_id_friend = client.
id
inner join im_client claimer on friend.
fk_client_id_claimer = claimer.
id
where friend.
fk_
client_id = #{clientId} and friend.state = 1
from im_friend friend inner join im_client client on friend.
client_id_friend = client.client_
id
inner join im_client claimer on friend.
client_id_claimer = claimer.client_
id
where friend.client_id = #{clientId} and friend.state = 1
</select>
<select
id=
"filterNegativeFriends"
resultType=
"java.lang.
Lo
ng"
>
<select
id=
"filterNegativeFriends"
resultType=
"java.lang.
Stri
ng"
>
select
fk_
client_id_friend
client_id_friend
from im_friend
where
fk_client_id = #{clientId} and fk_
client_id_friend in
where
client_id = #{clientId} and
client_id_friend in
<foreach
collection=
"friendClientIds"
item=
"friendClientId"
open=
"("
close=
")"
separator=
","
>
#{friendClientId}
</foreach>
</select>
<update
id=
"batchDeleteFriend"
>
update im_friend set state = 4 where
fk_client_id = #{clientId} and fk_
client_id_friend in (
select id from im_client where (fk_appid, client_id) in
update im_friend set state = 4 where
client_id = #{clientId} and
client_id_friend in (
select
client_
id from im_client where (fk_appid, client_id) in
<foreach
collection=
"friendClientIds"
item=
"friendClientId"
open=
"("
close=
")"
separator=
","
>
(#{fkAppId}, #{friendClientId})
</foreach>
...
...
core/src/main/resources/mapper/ImFriendRecommendMapper.xml
View file @
c4195da7
...
...
@@ -4,30 +4,30 @@
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id,
fk_client_id, fk_
client_id_friend, source, del_flag, create_time, update_time
id,
client_id,
client_id_friend, source, del_flag, create_time, update_time
</sql>
<select
id=
"getImFriendRecommendPageList"
resultType=
"com.wecloud.im.friend.param.ImFriendRecommendDto"
>
select
recommend.id, client.client_id as friendClientId, recommend.source, recommend.del_flag
from im_friend_recommend recommend inner join im_client client on recommend.
fk_client_id_friend = client.
id
where
fk_
client_id = #{clientId}
from im_friend_recommend recommend inner join im_client client on recommend.
client_id_friend = client.client_
id
where client_id = #{clientId}
</select>
<update
id=
"batchDeleteRecommend"
>
update im_friend_recommend set del_flag = 1 where
fk_client_id = #{clientId} and fk_
client_id_friend in (
select id from im_client where (fk_appid, client_id) in
<foreach
collection=
"friendClientIds"
item=
"friendC
L
ientId"
open=
"("
close=
")"
separator=
","
>
(#{fkAppId}, #{friendC
L
ientId})
update im_friend_recommend set del_flag = 1 where
client_id = #{clientId} and
client_id_friend in (
select
client_
id from im_client where (fk_appid, client_id) in
<foreach
collection=
"friendClientIds"
item=
"friendC
l
ientId"
open=
"("
close=
")"
separator=
","
>
(#{fkAppId}, #{friendC
l
ientId})
</foreach>
)
</update>
<insert
id=
"batchCreateRecommend"
>
insert into im_friend_recommend(id,
fk_client_id, fk_
client_id_friend, source, del_flag, create_time)
insert into im_friend_recommend(id,
client_id,
client_id_friend, source, del_flag, create_time)
values
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(#{item.id},#{item.
fkClientId},#{item.fkC
lientIdFriend},#{item.source},#{item.delFlag}, NOW())
(#{item.id},#{item.
clientId},#{item.c
lientIdFriend},#{item.source},#{item.delFlag}, NOW())
</foreach>
ON DUPLICATE KEY UPDATE update_time = now()
</insert>
...
...
docs/db/feature-cluster增量.sql
View file @
c4195da7
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
...
...
@@ -33,9 +33,9 @@ CREATE TABLE `im_msg_read_lastest`
CREATE
TABLE
`im_friend`
(
`id`
bigint
NOT
NULL
COMMENT
'主键id'
,
`
fk_client_id`
bigint
NOT
NULL
COMMENT
'自己id'
,
`
fk_client_id_friend`
bigint
NOT
NULL
COMMENT
'好友id'
,
`
fk_client_id_claimer`
bigint
NOT
NULL
COMMENT
'好友申请者'
,
`
client_id`
varchar
(
32
)
NOT
NULL
COMMENT
'自己id'
,
`
client_id_friend`
varchar
(
32
)
NOT
NULL
COMMENT
'好友id'
,
`
client_id_claimer`
varchar
(
32
)
NOT
NULL
COMMENT
'好友申请者'
,
`friend_name`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'好友名称备注'
,
`reject_remark`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'拒绝说明'
,
`request_remark`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'好友请求说明'
,
...
...
@@ -49,8 +49,8 @@ CREATE TABLE `im_friend`
CREATE
TABLE
`im_friend_recommend`
(
`id`
bigint
(
20
)
NOT
NULL
COMMENT
'主键id'
,
`
fk_client_id`
bigint
(
20
)
NOT
NULL
COMMENT
'自己id'
,
`
fk_client_id_friend`
bigint
(
20
)
NOT
NULL
COMMENT
'好友id'
,
`
client_id`
varchar
(
32
)
NOT
NULL
COMMENT
'自己id'
,
`
client_id_friend`
varchar
(
32
)
NOT
NULL
COMMENT
'好友id'
,
`source`
tinyint
DEFAULT
NULL
COMMENT
'推荐来源'
,
`del_flag`
bit
(
1
)
NOT
NULL
default
0
COMMENT
'删除标识'
,
`create_time`
timestamp
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment