|
@@ -6,6 +6,7 @@ import com.caimei.modules.product.entity.SearchFrequency;
|
|
import com.caimei.modules.product.entity.SearchFrequencyVo;
|
|
import com.caimei.modules.product.entity.SearchFrequencyVo;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.service.CrudService;
|
|
import com.thinkgem.jeesite.common.service.CrudService;
|
|
|
|
+import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -71,6 +72,22 @@ public class KeywordFrequencyService extends CrudService<KeywordFrequencyDao, Se
|
|
@Transactional(readOnly = false)
|
|
@Transactional(readOnly = false)
|
|
public String delKeyWordById(Integer id){
|
|
public String delKeyWordById(Integer id){
|
|
keywordFrequencyDao.delKeyWordById(id);
|
|
keywordFrequencyDao.delKeyWordById(id);
|
|
|
|
+ //删除缓存中的数据
|
|
|
|
+ SearchFrequency keyById = keywordFrequencyDao.getKeyById(id);
|
|
|
|
+ //根据key值获取数据,如果只有一条则直接删除,大于一条则删除后重新缓存
|
|
|
|
+ if(keyById!=null&& StringUtils.isNoneEmpty(keyById.getKeyword())){
|
|
|
|
+ String str=keyById.getKeyword();
|
|
|
|
+ String key="";
|
|
|
|
+ for(int i=0;i<str.length();i++){
|
|
|
|
+ key+=str.charAt(i);
|
|
|
|
+ redisService.remove(key);
|
|
|
|
+ List<SearchFrequencyVo> searchFrequencyVos = keywordFrequencyDao.getvalueList(key);
|
|
|
|
+ if(null !=searchFrequencyVos&& searchFrequencyVos.size()>0){
|
|
|
|
+ String keyword = JSONObject.toJSONString(searchFrequencyVos);//有值的字段才转
|
|
|
|
+ redisService.set(key,keyword,60L * 60 * 24 * 30);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return "删除关键词成功";
|
|
return "删除关键词成功";
|
|
}
|
|
}
|
|
@Transactional(readOnly = false)
|
|
@Transactional(readOnly = false)
|