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.MinerService;
import com.m2pool.oapi.vo.AccountDateVo;
import com.m2pool.oapi.vo.AccountMinerDateVo;
import com.m2pool.oapi.vo.AccountMinerVo;
import com.m2pool.oapi.vo.AccountVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Description 矿机开放api统一请求接口
 * @Date 2024/6/14 9:54
 * @Author dy
 */
@RestController
@RequestMapping("/miner")
public class MinerController extends BaseController {

    @Autowired
    private MinerService minerService;

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

        return  minerService.getHashRateReal(vo);

    }

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

        return  minerService.getHashRateHistory(vo);

    }

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

        return  minerService.getHashRateLast24h(vo);

    }



}
