Commit 7fd2781b authored by 赵啸非's avatar 赵啸非

添加主题缓存

parent f92de300
package com.mortals.xhx.module.site.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.annotation.UnAuth;
......@@ -19,8 +20,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
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.model.SiteThemeEntity;
import com.mortals.xhx.module.site.service.SiteThemeService;
......@@ -29,26 +32,28 @@ import com.mortals.framework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 主题
*
* @author zxfei
* @date 2022-11-23
*/
* 主题
*
* @author zxfei
* @date 2022-11-23
*/
@RestController
@RequestMapping("site/theme")
public class SiteThemeController extends BaseCRUDJsonBodyMappingController<SiteThemeService,SiteThemeEntity,Long> {
public class SiteThemeController extends BaseCRUDJsonBodyMappingController<SiteThemeService, SiteThemeEntity, Long> {
@Autowired
private ICacheService cacheService;
public SiteThemeController(){
super.setModuleDesc( "主题");
public SiteThemeController() {
super.setModuleDesc("主题");
}
@Override
......@@ -64,17 +69,34 @@ public class SiteThemeController extends BaseCRUDJsonBodyMappingController<SiteT
@UnAuth
public String getThemeCacheBySite(@RequestBody SiteThemeEntity site) {
JSONObject jsonObject = new JSONObject();
List<SiteThemeEntity> siteThemeList = new ArrayList<>();
String busiDesc = "根据站点id获取当前站点主题列表" + this.getModuleDesc();
try {
if(ObjectUtils.isEmpty(site.getSiteId())) throw new AppException("站点id不能为空!");
if(ObjectUtils.isEmpty(site.getUserType())) throw new AppException("服务类型不能为空!");
if (ObjectUtils.isEmpty(site.getSiteId())) throw new AppException("站点id不能为空!");
//if(ObjectUtils.isEmpty(site.getUserType())) throw new AppException("服务类型不能为空!");
if (ObjectUtils.isEmpty(site.getUserType())) {
//合并多个
for (int i = 1; i <= 3; i++) {
String jsonstr = cacheService.hget(RedisCacheKeys.getSiteUserTypeThemeCodeKey() + site.getSiteId(), String.valueOf(i), String.class);
if (!ObjectUtils.isEmpty(jsonstr)) {
List<SiteThemeEntity> siteThemeEntities = JSON.parseObject(jsonstr, new TypeReference<List<SiteThemeEntity>>() {
});
if (!ObjectUtils.isEmpty(siteThemeEntities)) {
siteThemeList.addAll(siteThemeEntities);
}
}
}
} else {
String jsonstr = cacheService.hget(RedisCacheKeys.getSiteUserTypeThemeCodeKey() + site.getSiteId(), site.getUserType(), String.class);
List<SiteThemeEntity> siteThemeEntities = JSON.parseObject(jsonstr, new TypeReference<List<SiteThemeEntity>>() {});
if(ObjectUtils.isEmpty(siteThemeEntities)){
jsonObject.put(KEY_RESULT_DATA, new ArrayList<SiteThemeEntity>());
}else{
jsonObject.put(KEY_RESULT_DATA, siteThemeEntities);
if (!ObjectUtils.isEmpty(jsonstr)) {
List<SiteThemeEntity> siteThemeEntities = JSON.parseObject(jsonstr, new TypeReference<List<SiteThemeEntity>>() {
});
if (!ObjectUtils.isEmpty(siteThemeEntities)) {
siteThemeList.addAll(siteThemeEntities);
}
}
}
jsonObject.put(KEY_RESULT_DATA, siteThemeList);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "根据站点id获取当前站点主题列表成功!");
recordSysLog(request, busiDesc + " 【成功】");
......
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