添加多学院对比查询缓存

This commit is contained in:
Cool 2024-05-31 20:39:05 +08:00
parent 6b390b6788
commit 40916c76d6
1 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import org.jeecg.modules.mapper.Cet_4Mapper;
import org.jeecg.modules.service.CenterService;
import org.jeecg.modules.service.ICet_4Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -41,6 +42,10 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
@Resource
private Cet4_majorMapper cet4_majorMapper;
@Resource
private RedisTemplate<String,Object> redisTemplate;
@Override
public Result<JSONObject> getRateByAllBatch(String college, String major) {
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
@ -285,6 +290,10 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
@Override
public Result<JSONObject> getRateByCollege(JSONObject webData) {
if (redisTemplate.opsForValue().get("getRateByCollege" + webData) != null) {
return Result.ok((JSONObject) redisTemplate.opsForValue().get("getRateByCollege" + webData));
}
JSONArray colleges = webData.getJSONArray("college");
JSONArray entryDateArray = webData.getJSONArray("entrydate");
//获取所有batch
@ -362,6 +371,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
oneEntryDate.put((String) collegeName, ans);
}
result.put("data", oneEntryDate);
redisTemplate.opsForValue().set("getRateByCollege" + webData, result);
return Result.ok(result);
}