package com.matrix.system.shopXcx.api.action; import com.matrix.core.pojo.AjaxResult; import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.shopXcx.bean.ShopAdvertis; import com.matrix.system.shopXcx.bean.ShopAdvertisType; import com.matrix.system.shopXcx.dao.ShopAdvertisDao; import com.matrix.system.shopXcx.dao.ShopAdvertisTypeDao; import com.matrix.system.shopXcx.shopEnum.ShopAdNodeType; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; /** * @author jyy * @description 广告表 * @date 2019-06-05 10:15 */ @CrossOrigin(origins = "*", maxAge = 3600) @Controller @RequestMapping(value = "/wxapi/ad") public class WxAdvertisingAction { @Autowired private ShopAdvertisDao shopAdvertisDao; @Autowired private ShopAdvertisTypeDao shopAdvertisTypeDao; @RequestMapping("/getAdPage") @ResponseBody public AjaxResult getAdPage(@RequestBody ShopAdvertisType shopAdvertisType) { shopAdvertisType.setCompanyId(HostInterceptor.getCompanyId()); List shopAdvertisTypes = shopAdvertisTypeDao.selectByModel(shopAdvertisType); for (ShopAdvertisType advertisType : shopAdvertisTypes) { if (ShopAdNodeType.NODE_TYPE_SWIPER.getCode() == advertisType.getNodeType() || ShopAdNodeType.NODE_TYPE_HUKUAI.getCode() == advertisType.getNodeType() ) { //轮播图类型 List advertisingList = shopAdvertisDao.selectListByTypeId(advertisType.getAdtId(), advertisType.getAdtCapacity()); advertisType.setAds(advertisingList); } } return AjaxResult.buildSuccessInstance(shopAdvertisTypes); } @RequestMapping("/getAdByCode") @ResponseBody public AjaxResult getAdByCode(@RequestBody ShopAdvertis shopAdvertis) { shopAdvertis.setCompanyId(HostInterceptor.getCompanyId()); return AjaxResult.buildSuccessInstance(shopAdvertisDao.selectByModel(shopAdvertis)); } }