package co.yixiang.yshop.module.distributor.controller.app.distributoruser;

import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.security.core.annotations.PreAuthenticated;
import co.yixiang.yshop.module.distributor.controller.app.distributoruser.vo.AppDistributorUserCountRespVO;
import co.yixiang.yshop.module.distributor.controller.app.distributoruser.vo.AppDistributorUserPageReqVO;
import co.yixiang.yshop.module.distributor.dal.dataobject.distributoruser.DistributorUserDO;
import co.yixiang.yshop.module.distributor.service.distributoruser.DistributorUserFacade;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

@Slf4j
@RestController
@Tag(name = "APP - 分销商用户模块")
@RequestMapping("/app/distributor/user")
public class AppDistributorUserController {

    @Resource
    private DistributorUserFacade distributorUserFacade;

    /**
     * 获取今日用户数量
     *
     * @param type 团队等级
     * @return /
     */
    @PreAuthenticated
    @GetMapping("/today-count")
    @Operation(summary = "今日加入我的用户")
    @Parameter(name = "type", description = "团队等级 一级 二级")
    public CommonResult<Integer> getTodayCount(@RequestParam("type") Integer type) {
        return success(distributorUserFacade.getTodayCount(type));
    }

    @PreAuthenticated
    @GetMapping("/count")
    @Operation(summary = "获取一级二级用户总数")
    public CommonResult<AppDistributorUserCountRespVO> getCount() {
        return success(distributorUserFacade.getCount());
    }

    // 获取我的用户详情
    @PreAuthenticated
    @GetMapping("/page")
    @Operation(summary = "我的团队分页(我的用户)")
    public CommonResult<PageResult<DistributorUserDO>> getAppPage(AppDistributorUserPageReqVO reqVO) {
        return success(distributorUserFacade.getAppPage(reqVO));
    }

}
