Authored by peuei

fix

... ... @@ -17,9 +17,6 @@ public interface PublicArticleRepository extends JpaRepository<PublicArticle, In
@Query("select id from PublicArticle where relateId = ?1 and articleType in (?2)")
Integer findByArticleId(Integer articleId, int[] types);
@Query("select article from PublicArticle article where article.relateId = ?1 and article.articleType in (?2)")
List<PublicArticle> findByArticleIdPlus(Integer articleId, int[] types);
@Transactional // required
@Modifying
@Query("update PublicArticle set coverImg = ?1 where id = ?2 and articleType in (?3)")
... ...
... ... @@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.xml.bind.ValidationException;
import java.util.List;
@Service
... ... @@ -159,11 +158,7 @@ public class PublicArticleService {
public Integer getPublicArticleIdByGrassArticleId(final Integer grassArticleId) {
final GrassArticle grassArticle = grassArticleService.getGrassArticleById(grassArticleId);
if (grassArticle == null) {
final List<PublicArticle> list = publicArticleRepository.findByArticleIdPlus(grassArticleId, ServiceConstant.articleTypesAll);
// 如果只有一条记录则返回
if (list != null && list.size() == 1) return list.get(0).getId();
log.error("the grass article data had deleted by someone, with grassArticleId {}, and in public database, there have more than one data, {}",
grassArticleId, list.toString());
log.error("the grass article data had deleted by someone, with grassArticleId {}, this operation may happen when sql delete", grassArticleId);
return null;
}
if (grassArticle != null && ServiceConstant.ARTICLE_TYPE_NOW.equals(grassArticle.getArticleType())) {
... ...