diff --git a/src/main/java/cn/teammodel/service/impl/NewsServiceImpl.java b/src/main/java/cn/teammodel/service/impl/NewsServiceImpl.java index 5425bd9..da8ed3c 100644 --- a/src/main/java/cn/teammodel/service/impl/NewsServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/NewsServiceImpl.java @@ -12,7 +12,6 @@ import cn.teammodel.repository.NewsRepository; import cn.teammodel.security.utils.SecurityUtil; import cn.teammodel.service.NewsService; import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -34,13 +33,7 @@ public class NewsServiceImpl implements NewsService { public List listNews(String periodId) { User user = SecurityUtil.getLoginUser(); String schoolId = user.getSchoolId(); - List res; - - if (StringUtils.isBlank(periodId)) { - res = newsRepository.findAllByCode(String.format(PK.NEWS, schoolId)); - } else { - res = newsRepository.findAllByCodeAndPeriodId(String.format(PK.NEWS, schoolId), periodId); - } + List res = newsRepository.findAllByCodeAndPeriodId(String.format(PK.NEWS, schoolId), periodId); // 降序排序 res = res.stream().sorted((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())).collect(Collectors.toList()); return res;