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

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

    加入推薦算法 優(yōu)化朋友圈 service 初級(jí)算法

    service 加入推薦算法 優(yōu)化朋友圈 初級(jí)算法

    import com.alibaba.dubbo.config.annotation.Reference;

    import com.tanhua.common.pojo.User;

    import com.tanhua.common.utils.UserThreadLocal;

    import com.tanhua.dubbo.server.api.QuanZiApi;

    import com.tanhua.dubbo.server.pojo.Publish;

    import lombok.extern.slf4j.Slf4j;

    import org.apache.rocketmq.spring.core.RocketMQTemplate;

    import org.springframework.beans.factory.annotation.Autowired;

    import org.springframework.stereotype.Service;

    import java.util.HashMap;

    import java.util.Map;

    @Service

    @Slf4j

    public class QuanziMQService {

    @Autowired

    private RocketMQTemplate rocketMQTemplate;

    @Reference(version = “1.0.0”)

    private QuanZiApi quanZiApi;

    /**

    * 發(fā)布動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean publishMsg(String publishId) {

    return this.sendMsg(publishId, 1);

    }

    /**

    * 瀏覽動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean queryPublishMsg(String publishId) {

    return this.sendMsg(publishId, 2);

    }

    /**

    * 點(diǎn)贊動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean likePublishMsg(String publishId) {

    return this.sendMsg(publishId, 3);

    }

    /**

    * 取消點(diǎn)贊動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean disLikePublishMsg(String publishId) {

    return this.sendMsg(publishId, 6);

    }

    /**

    * 喜歡動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean lovePublishMsg(String publishId) {

    return this.sendMsg(publishId, 4);

    }

    /**

    * 取消喜歡動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean disLovePublishMsg(String publishId) {

    return this.sendMsg(publishId, 7);

    }

    /**

    * 評(píng)論動(dòng)態(tài)消息

    *

    * @param publishId

    * @return

    */

    public Boolean commentPublishMsg(String publishId) {

    return this.sendMsg(publishId, 5);

    }

    /**

    * 發(fā)送圈子操作相關(guān)的消息

    *

    * @param publishId

    * @param type 1-發(fā)動(dòng)態(tài),2-瀏覽動(dòng)態(tài), 3-點(diǎn)贊, 4-喜歡, 5-評(píng)論,6-取消點(diǎn)贊,7-取消喜歡

    * @return

    */

    private Boolean sendMsg(String publishId, Integer type) {

    try {

    User user = UserThreadLocal.get();

    Publish publish = this.quanZiApi.queryPublishById(publishId);

    //構(gòu)建消息

    Map msg = new HashMap();

    msg.put(“userId”, user.getId());

    msg.put(“date”, System.currentTimeMillis());

    msg.put(“publishId”, publishId);

    msg.put(“pid”, publish.getPid());

    msg.put(“type”, type);

    this.rocketMQTemplate.convertAndSend(“tanhua-quanzi”, msg);

    } catch (Exception e) {

    log.error(“發(fā)送消息失敗! publishId = ” + publishId + “, type = ” + type, e);

    return false;

    }

    return true;

    }

    }

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

    相關(guān)推薦

    聯(lián)系我們

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