package com.heyu.api.controller.mm;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heyu.api.alibaba.request.mm.VvPromoterLineRequest;
import com.heyu.api.data.dao.vv.VvPromoterAwardLineDao;
import com.heyu.api.data.utils.R;
import com.heyu.api.utils.ISelect;
import com.heyu.api.utils.PPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/mm/promoter/award")
public class AdminPromoterAwardLineController {


    @Autowired
    private VvPromoterAwardLineDao vvPromoterAwardLineDao;

    /***
     * 奖励 列表
     * http://localhost:8888/mm/promoter/award/list
     */
    @RequestMapping("/list")
    public R list(@RequestBody VvPromoterLineRequest vvPromoterRequest) {
        PPageUtils pageUtils = PPageUtils.startPage(vvPromoterRequest.getPageNum(), vvPromoterRequest.getPageSize())
                .doSelect(new ISelect() {
                    @Override
                    public List doSelect(IPage page) {
                        return vvPromoterAwardLineDao.selectByCondition(page,
                                vvPromoterRequest.getPromoterId(),
                                vvPromoterRequest.getPromoterBuyerId(),
                                vvPromoterRequest.getPromoterBuyerName(),
                                vvPromoterRequest.getPromoterBuyerWeixin(),
                                vvPromoterRequest.getPromoterBuyerPhone(),
                                vvPromoterRequest.getMinCreateTimestamp(),
                                vvPromoterRequest.getMaxCreateTimestamp(),
                                vvPromoterRequest.getCreateTimestampSort()
                        );
                    }
                });

        return R.ok().setData(pageUtils);
    }

}
