
package com.heyu.api.controller.vv;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heyu.api.alibaba.request.vv.AppPromoterBuyerRequest;
import com.heyu.api.common.annotation.AppRealyLogin;
import com.heyu.api.common.annotation.Describe;
import com.heyu.api.data.dao.vv.VvPromoterBuyerDao;
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("/app/promoter/buyer")
public class AppPromoterBuyerController {

    @Autowired
    private VvPromoterBuyerDao vvPromoterBuyerDao;

    /***
     * 列表
     * http://localhost:8888/app/promoter/list
     */
    @Describe("我推荐的好友")
    @RequestMapping("/list")
    @AppRealyLogin
    public R list(@RequestBody AppPromoterBuyerRequest request) {
        PPageUtils pageUtils = PPageUtils.startPage(request.getPageNum(), request.getPageSize())
                .doSelect(new ISelect() {
                    @Override
                    public List doSelect(IPage page) {
                        return vvPromoterBuyerDao.selectAppByCondition(page,
                                request.getBuyerId(),
                                request.getMinCreateTimestamp(),
                                request.getMaxCreateTimestamp(),
                                request.getCreateTimestampSort()
                        );
                    }
                });
        return R.ok().setData(pageUtils);
    }
}