refactor: 新闻新增学段字段

11111
winter 10 months ago
parent a539afb9e8
commit 9f0cd7d01a

@ -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<News> listNews(String periodId) {
User user = SecurityUtil.getLoginUser();
String schoolId = user.getSchoolId();
List<News> res;
if (StringUtils.isBlank(periodId)) {
res = newsRepository.findAllByCode(String.format(PK.NEWS, schoolId));
} else {
res = newsRepository.findAllByCodeAndPeriodId(String.format(PK.NEWS, schoolId), periodId);
}
List<News> 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;

Loading…
Cancel
Save