...
|
...
|
@@ -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);
|
|
|
}
|
|
|
} |
...
|
...
|
|