在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    朋友圈 喜歡功能 接口API

    朋友圈 喜歡功能接口

    /** 朋友圈 喜歡功能接口* *//** * 喜歡 * * @param userId * @param publishId * @return */Boolean loveComment(Long userId, String publishId);/** * 取消喜歡 * * @param userId * @param publishId * @return */Boolean disLoveComment(Long userId, String publishId);/** * 查詢喜歡數(shù) * * @param publishId * @return */Long queryLoveCount(String publishId);/** * 查詢 戶是否喜歡該動(dòng)態(tài) * * @param userId * @param publishId * @return */Boolean queryUserIsLove(Long userId, String publishId);

    朋友圈 喜歡功能接口 實(shí)現(xiàn)類

    /** 朋友圈 喜歡功能* */@Overridepublic Boolean loveComment(Long userId, String publishId) { //查詢?cè)?戶是否已經(jīng)喜歡 if (this.queryUserIsLove(userId, publishId)) { return false; } //喜歡 boolean result = this.saveComment(userId, publishId, CommentType.LOVE, null); if (!result) { return false; } //喜歡成功后,修改Redis中的總的喜歡數(shù) String redisKey = this.getCommentRedisKeyPrefix(publishId); String hashKey = CommentType.LOVE.toString(); this.redisTemplate.opsForHash().increment(redisKey, hashKey, 1); //標(biāo)記 戶已經(jīng)喜歡 hashKey = this.getCommentUserLoveRedisKey(userId); this.redisTemplate.opsForHash().put(redisKey, hashKey, “1”); return true;}private String getCommentUserLoveRedisKey(Long userId) { return COMMENT_USER_LOVE_REDIS_KEY_PREFIX + userId;}@Overridepublic Boolean disLoveComment(Long userId, String publishId) { if (!this.queryUserIsLove(userId, publishId)) { //如果 戶沒(méi)有喜歡,就直接返回 return false; } boolean result = this.removeComment(userId, publishId, CommentType.LOVE); if (!result) { //刪除失敗 return false; } //刪除redis中的記錄 String redisKey = this.getCommentRedisKeyPrefix(publishId); String hashKey = this.getCommentUserLoveRedisKey(userId); this.redisTemplate.opsForHash().delete(redisKey, hashKey); this.redisTemplate.opsForHash().increment(redisKey, CommentType.LOVE.toString(), -1); return true;}@Overridepublic Long queryLoveCount(String publishId) { // 先從redis中命中,如果命中的話就返回,沒(méi)有命中就查詢Mongodb String redisKey = this.getCommentRedisKeyPrefix(publishId); String hashKey = CommentType.LOVE.toString(); Object value = this.redisTemplate.opsForHash().get(redisKey, hashKey); if (ObjectUtil.isNotEmpty(value)) { return Convert.toLong(value); } //查詢count Long count = this.queryCommentCount(publishId, CommentType.LOVE); //存儲(chǔ)到redis中 this.redisTemplate.opsForHash().put(redisKey, hashKey, String.valueOf(count)); return count;}@Overridepublic Boolean queryUserIsLove(Long userId, String publishId) { String redisKey = this.getCommentRedisKeyPrefix(publishId); String hashKey = this.getCommentUserLoveRedisKey(userId); Object value = this.redisTemplate.opsForHash().get(redisKey, hashKey); if (ObjectUtil.isNotEmpty(value)) { return StrUtil.equals(Convert.toStr(value), “1”); } //查詢mongodb Query query = Query.query(Criteria.where(“publishId”) .is(new ObjectId(publishId)) .and(“userId”).is(userId) .and(“commentType”).is(CommentType.LOVE.getType())); long count = this.mongoTemplate.count(query, Comment.class); if (count == 0) { return false; } //標(biāo)記 戶已經(jīng)喜歡 this.redisTemplate.opsForHash().put(redisKey, hashKey, “1”); return true;}

    鄭重聲明:本文內(nèi)容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場(chǎng),版權(quán)歸原作者所有,如有侵權(quán)請(qǐng)聯(lián)系管理員(admin#wlmqw.com)刪除。
    (0)
    用戶投稿
    上一篇 2022年6月13日 15:28
    下一篇 2022年6月13日 15:28

    相關(guān)推薦

    • 為慶祝八一建軍節(jié)

      為慶祝八一建軍節(jié)到來(lái)! 轉(zhuǎn)發(fā)抽送一臺(tái)Redmi K50電競(jìng)版手機(jī)! 轉(zhuǎn)發(fā) 關(guān)注@熊貓?jiān)u世界 八月八號(hào)抽出! 喜歡玩手游的朋友可別錯(cuò)過(guò)了[歡迎打call]

      2022年7月31日
    • 適合長(zhǎng)期不發(fā)朋友圈的人

      一、對(duì)他人的私事不關(guān)心,不介入,允許他人的道德觀、生活方式和自己不同,這將消除世上90%以上的煩惱。 二、承諾猶如放屁,當(dāng)時(shí)驚天動(dòng)地,過(guò)后蒼白無(wú)力。 三、這個(gè)世界的真相是:我們特別…

      2022年4月21日
    • 13句最走心的心情語(yǔ)錄,句句觸碰心靈

      1.時(shí)間會(huì)告訴我們,簡(jiǎn)單的喜歡最長(zhǎng)遠(yuǎn),平凡中的陪伴最心安,懂你的人最溫暖。 2.人到了一定年齡,都是帶著點(diǎn)心事,帶著點(diǎn)難言的痛,每天笑嘻嘻地生活下去的。 3.你若盛開(kāi),清風(fēng)自來(lái)。心…

      2022年8月26日
    • 北通新品曝光,搭載無(wú)線充電功能,坐擁兩大殺手锏,你期待嗎?

      說(shuō)到無(wú)線充電,相信大家第一時(shí)間想到的就是手機(jī)、耳機(jī)、移動(dòng)電源等等,很少看到會(huì)跟外設(shè)有掛鉤。以游戲手柄為例,目前搭載無(wú)線充電功能屈指可數(shù),就算有,但是在性能方面卻不如人意,難道就沒(méi)有…

      2022年7月23日
    • 夏天穿椰子拖YYDS

      椰子拖鞋近期心頭愛(ài)了 天天穿它 真的有踩棉花感覺(jué) 這個(gè)顏色太喜歡了配上我的指甲油 搭配所有的衣服都是可以滴嘿嘿~

      2022年6月26日
    • Red Hat Linux網(wǎng)絡(luò)和安全管理

      Red Hat Linux網(wǎng)絡(luò)和安全管理 推薦序 從市場(chǎng)價(jià)值來(lái)看,Linux操作系統(tǒng),經(jīng)過(guò)多年的開(kāi)發(fā)研究,功能越來(lái)越強(qiáng)大,操作界面也日趨簡(jiǎn)捷、方便,在安全性、穩(wěn)定性上已漸入佳境,擁…

      2022年6月17日
    • 618活動(dòng)現(xiàn)場(chǎng),OPPO也學(xué)會(huì)耍猴了?

      “耍猴”這個(gè)詞在手機(jī)界最初來(lái)自小米的產(chǎn)能匱乏造成了人們認(rèn)為的饑餓營(yíng)銷,可如今小米產(chǎn)能問(wèn)題差不多已完全解決,很少見(jiàn)到“到貨通知”字樣,可OPPO這樣的產(chǎn)能大廠怎么回事?[打臉] 下面…

      2022年6月20日
    • 最舒服的四指鍵位設(shè)置!特種兵要來(lái)挑戰(zhàn)一下自己的操作極限嗎?

      在和平賽場(chǎng)上,二指和三指的鍵位設(shè)置,足夠大部分特種兵使用。但是如果特種兵還想讓身法和操作更流暢的話,那就可以考慮進(jìn)階到四指操作了。雞仔本期帶來(lái)的就是適合絕大多數(shù)特種兵從二指或三指升…

      2022年8月21日
    • 下雨天適合發(fā)朋友圈的文案

      1、下雨天不要淋到雨,不然你會(huì)可愛(ài)到發(fā)芽。 2、如果你覺(jué)得我的誠(chéng)意不夠,我可以淋著雨愛(ài)你。 3、我在滂沱大雨中絕望,而你撐著傘向我走來(lái)。 4、讓我一直淋著雨,直到遇到那把我最愛(ài)的傘…

      2022年5月2日
    • Android音視頻開(kāi)發(fā)-Media FrameWork框架與源碼解析

      一、Media FrameWork背景 Media Framework (媒體函數(shù)庫(kù)):此函數(shù)庫(kù)讓Android 可以播放與錄制許多常見(jiàn)的音頻與視頻文件,支持的文件類型包括MPEG…

      2022年6月25日

    聯(lián)系我們

    聯(lián)系郵箱:admin#wlmqw.com
    工作時(shí)間:周一至周五,10:30-18:30,節(jié)假日休息