Commit 7f831df3 by lili

同步更新应用信息

parent d0bcfc24
......@@ -163,4 +163,23 @@ public class BookApplication {
return RabbitMQFactory.bindingExchange(updateWXGroupNameQueue(), MQTopicProducer.UPDATE_WXGROUP_NAME);
}
@Bean
public Queue updateAppInfoQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.APP_UPDATE);
}
@Bean
public Binding updateAppInfoBind() {
return RabbitMQFactory.bindingExchange(updateAppInfoQueue(), MQTopicProducer.APP_UPDATE);
}
@Bean
public Queue updateProductInfoQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.PRODUCT_UPDATE);
}
@Bean
public Binding updateProductInfoBind() {
return RabbitMQFactory.bindingExchange(updateProductInfoQueue(), MQTopicProducer.PRODUCT_UPDATE);
}
}
......@@ -284,7 +284,7 @@ public class SendWeixinRequestTools {
String content = "";
for (int i = 0; i < keywords.size(); i++) {
KeywordDTO keywordDTO = keywords.get(i);
String keyword = "关键词" + (i + 1) + ":" + keywordDTO.getKeywords() + "\n" + keywordDTO.getGuide();
String keyword = "关键词【" + keywordDTO.getKeywords() + "】\n" + " "+keywordDTO.getGuide();
if (content.length() + keyword.length() > 300) {
sendTextMessage(content, robotId, weixinGroupId);
content = keyword;
......
......@@ -24,4 +24,11 @@ public interface BookGuideReplyDao extends BaseDao<BookGuideReply> {
* @Date:2019/4/24 9:30
*/
List<ReplyMessageVO> getReplyMessage(Long guideId);
/**
* @Author:lili
* @Desr:更新应用基本信息
* @Date:2019/6/6 11:33
*/
void updateServeInfo(Long serveId, String serveType, String title, String squareImg);
}
package com.pcloud.book.keywords.dao;
import com.pcloud.book.keywords.entity.Keyword;
import com.pcloud.book.keywords.vo.KeywordVO;
import com.pcloud.common.core.dao.BaseDao;
/**
......@@ -16,5 +15,10 @@ public interface KeywordDao extends BaseDao<Keyword> {
*/
void deleteById(Long keywordId, Long partyId);
/**
* @Author:lili
* @Desr:更新服务基本信息
* @Date:2019/6/6 11:17
*/
void updateServeInfo(Long serveId, String serveType, String title, String squareImg);
}
......@@ -7,7 +7,9 @@ import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author lily
......@@ -18,11 +20,21 @@ public class BookGuideReplyDaoImpl extends BaseDaoImpl<BookGuideReply> implement
@Override
public void deleteByGuideId(Long bookGuideId) {
this.getSqlSession().update("deleteByGuideId", bookGuideId);
this.getSqlSession().update(this.getStatement("deleteByGuideId"), bookGuideId);
}
@Override
public List<ReplyMessageVO> getReplyMessage(Long guideId) {
return this.getSqlSession().selectList("getReplyMessage", guideId);
return this.getSqlSession().selectList(this.getStatement("getReplyMessage"), guideId);
}
@Override
public void updateServeInfo(Long serveId, String serveType, String title, String squareImg) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("serveId", serveId);
paramMap.put("serveType", serveType);
paramMap.put("content", title);
paramMap.put("picUrl", squareImg);
this.getSqlSession().update(this.getStatement("updateServeInfo"), paramMap);
}
}
......@@ -2,7 +2,6 @@ package com.pcloud.book.keywords.dao.impl;
import com.pcloud.book.keywords.dao.KeywordDao;
import com.pcloud.book.keywords.entity.Keyword;
import com.pcloud.book.keywords.vo.KeywordVO;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
......@@ -23,4 +22,14 @@ public class KeywordDaoImpl extends BaseDaoImpl<Keyword> implements KeywordDao {
paramMap.put("updateUser", partyId);
this.getSqlSession().update(this.getStatement("deleteById"), paramMap);
}
@Override
public void updateServeInfo(Long serveId, String serveType, String title, String squareImg){
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("serveId", serveId);
paramMap.put("serveType", serveType);
paramMap.put("title",title);
paramMap.put("picUrl", squareImg);
this.getSqlSession().update(this.getStatement("updateServeInfo"), paramMap);
}
}
......@@ -55,4 +55,14 @@ public class MQTopicConumer {
*/
public static final String UPDATE_WXGROUP_NAME = PREFIX + MQTopicProducer.UPDATE_WXGROUP_NAME;
/**
* 应用更新
*/
public static final String APP_UPDATE = PREFIX + MQTopicProducer.APP_UPDATE;
/**
* 商品更新
*/
public static final String PRODUCT_UPDATE = PREFIX + MQTopicProducer.PRODUCT_UPDATE;
}
package com.pcloud.book.mq.topic;
import com.pcloud.appcenter.app.entity.App;
import com.pcloud.appcenter.base.enums.AppEnum;
import com.pcloud.book.keywords.dao.BookGuideReplyDao;
import com.pcloud.book.keywords.dao.KeywordDao;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.common.core.aspect.ParamLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author lily
* @date 2019/6/6 11:10
*/
@Component
@RabbitListener(queues = MQTopicConumer.APP_UPDATE)
public class AppUpdateListener {
private static final Logger LOGGER = LoggerFactory.getLogger(AppUpdateListener.class);
@Autowired
private KeywordDao keywordDao;
@Autowired
private BookGuideReplyDao bookGuideReplyDao;
/**
* 接收消息
*/
@RabbitHandler
@ParamLog("应用修改消息监听")
public void onMessage(App app) {
if (null == app) {
return;
}
try {
if(AppEnum.AUDIT_STATE_PASS.value.equals(app.getAuditState())){
keywordDao.updateServeInfo(app.getAppId(), "APP", app.getTitle(), app.getSquareImg());
bookGuideReplyDao.updateServeInfo(app.getAppId(), "APP", app.getTitle(), app.getSquareImg());
}
} catch (Exception e) {
LOGGER.error("应用修改消息监听消费topic,<ERROR>:" + e.getMessage(), e);
return;
}
}
}
package com.pcloud.book.mq.topic;
import com.pcloud.book.keywords.dao.BookGuideReplyDao;
import com.pcloud.book.keywords.dao.KeywordDao;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.resourcecenter.product.entity.Product;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author lily
* @date 2019/6/6 11:10
*/
@Component
@RabbitListener(queues = MQTopicConumer.PRODUCT_UPDATE)
public class ProductUpdateListener {
@Autowired
private KeywordDao keywordDao;
@Autowired
private BookGuideReplyDao bookGuideReplyDao;
/**
* 接收资源中心消息
*/
@RabbitHandler
@ParamLog("接收商品修改消息")
public void onMessage(Product product) throws BizException {
if (product == null) {
return;
}
keywordDao.updateServeInfo(product.getProductId(), "PRODUCT", product.getProductName(), product.getCoverImg());
bookGuideReplyDao.updateServeInfo(product.getProductId(), "PRODUCT", product.getProductName(), product.getCoverImg());
}
}
......@@ -35,4 +35,16 @@
where
book_guide_id = #{_parameter,jdbcType=BIGINT} and is_delete = 0
</select>
<update id="updateServeInfo" parameterType="map">
update
book_guide_reply
set
content = #{content},
pic_url = #{picUrl}
where
serve_id = #{serveId,jdbcType=BIGINT} and serve_type = #{serveType}
</update>
</mapper>
\ No newline at end of file
......@@ -69,4 +69,13 @@
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateServeInfo" parameterType="map">
update
keyword
set
content = #{title},
pic_url = #{picUrl}
where
serve_id = #{serveId,jdbcType=BIGINT} and serve_type = #{serveType}
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment