Commit c4195da7 by Future

好友关系逻辑调整

parent 46cc0362
...@@ -66,7 +66,7 @@ public class ImFriendController extends BaseController { ...@@ -66,7 +66,7 @@ public class ImFriendController extends BaseController {
if(friendClient == null) { if(friendClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
ImFriendApplyDto friendInfo = imFriendService.getFriendInfo(currentClient.getId(), friendClient.getId()); ImFriendApplyDto friendInfo = imFriendService.getFriendInfo(currentClient.getClientId(), friendClient.getClientId());
return ApiResult.ok(friendInfo); return ApiResult.ok(friendInfo);
} }
......
...@@ -29,13 +29,13 @@ public class ImFriend extends BaseEntity { ...@@ -29,13 +29,13 @@ public class ImFriend extends BaseEntity {
private Long id; private Long id;
@ApiModelProperty("我的client-id") @ApiModelProperty("我的client-id")
private Long fkClientId; private String clientId;
@ApiModelProperty("好友的client-id") @ApiModelProperty("好友的client-id")
private Long fkClientIdFriend; private String clientIdFriend;
@ApiModelProperty("申请者") @ApiModelProperty("申请者")
private Long fkClientIdClaimer; private String clientIdClaimer;
@ApiModelProperty("好友的昵称备注") @ApiModelProperty("好友的昵称备注")
private String friendName; private String friendName;
......
...@@ -29,10 +29,10 @@ public class ImFriendRecommend extends BaseEntity { ...@@ -29,10 +29,10 @@ public class ImFriendRecommend extends BaseEntity {
private Long id; private Long id;
@ApiModelProperty("我的client-id") @ApiModelProperty("我的client-id")
private Long fkClientId; private String clientId;
@ApiModelProperty("好友的client-id") @ApiModelProperty("好友的client-id")
private Long fkClientIdFriend; private String clientIdFriend;
@ApiModelProperty("推荐来源") @ApiModelProperty("推荐来源")
private Integer source; private Integer source;
......
...@@ -21,23 +21,29 @@ public interface ImFriendMapper extends BaseMapper<ImFriend> { ...@@ -21,23 +21,29 @@ public interface ImFriendMapper extends BaseMapper<ImFriend> {
IPage<ImFriendBaseDto> getImFriendPageList(@Param("page") Page<ImFriendBaseDto> page, @Param("clientId") Long fkClientId); 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 fkFriendClientId); ImFriendApplyDto getFriendInfo(@Param("clientId") String clientId, @Param("friendClientId") String friendClientId);
/** /**
* 过滤得到真的好友,非好友的friendId将被它忽略 * 过滤得到真的好友,非好友的friendId将被它忽略
* @param fkClientId * @param clientId
* @param fkFriendClientIds * @param friendClientIds
* @return * @return
*/ */
List<Long> filterNegativeFriends(@Param("clientId") Long fkClientId, @Param("friendClientIds") List<Long> fkFriendClientIds); List<String> filterNegativeFriends(@Param("clientId") String clientId, @Param("friendClientIds") List<String> friendClientIds);
/** /**
* 批量删除好友 * 批量删除好友
* @param fkClientId 删除人的clientId * @param clientId 删除人的clientId
* @param fkAppId * @param fkAppId
* @param friendClientIds 被删除人的clientId列表 * @param friendClientIds 被删除人的clientId列表
*/ */
void batchDeleteFriend(@Param("clientId") Long fkClientId, @Param("fkAppId") Long fkAppId, @Param("friendClientIds") List<String> friendClientIds); void batchDeleteFriend(@Param("clientId") String clientId, @Param("fkAppId") Long fkAppId, @Param("friendClientIds") List<String> friendClientIds);
} }
...@@ -22,7 +22,13 @@ public interface ImFriendRecommendMapper extends BaseMapper<ImFriendRecommend> { ...@@ -22,7 +22,13 @@ public interface ImFriendRecommendMapper extends BaseMapper<ImFriendRecommend> {
IPage<ImFriendRecommendDto> getImFriendRecommendPageList(@Param("page") Page pageParam, @Param("clientId") Long clientId); 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); void batchCreateRecommend(@Param("list") List<ImFriendRecommend> list);
} }
...@@ -6,7 +6,7 @@ import lombok.Data; ...@@ -6,7 +6,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/** /**
* @Description TODO * @Description 申请好友入参
* @Author lixiaozhong * @Author lixiaozhong
* @Date 2022/1/13 4:24 下午 * @Date 2022/1/13 4:24 下午
*/ */
...@@ -16,6 +16,7 @@ public class ImFriendApplyParam extends ImFriendBaseParam { ...@@ -16,6 +16,7 @@ public class ImFriendApplyParam extends ImFriendBaseParam {
@ApiModelProperty("备注好友名称") @ApiModelProperty("备注好友名称")
private String friendName; private String friendName;
@ApiModelProperty("请求备注") @ApiModelProperty("请求备注")
private String requestRemark; private String requestRemark;
} }
...@@ -6,7 +6,7 @@ import lombok.Data; ...@@ -6,7 +6,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/** /**
* @Description TODO * @Description 好友相关base入参
* @Author lixiaozhong * @Author lixiaozhong
* @Date 2022/1/13 4:24 下午 * @Date 2022/1/13 4:24 下午
*/ */
......
...@@ -55,12 +55,12 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -55,12 +55,12 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
/** /**
* 查看朋友详情 * 查看朋友详情
* @param curentClientId * @param currentClientId
* @param friendClientId * @param friendClientId
* @return * @return
*/ */
public ImFriendApplyDto getFriendInfo(Long curentClientId, Long friendClientId) { public ImFriendApplyDto getFriendInfo(String currentClientId, String friendClientId) {
return imFriendMapper.getFriendInfo(curentClientId, friendClientId); return imFriendMapper.getFriendInfo(currentClientId, friendClientId);
} }
/** /**
...@@ -72,7 +72,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -72,7 +72,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
ImFriendPageParam pageParam = new ImFriendPageParam(); ImFriendPageParam pageParam = new ImFriendPageParam();
pageParam.setPageSize(1000L); pageParam.setPageSize(1000L);
Page<ImFriendApplyDto> page = new PageInfo(pageParam, OrderItem.desc(getLambdaColumn(ImFriend::getCreateTime))); 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.getClientId());
return pageList.getRecords(); return pageList.getRecords();
} }
...@@ -88,13 +88,13 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -88,13 +88,13 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
public Boolean applyFriend(ImClient currentClient, ImClient friendClient, String friendName, String requestRemark) { public Boolean applyFriend(ImClient currentClient, ImClient friendClient, String friendName, String requestRemark) {
//好友关系有维护两条,我和他,他和我 //好友关系有维护两条,我和他,他和我
ImFriend my = new ImFriend(); ImFriend my = new ImFriend();
my.setFkClientId(currentClient.getId()); my.setClientId(currentClient.getClientId());
my.setFkClientIdFriend(friendClient.getId()); my.setClientIdFriend(friendClient.getClientId());
my.setFkClientIdClaimer(currentClient.getId()); my.setClientIdClaimer(currentClient.getClientId());
my.setFriendName(friendName); my.setFriendName(friendName);
my.setRequestRemark(requestRemark); my.setRequestRemark(requestRemark);
my.setState(FriendStateEnum.UNSURE.getCode()); my.setState(FriendStateEnum.UNSURE.getCode());
if(getByKey(currentClient.getId(), friendClient.getId()) != null) { if(getByKey(currentClient.getClientId(), friendClient.getClientId()) != null) {
if(StringUtils.isNotEmpty(requestRemark)) { if(StringUtils.isNotEmpty(requestRemark)) {
my.setRequestRemark(requestRemark); my.setRequestRemark(requestRemark);
} }
...@@ -109,12 +109,12 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -109,12 +109,12 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
} }
ImFriend friend = new ImFriend(); ImFriend friend = new ImFriend();
friend.setFkClientId(friendClient.getId()); friend.setClientId(friendClient.getClientId());
friend.setFkClientIdFriend(currentClient.getId()); friend.setClientIdFriend(currentClient.getClientId());
friend.setFkClientIdClaimer(currentClient.getId()); friend.setClientIdClaimer(currentClient.getClientId());
friend.setRequestRemark(requestRemark); friend.setRequestRemark(requestRemark);
friend.setState(FriendStateEnum.UNSURE.getCode()); friend.setState(FriendStateEnum.UNSURE.getCode());
if(getByKey(friendClient.getId(), currentClient.getId()) != null) { if(getByKey(friendClient.getClientId(), currentClient.getClientId()) != null) {
if(StringUtils.isNotEmpty(requestRemark)) { if(StringUtils.isNotEmpty(requestRemark)) {
friend.setRequestRemark(requestRemark); friend.setRequestRemark(requestRemark);
} }
...@@ -142,10 +142,10 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -142,10 +142,10 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
* @param friendClientId * @param friendClientId
* @return * @return
*/ */
public ImFriend getByKey(Long clientId, Long friendClientId) { public ImFriend getByKey(String clientId, String friendClientId) {
return this.getOne(new QueryWrapper<ImFriend>().lambda() return this.getOne(new QueryWrapper<ImFriend>().lambda()
.eq(ImFriend::getFkClientId, clientId) .eq(ImFriend::getClientId, clientId)
.eq(ImFriend::getFkClientIdFriend, friendClientId)); .eq(ImFriend::getClientIdFriend, friendClientId));
} }
/** /**
...@@ -157,9 +157,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -157,9 +157,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
imFriend.setId(null); imFriend.setId(null);
imFriend.setCreateTime(null); imFriend.setCreateTime(null);
return this.update(imFriend, new QueryWrapper<ImFriend>().lambda() return this.update(imFriend, new QueryWrapper<ImFriend>().lambda()
.eq(ImFriend::getFkClientId, imFriend.getFkClientId()) .eq(ImFriend::getClientId, imFriend.getClientId())
.eq(ImFriend::getFkClientIdFriend, imFriend.getFkClientIdFriend()) .eq(ImFriend::getClientIdFriend, imFriend.getClientIdFriend())
.eq(ImFriend::getFkClientIdClaimer, imFriend.getFkClientIdClaimer())); .eq(ImFriend::getClientIdClaimer, imFriend.getClientIdClaimer()));
} }
/** /**
...@@ -177,9 +177,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -177,9 +177,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
//好友关系有维护两条,我和他,他和我 //好友关系有维护两条,我和他,他和我
//好友的先更新 //好友的先更新
ImFriend friend = new ImFriend(); ImFriend friend = new ImFriend();
friend.setFkClientId(friendClient.getId()); friend.setClientId(friendClient.getClientId());
friend.setFkClientIdFriend(currentClient.getId()); friend.setClientIdFriend(currentClient.getClientId());
friend.setFkClientIdClaimer(friendClient.getId()); friend.setClientIdClaimer(friendClient.getClientId());
friend.setState(agree ? FriendStateEnum.CONFORM.getCode() : FriendStateEnum.REJECT.getCode()); friend.setState(agree ? FriendStateEnum.CONFORM.getCode() : FriendStateEnum.REJECT.getCode());
if(StringUtils.isNotEmpty(rejectRemark)) { if(StringUtils.isNotEmpty(rejectRemark)) {
friend.setRejectRemark(rejectRemark); friend.setRejectRemark(rejectRemark);
...@@ -187,9 +187,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -187,9 +187,9 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
boolean ok1 = this.updateByKeyAndClaimer(friend); boolean ok1 = this.updateByKeyAndClaimer(friend);
// 同时更新我的 // 同时更新我的
ImFriend my = new ImFriend(); ImFriend my = new ImFriend();
my.setFkClientId(currentClient.getId()); my.setClientId(currentClient.getClientId());
my.setFkClientIdFriend(friendClient.getId()); my.setClientIdFriend(friendClient.getClientId());
my.setFkClientIdClaimer(friendClient.getId()); my.setClientIdClaimer(friendClient.getClientId());
my.setState(agree ? FriendStateEnum.CONFORM.getCode() : FriendStateEnum.REJECT.getCode()); my.setState(agree ? FriendStateEnum.CONFORM.getCode() : FriendStateEnum.REJECT.getCode());
if(StringUtils.isNotEmpty(rejectRemark)) { if(StringUtils.isNotEmpty(rejectRemark)) {
my.setRejectRemark(rejectRemark); my.setRejectRemark(rejectRemark);
...@@ -205,7 +205,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -205,7 +205,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
if(CollectionUtils.isEmpty(friendClientIds)) { if(CollectionUtils.isEmpty(friendClientIds)) {
return; return;
} }
imFriendMapper.batchDeleteFriend(currentClient.getId(), currentClient.getFkAppid(), friendClientIds); imFriendMapper.batchDeleteFriend(currentClient.getClientId(), currentClient.getFkAppid(), friendClientIds);
} }
public Paging<ImFriendBaseDto> getImFriendPageList(Long currentClientId, ImFriendPageParam pageParam) { public Paging<ImFriendBaseDto> getImFriendPageList(Long currentClientId, ImFriendPageParam pageParam) {
...@@ -224,7 +224,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -224,7 +224,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
if(CollectionUtils.isEmpty(friendClientIds)) { if(CollectionUtils.isEmpty(friendClientIds)) {
return; return;
} }
imFriendRecommendMapper.batchDeleteRecommend(currentClient.getId(), currentClient.getFkAppid(), friendClientIds); imFriendRecommendMapper.batchDeleteRecommend(currentClient.getClientId(), currentClient.getFkAppid(), friendClientIds);
} }
/** /**
...@@ -242,28 +242,28 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> { ...@@ -242,28 +242,28 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
return; return;
} }
//对已经存在的好友过滤掉 //对已经存在的好友过滤掉
List<Long> maybeFriendIds = simpleFriendClients.stream().map(ImClientSimpleDto::getId).collect(Collectors.toList()); List<String> maybeFriendClientIds = simpleFriendClients.stream().map(ImClientSimpleDto::getClientId).collect(Collectors.toList());
List<Long> alreadyFriendIds = imFriendMapper.filterNegativeFriends(currentClient.getId(), maybeFriendIds); List<String> alreadyFriendClientIds = imFriendMapper.filterNegativeFriends(currentClient.getClientId(), maybeFriendClientIds);
Map<String, Long> friendIdMap = simpleFriendClients.stream().collect(Collectors.toMap(ImClientSimpleDto::getClientId, Map<String, String> friendClientIdMap = simpleFriendClients.stream().collect(Collectors.toMap(ImClientSimpleDto::getClientId,
ImClientSimpleDto::getId, (a, b) -> a)); ImClientSimpleDto::getClientId, (a, b) -> a));
List<ImFriendRecommend> list = new ArrayList<>(); List<ImFriendRecommend> list = new ArrayList<>();
for (ImFriendRecommendDto p : friends) { for (ImFriendRecommendDto p : friends) {
Long fkFriendCliendId = friendIdMap.get(p.getFriendClientId()); String friendClientId = friendClientIdMap.get(p.getFriendClientId());
// 只有client存在的数据才是真数据 // 只有client存在的数据才是真数据
if(fkFriendCliendId == null) { if(friendClientId == null) {
continue; continue;
} }
// 如果推荐的人已经是好友,则忽略。 // 如果推荐的人已经是好友,则忽略。
if (alreadyFriendIds.contains(fkFriendCliendId)) { if (alreadyFriendClientIds.contains(friendClientId)) {
continue; continue;
} }
ImFriendRecommend recommend = new ImFriendRecommend(); ImFriendRecommend recommend = new ImFriendRecommend();
recommend.setId(SnowflakeUtil.getId()); recommend.setId(SnowflakeUtil.getId());
recommend.setFkClientId(currentClient.getId()); recommend.setClientId(currentClient.getClientId());
recommend.setFkClientIdFriend(fkFriendCliendId); recommend.setClientIdFriend(friendClientId);
recommend.setSource(p.getSource()); recommend.setSource(p.getSource());
recommend.setDelFlag(false); recommend.setDelFlag(false);
list.add(recommend); list.add(recommend);
......
...@@ -138,10 +138,10 @@ public interface ImClientService extends BaseService<ImClient> { ...@@ -138,10 +138,10 @@ public interface ImClientService extends BaseService<ImClient> {
/** /**
* 获取client的简单对象,减少开销 * 获取client的简单对象,减少开销
* @param applicationId * @param applicationId
* @param clientId * @param clientIds
* @return * @return
*/ */
List<ImClientSimpleDto> getSimpleClients(Long applicationId, List<String> clientId); List<ImClientSimpleDto> getSimpleClients(Long applicationId, List<String> clientIds);
List<ImClientSimpleDto> getSimpleClients(List<Long> ids); List<ImClientSimpleDto> getSimpleClients(List<Long> ids);
} }
...@@ -167,7 +167,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien ...@@ -167,7 +167,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
BeanUtils.copyProperties(infoList.get(0), clientInfoVo); BeanUtils.copyProperties(infoList.get(0), clientInfoVo);
clientInfoVo.setRelation(RelationEnum.STRANGER.getCode()); clientInfoVo.setRelation(RelationEnum.STRANGER.getCode());
// 查询该好友与自己关系: 陌生人、好友、被拉黑名单 // 查询该好友与自己关系: 陌生人、好友、被拉黑名单
ImFriend imFriend = imFriendService.getByKey(currentClient.getId(), clientInfoVo.getId()); ImFriend imFriend = imFriendService.getByKey(currentClient.getClientId(), clientInfoVo.getClientId());
if (imFriend != null && FriendStateEnum.CONFORM.getCode().equals(imFriend.getState())) { if (imFriend != null && FriendStateEnum.CONFORM.getCode().equals(imFriend.getState())) {
clientInfoVo.setRelation(RelationEnum.FRIEND.getCode()); clientInfoVo.setRelation(RelationEnum.FRIEND.getCode());
} }
...@@ -303,14 +303,14 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien ...@@ -303,14 +303,14 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
} }
@Override @Override
// @Cacheable(key = "#p0") @Cacheable(key = "#p0")
public ImClient getCacheImClient(Long id) { public ImClient getCacheImClient(Long id) {
return imClientMapper.selectById(id); return imClientMapper.selectById(id);
} }
@Override @Override
public List<ImClientSimpleDto> getSimpleClients(Long applicationId, List<String> clientId) { public List<ImClientSimpleDto> getSimpleClients(Long applicationId, List<String> clientIds) {
return imClientMapper.getSimpleClients(applicationId, clientId); return imClientMapper.getSimpleClients(applicationId, clientIds);
} }
@Override @Override
......
...@@ -4,47 +4,47 @@ ...@@ -4,47 +4,47 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <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> </sql>
<select id="getFriendInfo" resultType="com.wecloud.im.friend.param.ImFriendApplyDto"> <select id="getFriendInfo" resultType="com.wecloud.im.friend.param.ImFriendApplyDto">
select select
friend.id, client.client_id as friendClientId, friend.friend_name, claimer.client_id as claimerClientId, 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 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 from im_friend friend inner join im_client client on friend.client_id_friend = client.client_id
inner join im_client claimer on friend.fk_client_id_claimer = claimer.id inner join im_client claimer on friend.client_id_claimer = claimer.client_id
where friend.fk_client_id = #{clientId} and fk_client_id_friend = #{friendClientId} and friend.state = 2 where friend.client_id = #{clientId} and client_id_friend = #{friendClientId} and friend.state = 2
</select> </select>
<select id="getImFriendPageList" resultType="com.wecloud.im.friend.param.ImFriendBaseDto"> <select id="getImFriendPageList" resultType="com.wecloud.im.friend.param.ImFriendBaseDto">
select select
friend.id, client.client_id as friendClientId, friend.friend_name, friend.state 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 from im_friend friend inner join im_client client on friend.client_id_friend = client.client_id
where friend.fk_client_id = #{clientId} and friend.state = 2 where friend.client_id = #{clientId} and friend.state = 2
</select> </select>
<select id="getUnsureFriendPageList" resultType="com.wecloud.im.friend.param.ImFriendApplyDto"> <select id="getUnsureFriendPageList" resultType="com.wecloud.im.friend.param.ImFriendApplyDto">
select select
friend.id, client.client_id as friendClientId, friend.friend_name, claimer.client_id as claimerClientId, 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 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 from im_friend friend inner join im_client client on friend.client_id_friend = client.client_id
inner join im_client claimer on friend.fk_client_id_claimer = claimer.id inner join im_client claimer on friend.client_id_claimer = claimer.client_id
where friend.fk_client_id = #{clientId} and friend.state = 1 where friend.client_id = #{clientId} and friend.state = 1
</select> </select>
<select id="filterNegativeFriends" resultType="java.lang.Long"> <select id="filterNegativeFriends" resultType="java.lang.String">
select select
fk_client_id_friend client_id_friend
from im_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=","> <foreach collection="friendClientIds" item="friendClientId" open="(" close=")" separator=",">
#{friendClientId} #{friendClientId}
</foreach> </foreach>
</select> </select>
<update id="batchDeleteFriend"> <update id="batchDeleteFriend">
update im_friend set state = 4 where fk_client_id = #{clientId} and fk_client_id_friend in ( update im_friend set state = 4 where client_id = #{clientId} and client_id_friend in (
select id from im_client where (fk_appid, client_id) in select client_id from im_client where (fk_appid, client_id) in
<foreach collection="friendClientIds" item="friendClientId" open="(" close=")" separator=","> <foreach collection="friendClientIds" item="friendClientId" open="(" close=")" separator=",">
(#{fkAppId}, #{friendClientId}) (#{fkAppId}, #{friendClientId})
</foreach> </foreach>
......
...@@ -4,30 +4,30 @@ ...@@ -4,30 +4,30 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <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> </sql>
<select id="getImFriendRecommendPageList" resultType="com.wecloud.im.friend.param.ImFriendRecommendDto"> <select id="getImFriendRecommendPageList" resultType="com.wecloud.im.friend.param.ImFriendRecommendDto">
select select
recommend.id, client.client_id as friendClientId, recommend.source, recommend.del_flag 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 from im_friend_recommend recommend inner join im_client client on recommend.client_id_friend = client.client_id
where fk_client_id = #{clientId} where client_id = #{clientId}
</select> </select>
<update id="batchDeleteRecommend"> <update id="batchDeleteRecommend">
update im_friend_recommend set del_flag = 1 where fk_client_id = #{clientId} and fk_client_id_friend in ( update im_friend_recommend set del_flag = 1 where client_id = #{clientId} and client_id_friend in (
select id from im_client where (fk_appid, client_id) in select client_id from im_client where (fk_appid, client_id) in
<foreach collection="friendClientIds" item="friendCLientId" open="(" close=")" separator=","> <foreach collection="friendClientIds" item="friendClientId" open="(" close=")" separator=",">
(#{fkAppId}, #{friendCLientId}) (#{fkAppId}, #{friendClientId})
</foreach> </foreach>
) )
</update> </update>
<insert id="batchCreateRecommend" > <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 values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id},#{item.fkClientId},#{item.fkClientIdFriend},#{item.source},#{item.delFlag}, NOW()) (#{item.id},#{item.clientId},#{item.clientIdFriend},#{item.source},#{item.delFlag}, NOW())
</foreach> </foreach>
ON DUPLICATE KEY UPDATE update_time = now() ON DUPLICATE KEY UPDATE update_time = now()
</insert> </insert>
......
-- 在feature-cluster 2021年12月22日之后,需要执行的的sql增量脚本 -- 在feature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
...@@ -33,9 +33,9 @@ CREATE TABLE `im_msg_read_lastest` ...@@ -33,9 +33,9 @@ CREATE TABLE `im_msg_read_lastest`
CREATE TABLE `im_friend` CREATE TABLE `im_friend`
( (
`id` bigint NOT NULL COMMENT '主键id', `id` bigint NOT NULL COMMENT '主键id',
`fk_client_id` bigint NOT NULL COMMENT '自己id', `client_id` varchar(32) NOT NULL COMMENT '自己id',
`fk_client_id_friend` bigint NOT NULL COMMENT '好友id', `client_id_friend` varchar(32) NOT NULL COMMENT '好友id',
`fk_client_id_claimer` bigint NOT NULL COMMENT '好友申请者', `client_id_claimer` varchar(32) NOT NULL COMMENT '好友申请者',
`friend_name` varchar(255) DEFAULT NULL COMMENT '好友名称备注', `friend_name` varchar(255) DEFAULT NULL COMMENT '好友名称备注',
`reject_remark` varchar(255) DEFAULT NULL COMMENT '拒绝说明', `reject_remark` varchar(255) DEFAULT NULL COMMENT '拒绝说明',
`request_remark` varchar(255) DEFAULT NULL COMMENT '好友请求说明', `request_remark` varchar(255) DEFAULT NULL COMMENT '好友请求说明',
...@@ -49,8 +49,8 @@ CREATE TABLE `im_friend` ...@@ -49,8 +49,8 @@ CREATE TABLE `im_friend`
CREATE TABLE `im_friend_recommend` CREATE TABLE `im_friend_recommend`
( (
`id` bigint(20) NOT NULL COMMENT '主键id', `id` bigint(20) NOT NULL COMMENT '主键id',
`fk_client_id` bigint(20) NOT NULL COMMENT '自己id', `client_id` varchar(32) NOT NULL COMMENT '自己id',
`fk_client_id_friend` bigint(20) NOT NULL COMMENT '好友id', `client_id_friend` varchar(32) NOT NULL COMMENT '好友id',
`source` tinyint DEFAULT NULL COMMENT '推荐来源', `source` tinyint DEFAULT NULL COMMENT '推荐来源',
`del_flag` bit(1) NOT NULL default 0 COMMENT '删除标识', `del_flag` bit(1) NOT NULL default 0 COMMENT '删除标识',
`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment