数据进行缓存

This commit is contained in:
xbx 2024-05-20 12:22:26 +08:00
parent 182f2913c6
commit 78c1a6a44a
1 changed files with 5 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import org.jeecg.modules.service.CenterService;
import org.jeecg.modules.service.ICet_4Service; import org.jeecg.modules.service.ICet_4Service;
import org.jeecg.modules.service.ICet_6Service; import org.jeecg.modules.service.ICet_6Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -59,17 +60,16 @@ public class CenterController {
* 依据学院和年级获取四级和六级通过数据 * 依据学院和年级获取四级和六级通过数据
*/ */
@GetMapping(value = "/getData") @GetMapping(value = "/getData")
// @Cacheable(value = "getData", key = "'getData'+#college+#grade") @Cacheable(value = "getData", key = "'getData' + #college+#major+#entrydate")
public Result<JSONObject> getData(@RequestParam("college") String college, @RequestParam("major") String major, @RequestParam("entrydate") String entrydate) { public Result<JSONObject> getData(@RequestParam("college") String college, @RequestParam("major") String major, @RequestParam("entrydate") String entrydate) {
return centerService.getData(college, major, entrydate); return centerService.getData(college, major, entrydate);
} }
@PostMapping("/getAllRate") @PostMapping("/getAllRate")
@Cacheable(value = "getAllRate", key = "'getAllRate' + #webData")
public Result<JSONObject> getAllRate(@RequestBody JSONObject webData) { public Result<JSONObject> getAllRate(@RequestBody JSONObject webData) {
String level= webData.getString("level"); String level= webData.getString("level");
//四六级分开查询 //四六级分开查询
if (level.equals("cet4")) { if (level.equals("cet4")) {
return cet4Service.getAllRate(webData); return cet4Service.getAllRate(webData);
@ -87,6 +87,7 @@ public class CenterController {
} }
@GetMapping("/getRateByAllBatch") @GetMapping("/getRateByAllBatch")
@Cacheable(value = "getRateByAllBatch", key = "'getRateByAllBatch' + #college+#major+#level")
public Result<JSONObject> getRateByAllBatch(@RequestParam("college") String college,@RequestParam("major") String major, @RequestParam("level") String level) { public Result<JSONObject> getRateByAllBatch(@RequestParam("college") String college,@RequestParam("major") String major, @RequestParam("level") String level) {
// System.out.println(college + " " + level); // System.out.println(college + " " + level);
if (level.equals("cet4")) { if (level.equals("cet4")) {
@ -100,6 +101,7 @@ public class CenterController {
} }
} }
@GetMapping("/getRateByBatch") @GetMapping("/getRateByBatch")
@Cacheable(value = "getRateByBatch", key = "'getRateByBatch' + #batch+#college+#level")
public Result<JSONObject> getRateByBatch(@RequestParam("batch")String batch, @RequestParam("college") String college, @RequestParam("level")String level){ public Result<JSONObject> getRateByBatch(@RequestParam("batch")String batch, @RequestParam("college") String college, @RequestParam("level")String level){
if (level.equals("cet4")){ if (level.equals("cet4")){
return cet4Service.getRateByBatch(college,batch); return cet4Service.getRateByBatch(college,batch);