内容简介:Netty+SpringBoot+FastDFS+Html5实现聊天App,项目介绍。Netty+SpringBoot+FastDFS+Html5实现聊天App,
Netty+SpringBoot+FastDFS+Html5实现聊天App,项目介绍。
Netty+SpringBoot+FastDFS+Html5实现聊天App, 项目github链接 。
本章完整代码链接 。
本章内容
(1) 查询好友列表的接口
(2)通过或忽略好友请求的接口
(3)添加好友功能展示
查询好友列表的接口
/**
* @Description: 查询我的好友列表
*/
@PostMapping("/myFriends")
public IMoocJSONResult myFriends(String userId) {
// 0. userId 判断不能为空
if (StringUtils.isBlank(userId)) {
return IMoocJSONResult.errorMsg("");
}
// 1. 数据库查询好友列表
List<MyFriendsVO> myFirends = userService.queryMyFriends(userId);
return IMoocJSONResult.ok(myFirends);
}
通过或忽略好友请求的接口
定义枚举类型
/**
*
* @Description: 忽略或者通过 好友请求的枚举
*/
public enum OperatorFriendRequestTypeEnum {
IGNORE(0, "忽略"),
PASS(1, "通过");
public final Integer type;
public final String msg;
OperatorFriendRequestTypeEnum(Integer type, String msg){
this.type = type;
this.msg = msg;
}
public Integer getType() {
return type;
}
public static String getMsgByType(Integer type) {
for (OperatorFriendRequestTypeEnum operType : OperatorFriendRequestTypeEnum.values()) {
if (operType.getType() == type) {
return operType.msg;
}
}
return null;
}
}
controller中提供通过或忽略好友请求的接口
/**
* @Description: 接受方 通过或者忽略朋友请求
*/
@PostMapping("/operFriendRequest")
public IMoocJSONResult operFriendRequest(String acceptUserId, String sendUserId,
Integer operType) {
// 0. acceptUserId sendUserId operType 判断不能为空
if (StringUtils.isBlank(acceptUserId)
|| StringUtils.isBlank(sendUserId)
|| operType == null) {
return IMoocJSONResult.errorMsg("");
}
// 1. 如果operType 没有对应的枚举值,则直接抛出空错误信息
if (StringUtils.isBlank(OperatorFriendRequestTypeEnum.getMsgByType(operType))) {
return IMoocJSONResult.errorMsg("");
}
if (operType == OperatorFriendRequestTypeEnum.IGNORE.type) {
// 2. 判断如果忽略好友请求,则直接删除好友请求的数据库表记录
userService.deleteFriendRequest(sendUserId, acceptUserId);
} else if (operType == OperatorFriendRequestTypeEnum.PASS.type) {
// 3. 判断如果是通过好友请求,则互相增加好友记录到数据库对应的表
// 然后删除好友请求的数据库表记录
userService.passFriendRequest(sendUserId, acceptUserId);
}
// 4. 数据库查询好友列表
List<MyFriendsVO> myFirends = userService.queryMyFriends(acceptUserId);
// 5. 将查询到的好友列表返回给前端
return IMoocJSONResult.ok(myFirends);
}
添加好友功展示
通过搜索好友姓名添加好友
通过扫描二维码添加好友
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
无线:网络文化中激进的经验主义
[英] 阿德里安·麦肯齐 / 张帆 / 上海译文出版社 / 2018-9
本书研究了无线是如何成为当代人类经验的主角的。从路由器、智能电话、电子书、城市到在线工作、服务协议、玩具以及国家等各个方面,人们已经感觉到了无线技术所引发的变革。本书作者援引一个世纪之前的哲学技术来分析当代最前沿的后网络时代的人类状况。基于威廉•詹姆斯的实用主义哲学相关的彻底经验主义,作者提出了把失序的无线网络世界与人们的感知匹配起来的新方式。一起来看看 《无线:网络文化中激进的经验主义》 这本书的介绍吧!