Authored by Lixiaodi

清除资源位缓存

... ... @@ -3,6 +3,7 @@ package com.yohoufo.product.controller;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -16,7 +17,6 @@ import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.cache.Cachable;
import com.yohoufo.common.cache.ControllerCacheAop;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.product.helper.SearchHelpService;
import com.yohoufo.product.request.ProductSearchReq;
... ... @@ -38,8 +38,6 @@ public class ProductSearchController {
private SearchHelpService searchHelpService;
@Autowired
private UfoServiceCaller ufoServiceCaller;
@Autowired
private ControllerCacheAop cacheAop;
@ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐")
@RequestMapping(params = "method=ufo.product.search.list")
... ... @@ -156,6 +154,7 @@ public class ProductSearchController {
@RequestMapping(params = "method=ufo.product.search.saleCalendar")
@IgnoreSession
public ApiResponse searchSaleCalendar(@RequestParam(value = "uid", required = false)Integer uid,
@RequestParam(value = "year_month", required = false)String yearMonth,
@RequestParam(value = "page", required = false)Integer page,
@RequestParam(value = "limit", required = false) Integer limit) {
if (page == null || page < 1) {
... ... @@ -164,8 +163,11 @@ public class ProductSearchController {
if (limit == null || limit < 1) {
limit = 10;
}
if (StringUtils.isBlank(yearMonth)) {
yearMonth = "";
}
LOG.info("in method=ufo.product.search.saleCalendar uid={}, page={}, limit={}", uid, page, limit);
JSONObject productJson = productSearchService.searchSaleCalendar(page, limit);
JSONObject productJson = productSearchService.searchSaleCalendar(yearMonth, page, limit);
productSearchService.processUserFavoriteProductList(productJson, uid);
return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.saleCalendar").data(productJson).build();
}
... ...
... ... @@ -84,6 +84,8 @@ public final class SearchConstants {
String SOON_SALE = "isSoonSale";
String NOT_ID = "not_id";
String FILTER_YEAR_MONTH = "filter_year_month";
}
... ...
... ... @@ -50,7 +50,7 @@ public class SearchParam {
.setQuery(req.getQuery()).setSoonSale(req.getIsSoonSale())
.setProductPool(req.getPool()).setId(req.getId()).setIdFilter(req.getIsIdFilter())
.setViewNum(req.getViewNum()).setPage(req.getPage())
.setBrandSeries(req.getSeries()).setGender(req.getGender());
.setBrandSeries(req.getSeries()).setGender(req.getGender()).setFilterYearMonth(req.getFilterYearMonth());
return this;
}
... ... @@ -58,7 +58,8 @@ public class SearchParam {
setOrder(req.getOrder()).setBrand(req.getBrand()).setSize(req.getSize())
.setMaxSort(req.getMaxSort()).setMidSort(req.getMidSort())
.setQuery(req.getQuery()).setSoonSale(req.getIsSoonSale())
.setProductPool(req.getPool()).setBrandSeries(req.getSeries()).setGender(req.getGender()).setNotId(req.getNot_id());
.setProductPool(req.getPool()).setBrandSeries(req.getSeries()).setGender(req.getGender()).setNotId(req.getNot_id())
.setFilterYearMonth(req.getFilterYearMonth());;
return this;
}
... ... @@ -191,6 +192,13 @@ public class SearchParam {
}
return this;
}
public SearchParam setFilterYearMonth(String yearMonth) {
if (StringUtils.isNotBlank(yearMonth)) {
param.put(SearchConstants.IndexNameConstant.FILTER_YEAR_MONTH, yearMonth);
}
return this;
}
/**
* 设置id
... ...
... ... @@ -19,6 +19,7 @@ public class ProductSearchReq {
private String isSoonSale; //Y saletime查了大于now的
private String not_id;
private String isIdFilter;
private String filterYearMonth;
@Override
... ... @@ -39,6 +40,7 @@ public class ProductSearchReq {
.append("not_id", not_id)
.append("id", id)
.append("isIdFilter", isIdFilter)
.append("filterYearMonth",filterYearMonth)
.toString();
}
... ... @@ -174,7 +176,15 @@ public class ProductSearchReq {
return isIdFilter;
}
public ProductSearchReq setIsIdFilter(Integer type) {
public String getFilterYearMonth() {
return filterYearMonth;
}
public void setFilterYearMonth(String filterYearMonth) {
this.filterYearMonth = filterYearMonth;
}
public ProductSearchReq setIsIdFilter(Integer type) {
if (type != null && type.equals(Integer.valueOf(7))) {
this.isIdFilter = "Y";
}
... ...
... ... @@ -27,7 +27,7 @@ public interface ProductSearchService {
List<ProductBrandSeriesResp> searchSeriesList();
JSONObject searchSaleCalendar(Integer page, Integer limit);
JSONObject searchSaleCalendar(String yearMonth, Integer page, Integer limit);
JSONObject searchHotSale(Integer page, Integer limit);
... ...
... ... @@ -387,8 +387,9 @@ public class ProductSearchServiceImpl implements ProductSearchService {
@Override
@Cachable(expire=180)
public JSONObject searchSaleCalendar(Integer page, Integer limit) {
public JSONObject searchSaleCalendar(String yearMonth, Integer page, Integer limit) {
ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page);
req.setFilterYearMonth(yearMonth);
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
JSONObject data = search(searchParam.getParam(), SALE_CALENDAR_LIST_URL);
// 将图片的相对路径转成绝对路径
... ...
... ... @@ -5,17 +5,22 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yoho.tools.docs.ApiOperation;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.resource.request.ResourcesRequest;
import com.yohoufo.resource.service.IResourcesService;
@RestController
@ServiceDesc("resources")
public class ResourcesController {
private static final Logger logger = LoggerFactory.getLogger(ResourcesController.class);
... ... @@ -46,12 +51,14 @@ public class ResourcesController {
}
@ApiOperation(name = "ufo.resource.clearCache", desc="资源位清除缓存")
@RequestMapping(params = "method=ufo.resource.clearCache")
@ApiOperation(name = "clearResourceCache", desc="资源位清除缓存")
@RequestMapping(params = "/clearResourceCache")
@IgnoreSession
@IgnoreSignature
@ResponseBody
public ApiResponse getResource(@RequestParam(name = "content_code") String contentCode) {
public ApiResponse clearResourceCache(@RequestBody String contentCode) {
logger.info("ufo.resource.clearCache content_code={}", contentCode);
logger.info("ufo.resource.clearCache contentCode={}", contentCode);
resourcesService.clearCache(contentCode);
return new ApiResponse.ApiResponseBuilder().data(null).code(200).message("resources data").build();
}
... ...
... ... @@ -85,7 +85,7 @@ public class ResourcesServiceImpl implements IResourcesService {
@Override
public void clearCache(String contentCode) {
String[] clientType = { "android", "ios" };
String[] clientType = { "android", "ios" ,"miniapp","H5"};
for (String ct : clientType) {
try {
RedisKeyBuilder cacheKey = CacheEnum.RESOURCE_GET.generateKeyLowerCase(contentCode, ct);
... ...