|
|
|
@ -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;
|
|
|
|
|