/**
 * Copyright (C) 2018-2022
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package co.yixiang.yshop.module.product.controller.app.teamworkinfo;


import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.module.product.controller.admin.teamworkinfo.vo.TeamworkOrderInfoPageReqVO;
import co.yixiang.yshop.module.product.controller.admin.teamworkinfo.vo.TeamworkOrderInfoRespVO;
import co.yixiang.yshop.module.product.controller.app.teamworkinfo.vo.AppTeamworkProductDetailRespVO;
import co.yixiang.yshop.module.product.controller.app.teamworkinfo.vo.AppWaitTeamworkReqVO;
import co.yixiang.yshop.module.product.controller.app.teamworkinfo.vo.AppWaitTeamworkRespVO;
import co.yixiang.yshop.module.product.controller.app.teamworkinfo.vo.AppWaitTeamworkUserRespVO;
import co.yixiang.yshop.module.product.service.teamworkinfo.TeamworkInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

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

/**
 * <p>
 * 拼团
 * </p>
 *
 * @author hupeng
 * @since 2024-01-26
 */
@Slf4j
@RestController
@Tag(name = "用户 APP - 拼团")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/teamwork")
public class AppTeamworkController {


    @Resource
    private TeamworkInfoService teamworkInfoService;

    @GetMapping("/wait-list")
    @Operation(summary = "获得可成团拼团列表")
    public CommonResult<List<AppWaitTeamworkRespVO>> getWaitTeamworkList(@Valid AppWaitTeamworkReqVO pageVO) {
        return success(teamworkInfoService.getWaitTeamworkList(pageVO));
    }

    @GetMapping("/user-list")
    @Operation(summary = "获得拼团用户列表")
    public CommonResult<List<AppWaitTeamworkUserRespVO>> getUserTeamworkList(@RequestParam Long id) {
        return success(teamworkInfoService.getUserTeamworkList(id));
    }

    @GetMapping("/product-detail")
    @Operation(summary = "获得拼团商品详情")
    public CommonResult<AppTeamworkProductDetailRespVO> getProductDetail(@RequestParam Long id) {
        return success(teamworkInfoService.getProductDetail(id));
    }

}

