Authored by liangyi.chen@yoho.cn

Fix bug

@@ -36,10 +36,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle @@ -36,10 +36,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
36 private static final Logger logger = LoggerFactory.getLogger(GrassArticlePraiseListener.class); 36 private static final Logger logger = LoggerFactory.getLogger(GrassArticlePraiseListener.class);
37 37
38 @Override 38 @Override
39 - protected void deleteData(GrassArticleComment sourceObject) throws Exception {  
40 - if(sourceObject == null){  
41 - return;  
42 - } 39 + protected void deleteData(GrassArticleComment sourceObject , Object checkResult) throws Exception {
43 PublicUserComment publicUserComment = annotationClassFactory.convertTargetObjectFromSource 40 PublicUserComment publicUserComment = annotationClassFactory.convertTargetObjectFromSource
44 (sourceObject,PublicUserComment.class); 41 (sourceObject,PublicUserComment.class);
45 if(publicUserComment == null){ 42 if(publicUserComment == null){
@@ -51,7 +48,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle @@ -51,7 +48,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
51 } 48 }
52 49
53 @Override 50 @Override
54 - protected void updateData(GrassArticleComment sourceObject) throws Exception { 51 + protected void updateData(GrassArticleComment sourceObject , Object checkResult) throws Exception {
55 if(sourceObject == null){ 52 if(sourceObject == null){
56 return; 53 return;
57 } 54 }
@@ -62,8 +59,9 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle @@ -62,8 +59,9 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
62 return; 59 return;
63 } 60 }
64 publicUserComment.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS); 61 publicUserComment.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
65 - //查询关联的文章ID  
66 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(publicUserComment.getRelateId(), 62 + //1、public_user_comment.article_id取值:select id from public_article where relate_id =
  63 + // #{grass_article_comment.dest_id} and article_type in (1,2,4);
  64 + Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getDestId(),
67 ServiceConstant.articleTypes); 65 ServiceConstant.articleTypes);
68 publicUserComment.setArticleId(articleId); 66 publicUserComment.setArticleId(articleId);
69 //查询当前评论被回复的id,即GrassArticleComment中的parentId对应的评论ID 67 //查询当前评论被回复的id,即GrassArticleComment中的parentId对应的评论ID
@@ -115,4 +113,5 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle @@ -115,4 +113,5 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
115 protected EventEnum getEventReportEnum() { 113 protected EventEnum getEventReportEnum() {
116 return EventEnum.GRASSARTICLECOMMENTLISTENER_UPDATE; 114 return EventEnum.GRASSARTICLECOMMENTLISTENER_UPDATE;
117 } 115 }
  116 +
118 } 117 }
@@ -31,40 +31,31 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP @@ -31,40 +31,31 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP
31 private static final Logger logger = LoggerFactory.getLogger(GrassArticlePraiseListener.class); 31 private static final Logger logger = LoggerFactory.getLogger(GrassArticlePraiseListener.class);
32 32
33 @Override 33 @Override
34 - protected void deleteData(GrassArticlePraise sourceObject) throws Exception {  
35 - if(sourceObject == null){  
36 - return;  
37 - }  
38 - PublicUserPraise publicUserPraise = convertToPublicUserPraise(sourceObject); 34 + protected void deleteData(GrassArticlePraise sourceObject , Object checkResult) throws Exception {
  35 + PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource
  36 + (sourceObject,PublicUserPraise.class);
39 if(publicUserPraise == null){ 37 if(publicUserPraise == null){
40 logger.error("deleteData failed , publicUserPraise is null"); 38 logger.error("deleteData failed , publicUserPraise is null");
41 return; 39 return;
42 } 40 }
43 -  
44 //public_user_praise.target_id取值:select id from public_article where relate_id = 41 //public_user_praise.target_id取值:select id from public_article where relate_id =
45 // #{grass_article_praise.article_id} and article_type in (1,2,4); 42 // #{grass_article_praise.article_id} and article_type in (1,2,4);
46 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),  
47 - ServiceConstant.articleTypes);  
48 - publicUserPraise.setTargetId(articleId); 43 + publicUserPraise.setTargetId((Integer)checkResult);
49 publicUserPraise.setPraiseType(ServiceConstant.Public_User_Phraise.ARTICLE_PHRAISE); 44 publicUserPraise.setPraiseType(ServiceConstant.Public_User_Phraise.ARTICLE_PHRAISE);
50 praiseService.deletePublicUserPraise(publicUserPraise); 45 praiseService.deletePublicUserPraise(publicUserPraise);
51 } 46 }
52 47
53 @Override 48 @Override
54 - protected void updateData(GrassArticlePraise sourceObject) throws Exception {  
55 - if(sourceObject == null){  
56 - return;  
57 - }  
58 - PublicUserPraise publicUserPraise = convertToPublicUserPraise(sourceObject); 49 + protected void updateData(GrassArticlePraise sourceObject , Object checkResult) throws Exception {
  50 + PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource
  51 + (sourceObject,PublicUserPraise.class);
59 if(publicUserPraise == null){ 52 if(publicUserPraise == null){
60 logger.error("updateData failed , publicUserPraise is null"); 53 logger.error("updateData failed , publicUserPraise is null");
61 return; 54 return;
62 } 55 }
63 //public_user_praise.target_id取值:select id from public_article where relate_id = 56 //public_user_praise.target_id取值:select id from public_article where relate_id =
64 // #{grass_article_praise.article_id} and article_type in (1,2,4); 57 // #{grass_article_praise.article_id} and article_type in (1,2,4);
65 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),  
66 - ServiceConstant.articleTypes);  
67 - publicUserPraise.setTargetId(articleId); 58 + publicUserPraise.setTargetId((Integer)checkResult);
68 //grass_article_praise.status(0:已点赞,1:已取消)和public_user_praise.status(1-已点赞,2-已取消)状态转换 59 //grass_article_praise.status(0:已点赞,1:已取消)和public_user_praise.status(1-已点赞,2-已取消)状态转换
69 if(sourceObject.getStatus() != null){ 60 if(sourceObject.getStatus() != null){
70 switch (sourceObject.getStatus()){ 61 switch (sourceObject.getStatus()){
@@ -81,16 +72,14 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP @@ -81,16 +72,14 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP
81 72
82 } 73 }
83 74
84 - private PublicUserPraise convertToPublicUserPraise(GrassArticlePraise sourceObject) throws Exception{  
85 - if(sourceObject == null){  
86 - return null;  
87 - }  
88 - return annotationClassFactory.convertTargetObjectFromSource(sourceObject,PublicUserPraise.class);  
89 -  
90 - }  
91 -  
92 @Override 75 @Override
93 protected EventEnum getEventReportEnum() { 76 protected EventEnum getEventReportEnum() {
94 return EventEnum.GRASSARTICLEPRAISELISTENER_UPDATEDATA; 77 return EventEnum.GRASSARTICLEPRAISELISTENER_UPDATEDATA;
95 } 78 }
  79 +
  80 + @Override
  81 + protected Object checkData(GrassArticlePraise sourceObject) {
  82 + return publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
  83 + ServiceConstant.articleTypes);
  84 + }
96 } 85 }
@@ -31,10 +31,7 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP @@ -31,10 +31,7 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
31 private static final Logger logger = LoggerFactory.getLogger(GrassCommentPraiseListener.class); 31 private static final Logger logger = LoggerFactory.getLogger(GrassCommentPraiseListener.class);
32 32
33 @Override 33 @Override
34 - protected void deleteData(GrassCommentPraise sourceObject) throws Exception {  
35 - if(sourceObject == null){  
36 - return;  
37 - } 34 + protected void deleteData(GrassCommentPraise sourceObject , Object checkResult) throws Exception {
38 PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource(sourceObject, 35 PublicUserPraise publicUserPraise = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
39 PublicUserPraise.class); 36 PublicUserPraise.class);
40 if(publicUserPraise == null){ 37 if(publicUserPraise == null){
@@ -43,17 +40,14 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP @@ -43,17 +40,14 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
43 } 40 }
44 //public_user_praise.target_id取值:select id from public_article where relate_id = 41 //public_user_praise.target_id取值:select id from public_article where relate_id =
45 // #{grass_comment_praise.comment_id} and article_type in (1,2,4); 42 // #{grass_comment_praise.comment_id} and article_type in (1,2,4);
46 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getCommentId(),  
47 - ServiceConstant.articleTypes);  
48 - publicUserPraise.setTargetId(articleId);  
49 - 43 + publicUserPraise.setTargetId((Integer)checkResult);
50 publicUserPraise.setPraiseType(ServiceConstant.Public_User_Phraise.COMMENT_PHRAISE); 44 publicUserPraise.setPraiseType(ServiceConstant.Public_User_Phraise.COMMENT_PHRAISE);
51 publicUserPraise.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS); 45 publicUserPraise.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
52 praiseService.deletePublicUserPraise(publicUserPraise); 46 praiseService.deletePublicUserPraise(publicUserPraise);
53 } 47 }
54 48
55 @Override 49 @Override
56 - protected void updateData(GrassCommentPraise sourceObject) throws Exception { 50 + protected void updateData(GrassCommentPraise sourceObject , Object checkResult) throws Exception {
57 if(sourceObject == null){ 51 if(sourceObject == null){
58 return; 52 return;
59 } 53 }
@@ -62,11 +56,7 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP @@ -62,11 +56,7 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
62 logger.error("updateData failed , publicUserPraise is null"); 56 logger.error("updateData failed , publicUserPraise is null");
63 return; 57 return;
64 } 58 }
65 - //public_user_praise.target_id取值:select id from public_article where relate_id =  
66 - // #{grass_comment_praise.comment_id} and article_type in (1,2,4);  
67 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getCommentId(),  
68 - ServiceConstant.articleTypes);  
69 - publicUserPraise.setTargetId(articleId); 59 + publicUserPraise.setTargetId((Integer)checkResult);
70 //grass_article_praise.status(0:已点赞,1:已取消)和public_user_praise.status(1-已点赞,2-已取消)状态转换 60 //grass_article_praise.status(0:已点赞,1:已取消)和public_user_praise.status(1-已点赞,2-已取消)状态转换
71 if(sourceObject.getStatus() != null){ 61 if(sourceObject.getStatus() != null){
72 switch (sourceObject.getStatus()){ 62 switch (sourceObject.getStatus()){
@@ -83,6 +73,11 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP @@ -83,6 +73,11 @@ public class GrassCommentPraiseListener extends AbstractMqListener<GrassCommentP
83 73
84 } 74 }
85 75
  76 + @Override
  77 + protected Object checkData(GrassCommentPraise sourceObject) {
  78 + return publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getCommentId(),
  79 + ServiceConstant.articleTypes);
  80 + }
86 81
87 @Override 82 @Override
88 protected EventEnum getEventReportEnum() { 83 protected EventEnum getEventReportEnum() {
@@ -31,7 +31,7 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite @@ -31,7 +31,7 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
31 private static final Logger logger = LoggerFactory.getLogger(UserFavoriteArticleListener.class); 31 private static final Logger logger = LoggerFactory.getLogger(UserFavoriteArticleListener.class);
32 32
33 @Override 33 @Override
34 - protected void deleteData(UserFavoriteArticle sourceObject) throws Exception { 34 + protected void deleteData(UserFavoriteArticle sourceObject , Object checkResult) throws Exception {
35 PublicUserFavorite publicUserFavorite = annotationClassFactory.convertTargetObjectFromSource(sourceObject, 35 PublicUserFavorite publicUserFavorite = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
36 PublicUserFavorite.class); 36 PublicUserFavorite.class);
37 if(publicUserFavorite == null){ 37 if(publicUserFavorite == null){
@@ -40,15 +40,13 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite @@ -40,15 +40,13 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
40 } 40 }
41 //public_user_favorite.target_id取值:select id from public_article where relate_id = 41 //public_user_favorite.target_id取值:select id from public_article where relate_id =
42 // #{user_favorite_article.article_id} and article_type in (1,2,4); 42 // #{user_favorite_article.article_id} and article_type in (1,2,4);
43 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),  
44 - ServiceConstant.articleTypes);  
45 - publicUserFavorite.setTargetId(articleId); 43 + publicUserFavorite.setTargetId((Integer)checkResult);
46 publicUserFavorite.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS); 44 publicUserFavorite.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
47 publicUserFavoriteService.deletePublicUserPraise(publicUserFavorite); 45 publicUserFavoriteService.deletePublicUserPraise(publicUserFavorite);
48 } 46 }
49 47
50 @Override 48 @Override
51 - protected void updateData(UserFavoriteArticle sourceObject) throws Exception { 49 + protected void updateData(UserFavoriteArticle sourceObject , Object checkResult) throws Exception {
52 PublicUserFavorite publicUserFavorite = annotationClassFactory.convertTargetObjectFromSource 50 PublicUserFavorite publicUserFavorite = annotationClassFactory.convertTargetObjectFromSource
53 (sourceObject,PublicUserFavorite.class); 51 (sourceObject,PublicUserFavorite.class);
54 if(publicUserFavorite == null){ 52 if(publicUserFavorite == null){
@@ -57,9 +55,7 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite @@ -57,9 +55,7 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
57 } 55 }
58 //public_user_favorite.target_id取值:select id from public_article where relate_id = 56 //public_user_favorite.target_id取值:select id from public_article where relate_id =
59 // #{user_favorite_article.article_id} and article_type in (1,2,4); 57 // #{user_favorite_article.article_id} and article_type in (1,2,4);
60 - Integer articleId = publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),  
61 - ServiceConstant.articleTypes);  
62 - publicUserFavorite.setTargetId(articleId); 58 + publicUserFavorite.setTargetId((Integer)checkResult);
63 publicUserFavorite.setFavoriteType(ServiceConstant.Public_User_Favorite.FAVORITE_TYPE_ARTICLE); 59 publicUserFavorite.setFavoriteType(ServiceConstant.Public_User_Favorite.FAVORITE_TYPE_ARTICLE);
64 publicUserFavorite.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS); 60 publicUserFavorite.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
65 publicUserFavoriteService.saveOrUpdatePublicUserPraise(publicUserFavorite); 61 publicUserFavoriteService.saveOrUpdatePublicUserPraise(publicUserFavorite);
@@ -71,4 +67,10 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite @@ -71,4 +67,10 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
71 protected EventEnum getEventReportEnum() { 67 protected EventEnum getEventReportEnum() {
72 return EventEnum.USERFAVORITEARTICLELISTENER_UPDATE; 68 return EventEnum.USERFAVORITEARTICLELISTENER_UPDATE;
73 } 69 }
  70 +
  71 + @Override
  72 + protected Object checkData(UserFavoriteArticle sourceObject) {
  73 + return publicArticleService.findArticleIdByRelateIdInArticleTypes(sourceObject.getArticleId(),
  74 + ServiceConstant.articleTypes);
  75 + }
74 } 76 }