Commit 28c8555e authored by 赵啸非's avatar 赵啸非

添加主题缓存

parent 155702e0
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.exception.AppException;
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.common.key.RedisKey;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.window.model.WindowBusinessEntity;
import org.apache.ibatis.cache.CacheKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
......@@ -36,7 +47,7 @@ import static com.mortals.framework.ap.SysConstains.*;
public class SiteThemeController extends BaseCRUDJsonBodyMappingController<SiteThemeService,SiteThemeEntity,Long> {
@Autowired
private ParamService paramService;
private ICacheService cacheService;
public SiteThemeController(){
super.setModuleDesc( "主题");
......@@ -48,4 +59,36 @@ public class SiteThemeController extends BaseCRUDJsonBodyMappingController<SiteT
}
/**
* 根据站点id获取当前站点主题
*/
@PostMapping(value = "site")
@UnAuth
public String getThemeCacheBySite(@RequestBody SiteThemeEntity site) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "根据站点id获取当前站点主题列表" + this.getModuleDesc();
try {
if(ObjectUtils.isEmpty(site.getSiteId()))
throw new AppException("站点id不能为空!");
if(ObjectUtils.isEmpty(site.getUserType()))
throw new AppException("服务类型不能为空!");
String jsonstr = cacheService.hget(RedisCacheKeys.getSiteUserTypeThemeCodeKey() + site.getSiteId(), site.getUserType(), String.class);
List<SiteThemeEntity> siteThemeEntities = JSON.parseObject(jsonstr, new TypeReference<List<SiteThemeEntity>>() {
});
jsonObject.put(KEY_RESULT_DATA, siteThemeEntities);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "根据站点id获取当前站点主题列表成功!");
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
}
\ No newline at end of file
......@@ -115,7 +115,7 @@ POST {{baseUrl}}/site/syncGovMatterBySiteId
Content-Type: application/json
{
"id":23
"id":24
}
......
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