package co.yixiang.yshop.module.product.controller.app.campaigninfo;

import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.module.product.controller.admin.campaigninfo.vo.CampaignInfoRespVO;
import co.yixiang.yshop.module.product.controller.app.campaigninfo.vo.CampaignProductReqVO;
import co.yixiang.yshop.module.product.controller.app.campaigninfo.vo.CampaignProductRespVO;
import co.yixiang.yshop.module.product.service.campaigninfo.AppCampaignInfoService;
import co.yixiang.yshop.module.product.service.campaigninfo.CampaignInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 营销活动")
@RestController
@RequestMapping("/product/campaign")
@Validated
public class AppCampaignController {

    @Resource
    private AppCampaignInfoService appCampaignInfoService;

    @Resource
    private CampaignInfoService campaignInfoService;


    @PostMapping("/product-page")
    @Operation(summary = "获得营销活动商品列表")
    public CommonResult<PageResult<CampaignProductRespVO>> getCampaignProductPage(@RequestBody CampaignProductReqVO reqVO) {
        return success(appCampaignInfoService.getCampaignProductPage(reqVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获得活动信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<CampaignInfoRespVO> getCampaignInfo(@RequestParam("id") Long id) {
        return success(campaignInfoService.getCampaignInfo(id));
    }

}
