亚洲精品中文免费|亚洲日韩中文字幕制服|久久精品亚洲免费|一本之道久久免费

      
      

            <dl id="hur0q"><div id="hur0q"></div></dl>

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

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

                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ā)布動態(tài)消息

                *

                * @param publishId

                * @return

                */

                public Boolean publishMsg(String publishId) {

                return this.sendMsg(publishId, 1);

                }

                /**

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

                *

                * @param publishId

                * @return

                */

                public Boolean queryPublishMsg(String publishId) {

                return this.sendMsg(publishId, 2);

                }

                /**

                * 點贊動態(tài)消息

                *

                * @param publishId

                * @return

                */

                public Boolean likePublishMsg(String publishId) {

                return this.sendMsg(publishId, 3);

                }

                /**

                * 取消點贊動態(tài)消息

                *

                * @param publishId

                * @return

                */

                public Boolean disLikePublishMsg(String publishId) {

                return this.sendMsg(publishId, 6);

                }

                /**

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

                *

                * @param publishId

                * @return

                */

                public Boolean lovePublishMsg(String publishId) {

                return this.sendMsg(publishId, 4);

                }

                /**

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

                *

                * @param publishId

                * @return

                */

                public Boolean disLovePublishMsg(String publishId) {

                return this.sendMsg(publishId, 7);

                }

                /**

                * 評論動態(tài)消息

                *

                * @param publishId

                * @return

                */

                public Boolean commentPublishMsg(String publishId) {

                return this.sendMsg(publishId, 5);

                }

                /**

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

                *

                * @param publishId

                * @param type 1-發(fā)動態(tài),2-瀏覽動態(tài), 3-點贊, 4-喜歡, 5-評論,6-取消點贊,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),不代表本站立場,版權(quán)歸原作者所有,如有侵權(quán)請聯(lián)系管理員(admin#wlmqw.com)刪除。
                用戶投稿
                上一篇 2022年6月28日 00:44
                下一篇 2022年6月28日 00:45

                相關(guān)推薦

                聯(lián)系我們

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