|
|
package com.yoho.datasync.consumer.service;
|
|
|
|
|
|
import com.yoho.datasync.consumer.common.BeanCopyUtils;
|
|
|
import com.yoho.datasync.consumer.common.ContentConvertUtil;
|
|
|
import com.yoho.datasync.consumer.common.ServiceConstant;
|
|
|
import com.yoho.datasync.consumer.dal.repository.PublicArticleBlockRepository;
|
...
|
...
|
@@ -59,9 +60,9 @@ public class PublicArticleBlockService { |
|
|
* @param flag 标记状态位是否为删除状态
|
|
|
*/
|
|
|
public void updateData(PublicArticleBlock targetObject, boolean flag) {
|
|
|
PublicArticleBlock existObject = publicArticleBlockRepository.
|
|
|
findByArticleIdAndCreateTimeAndOrderBy(targetObject.getArticleId(), targetObject.getCreateTime(), targetObject.getOrderBy());
|
|
|
if (flag) {
|
|
|
PublicArticleBlock existObject = publicArticleBlockRepository.
|
|
|
findByArticleIdAndCreateTimeAndOrderBy(targetObject.getArticleId(), targetObject.getCreateTime(), targetObject.getOrderBy());
|
|
|
if (existObject == null) {
|
|
|
log.error("something goes wrong ... data is null...");
|
|
|
return;
|
...
|
...
|
@@ -69,8 +70,13 @@ public class PublicArticleBlockService { |
|
|
publicArticleBlockRepository.deleteById(existObject.getId());
|
|
|
return;
|
|
|
}
|
|
|
// 否则为插入操作
|
|
|
publicArticleBlockRepository.save(targetObject);
|
|
|
if (existObject != null) {
|
|
|
existObject = BeanCopyUtils.copyNonNullProperties(targetObject, existObject, PublicArticleBlock.class);
|
|
|
publicArticleBlockRepository.save(existObject);
|
|
|
} else {
|
|
|
// 否则为插入操作
|
|
|
publicArticleBlockRepository.save(targetObject);
|
|
|
}
|
|
|
// 更新 public_article.cover_img
|
|
|
if (targetObject.getOrderBy() == 0) {
|
|
|
if (targetObject.getContentData() != null) {
|
...
|
...
|
|