关注取关方法

    @RequestCode(requestId = "REQ_FOLLOW_OR_UNFOLLOW")
    public ResponseEnvelope follow(@RequestBody RequestEnvelope requestEnvelope) {
        //获取查询参数
        JSONObject params = requestEnvelope.getParam2JsonObj("params");
        String targetId = params.getString("targetId");
        String sendId = params.getString("sendId");

        LambdaQueryWrapper<KbFansFollowInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(KbFansFollowInfo::getFollowId, targetId).eq(KbFansFollowInfo::getFansId, sendId);
        //删除已有关注数据
        int delete = kbFansFollowInfoMapper.delete(wrapper);
        if (delete == 0) {
            //添加关注
            KbFansFollowInfo kbFansFollowInfoNew = new KbFansFollowInfo();
            kbFansFollowInfoNew.setFollowId(targetId);
            kbFansFollowInfoNew.setFansId(sendId);
            kbFansFollowInfoNew.setNoticeStatus(0);
            kbFansFollowInfoMapper.insert(kbFansFollowInfoNew);

            //消息通知中添加数据
            KbSystemNotice kbSystemNotice = new KbSystemNotice();
            kbSystemNotice.setNoticeStatus(NoticeStatus.UNREAD.getValue());
            kbSystemNotice.setNoticeType(KbSystemNotice.NoticeType.FOLLOW.getValue());
            kbSystemNotice.setSendType("0");
            kbSystemNotice.setSendId(sendId);
            kbSystemNotice.setTargetId(targetId);
            kbSystemNotice.setContent("关注了你");
            kbSystemNotice.setOriginId(kbFansFollowInfoNew.getCfpId());
            kbSystemNoticeMapper.insert(kbSystemNotice);
        }
        return ResponseEnvelope.success();
    }

关注按钮是回显在页面上的,如果有数据显示已关注,没有关注数据显示关注。

后台代码直接用粉丝id和作者id就可以完成关注取关。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值