xiongzhu 3 years ago
parent
commit
e01eff0cfd

+ 3 - 2
src/main/java/com/izouma/nineth/service/netease/TeamService.java

@@ -18,6 +18,7 @@ import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -40,8 +41,8 @@ public class TeamService {
     private NeteaseMessageRepo            neteaseMessageRepo;
     private NeteaseMessageRepo            neteaseMessageRepo;
     private AssetRepo                     assetRepo;
     private AssetRepo                     assetRepo;
 
 
-    public Page<Team> all(PageQuery pageQuery) {
-        Long userId = SecurityUtils.getAuthenticatedUser().getId();
+    @Cacheable(value = "teamAll", key = "#userId+'@'+#pageQuery.hashCode()")
+    public Page<Team> all(Long userId, PageQuery pageQuery) {
         Page<Team> teams = teamRepo
         Page<Team> teams = teamRepo
                 .findAll(JpaUtils.toSpecification(pageQuery, Team.class), JpaUtils.toPageRequest(pageQuery));
                 .findAll(JpaUtils.toSpecification(pageQuery, Team.class), JpaUtils.toPageRequest(pageQuery));
         List<Team> content = teams.getContent();
         List<Team> content = teams.getContent();

+ 1 - 4
src/main/java/com/izouma/nineth/web/GPTController.java

@@ -7,9 +7,7 @@ import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.service.SysConfigService;
 import com.izouma.nineth.service.SysConfigService;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
@@ -17,7 +15,6 @@ import java.util.Map;
 @RestController
 @RestController
 @RequestMapping("/gpt3")
 @RequestMapping("/gpt3")
 @AllArgsConstructor
 @AllArgsConstructor
-@NoArgsConstructor
 public class GPTController {
 public class GPTController {
 
 
     private SysConfigService sysConfigService;
     private SysConfigService sysConfigService;

+ 1 - 1
src/main/java/com/izouma/nineth/web/netease/TeamController.java

@@ -91,7 +91,7 @@ public class TeamController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     @PostMapping("/all")
     public Page<Team> all(@RequestBody PageQuery pageQuery) {
     public Page<Team> all(@RequestBody PageQuery pageQuery) {
-        return teamService.all(pageQuery);
+        return teamService.all(SecurityUtils.getAuthenticatedUser().getId(), pageQuery);
     }
     }
 
 
     @GetMapping("/get/{id}")
     @GetMapping("/get/{id}")