package org.jeecg.modules.api.studytourController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.api.bean.PageBean;
import org.jeecg.modules.api.service.CouponService;
import org.jeecg.modules.studytourCouponUser.entity.StudytourCouponUser;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags="优惠券-相关接口")
@RestController
@RequestMapping("/studytour/coupon")
@Slf4j
public class CouponController {

    /******************************************************************************************************************/
    //优惠券信息
    @Resource
    private CouponService couponService;
    /******************************************************************************************************************/

    //优惠券-优惠券列表
    @ApiOperation(value="优惠券-我的优惠券列表", notes="status：0-未使用 1-已使用 2-已失效")
    @RequestMapping(value = "/queryCouponList", method = {RequestMethod.GET})
    public Result<?> queryCouponList(@RequestHeader("X-Access-Token") String token, StudytourCouponUser studytourCouponUser, PageBean pageBean){
        return couponService.queryCouponList(token, studytourCouponUser, pageBean);
    }

    //根据id查看优惠券详情
    @ApiOperation(value="优惠券-根据id查看优惠券详情", notes="优惠券-根据id查看优惠券详情")
    @RequestMapping(value = "/queryCouponById", method = {RequestMethod.GET})
    public Result<?> queryCouponById(@RequestHeader("X-Access-Token") String token, String usercouponId){
        return couponService.queryCouponById(token, usercouponId);
    }

    //查看可领取的优惠券
    @ApiOperation(value="优惠券-查看可领取的优惠券", notes="优惠券-查看可领取的优惠券")
    @RequestMapping(value = "/queryFetchCouponList", method = {RequestMethod.GET})
    public Result<?> queryFetchCouponList(@RequestHeader("X-Access-Token") String token){
        return couponService.queryFetchCouponList(token);
    }

    //领取优惠券
    @ApiOperation(value="优惠券-领取优惠券", notes="优惠券-领取优惠券")
    @RequestMapping(value = "/fetchCoupon", method = {RequestMethod.POST})
    public Result<?> fetchCoupon(@RequestHeader("X-Access-Token") String token, String couponId){
        return couponService.fetchCoupon(token, couponId);
    }

}
