package com.ruoyi.cai.controller.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cai.dto.app.vo.invite.InviteHomeVo;
import com.ruoyi.cai.dto.app.vo.user.UserListVo;
import com.ruoyi.cai.service.UserInviteService;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.helper.LoginHelper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/invite")
@Tag(name = "邀请相关接口")
public class InviteAppController {

    @Autowired
    private UserInviteService userInviteService;

    @GetMapping("/home")
    @Operation(summary = "邀请有奖页面")
    public R<InviteHomeVo> inviteHome(){
        Long userId = LoginHelper.getUserId();
        InviteHomeVo inviteHome = userInviteService.inviteHome(userId);
        return R.ok(inviteHome);
    }

    @GetMapping("/user/page")
    @Operation(summary = "我邀请的人")
    public TableDataInfo<UserListVo> inviteUserPage(PageQuery pageQuery){
        Long userId = LoginHelper.getUserId();
        Page<UserListVo> userPage = userInviteService.inviteUserPage(pageQuery,userId);
        return TableDataInfo.build(userPage);
    }

}
