Browse Source

Merge branch 'master' of http://git.izouma.com/xiongzhu/raex_back into dev-meta-dz

LH 3 years ago
parent
commit
e73d114f00

+ 14 - 0
src/main/java/com/izouma/nineth/dto/excel/NewsDTO.java

@@ -0,0 +1,14 @@
+package com.izouma.nineth.dto.excel;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class NewsDTO {
+    private List<NoticeDTO> data;
+}

+ 15 - 0
src/main/java/com/izouma/nineth/dto/excel/NoticeDTO.java

@@ -0,0 +1,15 @@
+package com.izouma.nineth.dto.excel;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class NoticeDTO {
+    private String id;
+    private String title;
+    private String imageUrl;
+    private String link;
+}

+ 1 - 0
src/main/java/com/izouma/nineth/security/WebSecurityConfig.java

@@ -179,6 +179,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/gpt3/**").permitAll()
                 .antMatchers("/gpt3/**").permitAll()
                 .antMatchers("/metaSwitch/*/findSwitch").permitAll()
                 .antMatchers("/metaSwitch/*/findSwitch").permitAll()
                 .antMatchers("/metaResources/getUrl").permitAll()
                 .antMatchers("/metaResources/getUrl").permitAll()
+                .antMatchers("/news/newsInfo").permitAll()
                 // all other requests need to be authenticated
                 // all other requests need to be authenticated
                 .anyRequest().authenticated().and()
                 .anyRequest().authenticated().and()
                 // make sure we use stateless session; session won't be used to
                 // make sure we use stateless session; session won't be used to

+ 4 - 0
src/main/java/com/izouma/nineth/service/CacheService.java

@@ -122,6 +122,10 @@ public class CacheService {
     public void clearNews(Long id) {
     public void clearNews(Long id) {
     }
     }
 
 
+    @CacheEvict(value = "newsInfo", allEntries = true)
+    public void clearNewsInfo() {
+    }
+
     @Scheduled(cron = "0 0 0 * * ?")
     @Scheduled(cron = "0 0 0 * * ?")
     @CacheEvict(value = "fixedTop", allEntries = true)
     @CacheEvict(value = "fixedTop", allEntries = true)
     public void clearFixedTop() {
     public void clearFixedTop() {

+ 32 - 0
src/main/java/com/izouma/nineth/service/NewsService.java

@@ -2,12 +2,20 @@ package com.izouma.nineth.service;
 
 
 import com.izouma.nineth.domain.News;
 import com.izouma.nineth.domain.News;
 import com.izouma.nineth.dto.PageQuery;
 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.repo.NewsRepo;
 import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.JpaUtils;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @Service
 @Service
 @AllArgsConstructor
 @AllArgsConstructor
 public class NewsService {
 public class NewsService {
@@ -17,4 +25,28 @@ public class NewsService {
     public Page<News> all(PageQuery pageQuery) {
     public Page<News> all(PageQuery pageQuery) {
         return newsRepo.findAll(JpaUtils.toSpecification(pageQuery, News.class), JpaUtils.toPageRequest(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;
+    }
 }
 }

+ 2 - 2
src/main/java/com/izouma/nineth/service/sms/AliSmsService.java

@@ -86,7 +86,7 @@ public class AliSmsService implements SmsService {
             if (response.getHttpStatus() != 200) {
             if (response.getHttpStatus() != 200) {
                 throw new BusinessException("发送失败,请稍后再试", response.getHttpStatus() + "," + response.getData());
                 throw new BusinessException("发送失败,请稍后再试", response.getHttpStatus() + "," + response.getData());
             }
             }
-            log.info("send sms response {}", response.getData());
+            log.info("{} send sms response {}", phone, response.getData());
             JSONObject jsonObject = JSON.parseObject(response.getData());
             JSONObject jsonObject = JSON.parseObject(response.getData());
             if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
             if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
                 throw new BusinessException("发送失败,请稍后再试", jsonObject.getString("Message"));
                 throw new BusinessException("发送失败,请稍后再试", jsonObject.getString("Message"));
@@ -152,7 +152,7 @@ public class AliSmsService implements SmsService {
             if (response.getHttpStatus() != 200) {
             if (response.getHttpStatus() != 200) {
                 log.error("发送失败," + response.getHttpStatus() + "," + response.getData());
                 log.error("发送失败," + response.getHttpStatus() + "," + response.getData());
             }
             }
-            log.info("send sms response {}", response.getData());
+            log.info("{} send sms response {}", phone, response.getData());
             JSONObject jsonObject = JSON.parseObject(response.getData());
             JSONObject jsonObject = JSON.parseObject(response.getData());
             if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
             if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
                 log.error("发送失败," + jsonObject.getString("Message"));
                 log.error("发送失败," + jsonObject.getString("Message"));

+ 8 - 0
src/main/java/com/izouma/nineth/web/NewsController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import com.izouma.nineth.domain.News;
 import com.izouma.nineth.domain.News;
 import com.izouma.nineth.domain.NewsLike;
 import com.izouma.nineth.domain.NewsLike;
 import com.izouma.nineth.domain.User;
 import com.izouma.nineth.domain.User;
+import com.izouma.nineth.dto.excel.NewsDTO;
 import com.izouma.nineth.repo.NewsLikeRepo;
 import com.izouma.nineth.repo.NewsLikeRepo;
 import com.izouma.nineth.service.CacheService;
 import com.izouma.nineth.service.CacheService;
 import com.izouma.nineth.service.NewsService;
 import com.izouma.nineth.service.NewsService;
@@ -43,6 +44,7 @@ public class NewsController extends BaseController {
             ObjUtils.merge(orig, record);
             ObjUtils.merge(orig, record);
             orig = newsRepo.save(orig);
             orig = newsRepo.save(orig);
             cacheService.clearNews(orig.getId());
             cacheService.clearNews(orig.getId());
+            cacheService.clearNewsInfo();
             return orig;
             return orig;
         }
         }
         return newsRepo.save(record);
         return newsRepo.save(record);
@@ -82,5 +84,11 @@ public class NewsController extends BaseController {
         List<News> data = all(pageQuery).getContent();
         List<News> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
         ExcelUtils.export(response, data);
     }
     }
+
+    @PostMapping("/newsInfo")
+    @Cacheable("newsInfo")
+    public NewsDTO newsInfo() {
+        return newsService.newsInfo();
+    }
 }
 }