|
|
@@ -2,17 +2,23 @@ package com.kede.linksAndHot.service.impl;
|
|
|
|
|
|
import com.kede.common.dao.PopularCitiesMapper;
|
|
|
import com.kede.common.model.Links;
|
|
|
+import com.kede.common.utils.LoggerUtils;
|
|
|
import com.kede.core.mybatis.BaseMybatisDao;
|
|
|
import com.kede.linksAndHot.bo.InputLinksList;
|
|
|
import com.kede.linksAndHot.bo.InputPopularCities;
|
|
|
import com.kede.linksAndHot.bo.InputPopularCitiesList;
|
|
|
+import com.kede.linksAndHot.bo.outPopularCitiesList;
|
|
|
import com.kede.linksAndHot.service.PopularCitiesService;
|
|
|
+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;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
@@ -21,6 +27,8 @@ public class PopularCitiesServiceImpl extends BaseMybatisDao<PopularCitiesMapper
|
|
|
@Autowired
|
|
|
private PopularCitiesMapper popularCitiesMapper;
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(PopularCitiesServiceImpl.class);
|
|
|
+
|
|
|
@Override
|
|
|
public int add(InputPopularCities in) {
|
|
|
return popularCitiesMapper.insertSelective(in);
|
|
|
@@ -35,15 +43,29 @@ public class PopularCitiesServiceImpl extends BaseMybatisDao<PopularCitiesMapper
|
|
|
public Object list(InputPopularCitiesList in) {
|
|
|
Map<String,Object> param=new HashMap<>();
|
|
|
if (in.getName()!=null)param.put("name",in.getName());
|
|
|
- if (in.getSortType()!=null)param.put("sortType",in.getSortType());
|
|
|
- if(in.getStatus()!=null)param.put("status",in.getStatus());
|
|
|
+ if (in.getSortType()!=null){
|
|
|
+ param.put("sortType",in.getSortType());
|
|
|
+ }else{
|
|
|
+ param.put("sortType",0);
|
|
|
+ }
|
|
|
+ if(in.getStatus()!=null){
|
|
|
+ param.put("status",in.getStatus());
|
|
|
+ }
|
|
|
return findPage("popularCitiesList","popularCitiesCount",param, in.getPageNo(), in.getPageSize());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object getAllpopularCities() {
|
|
|
+ @Cacheable(value="getAllpopularCities", key = "'popularCities'+'All'")
|
|
|
+ public List<outPopularCitiesList> getAllpopularCities() {
|
|
|
+ LoggerUtils.debug(logger, "热门城市缓存");
|
|
|
Map<String,Object> param=new HashMap<>();
|
|
|
- param.put("status",1);
|
|
|
- return findList("popularCitiesList",param,1,9999);
|
|
|
+ param.put("status",0);
|
|
|
+ return (List<outPopularCitiesList>) findList("popularCitiesList",param,1,9999);
|
|
|
+ }
|
|
|
+
|
|
|
+ @CacheEvict(value = "getAllLinks", allEntries = true)
|
|
|
+ public int cleanAllpopularCities() {
|
|
|
+ LoggerUtils.debug(logger, "清除热门城市缓存");
|
|
|
+ return 1;
|
|
|
}
|
|
|
}
|