Commit b5f81796 authored by 赵啸非's avatar 赵啸非

添加查询缓存

parent 669632d0
......@@ -12,6 +12,12 @@ public class RedisKey {
public static final String KEY_USER_MENU_CACHE = "user:menu";
/**
* 大厅业务缓存
*/
public static final String KEY_SEARCH_HALL_BUSINESS_CACHE = "base:search:hall:business:";
/**
* 站点业务id缓存
*/
......
......@@ -14,5 +14,4 @@ import lombok.Data;
public class SiteHallVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.site.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.business.model.BusinessEntity;
import com.mortals.xhx.module.site.model.*;
import com.mortals.xhx.module.window.model.WindowBusinessEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -13,27 +18,13 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.site.service.SiteHallService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import static com.mortals.xhx.common.key.RedisKey.*;
/**
* 站点大厅信息
......@@ -47,6 +38,8 @@ public class SiteHallController extends BaseCRUDJsonBodyMappingController<SiteHa
@Autowired
private ParamService paramService;
@Autowired
private ICacheService cacheService;
public SiteHallController() {
super.setModuleDesc("站点大厅信息");
......@@ -71,7 +64,19 @@ public class SiteHallController extends BaseCRUDJsonBodyMappingController<SiteHa
String busiDesc = "根据大厅查询所属业务";
int code = VALUE_RESULT_SUCCESS;
try {
Rest<List<BusinessEntity>> rest = this.service.getBusinessByHall(siteHall, getContext());
if (ObjectUtils.isEmpty(siteHall.getId())) {
return Rest.fail("大厅ID不能为空!");
}
Rest<List<BusinessEntity>> rest = null;
String cacheResult = cacheService.get(KEY_SEARCH_HALL_BUSINESS_CACHE + siteHall.getId(), String.class);
if (!ObjectUtils.isEmpty(cacheResult)) {
rest = JSON.parseObject(cacheResult, new TypeReference<Rest<List<BusinessEntity>>>() {
});
} else {
//查询数据库
rest = this.service.getBusinessByHall(siteHall, getContext());
cacheService.set(KEY_SEARCH_HALL_BUSINESS_CACHE + siteHall.getId(), JSON.toJSONString(rest), KEY_SEARCH_TIMEOUTT_CACHE);
}
if (!ObjectUtils.isEmpty(getContext()) && !ObjectUtils.isEmpty(getContext().getUser())) {
recordSysLog(request, busiDesc + " 【成功】");
......
......@@ -17,13 +17,13 @@ Content-Type: application/json
POST {{baseUrl}}/window/business/interlist
Content-Type: application/json
{"windowId":1,"size":-1,"searchCache": 1}
{"windowId":1,"size":-1}
###窗口业务列表缓存3
POST {{baseUrl}}/window/business/interlist
Content-Type: application/json
{"windowIdList":["77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99"],"size":-1}
{"searchCache": 1,"windowIdList":["78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99"],"size":-1}
###窗口业务更新与保存
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment