package com.m2pool.manage.controller;

import com.m2pool.common.core.Result.R;
import com.m2pool.common.core.web.page.TableDataInfo;
import com.m2pool.common.security.annotation.Logical;
import com.m2pool.common.security.annotation.RequiresLogin;
import com.m2pool.common.security.annotation.RequiresRoles;
import com.m2pool.manage.dto.*;
import com.m2pool.manage.service.ManageUserService;
import com.m2pool.manage.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 管理系统用户信息控制器类
 * @Date 2025/5/22 14:33
 * @Author yyb
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户信息控制器类")
public class ManageUserController {

    @Resource
    private ManageUserService manageUserService;

    @PostMapping("/list/info")
    @ApiOperation(value = "管理系统:查询注册用户信息列表，包括邮箱、挖矿账号、钱包地址、起付额、挖矿账户状态等信息")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public TableDataInfo<ManageUserDto> listInfo(@RequestBody ManageUserVo manageUserVo){
        return manageUserService.listInfo(manageUserVo);
    }


    @PostMapping("/send/text/mail/message")
    @ApiOperation(value = "管理系统:发送邮件给某些用户")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public R<String> sendTextMailMessage(@RequestBody EmailVo emailVo){
        return manageUserService.sendTextMailMessage(emailVo.getTo(),emailVo.getSubject(),emailVo.getText());
    }

    @PostMapping("/get/user/info")
    @ApiOperation(value = "管理系统:挖矿账户所有收益金额、时间、状态、转账地址")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public R<WalletEarningsInfoDto> getUserInfo(@RequestBody ManageUserInfoVo manageUserInfoVo){
        return manageUserService.getUserInfo(manageUserInfoVo);
    }

    @PostMapping("/getMiningUserInfo")
    @ApiOperation(value = "管理系统:根据用户邮箱查询用户对应的挖矿账户及币种信息")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public R<List<ManageMiningUserDto>> getMiningUserInfo(@RequestBody ManageMiningUserVo manageMiningUserVo){
        return manageUserService.getMiningUserInfo(manageMiningUserVo);
    }

    @PostMapping("/getMiningPowerInfo")
    @ApiOperation(value = "管理系统:根据币种，挖矿账户，时间，查询用户算力曲线")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public R<List<ManageMiningUserPowerDto>> getMiningPowerInfo(@RequestBody ManageMiningUserPowerVo manageMiningUserPowerVo){
        return manageUserService.getMiningPowerInfo(manageMiningUserPowerVo);
    }



    @PostMapping("/getMinerUserOnlineStatus")
    @ApiOperation(value = "管理系统:获取挖矿账户对应的矿工在离线情况")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public R<List<ManageMiningUserOnlineDto>> getMinerUserOnlineStatus(@RequestBody ManageMiningUserPowerVo manageMiningUserPowerVo){
        return manageUserService.getMinerUserOnlineStatus(manageMiningUserPowerVo);
    }


    @PostMapping("/summaryOfPendingPayments")
    @ApiOperation(value = "管理系统:用户待支付汇总")
    @RequiresLogin
    @RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
    public TableDataInfo<SummaryOfPendingPaymentsDto> summaryOfPendingPayments(@RequestBody PageVo pageVo){
        return manageUserService.summaryOfPendingPayments(pageVo);
    }
}
