Netty+SprigBoot+FastDFS+Html 5チャットアプリの詳細(4)
Netty+Spring Boot+FastDFS+Html 5がチャットアプリを実現し、プロジェクト紹介。Netty+SprigBoot+FastDFS+Html 5がチャットアプリを実現し、プロジェクトgithubリンク。この章の完全なコードリンク。
本章の内容
(1)親友リストを検索するインターフェース
(2)親友の要求を無視するインターフェース
(3)親友機能を追加して展示する
友達リストを検索するインターフェース
列挙の種類を定義
友達の名前を検索して友達を追加します。
二次元コードをスキャンして友達を追加します。
本章の内容
(1)親友リストを検索するインターフェース
(2)親友の要求を無視するインターフェース
(3)親友機能を追加して展示する
友達リストを検索するインターフェース
/**
* @Description:
*/
@PostMapping("/myFriends")
public IMoocJSONResult myFriends(String userId) {
// 0. userId
if (StringUtils.isBlank(userId)) {
return IMoocJSONResult.errorMsg("");
}
// 1.
List 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 myFirends = userService.queryMyFriends(acceptUserId);
// 5.
return IMoocJSONResult.ok(myFirends);
}
友達の功の展示を追加します。友達の名前を検索して友達を追加します。
二次元コードをスキャンして友達を追加します。