package com.gree.mall.manager.controller.member;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gree.mall.manager.exception.RemoteServiceException;
import com.gree.mall.manager.helper.ResponseHelper;
import com.gree.mall.manager.logic.member.UserCouponLogic;
import com.gree.mall.manager.plus.entity.UserCoupon;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@Api(value = "券领取记录", tags ={"券领取记录"} )
@RequestMapping(value = "/coupon/receive", produces = "application/json; charset=utf-8")
public class MemberCouponController {

    @Resource
    UserCouponLogic userCouponLogic;

    @GetMapping("/list/page")
    @ApiOperation(value = "领取记录列表")
    public ResponseHelper<Page<UserCoupon>> page(
            HttpServletRequest request,
            @ApiParam(value = "券名称") @RequestParam(required = false) String couponName,
            @ApiParam(value = "券类型") @RequestParam(required = false) String couponType,
//            @ApiParam(value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(value = "结束时间") @RequestParam(required = false) String endTime,
//            @ApiParam(value = "排序json格式[{sortColumn: 'ID', type: true },...] " +
//                    "sortColumn:" +
//                    "type: true=升序 false=倒序")
//            @RequestParam(required = false) String sortJson,
            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
    ) throws RemoteServiceException {
        IPage<UserCoupon> page = userCouponLogic.page(request,couponName, couponType, pageNum, pageSize);
        return ResponseHelper.success(page);
    }
}
