123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package com.ruoyi.demo.controller;
- import com.ruoyi.common.core.domain.R;
- import com.ruoyi.demo.constant.RedisContant;
- import com.ruoyi.demo.entity.TopologicalEnterpriseWd;
- import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
- import com.ruoyi.demo.service.TopologicalEnterpriseWdService;
- import com.ruoyi.demo.valida.TopologicalWdListGroup;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.HashMap;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- @RestController
- @RequestMapping("/poi/topologicalEnterpriseWd")
- public class TopologicalEnterpriseWdController {
- @Autowired
- TopologicalEnterpriseWdService topologicalEnterpriseWdService;
- @Autowired
- RedisTemplate redisTemplate;
- @RequestMapping("/list")
- public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
- String md5 = topologicalWdAceeptVo.getHash();
- //2.查看redis中是否存在有缓存
- HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
- if (wdCount != null) {
- return R.ok(wdCount);
- }
- HashMap<String,Object> list = topologicalEnterpriseWdService.list(topologicalWdAceeptVo);
- redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).put(md5,list);
- redisTemplate.expire(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST,RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟
- return R.ok(list);
- }
- }
|