Authored by liangyi.chen@yoho.cn

Fix bug

... ... @@ -36,10 +36,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
private static final Logger logger = LoggerFactory.getLogger(GrassArticlePraiseListener.class);
@Override
protected void deleteData(GrassArticleComment sourceObject) throws Exception {
if(sourceObject == null){
return;
}
protected void deleteData(GrassArticleComment sourceObject , Object checkResult) throws Exception {
PublicUserComment publicUserComment = annotationClassFactory.convertTargetObjectFromSource
(sourceObject,PublicUserComment.class);
if(publicUserComment == null){
... ... @@ -51,7 +48,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
}
@Override
protected void updateData(GrassArticleComment sourceObject) throws Exception {
protected void updateData(GrassArticleComment sourceObject , Object checkResult) throws Exception {
if(sourceObject == null){
return;
}
... ... @@ -62,8 +59,9 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
return;
}
publicUserComment.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
//查询关联的文章ID
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(publicUserComment.getRelateId(),
//1、public_user_comment.article_id取值:select id from public_article where relate_id =
// #{grass_article_comment.dest_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getDestId(),
ServiceConstant.articleTypes);
publicUserComment.setArticleId(articleId);
//查询当前评论被回复的id,即GrassArticleComment中的parentId对应的评论ID
... ... @@ -115,4 +113,5 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
protected EventEnum getEventReportEnum() {
return EventEnum.GRASSARTICLECOMMENTLISTENER_UPDATE;
}
}
... ...
... ... @@ -31,40 +31,31 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP
private static final Logger logger = LoggerFactory.getLogger(GrassArticlePraiseListener.class);
@Override
protected void deleteData(GrassArticlePraise sourceObject) throws Exception {
if(sourceObject == null){
return;
}
PublicUserPraise publicUserPraise = convertToPublicUserPraise(sourceObject);
protected void deleteData(GrassArticlePraise sourceObject , Object checkResult) throws Exception {
PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource
(sourceObject,PublicUserPraise.class);
if(publicUserPraise == null){
logger.error("deleteData failed , publicUserPraise is null");
return;
}
//public_user_praise.target_id取值:select id from public_article where relate_id =
// #{grass_article_praise.article_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
ServiceConstant.articleTypes);
publicUserPraise.setTargetId(articleId);
publicUserPraise.setTargetId((Integer)checkResult);
publicUserPraise.setPraiseType(ServiceConstant.Public_User_Phraise.ARTICLE_PHRAISE);
praiseService.deletePublicUserPraise(publicUserPraise);
}
@Override
protected void updateData(GrassArticlePraise sourceObject) throws Exception {
if(sourceObject == null){
return;
}
PublicUserPraise publicUserPraise = convertToPublicUserPraise(sourceObject);
protected void updateData(GrassArticlePraise sourceObject , Object checkResult) throws Exception {
PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource
(sourceObject,PublicUserPraise.class);
if(publicUserPraise == null){
logger.error("updateData failed , publicUserPraise is null");
return;
}
//public_user_praise.target_id取值:select id from public_article where relate_id =
// #{grass_article_praise.article_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
ServiceConstant.articleTypes);
publicUserPraise.setTargetId(articleId);
publicUserPraise.setTargetId((Integer)checkResult);
//grass_article_praise.status(0:已点赞,1:已取消)和public_user_praise.status(1-已点赞,2-已取消)状态转换
if(sourceObject.getStatus() != null){
switch (sourceObject.getStatus()){
... ... @@ -81,16 +72,14 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP
}
private PublicUserPraise convertToPublicUserPraise(GrassArticlePraise sourceObject) throws Exception{
if(sourceObject == null){
return null;
}
return annotationClassFactory.convertTargetObjectFromSource(sourceObject,PublicUserPraise.class);
}
@Override
protected EventEnum getEventReportEnum() {
return EventEnum.GRASSARTICLEPRAISELISTENER_UPDATEDATA;
}
@Override
protected Object checkData(GrassArticlePraise sourceObject) {
return publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
ServiceConstant.articleTypes);
}
}
... ...
... ... @@ -31,10 +31,7 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
private static final Logger logger = LoggerFactory.getLogger(GrassCommentPraiseListener.class);
@Override
protected void deleteData(GrassCommentPraise sourceObject) throws Exception {
if(sourceObject == null){
return;
}
protected void deleteData(GrassCommentPraise sourceObject , Object checkResult) throws Exception {
PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
PublicUserPraise.class);
if(publicUserPraise == null){
... ... @@ -43,17 +40,14 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
}
//public_user_praise.target_id取值:select id from public_article where relate_id =
// #{grass_comment_praise.comment_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getCommentId(),
ServiceConstant.articleTypes);
publicUserPraise.setTargetId(articleId);
publicUserPraise.setTargetId((Integer)checkResult);
publicUserPraise.setPraiseType(ServiceConstant.Public_User_Phraise.COMMENT_PHRAISE);
publicUserPraise.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
praiseService.deletePublicUserPraise(publicUserPraise);
}
@Override
protected void updateData(GrassCommentPraise sourceObject) throws Exception {
protected void updateData(GrassCommentPraise sourceObject , Object checkResult) throws Exception {
if(sourceObject == null){
return;
}
... ... @@ -62,11 +56,7 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
logger.error("updateData failed , publicUserPraise is null");
return;
}
//public_user_praise.target_id取值:select id from public_article where relate_id =
// #{grass_comment_praise.comment_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getCommentId(),
ServiceConstant.articleTypes);
publicUserPraise.setTargetId(articleId);
publicUserPraise.setTargetId((Integer)checkResult);
//grass_article_praise.status(0:已点赞,1:已取消)和public_user_praise.status(1-已点赞,2-已取消)状态转换
if(sourceObject.getStatus() != null){
switch (sourceObject.getStatus()){
... ... @@ -83,6 +73,11 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
}
@Override
protected Object checkData(GrassCommentPraise sourceObject) {
return publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getCommentId(),
ServiceConstant.articleTypes);
}
@Override
protected EventEnum getEventReportEnum() {
... ...
... ... @@ -31,7 +31,7 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
private static final Logger logger = LoggerFactory.getLogger(UserFavoriteArticleListener.class);
@Override
protected void deleteData(UserFavoriteArticle sourceObject) throws Exception {
protected void deleteData(UserFavoriteArticle sourceObject , Object checkResult) throws Exception {
PublicUserFavorite publicUserFavorite = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
PublicUserFavorite.class);
if(publicUserFavorite == null){
... ... @@ -40,15 +40,13 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
}
//public_user_favorite.target_id取值:select id from public_article where relate_id =
// #{user_favorite_article.article_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
ServiceConstant.articleTypes);
publicUserFavorite.setTargetId(articleId);
publicUserFavorite.setTargetId((Integer)checkResult);
publicUserFavorite.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
publicUserFavoriteService.deletePublicUserPraise(publicUserFavorite);
}
@Override
protected void updateData(UserFavoriteArticle sourceObject) throws Exception {
protected void updateData(UserFavoriteArticle sourceObject , Object checkResult) throws Exception {
PublicUserFavorite publicUserFavorite = annotationClassFactory.convertTargetObjectFromSource
(sourceObject,PublicUserFavorite.class);
if(publicUserFavorite == null){
... ... @@ -57,9 +55,7 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
}
//public_user_favorite.target_id取值:select id from public_article where relate_id =
// #{user_favorite_article.article_id} and article_type in (1,2,4);
Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
ServiceConstant.articleTypes);
publicUserFavorite.setTargetId(articleId);
publicUserFavorite.setTargetId((Integer)checkResult);
publicUserFavorite.setFavoriteType(ServiceConstant.Public_User_Favorite.FAVORITE_TYPE_ARTICLE);
publicUserFavorite.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
publicUserFavoriteService.saveOrUpdatePublicUserPraise(publicUserFavorite);
... ... @@ -71,4 +67,10 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
protected EventEnum getEventReportEnum() {
return EventEnum.USERFAVORITEARTICLELISTENER_UPDATE;
}
@Override
protected Object checkData(UserFavoriteArticle sourceObject) {
return publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
ServiceConstant.articleTypes);
}
}
... ...