成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Netty+SpringBoot+FastDFS+Html5實(shí)現(xiàn)聊天App詳解(四)

why_rookie / 1837人閱讀

Netty+SpringBoot+FastDFS+Html5實(shí)現(xiàn)聊天App,項(xiàng)目介紹。

Netty+SpringBoot+FastDFS+Html5實(shí)現(xiàn)聊天App,項(xiàng)目github鏈接。

本章完整代碼鏈接。

本章內(nèi)容 (1) 查詢好友列表的接口 (2)通過(guò)或忽略好友請(qǐng)求的接口 (3)添加好友功能展示



查詢好友列表的接口
    /**
     * @Description: 查詢我的好友列表
     */
    @PostMapping("/myFriends")
    public IMoocJSONResult myFriends(String userId) {
        // 0. userId 判斷不能為空
        if (StringUtils.isBlank(userId)) {
            return IMoocJSONResult.errorMsg("");
        }
        
        // 1. 數(shù)據(jù)庫(kù)查詢好友列表
        List myFirends = userService.queryMyFriends(userId);
        
        return IMoocJSONResult.ok(myFirends);
    }
通過(guò)或忽略好友請(qǐng)求的接口

定義枚舉類型

/**
 * 
 * @Description: 忽略或者通過(guò) 好友請(qǐng)求的枚舉
 */
public enum OperatorFriendRequestTypeEnum {
    
    IGNORE(0, "忽略"),
    PASS(1, "通過(guò)");
    
    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中提供通過(guò)或忽略好友請(qǐng)求的接口

    /**
     * @Description: 接受方 通過(guò)或者忽略朋友請(qǐng)求
     */
    @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 沒(méi)有對(duì)應(yīng)的枚舉值,則直接拋出空錯(cuò)誤信息
        if (StringUtils.isBlank(OperatorFriendRequestTypeEnum.getMsgByType(operType))) {
            return IMoocJSONResult.errorMsg("");
        }
        
        if (operType == OperatorFriendRequestTypeEnum.IGNORE.type) {
            // 2. 判斷如果忽略好友請(qǐng)求,則直接刪除好友請(qǐng)求的數(shù)據(jù)庫(kù)表記錄
            userService.deleteFriendRequest(sendUserId, acceptUserId);
        } else if (operType == OperatorFriendRequestTypeEnum.PASS.type) {
            // 3. 判斷如果是通過(guò)好友請(qǐng)求,則互相增加好友記錄到數(shù)據(jù)庫(kù)對(duì)應(yīng)的表
            //       然后刪除好友請(qǐng)求的數(shù)據(jù)庫(kù)表記錄
            userService.passFriendRequest(sendUserId, acceptUserId);
        }
        
        // 4. 數(shù)據(jù)庫(kù)查詢好友列表
        List myFirends = userService.queryMyFriends(acceptUserId);
        
        // 5. 將查詢到的好友列表返回給前端
        return IMoocJSONResult.ok(myFirends);
    }
添加好友功展示 通過(guò)搜索好友姓名添加好友



通過(guò)掃描二維碼添加好友



文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/73288.html

相關(guān)文章

  • Netty+SpringBoot+FastDFS+Html5實(shí)現(xiàn)聊天App詳解(三)

    摘要:實(shí)現(xiàn)聊天,項(xiàng)目介紹。首先根據(jù)搜索的用戶的名稱查找是否存在這個(gè)用戶。如果搜索前置條件為成功,則向前端返回搜索用戶的信息。發(fā)送添加好友的請(qǐng)求判斷不能為空查詢用戶接受到的朋友申請(qǐng)最終實(shí)現(xiàn)效果 Netty+SpringBoot+FastDFS+Html5實(shí)現(xiàn)聊天App,項(xiàng)目介紹。Netty+SpringBoot+FastDFS+Html5實(shí)現(xiàn)聊天App,項(xiàng)目github鏈接。本章完整代碼鏈接。...

    isLishude 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<