|
|
@@ -2,7 +2,10 @@ package com.izouma.nineth.web;
|
|
|
|
|
|
import com.izouma.nineth.domain.Collection;
|
|
|
import com.izouma.nineth.domain.FileObject;
|
|
|
-import com.izouma.nineth.dto.*;
|
|
|
+import com.izouma.nineth.dto.CollectionDTO;
|
|
|
+import com.izouma.nineth.dto.CreateBlindBox;
|
|
|
+import com.izouma.nineth.dto.PageQuery;
|
|
|
+import com.izouma.nineth.dto.RecommendDTO;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.CollectionRepo;
|
|
|
import com.izouma.nineth.repo.NewsRepo;
|
|
|
@@ -16,16 +19,18 @@ import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
-
|
|
|
@RestController
|
|
|
@RequestMapping("/collection")
|
|
|
@AllArgsConstructor
|
|
|
@@ -36,12 +41,13 @@ public class CollectionController extends BaseController {
|
|
|
private NewsRepo newsRepo;
|
|
|
private CacheService cacheService;
|
|
|
|
|
|
- //@PreAuthorize("hasRole('ADMIN')")
|
|
|
+ @PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
public Collection save(@RequestBody Collection record) {
|
|
|
return collectionService.update(record);
|
|
|
}
|
|
|
|
|
|
+ @PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/create")
|
|
|
public Collection create(@RequestBody Collection record) {
|
|
|
return collectionService.create(record);
|
|
|
@@ -59,10 +65,11 @@ public class CollectionController extends BaseController {
|
|
|
.orElseThrow(new BusinessException("无记录")), true, true);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/del/{id}")
|
|
|
- public void del(@PathVariable Long id) {
|
|
|
- collectionRepo.softDelete(id);
|
|
|
- }
|
|
|
+// @PreAuthorize("hasRole('ADMIN')")
|
|
|
+// @PostMapping("/del/{id}")
|
|
|
+// public void del(@PathVariable Long id) {
|
|
|
+// collectionRepo.softDelete(id);
|
|
|
+// }
|
|
|
|
|
|
@GetMapping("/excel")
|
|
|
@ResponseBody
|
|
|
@@ -91,6 +98,7 @@ public class CollectionController extends BaseController {
|
|
|
return collectionService.toDTO(collectionRepo.userLikes(SecurityUtils.getAuthenticatedUser().getId()));
|
|
|
}
|
|
|
|
|
|
+ @PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/createBlindBox")
|
|
|
public Collection createBlindBox(@RequestBody CreateBlindBox createBlindBox) {
|
|
|
return collectionService.createBlindBox(createBlindBox);
|
|
|
@@ -149,6 +157,7 @@ public class CollectionController extends BaseController {
|
|
|
return recommedDTOS;
|
|
|
}
|
|
|
|
|
|
+ @PreAuthorize("hasRole('ADMIN')")
|
|
|
@GetMapping("/clearRecommend")
|
|
|
public String clearRecommend() {
|
|
|
cacheService.clearRecommend();
|