|
|
|
@ -1,9 +1,11 @@ |
|
|
|
|
package com.cweb.controller.cms; |
|
|
|
|
|
|
|
|
|
import com.hfkj.common.utils.RedisUtil; |
|
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hfkj.entity.CmsContent; |
|
|
|
|
import com.hfkj.entity.GoodsMsg; |
|
|
|
|
import com.hfkj.entity.GoodsSpecs; |
|
|
|
|
import com.hfkj.model.BsMerModel; |
|
|
|
|
import com.hfkj.model.CmsContentModel; |
|
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
|
import com.hfkj.model.goods.GoodsModel; |
|
|
|
@ -16,6 +18,7 @@ import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
@ -37,35 +40,43 @@ public class CmsContentController { |
|
|
|
|
|
|
|
|
|
Logger log = LoggerFactory.getLogger(CmsContentController.class); |
|
|
|
|
|
|
|
|
|
// 缓存前缀KEY
|
|
|
|
|
public final static String CACHE_KEY = "CMS:"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private CmsContentService cmsContentService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GoodsMsgService goodsMsgService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GoodsSpecsService goodsSpecsService; |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/getCms",method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询列表") |
|
|
|
|
public ResponseData getCms(@RequestParam(value = "code" , required = false) String code, |
|
|
|
|
@RequestParam(value = "platformCode" , required = false) String platformCode) { |
|
|
|
|
try { |
|
|
|
|
List<CmsContentModel> cmsContents = new ArrayList<>(); |
|
|
|
|
Object cacheObj = redisUtil.get(CACHE_KEY+code+platformCode); |
|
|
|
|
if (cacheObj != null) { |
|
|
|
|
cmsContents = (List<CmsContentModel>) cacheObj; |
|
|
|
|
} else { |
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
map.put("code", code); |
|
|
|
|
if (platformCode == null) { |
|
|
|
|
platformCode = "WXAPPLETS"; |
|
|
|
|
} |
|
|
|
|
map.put("status", 1); |
|
|
|
|
map.put("platformCode", platformCode); |
|
|
|
|
List<CmsContent> list = cmsContentService.getList(map); |
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
map.put("code", code); |
|
|
|
|
if (platformCode == null) { |
|
|
|
|
platformCode = "WXAPPLETS"; |
|
|
|
|
} |
|
|
|
|
map.put("status", 1); |
|
|
|
|
map.put("platformCode", platformCode); |
|
|
|
|
List<CmsContent> list = cmsContentService.getList(map); |
|
|
|
|
|
|
|
|
|
List<CmsContentModel> cmsContents = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (CmsContent cmsContent : list) { |
|
|
|
|
List<JdGoodsModel> goodsModels = new ArrayList<>(); |
|
|
|
|
for (CmsContent cmsContent : list) { |
|
|
|
|
List<JdGoodsModel> goodsModels = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> goodsMap = new HashMap<>(); |
|
|
|
@ -74,43 +85,47 @@ public class CmsContentController { |
|
|
|
|
|
|
|
|
|
List<JdGoodsModel> goodsMsgs = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
if (cmsContent.getAutomatic() == 1) { |
|
|
|
|
goodsMap.put("goodsType", cmsContent.getShowDataId()); |
|
|
|
|
if (cmsContent.getShowDataId() != null) { |
|
|
|
|
cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); |
|
|
|
|
if (cmsContent.getAutomatic() == 1) { |
|
|
|
|
goodsMap.put("goodsType", cmsContent.getShowDataId()); |
|
|
|
|
if (cmsContent.getShowDataId() != null) { |
|
|
|
|
cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&goodsType=" + cmsContent.getShowDataId()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); |
|
|
|
|
goodsMap.put("automaticCode" , cmsContent.getId()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
cmsContent.setJumpUrl(cmsContent.getJumpUrl() + "&automaticCode=" + cmsContent.getId()); |
|
|
|
|
goodsMap.put("automaticCode" , cmsContent.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( cmsContent.getShowType() != null && cmsContent.getShowType() == 1) { |
|
|
|
|
if ( cmsContent.getShowType() != null && cmsContent.getShowType() == 1) { |
|
|
|
|
|
|
|
|
|
goodsMap.put("limit" , 2); |
|
|
|
|
goodsMsgs = goodsMsgService.getListCrest(goodsMap); |
|
|
|
|
} |
|
|
|
|
if (cmsContent.getShowType() != null && cmsContent.getShowType() == 2) { |
|
|
|
|
goodsMap.put("limit" , 2); |
|
|
|
|
goodsMsgs = goodsMsgService.getListCrest(goodsMap); |
|
|
|
|
} |
|
|
|
|
if (cmsContent.getShowType() != null && cmsContent.getShowType() == 2) { |
|
|
|
|
|
|
|
|
|
goodsMap.put("limit" , 4); |
|
|
|
|
goodsMap.put("saleNum" , 2); |
|
|
|
|
goodsMap.put("limit" , 4); |
|
|
|
|
goodsMap.put("saleNum" , 2); |
|
|
|
|
|
|
|
|
|
goodsMsgs = goodsMsgService.getListCrest(goodsMap); |
|
|
|
|
} |
|
|
|
|
if (cmsContent.getShowType() != null && cmsContent.getShowType() == 3) { |
|
|
|
|
goodsMsgs = goodsMsgService.getListCrest(goodsMap); |
|
|
|
|
} |
|
|
|
|
if (cmsContent.getShowType() != null && cmsContent.getShowType() == 3) { |
|
|
|
|
|
|
|
|
|
goodsMap.put("limit" , 10); |
|
|
|
|
goodsMap.put("type" , 1); |
|
|
|
|
goodsMsgs = goodsMsgService.getListCrest(goodsMap); |
|
|
|
|
} |
|
|
|
|
goodsMap.put("limit" , 10); |
|
|
|
|
goodsMap.put("type" , 1); |
|
|
|
|
goodsMsgs = goodsMsgService.getListCrest(goodsMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goodsModels.addAll(goodsMsgs); |
|
|
|
|
|
|
|
|
|
CmsContentModel cmsContentModel = new CmsContentModel(); |
|
|
|
|
CmsContentModel cmsContentModel = new CmsContentModel(); |
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(cmsContent, cmsContentModel); |
|
|
|
|
cmsContentModel.setGoodsMsgList(goodsModels); |
|
|
|
|
cmsContents.add(cmsContentModel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(cmsContent, cmsContentModel); |
|
|
|
|
cmsContentModel.setGoodsMsgList(goodsModels); |
|
|
|
|
cmsContents.add(cmsContentModel); |
|
|
|
|
// 更新缓存
|
|
|
|
|
cmsContentService.cache(cmsContents , code+platformCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(cmsContents); |
|
|
|
|