|
|
@@ -2,12 +2,20 @@ package com.izouma.nineth.service;
|
|
|
|
|
|
import com.izouma.nineth.domain.News;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
+import com.izouma.nineth.dto.excel.NewsDTO;
|
|
|
+import com.izouma.nineth.dto.excel.NoticeDTO;
|
|
|
import com.izouma.nineth.repo.NewsRepo;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.jpa.repository.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class NewsService {
|
|
|
@@ -17,4 +25,28 @@ public class NewsService {
|
|
|
public Page<News> all(PageQuery pageQuery) {
|
|
|
return newsRepo.findAll(JpaUtils.toSpecification(pageQuery, News.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
|
+
|
|
|
+ public NewsDTO newsInfo() {
|
|
|
+ PageQuery pageQuery = new PageQuery();
|
|
|
+ pageQuery.setPage(0);
|
|
|
+ pageQuery.setSize(100000);
|
|
|
+ Map<String, Object> query = new HashMap<>();
|
|
|
+ query.put("del", false);
|
|
|
+ query.put("companyId", 1L);
|
|
|
+ pageQuery.setSort("sort,desc");
|
|
|
+ pageQuery.setQuery(query);
|
|
|
+ List<News> content = all(pageQuery).getContent();
|
|
|
+ List<NoticeDTO> resultDTOs = new ArrayList<>();
|
|
|
+ content.forEach(news -> {
|
|
|
+ NoticeDTO dto = new NoticeDTO();
|
|
|
+ dto.setId(news.getId().toString());
|
|
|
+ dto.setTitle(news.getTitle());
|
|
|
+ dto.setImageUrl(news.getPic());
|
|
|
+ dto.setLink("https://raex.vip/9th/newsDetail?id=" + news.getId());
|
|
|
+ resultDTOs.add(dto);
|
|
|
+ });
|
|
|
+ NewsDTO newsDTO = new NewsDTO();
|
|
|
+ newsDTO.setData(resultDTOs);
|
|
|
+ return newsDTO;
|
|
|
+ }
|
|
|
}
|