Authored by Lixiaodi

解析两张图修改

... ... @@ -44,4 +44,15 @@ public class ResourcesController {
request.getClientType());
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("resources data").build();
}
@ApiOperation(name = "ufo.resource.clearCache", desc="资源位清除缓存")
@RequestMapping(params = "method=ufo.resource.clearCache")
@ResponseBody
public ApiResponse getResource(@RequestParam(name = "content_code") String contentCode) {
logger.info("ufo.resource.clearCache content_code={}", contentCode);
resourcesService.clearCache(contentCode);
return new ApiResponse.ApiResponseBuilder().data(null).code(200).message("resources data").build();
}
}
... ...
... ... @@ -14,4 +14,6 @@ public interface IResourcesService {
*/
List<Object> get(ResourcesRequest request);
void clearCache(String contentCode);
}
... ...
... ... @@ -83,6 +83,20 @@ public class ResourcesServiceImpl implements IResourcesService {
resourcesRedisCache.setEx(cacheKey, list, CacheEnum.RESOURCE_GET.getCacheTime()); return list;
}
@Override
public void clearCache(String contentCode) {
String[] clientType = { "android", "ios" };
for (String ct : clientType) {
try {
RedisKeyBuilder cacheKey = CacheEnum.RESOURCE_GET.generateKeyLowerCase(contentCode, ct);
log.info("清除资源位缓存 contentCode={},clientType={}", contentCode, ct);
resourcesRedisCache.delete(cacheKey);
} catch (Exception e) {
log.error("清除资源位缓存错误 contentCode={},clientType={}, err={}", contentCode, ct, e.getMessage());
}
}
}
private void validateRequestForGet(ResourcesRequest request) {
if (StringUtils.isEmpty(request.getContentCode())) {
log.warn("Content code is empty.");
... ...
... ... @@ -44,12 +44,10 @@ public class TwoPictureResourceParse implements IResourceParse {
// 处理 data(充分利用原数据库中数据转成的JSONObject,只是遍历之后把URLObject替换成解析之后的数据)
JSONObject data = resource.getData().getJSONObject("data");
returnJSON.put("template_name",this.TEMPLATE_NAME);
returnJSON.put("template_name",TEMPLATE_NAME);
// 处理 两张图的list
for (String index: data.getJSONObject("list").keySet()) {
makeUrl(data.getJSONObject("list").getJSONObject(index), resource.getClientType());
for (String index: data.keySet()) {
makeUrl(data.getJSONObject(index), resource.getClientType());
}
returnJSON.put("data",data);
return returnJSON;
... ...