albertshaw 8 years ago
parent
commit
0b691610af

+ 6 - 3
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -67,7 +67,7 @@ public class PublicController extends BaseController {
 
 	@Autowired
 	private IndustryCategoryService	industryCategoryService;
-	
+
 	@Autowired
 	private DistrictGlossoryService	districtGlossoryService;
 
@@ -363,10 +363,10 @@ public class PublicController extends BaseController {
 		}
 		return new Result().data(industryCategoryService.list(pid));
 	}
-	
+
 	@RequestMapping(value = "/findDistrict", method = RequestMethod.GET)
 	@ResponseBody
-	public Result findDistrictGlossory(String id) {
+	public Result findDistrictGlossory(String id, String noCache) {
 		Integer pid = 0;
 		if (StringUtils.isNumeric(id)) {
 			try {
@@ -375,6 +375,9 @@ public class PublicController extends BaseController {
 				pid = 0;
 			}
 		}
+		if (StringUtils.isNotBlank(noCache)) {
+			districtGlossoryService.clear(pid);
+		}
 		return new Result().data(districtGlossoryService.list(pid));
 	}
 

+ 2 - 0
src/main/java/com/goafanti/dataGlossory/service/DistrictGlossoryService.java

@@ -10,4 +10,6 @@ public interface DistrictGlossoryService {
 	
 	public List<DistrictGlossory> list(Integer pid);
 
+	public void clear(Integer pid);
+
 }

+ 7 - 0
src/main/java/com/goafanti/dataGlossory/service/impl/DistrictGlossoryServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
@@ -30,4 +31,10 @@ public class DistrictGlossoryServiceImpl implements DistrictGlossoryService {
 		LoggerUtils.debug(logger, "缓存地区列表:[%s]", pid);
 		return districtGlossoryMapper.findByPid(pid);
 	}
+
+	@Override
+	@CacheEvict(value = "DistrictGlossoryCache", key = "'DistrictGlossory:'+#pid")
+	public void clear(Integer pid) {
+		LoggerUtils.debug(logger, "清除地区列表缓存:[%s]", pid);
+	}
 }