package com.sqx.modules.shopping.controller.app;


import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.shopping.entity.Coupons;
import com.sqx.modules.shopping.service.CouponsService;
import com.sqx.modules.shopping.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value="自营商城优惠券",tags={"自营商城优惠券"})
@RequestMapping(value = "/app/coupons")
public class AppCouponsController {
    @Autowired
    private CouponsService service;

    @GetMapping("/list")
    @ApiOperation("列表")
    public Result findAll(Integer page, Integer size) {
        return service.findAll(page, size);
    }


    @GetMapping("/find")
    @ApiOperation("查询")
    public Result findOne(Long id) {
        return service.findOne(id);
    }

    @Login
    @GetMapping("/userGet")
    @ApiOperation("用户端领取优惠券")
    public Result userGetCoupons(@RequestAttribute Long userId, Long couponsId) {
        return service.userGetCoupons(userId, couponsId);
    }

    @Login
    @GetMapping("/userCoupons")
    @ApiOperation("用户端优惠券列表")
    public Result userCoupons(@RequestAttribute Long userId) {
        return service.userCoupons(userId);
    }

}
