|
@@ -11,6 +11,7 @@ import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
@@ -27,8 +28,10 @@ public class NewsServiceImpl implements NewsService {
|
|
|
private NewsRepository newsRepository;
|
|
private NewsRepository newsRepository;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
public News findone(Long id) {
|
|
public News findone(Long id) {
|
|
|
News news = newsRepository.findOne(id);
|
|
News news = newsRepository.findOne(id);
|
|
|
|
|
+ newsRepository.addCount(id);
|
|
|
//判断summary字段是否为空
|
|
//判断summary字段是否为空
|
|
|
if (news != null && StringUtils.isEmpty(news.getSummary())) {
|
|
if (news != null && StringUtils.isEmpty(news.getSummary())) {
|
|
|
news.setSummary(NewsCloumnCutUtil.getHtmlText(100,news.getContent()));
|
|
news.setSummary(NewsCloumnCutUtil.getHtmlText(100,news.getContent()));
|