package cn.iocoder.yudao.module.inspection.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.appBase.entity.AppSwiper;
import cn.iocoder.yudao.module.appBase.service.IAppSwiperService;
import cn.iocoder.yudao.module.inspection.entity.InspectionNews;
import cn.iocoder.yudao.module.inspection.service.AppInspectionGoodsService;
import cn.iocoder.yudao.module.inspection.service.IInspectionNewsService;
import cn.iocoder.yudao.module.inspection.vo.PartnerListVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import cn.iocoder.yudao.module.core.controller.BaseController;

import java.util.List;

/**
 * 车检商品表(ShopInspectionGoods)表控制层
 *
 * @author makejava
 * @since 2023-08-01 16:04:12
 */
@RestController("AppShopInspectionGoods")
@RequestMapping("/admin-api/appInspection/appHome")
public class AppHomeController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private AppInspectionGoodsService shopInspectionGoodsService;
    @Autowired
    private IInspectionNewsService inspectionNewsService;

    @Autowired
    private IAppSwiperService appSwiperService;

    /**
     * 首页swiper
     */
    @GetMapping("/listSwiper")
    @TenantIgnore
    public CommonResult listSwiper(AppSwiper appSwiper,
                                   @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
                                   @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
    {
        Page<AppSwiper> page = new Page<>(pageNum, pageSize);
        IPage<AppSwiper> list = appSwiperService.selectAppSwiperList(page,appSwiper);
        return success(list);
    }


    /**
     * 首页公告
     */
    @GetMapping("/listNews")
    @TenantIgnore
    public CommonResult listNews()
    {
        List<InspectionNews> list = inspectionNewsService.appHomeNewsList();
        return success(list);
    }



    /**
     * 首页商品推荐
     */
    @GetMapping("/homePartner")
    @TenantIgnore
    public CommonResult homePartner(Double longitude, Double latitude,
                                     @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
                                     @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
    {
        Page<PartnerListVo> page = new Page<>(pageNum, pageSize);
        IPage<PartnerListVo> list = shopInspectionGoodsService.homePartner(page,longitude,latitude);
        return success(list);
    }
}

