package com.jeequan.jeepay.mch.ctrl.red;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.db.entity.RedPacketInfo;
import com.jeequan.jeepay.db.entity.RedPacketRule;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.RedPacketInfoService;
import com.jeequan.jeepay.service.impl.RedPacketRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * TODO
 * @author crystal
 * @date 2023/12/6 15:11
 */
@RestController
@RequestMapping("/api/redPacketInfo")
public class RedPacketInfoController extends CommonCtrl {

    @Autowired private RedPacketInfoService redPacketInfoService;

    @PreAuthorize("hasAuthority('ENT_REDPACKET_INFO_LIST')")
    @GetMapping
    public ApiRes list() {
        RedPacketInfo info = getObject(RedPacketInfo.class);
        LambdaQueryWrapper<RedPacketInfo> wrapper = RedPacketInfo.gw();
        wrapper.eq(RedPacketInfo::getMchNo, getCurrentMchNo());
        Page<RedPacketInfo> pages = redPacketInfoService.pageList(getIPage(), wrapper,info);
        return ApiRes.page(pages);
    }

}
