package com.m2pool.oapi.controller;

import com.m2pool.common.core.web.Result.AjaxResult;
import com.m2pool.common.core.web.controller.BaseController;
import com.m2pool.common.security.annotation.OpenApiPermissions;
import com.m2pool.common.security.annotation.RequiresPermissions;
import com.m2pool.oapi.service.AccountService;
import com.m2pool.oapi.vo.AccountDateVo;
import com.m2pool.oapi.vo.AccountVo;
import com.m2pool.oapi.vo.CoinVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Description 统一请求接口
 * @Date 2024/6/14 9:54
 * @Author dy
 */
@RestController
@RequestMapping("/account")
public class AccountController extends BaseController {

    @Autowired
    private AccountService accountService;

    @PostMapping("/hashrate_real")
    @ApiOperation(value = "挖矿账户实时算力、24小时算力")
    @OpenApiPermissions("account")
    public AjaxResult hashrate_real(@Valid @RequestBody AccountVo vo){

        return  accountService.getHashRateReal(vo);

    }

    @PostMapping("/hashrate_history")
    @ApiOperation(value = "挖矿账户历史算力(只支持24小时,最多3个月)")
    @OpenApiPermissions("account")
    public AjaxResult hashRateHistory(@Valid @RequestBody AccountDateVo vo){

        return  accountService.getHashRateHistory(vo);

    }

    @PostMapping("/hashrate_last24h")
    @ApiOperation(value = "挖矿账户最近24小时算力(30分钟算力)")
    @OpenApiPermissions("account")
    public AjaxResult getHashRateLast24h(@Valid @RequestBody AccountVo vo){

        return  accountService.getHashRateLast24h(vo);

    }

    @PostMapping("/miners_list")
    @ApiOperation(value = "挖矿账号矿工列表")
    @OpenApiPermissions("account")
    public AjaxResult minersList(@Valid @RequestBody AccountVo vo){

        return  accountService.getMinersList(vo);

    }

    @PostMapping("/watch")
    @ApiOperation(value = "挖矿账号矿工总览")
    @OpenApiPermissions("account")
    public AjaxResult watch(@Valid @RequestBody AccountVo vo){

        return  accountService.getWatch(vo);

    }

    @GetMapping("/test1")
    @ApiOperation(value = "挖矿账号矿工总览")
    //@OpenApiPermissions("account")
    public AjaxResult test1(){

        return  AjaxResult.success();

    }


}
