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
4b4f9f39
Commit
4b4f9f39
authored
Jan 12, 2022
by
lixiaozhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、好友关系:好友请求,好友通过,好友拒绝,查询好友,好友列表,待验证好友列表等等
2、好友推荐关系:批量推荐创建,推荐关系列表等等
parent
99938109
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
680 additions
and
5 deletions
+680
-5
bootstrap/src/main/java/io/geekidea/springbootplus/config/Swagger2Config.java
+1
-1
core/src/main/java/com/wecloud/im/enums/FriendStateEnum.java
+46
-0
core/src/main/java/com/wecloud/im/friend/controller/ImFriendController.java
+202
-0
core/src/main/java/com/wecloud/im/friend/entity/ImFriend.java
+58
-0
core/src/main/java/com/wecloud/im/friend/entity/ImFriendRecommend.java
+49
-0
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendMapper.java
+29
-0
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendRecommendMapper.java
+28
-0
core/src/main/java/com/wecloud/im/friend/param/ImFriendApplyDto.java
+24
-0
core/src/main/java/com/wecloud/im/friend/param/ImFriendBaseDto.java
+29
-0
core/src/main/java/com/wecloud/im/friend/param/ImFriendPageParam.java
+21
-0
core/src/main/java/com/wecloud/im/friend/param/ImFriendRecommendDto.java
+26
-0
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
+0
-0
core/src/main/java/com/wecloud/im/mapper/ImClientMapper.java
+2
-0
core/src/main/java/com/wecloud/im/param/ImClientSimpleDto.java
+37
-0
core/src/main/java/com/wecloud/im/service/ImClientService.java
+8
-0
core/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
+6
-0
core/src/main/java/com/wecloud/im/thousandchat/entity/ImMsgReadLastest.java
+2
-2
core/src/main/resources/mapper/ImClientMapper.xml
+7
-0
core/src/main/resources/mapper/ImFriendMapper.xml
+42
-0
core/src/main/resources/mapper/ImFriendRecommendMapper.xml
+35
-0
docs/db/wecloud_im.sql
+27
-0
framework/src/main/java/io/geekidea/springbootplus/framework/common/service/impl/BaseServiceImpl.java
+1
-2
No files found.
bootstrap/src/main/java/io/geekidea/springbootplus/config/Swagger2Config.java
View file @
4b4f9f39
...
...
@@ -155,7 +155,7 @@ public class Swagger2Config {
@Bean
public
Docket
restAppApi
()
{
// 获取需要扫描的包
String
[]
basePackages
=
{
"com.wecloud.im.controller"
,
"com.wecloud.im
.thousandchat.controller
"
};
String
[]
basePackages
=
{
"com.wecloud.im.controller"
,
"com.wecloud.im"
};
ApiSelectorBuilder
apiSelectorBuilder
=
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
groupName
(
"app"
)
...
...
core/src/main/java/com/wecloud/im/enums/FriendStateEnum.java
0 → 100644
View file @
4b4f9f39
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
wecloud
.
im
.
enums
;
import
io.geekidea.springbootplus.framework.common.enums.BaseEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 好友关系 1:待确定,2:已确认,3:已拒绝,4:已删除
* @author lixiaozhong
*
*/
@Getter
@AllArgsConstructor
public
enum
FriendStateEnum
implements
BaseEnum
{
/**
* 禁用
**/
UNSURE
(
1
,
"待确认"
),
/**
* 启用
**/
CONFORM
(
2
,
"已确认"
),
REJECT
(
3
,
"已拒绝"
),
DEL
(
4
,
"已删除"
);
private
final
Integer
code
;
private
final
String
desc
;
}
core/src/main/java/com/wecloud/im/friend/controller/ImFriendController.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
controller
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.friend.param.ImFriendApplyDto
;
import
com.wecloud.im.friend.param.ImFriendBaseDto
;
import
com.wecloud.im.friend.param.ImFriendPageParam
;
import
com.wecloud.im.friend.param.ImFriendRecommendDto
;
import
com.wecloud.im.friend.service.ImFriendService
;
import
com.wecloud.im.service.ImClientService
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.controller.BaseController
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
io.geekidea.springbootplus.framework.log.annotation.OperationLog
;
import
io.geekidea.springbootplus.framework.log.enums.OperationLogType
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author lixiaozhong
* 好友与好友推荐相关接口
*/
@Slf4j
@RestController
@RequestMapping
(
"/friend"
)
@Api
(
value
=
"好友与好友推荐相关API"
,
tags
=
{
"好友关系"
})
public
class
ImFriendController
extends
BaseController
{
@Autowired
private
ImFriendService
imFriendService
;
@Autowired
private
ImClientService
imClientService
;
/**
* 查询好友信息,只有自己的好友才查得到
*/
@PostMapping
(
"/info"
)
@ApiOperation
(
value
=
"查询好友信息,只有自己的好友才查得到"
)
public
ApiResult
<
ImFriendApplyDto
>
getFriendInfo
(
@ApiParam
(
"好友的clientId"
)
String
friendClientId
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
ImClient
friendClient
=
imClientService
.
getCacheImClient
(
currentClient
.
getFkAppid
(),
friendClientId
);
if
(
friendClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
ImFriendApplyDto
friendInfo
=
imFriendService
.
getFriendInfo
(
currentClient
.
getId
(),
friendClient
.
getId
());
return
ApiResult
.
ok
(
friendInfo
);
}
/**
* 申请添加好友
*/
@PostMapping
(
"/apply"
)
@ApiOperation
(
value
=
"申请添加好友"
)
public
ApiResult
<
Boolean
>
applyFriend
(
@ApiParam
(
"好友的clientId"
)
String
friendClientId
,
@ApiParam
(
"备注好友名称"
)
String
friendName
,
@ApiParam
(
"请求备注"
)
String
requestRemark
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
ImClient
friendClient
=
imClientService
.
getCacheImClient
(
currentClient
.
getFkAppid
(),
friendClientId
);
if
(
friendClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
if
(
currentClient
.
getId
().
equals
(
friendClient
.
getId
()))
{
return
ApiResult
.
fail
(
ApiCode
.
PARAMETER_EXCEPTION
,
null
);
}
imFriendService
.
applyFriend
(
currentClient
.
getId
(),
friendClient
.
getId
(),
friendName
,
requestRemark
);
return
ApiResult
.
ok
();
}
/**
* 待接受的好友请求列表
*/
@PostMapping
(
"/unsureFriends"
)
@ApiOperation
(
value
=
"待接受的好友请求列表"
)
public
ApiResult
<
Paging
<
ImFriendApplyDto
>>
getUnsureFriends
()
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
Paging
<
ImFriendApplyDto
>
friendInfo
=
imFriendService
.
getUnsureFriends
(
currentClient
.
getId
());
return
ApiResult
.
ok
(
friendInfo
);
}
/**
* 接受/拒绝好友申请
*/
@PostMapping
(
"/approve"
)
@ApiOperation
(
value
=
"接受/拒绝好友申请"
)
public
ApiResult
<
Boolean
>
approveFriend
(
String
friendClientId
,
Boolean
agree
,
String
rejectRemark
)
{
if
(
agree
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
PARAMETER_EXCEPTION
,
null
);
}
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
ImClient
friendClient
=
imClientService
.
getCacheImClient
(
currentClient
.
getFkAppid
(),
friendClientId
);
if
(
friendClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
imFriendService
.
approveFriend
(
currentClient
.
getId
(),
friendClient
.
getId
(),
agree
,
rejectRemark
);
return
ApiResult
.
ok
();
}
/**
* 批量删除好友
*/
@PostMapping
(
"/batchDelete"
)
@ApiOperation
(
value
=
"删除好友"
)
public
ApiResult
<
Boolean
>
batchDeleteFriend
(
@RequestBody
List
<
String
>
friendClientIds
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
imFriendService
.
batchDeleteFriend
(
currentClient
,
friendClientIds
);
return
ApiResult
.
ok
();
}
/**
* 好友分页列表
*/
@PostMapping
(
"/getPageList"
)
@OperationLog
(
name
=
"好友分页列表"
,
type
=
OperationLogType
.
PAGE
)
@ApiOperation
(
value
=
"好友分页列表"
)
public
ApiResult
<
Paging
<
ImFriendBaseDto
>>
getImFriendPageList
(
@RequestBody
ImFriendPageParam
pageParam
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
Paging
<
ImFriendBaseDto
>
friends
=
imFriendService
.
getImFriendPageList
(
currentClient
.
getId
(),
pageParam
);
return
ApiResult
.
ok
(
friends
);
}
/**
* 批量创建好友推荐
*/
@PostMapping
(
"/recommend/batchCreate"
)
@OperationLog
(
name
=
"批量创建好友推荐"
,
type
=
OperationLogType
.
PAGE
)
@ApiOperation
(
value
=
"批量创建好友推荐"
)
public
ApiResult
<
Boolean
>
batchCreateRecommend
(
@RequestBody
List
<
ImFriendRecommendDto
>
recommendFriends
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
if
(
CollectionUtils
.
isEmpty
(
recommendFriends
))
{
return
ApiResult
.
fail
(
ApiCode
.
PARAMETER_EXCEPTION
,
null
);
}
imFriendService
.
batchCreateRecommend
(
currentClient
,
recommendFriends
);
return
ApiResult
.
ok
();
}
/**
* 好友推荐分页列表
*/
@PostMapping
(
"/recommend/getPageList"
)
@OperationLog
(
name
=
"好友推荐分页列表"
,
type
=
OperationLogType
.
PAGE
)
@ApiOperation
(
value
=
"好友推荐分页列表"
)
public
ApiResult
<
Paging
<
ImFriendRecommendDto
>>
getImFriendRecommendPageList
(
@RequestBody
ImFriendPageParam
pageParam
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
Paging
<
ImFriendRecommendDto
>
res
=
imFriendService
.
getImFriendRecommendPageList
(
currentClient
.
getId
(),
pageParam
);
return
ApiResult
.
ok
(
res
);
}
/**
* 批量删除好友推荐
*/
@PostMapping
(
"/recommend/batchDelete"
)
@ApiOperation
(
value
=
"删除好友推荐"
)
public
ApiResult
<
Boolean
>
batchDeleteRecommend
(
@RequestBody
List
<
String
>
friendClientIds
)
{
ImClient
currentClient
=
imClientService
.
getCurentClient
();
if
(
currentClient
==
null
)
{
return
ApiResult
.
fail
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
imFriendService
.
batchDeleteRecommend
(
currentClient
,
friendClientIds
);
return
ApiResult
.
ok
();
}
}
core/src/main/java/com/wecloud/im/friend/entity/ImFriend.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* @author lixiaozhong
* 好友关系表
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ImFriend对象"
)
public
class
ImFriend
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"主键id不能为空"
)
@ApiModelProperty
(
"主键id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
@ApiModelProperty
(
"我的client-id"
)
private
Long
fkClientId
;
@ApiModelProperty
(
"好友的client-id"
)
private
Long
fkClientIdFriend
;
@ApiModelProperty
(
"申请者"
)
private
Long
fkClientIdClaimer
;
@ApiModelProperty
(
"好友的昵称备注"
)
private
String
friendName
;
@ApiModelProperty
(
"好友拒绝原因"
)
private
String
rejectRemark
;
@ApiModelProperty
(
"好友请求说明"
)
private
String
requestRemark
;
@ApiModelProperty
(
"好友关系状态"
)
private
Integer
state
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateTime
;
}
core/src/main/java/com/wecloud/im/friend/entity/ImFriendRecommend.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* @author lixiaozhong
* 好友关系表
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ImFriendRecommend好友推荐对象"
)
public
class
ImFriendRecommend
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"主键id不能为空"
)
@ApiModelProperty
(
"主键id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
@ApiModelProperty
(
"我的client-id"
)
private
Long
fkClientId
;
@ApiModelProperty
(
"好友的client-id"
)
private
Long
fkClientIdFriend
;
@ApiModelProperty
(
"推荐来源"
)
private
Integer
source
;
@ApiModelProperty
(
"是否删除"
)
private
Boolean
delFlag
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateTime
;
}
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendMapper.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.wecloud.im.friend.entity.ImFriend
;
import
com.wecloud.im.friend.param.ImFriendApplyDto
;
import
com.wecloud.im.friend.param.ImFriendBaseDto
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* @Description 好友关系mapper
* @Author lixiaozhong
* @Date 2022/1/12 11:41 上午
*/
@Repository
public
interface
ImFriendMapper
extends
BaseMapper
<
ImFriend
>
{
IPage
<
ImFriendBaseDto
>
getImFriendPageList
(
@Param
(
"page"
)
Page
<
ImFriendBaseDto
>
page
,
@Param
(
"clientId"
)
Long
clientId
);
IPage
<
ImFriendApplyDto
>
getUnsureFriendPageList
(
@Param
(
"page"
)
Page
<
ImFriendApplyDto
>
page
,
@Param
(
"clientId"
)
Long
clientId
);
ImFriendApplyDto
getFriendInfo
(
@Param
(
"clientId"
)
Long
clientId
,
@Param
(
"friendClientId"
)
Long
friendClientId
);
void
batchDeleteFriend
(
@Param
(
"clientId"
)
Long
clientId
,
@Param
(
"fkAppId"
)
Long
fkAppId
,
@Param
(
"friendClientIds"
)
List
<
String
>
friendClientIds
);
}
core/src/main/java/com/wecloud/im/friend/mapper/ImFriendRecommendMapper.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.wecloud.im.friend.entity.ImFriendRecommend
;
import
com.wecloud.im.friend.param.ImFriendPageParam
;
import
com.wecloud.im.friend.param.ImFriendRecommendDto
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* @Description 好友推荐关系mapper
* @Author lixiaozhong
* @Date 2022/1/12 11:41 上午
*/
@Repository
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
);
void
batchCreateRecommend
(
@Param
(
"list"
)
List
<
ImFriendRecommend
>
list
);
}
core/src/main/java/com/wecloud/im/friend/param/ImFriendApplyDto.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
param
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @Description 好友信息
* @Author lixiaozhong
* @Date 2022/1/12 1:59 下午
*/
@Data
public
class
ImFriendApplyDto
extends
ImFriendBaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"好友申请者"
)
private
String
claimerClientId
;
@ApiModelProperty
(
"好友拒绝原因"
)
private
String
rejectRemark
;
@ApiModelProperty
(
"好友请求说明"
)
private
String
requestRemark
;
}
core/src/main/java/com/wecloud/im/friend/param/ImFriendBaseDto.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
param
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Description 好友信息
* @Author lixiaozhong
* @Date 2022/1/12 1:59 下午
*/
@Data
public
class
ImFriendBaseDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"主键id"
)
private
Long
id
;
@ApiModelProperty
(
"好友的client-id"
)
private
String
friendClientId
;
@ApiModelProperty
(
"好友的昵称备注"
)
private
String
friendName
;
@ApiModelProperty
(
"好友关系状态"
)
private
Integer
state
;
}
core/src/main/java/com/wecloud/im/friend/param/ImFriendPageParam.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
param
;
import
io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* @Description 好友分页
* @Author lixiaozhong
* @Date 2022/1/12 2:24 下午
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"好友分页"
)
public
class
ImFriendPageParam
extends
BasePageOrderParam
{
private
static
final
long
serialVersionUID
=
1L
;
}
core/src/main/java/com/wecloud/im/friend/param/ImFriendRecommendDto.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
friend
.
param
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Description 好友信息
* @Author lixiaozhong
* @Date 2022/1/12 1:59 下午
*/
@Data
public
class
ImFriendRecommendDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"好友的clientId"
)
private
String
friendClientId
;
@ApiModelProperty
(
"好友推荐来源,1:通讯录,2:二度人脉,3:附近的人,4:同类标签"
)
private
Integer
source
;
@ApiModelProperty
(
"是否删除"
)
private
Boolean
delFlag
;
}
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
0 → 100644
View file @
4b4f9f39
This diff is collapsed.
Click to expand it.
core/src/main/java/com/wecloud/im/mapper/ImClientMapper.java
View file @
4b4f9f39
...
...
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.vo.GetInfoListVo
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -45,4 +46,5 @@ public interface ImClientMapper extends BaseMapper<ImClient> {
List
<
GetInfoListVo
>
getInfoList
(
@Param
(
"appId"
)
Long
appId
,
@Param
(
"conversationId"
)
Long
conversationId
,
@Param
(
"clientIds"
)
List
<
String
>
clientIds
);
List
<
ImClientSimpleDto
>
getSimpleClients
(
@Param
(
"appId"
)
Long
appId
,
@Param
(
"clientIds"
)
List
<
String
>
clientIds
);
}
core/src/main/java/com/wecloud/im/param/ImClientSimpleDto.java
0 → 100644
View file @
4b4f9f39
package
com
.
wecloud
.
im
.
param
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* 终端表
*
* @author wei
* @since 2021-04-27
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ImClientSimpleDto简单对象"
)
public
class
ImClientSimpleDto
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"客户端id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
@ApiModelProperty
(
"应用appid"
)
private
Long
fkAppid
;
@ApiModelProperty
(
"客户方提供的唯一id"
)
private
String
clientId
;
}
core/src/main/java/com/wecloud/im/service/ImClientService.java
View file @
4b4f9f39
...
...
@@ -4,6 +4,7 @@ import com.wecloud.im.entity.ImClient;
import
com.wecloud.im.param.GetClientInfoParam
;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.add.ImClientDeviceInfoAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
...
...
@@ -117,4 +118,11 @@ public interface ImClientService extends BaseService<ImClient> {
*/
ImClient
getCacheImClient
(
Long
id
);
/**
* 获取client的简单对象,减少开销
* @param applicationId
* @param clientId
* @return
*/
List
<
ImClientSimpleDto
>
getSimpleClients
(
Long
applicationId
,
List
<
String
>
clientId
);
}
core/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
View file @
4b4f9f39
...
...
@@ -11,6 +11,7 @@ import com.wecloud.im.mapper.ImClientMapper;
import
com.wecloud.im.param.GetClientInfoParam
;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.param.ImClientSimpleDto
;
import
com.wecloud.im.param.add.ImClientDeviceInfoAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAdd
;
import
com.wecloud.im.param.add.ImClientHeadPortraitAndNicknameUpdate
;
...
...
@@ -247,4 +248,9 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
return
imClientMapper
.
selectById
(
id
);
}
@Override
public
List
<
ImClientSimpleDto
>
getSimpleClients
(
Long
applicationId
,
List
<
String
>
clientId
)
{
return
imClientMapper
.
getSimpleClients
(
applicationId
,
clientId
);
}
}
core/src/main/java/com/wecloud/im/thousandchat/entity/ImMsgReadLastest.java
View file @
4b4f9f39
...
...
@@ -25,8 +25,8 @@ import java.util.Date;
public
class
ImMsgReadLastest
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"
收件
id不能为空"
)
@ApiModelProperty
(
"
收件
id"
)
@NotNull
(
message
=
"
主键
id不能为空"
)
@ApiModelProperty
(
"
主键
id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
...
...
core/src/main/resources/mapper/ImClientMapper.xml
View file @
4b4f9f39
...
...
@@ -47,4 +47,11 @@
</select>
<select
id=
"getSimpleClients"
resultType=
"com.wecloud.im.param.ImClientSimpleDto"
>
select id, fk_appid, attributes,client_id from im_client where fk_appi = #{appId} and client_id in
<foreach
collection=
"clientIds"
item=
"clientId"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{clientId}
</foreach>
</select>
</mapper>
core/src/main/resources/mapper/ImFriendMapper.xml
0 → 100644
View file @
4b4f9f39
<?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.wecloud.im.friend.mapper.ImFriendMapper"
>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, fk_client_id, fk_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
id, fk_client_id_friend as friendClientId, friend_name, fk_client_id_claimer as claimerClientId,
reject_remark, request_remark, state, create_time, update_time
from im_friend
where fk_client_id = #{clientId} and fk_client_id_friend = #{friendClientId} and state = 2
</select>
<select
id=
"getImFriendPageList"
resultType=
"com.wecloud.im.friend.param.ImFriendBaseDto"
>
select
id, fk_client_id_friend as friendClientId, friend_name, state
from im_friend
where fk_client_id = #{clientId} and state = 2
</select>
<select
id=
"getUnsureFriendPageList"
resultType=
"com.wecloud.im.friend.param.ImFriendApplyDto"
>
select
id, fk_client_id_friend as friendClientId, friend_name, fk_client_id_claimer as claimerClientId,
reject_remark, request_remark, state, create_time
from im_friend
where fk_client_id = #{clientId} and state = 1
</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
<foreach
collection=
"friendClientIds"
item=
"friendCLientId"
open=
"("
close=
")"
separator=
","
>
(#{fkAppId}, #{friendCLientId})
</foreach>
)
</update>
</mapper>
core/src/main/resources/mapper/ImFriendRecommendMapper.xml
0 → 100644
View file @
4b4f9f39
<?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.wecloud.im.friend.mapper.ImFriendRecommendMapper"
>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, fk_client_id, fk_client_id_friend, source, del_flag, create_time, update_time
</sql>
<select
id=
"getImFriendRecommendPageList"
resultType=
"com.wecloud.im.friend.param.ImFriendRecommendDto"
>
select
id, fk_client_id_friend as friendClientId, source, del_flag
from im_friend_recommend
where fk_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=
"friendCLientId"
open=
"("
close=
")"
separator=
","
>
(#{fkAppId}, #{friendCLientId})
</foreach>
)
</update>
<insert
id=
"batchCreateRecommend"
>
insert into im_friend_recommend(id, fk_client_id, fk_client_id_friend, source, del_flag, create_time)
values
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(#{item.id},#{item.fkClientId},#{item.fkClientIdFriend},#{item.source},#{item.delFlag}, NOW())
</foreach>
ON DUPLICATE KEY UPDATE update_time = now()
</insert>
</mapper>
docs/db/wecloud_im.sql
View file @
4b4f9f39
...
...
@@ -240,3 +240,30 @@ CREATE TABLE `im_msg_read_lastest` (
UNIQUE KEY `
receiver_conversation
` (`
fk_client_id
`,`
fk_conversation_id
`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息最新已读寻址表';
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 '好友申请者',
`
friend_name
` varchar(255) DEFAULT NULL COMMENT '好友名称备注',
`
reject_remark
` varchar(255) DEFAULT NULL COMMENT '拒绝说明',
`
request_remark
` varchar(255) DEFAULT NULL COMMENT '好友请求说明',
`
state
` tinyint NOT NULL DEFAULT '0' COMMENT '好友状态,1:待确定,2:已确认,3:已删除',
`
create_time
` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`
update_time
` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`
id
`) USING BTREE,
UNIQUE KEY `
friend_id
` (`
fk_client_id
`,`
fk_client_id_friend
`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='好友表';
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',
`
source
` tinyint DEFAULT NULL COMMENT '推荐来源',
`
del_flag
` bit(1) NOT NULL default 0 COMMENT '删除标识',
`
create_time
` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`
update_time
` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`
id
`) USING BTREE,
UNIQUE KEY `
friend_id
` (fk_client_id, fk_client_id_friend) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='好友表';
framework/src/main/java/io/geekidea/springbootplus/framework/common/service/impl/BaseServiceImpl.java
View file @
4b4f9f39
...
...
@@ -24,6 +24,7 @@ import io.geekidea.springbootplus.framework.util.LambdaColumn;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.util.List
;
/**
* 公共Service父类
...
...
@@ -56,6 +57,4 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends Servic
public
String
getLambdaColumn
(
SFunction
<
T
,
?>
func
)
{
return
new
LambdaColumn
<
T
>().
get
(
func
);
}
}
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