Authored by liangyi.chen@yoho.cn

Fix

... ... @@ -88,7 +88,7 @@ public class GrassArticleBlockListener extends AbstractMqListener<GrassArticleBl
/**
* public_article_block表的article_id字段为grass_article表中对应的数据同步到public_article表之后的自增主键id
*/
final Integer relatedId = publicArticleService.getPublicArticleIdStage1(sourceObject.getArticleId());
final Integer relatedId = publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getArticleId());
if (relatedId == null) {
log.info("can not get public_article primary key with original articleId {}", sourceObject.getArticleId());
return null;
... ...
... ... @@ -61,7 +61,7 @@ public class GrassArticleCommentListener extends AbstractMqListener<GrassArticle
publicUserComment.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
//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.getPublicArticleIdStage1(sourceObject.getDestId());
Integer articleId = publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getDestId());
publicUserComment.setArticleId(articleId);
//查询当前评论被回复的id,即GrassArticleComment中的parentId对应的评论ID
if(sourceObject.getParentId() != null){
... ...
... ... @@ -94,7 +94,7 @@ public class GrassArticleLabelListener extends AbstractMqListener<GrassArticleLa
/**
* public_article_label 表的 article_id 字段为 grass_article_label.article_id 在 grass_article 表中对应的数据同步到 public_article 表之后的自增主键id
*/
final Integer trueId = publicArticleService.getPublicArticleIdStage1(sourceObject.getArticleId());
final Integer trueId = publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getArticleId());
if (trueId == null) {
log.info("can not get public_article primary key with articleId {}", sourceObject.getArticleId());
return null;
... ...
... ... @@ -72,7 +72,7 @@ public class GrassArticleListener extends AbstractMqListener<GrassArticle> {
protected Object checkData(GrassArticle sourceObject, String action) {
if (DatasyncConstant.ACTION_UPDATE.equals(action)) {
// 更新操作才去查找 cover_img
Integer trueId = publicArticleService.getPublicArticleIdStage2(sourceObject);
Integer trueId = publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getId());
if (trueId == null) return "";
String contentData = publicArticleBlockService.findContentData(trueId);
if (contentData == null) return "";
... ...
... ... @@ -79,6 +79,6 @@ public class GrassArticlePraiseListener extends AbstractMqListener<GrassArticleP
@Override
protected Object checkData(GrassArticlePraise sourceObject, String action) {
return publicArticleService.getPublicArticleIdStage1(sourceObject.getArticleId());
return publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getArticleId());
}
}
... ...
... ... @@ -81,7 +81,7 @@ public class GrassArticleProductListener extends AbstractMqListener<GrassArticle
/**
* public_article_product 表的 article_id 字段为 grass_article_product.article_id 在 grass_article 表中对应的数据同步到 public_article 表之后的自增主键id
*/
final Integer trueId = publicArticleService.getPublicArticleIdStage1(sourceObject.getArticleId());
final Integer trueId = publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getArticleId());
if (trueId == null) {
log.info("can not get public_article primary key with articleId {}", sourceObject.getArticleId());
return null;
... ...
... ... @@ -71,6 +71,6 @@ public class UserFavoriteArticleListener extends AbstractMqListener<UserFavorite
@Override
protected Object checkData(UserFavoriteArticle sourceObject, String action) {
return publicArticleService.getPublicArticleIdStage1(sourceObject.getArticleId());
return publicArticleService.getPublicArticleIdByGrassArticleId(sourceObject.getArticleId());
}
}
... ...
... ... @@ -155,18 +155,14 @@ public class PublicArticleService {
* @param grassArticleId
* @return
*/
public Integer getPublicArticleIdStage1(final Integer grassArticleId) {
public Integer getPublicArticleIdByGrassArticleId(final Integer grassArticleId) {
final GrassArticle grassArticle = grassArticleService.getGrassArticleById(grassArticleId);
return getPublicArticleIdStage2(grassArticle);
}
public Integer getPublicArticleIdStage2(final GrassArticle grassArticle) {
if (grassArticle != null && grassArticle.getArticleType() == ServiceConstant.ARTICLE_TYPE_NOW) {
if (grassArticle != null && ServiceConstant.ARTICLE_TYPE_NOW.equals(grassArticle.getArticleType())) {
final PublicArticle result = publicArticleRepository.findByRelateIdAndArticleType(grassArticle.getRelateId(), ServiceConstant.ARTICLE_TYPE_NOW);
return result == null ? null : result.getId();
} else {
return publicArticleRepository.findByArticleId(grassArticle.getId(), ServiceConstant.articleTypes);
return publicArticleRepository.findByArticleId(grassArticleId, ServiceConstant.articleTypes);
}
}
}
... ...
... ... @@ -4,7 +4,12 @@ spring:
jpa:
properties:
hibernate:
show_sql: true
show_sql: false
enable_lazy_load_no_trans: true
use_sql_comments: false
format_sql: false
type: trace
show-sql: true
server:
port: 8080
... ...