jiangqs
2023-05-25 3183d1a910d72eefb96d4cb72f556a54a5d2f874
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppHomeController.java
@@ -2,8 +2,11 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.goods.domain.dto.AppRecommendGoodsPageDto;
import com.ruoyi.system.api.constant.AppErrorConstant;
import com.ruoyi.system.api.domain.dto.AppPageDto;
import com.ruoyi.goods.domain.dto.AppSearchGoodsPageDto;
import com.ruoyi.goods.domain.dto.AppShopGoodsPageDto;
@@ -45,25 +48,24 @@
    @RequestMapping(value = "/pageRecommendGoods", method = RequestMethod.POST)
    @ApiOperation(value = "推荐商品")
    public R<Page<AppSimpleGoodsVo>> pageRecommendGoods(@RequestBody AppPageDto appPageDto) {
    public R<Page<AppSimpleGoodsVo>> pageRecommendGoods(@RequestBody AppRecommendGoodsPageDto appRecommendGoodsPageDto) {
        Long userId = SecurityUtils.getUserId();
        logger.info("userId-----"+userId.toString());
        Long shopId = null;
        if(userId!=null){
            Member member = memberService.getMember(userId).getData();
            if(member!=null&&member.getRelationShopId()!=null){
                shopId = member.getRelationShopId();
            }
        }else{
            shopId = appRecommendGoodsPageDto.getPositionShopId();
        }
        if(shopId==null){
            shopId = 1L;
            throw new ServiceException(AppErrorConstant.NO_POSITION);
        }
        Page<AppSimpleGoodsVo> page = new Page<>();
        page.setSize(appPageDto.getPageSize());
        page.setCurrent(appPageDto.getPageNum());
        //logger.info("shopId"+shopId.toString());
        page.setSize(appRecommendGoodsPageDto.getPageSize());
        page.setCurrent(appRecommendGoodsPageDto.getPageNum());
        List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsService.pageRecommendGoods(page,shopId);
        //logger.info("appSimpleGoodsVoList"+appSimpleGoodsVoList.toString());
        return R.ok(page.setRecords(appSimpleGoodsVoList));
    }
@@ -76,8 +78,11 @@
            if(member!=null&&member.getRelationShopId()!=null){
                appShopGoodsPageDto.setShopId(member.getRelationShopId());
            }else{
                appShopGoodsPageDto.setShopId(1L);
                appShopGoodsPageDto.setShopId(appShopGoodsPageDto.getPositionShopId());
            }
        }
        if(appShopGoodsPageDto.getShopId()==null){
            throw new ServiceException(AppErrorConstant.NO_POSITION);
        }
        Page<AppSimpleGoodsVo> page = new Page<>();
        page.setSize(appShopGoodsPageDto.getPageSize());
@@ -95,8 +100,11 @@
            if(member!=null&&member.getRelationShopId()!=null){
                appSearchGoodsPageDto.setShopId(member.getRelationShopId());
            }else{
                appSearchGoodsPageDto.setShopId(1L);
                appSearchGoodsPageDto.setShopId(appSearchGoodsPageDto.getPositionShopId());
            }
        }
        if(appSearchGoodsPageDto.getShopId()==null){
            throw new ServiceException(AppErrorConstant.NO_POSITION);
        }
        Page<AppSimpleGoodsVo> page = new Page<>();
        page.setSize(appSearchGoodsPageDto.getPageSize());
@@ -114,9 +122,12 @@
            if(member!=null&&member.getRelationShopId()!=null){
                appSearchGoodsPageDto.setShopId(member.getRelationShopId());
            }else{
                appSearchGoodsPageDto.setShopId(1L);
                appSearchGoodsPageDto.setShopId(appSearchGoodsPageDto.getPositionShopId());
            }
        }
        if(appSearchGoodsPageDto.getShopId()==null){
            throw new ServiceException(AppErrorConstant.NO_POSITION);
        }
        Page<AppSimpleActivityGoodsVo> page = new Page<>();
        page.setSize(appSearchGoodsPageDto.getPageSize());
        page.setCurrent(appSearchGoodsPageDto.getPageNum());