TopologicalEnterpriseWdController.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.ruoyi.demo.controller;
  2. import com.ruoyi.common.core.domain.R;
  3. import com.ruoyi.demo.constant.RedisContant;
  4. import com.ruoyi.demo.entity.TopologicalEnterpriseWd;
  5. import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
  6. import com.ruoyi.demo.service.TopologicalEnterpriseWdService;
  7. import com.ruoyi.demo.valida.TopologicalWdListGroup;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.data.redis.core.RedisTemplate;
  10. import org.springframework.validation.annotation.Validated;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.concurrent.TimeUnit;
  16. @RestController
  17. @RequestMapping("/poi/topologicalEnterpriseWd")
  18. public class TopologicalEnterpriseWdController {
  19. @Autowired
  20. TopologicalEnterpriseWdService topologicalEnterpriseWdService;
  21. @Autowired
  22. RedisTemplate redisTemplate;
  23. @RequestMapping("/list")
  24. public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
  25. String md5 = topologicalWdAceeptVo.getHash();
  26. //2.查看redis中是否存在有缓存
  27. HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
  28. if (wdCount != null) {
  29. return R.ok(wdCount);
  30. }
  31. HashMap<String,Object> list = topologicalEnterpriseWdService.list(topologicalWdAceeptVo);
  32. redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).put(md5,list);
  33. redisTemplate.expire(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST,RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟
  34. return R.ok(list);
  35. }
  36. }