package com.iformall.controller.market;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;
import com.iformall.service.WxCouponPasswordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gongbiao
 */
@RestController
@RequestMapping("couponPassword")
@Api(description = "免费卡接口")
public class WxCouponPasswordController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxCouponPasswordService wxCouponPasswordService;

    @ApiOperation("分页列表接口")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
    @SystemControllerLog(description = "列表")
    public ResultData list(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::list");
        wxCouponPassword.setTenantId(getTenantId());
        wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC);
        final PageInfo<WxCouponPassword> page = wxCouponPasswordService.listAsPage(wxCouponPassword, pageNum, pageSize);
        return new ResultData(page);
    }

    @ApiOperation("可发送卡数据")
    @GetMapping("/findCouponList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
    @SystemControllerLog(description = "可发送卡数据")
    public ResultData findCouponList(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::findCouponList");
        wxCouponPassword.setTenantId(getTenantId());
        final PageInfo<WxCouponPasswordCountInfoVO> page = wxCouponPasswordService.findCouponList(wxCouponPassword, pageNum, pageSize);
        return new ResultData(page);
    }


}
