This commit is contained in:
hh 2024-03-27 16:22:17 +08:00
parent 2403940d08
commit 7417bfac04
2 changed files with 6 additions and 2 deletions

View File

@ -63,7 +63,7 @@ public class CenterController {
return centerService.getData(college,entrydate); return centerService.getData(college,entrydate);
} }
@PostMapping("/getRateByBatch") @GetMapping("/getRateByBatch")
public Result<JSONObject> getRateByBatch(@RequestParam("batch") Date batch, @RequestParam("level") String level) { public Result<JSONObject> getRateByBatch(@RequestParam("batch") Date batch, @RequestParam("level") String level) {
//四六级分开查询 //四六级分开查询
if (level.equals("cet4")) { if (level.equals("cet4")) {

View File

@ -38,6 +38,10 @@ public class CenterServiceImpl implements CenterService {
*/ */
@Override @Override
public JSONObject getCollege() { public JSONObject getCollege() {
// 判断是否存在缓存 getBatch
if (Boolean.TRUE.equals(redisTemplate.hasKey("getCollege"))) {
return (JSONObject) redisTemplate.opsForValue().get("getCollege");
}
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
// 收集学院名称 // 收集学院名称
LambdaQueryWrapper<Cet_4> Cet_4CollegeQW = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cet_4> Cet_4CollegeQW = new LambdaQueryWrapper<>();
@ -66,7 +70,7 @@ public class CenterServiceImpl implements CenterService {
} }
result.put("colleges", colleges); result.put("colleges", colleges);
// 将数据存入缓存 // 将数据存入缓存
redisTemplate.opsForValue().set("getBatch", result); redisTemplate.opsForValue().set("getCollege", result);
return result; return result;
} }