package com.m2pool.lease.controller;


import com.m2pool.lease.annotation.LoginRequired;
import com.m2pool.lease.dto.*;
import com.m2pool.lease.dto.v2.MachineInfoDto;
import com.m2pool.lease.dto.v2.SellerMachineInfoDto;
import com.m2pool.lease.dto.v2.ShopInfoDto;
import com.m2pool.lease.service.LeaseMachineService;
import com.m2pool.lease.vo.*;
import com.m2pool.lease.vo.v2.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 * 商品表对应的物品机器表 前端控制器
 * </p>
 *
 * @author yyb
 * @since 2025-07-23
 */
@Api(tags = "v2版本--矿机控制器类")
@LoginRequired
@RestController
@RequestMapping("/v2/product/machine")
public class LeaseProductMachineV2Controller {


    @Resource
    private LeaseMachineService leaseMachineService;

    @ApiOperation("商城首页---店铺列表")
    @LoginRequired(value = false)
    @PostMapping("/getShopList")
    public PageResult<ShopInfoDto> getShopList(@RequestBody(required = false) ProductPageVo productPageVo) {
        if(productPageVo == null){
            productPageVo = new ProductPageVo();
        }
        return leaseMachineService.getShopList(productPageVo);
    }


    @ApiOperation("商城首页---店铺对应矿机详情列表")
    @LoginRequired(value = false)
    @PostMapping("/getShopMachineList")
    public PageResult<MachineInfoDto> getShopMachineList(@RequestBody ShopMachineVo shopMachineVo) {
        return leaseMachineService.getShopMachineList(shopMachineVo);
    }

    @ApiOperation("卖家页面---矿机列表")
    @PostMapping("/getShopMachineListForSeller")
    public PageResult<SellerMachineInfoDto> getShopMachineListForSeller(@RequestBody(required = false) SellerMachineVo sellerMachineVo) {
        if (sellerMachineVo == null) {
            sellerMachineVo = new SellerMachineVo();
        }
        return leaseMachineService.getShopMachineListForSeller(sellerMachineVo);
    }

    @ApiOperation("卖家页面---新增ASIC矿机")
    @PostMapping("/addAsicMachine")
    public Result<String> addAsicMachine(@RequestBody AsicMachineParamsVo asicMachineParamsVo) {
        return leaseMachineService.addAsicMachine(asicMachineParamsVo);
    }

    @ApiOperation("卖家页面---修改ASIC矿机")
    @PostMapping("/updateAsicMachine")
    public Result<String> updateAsicMachine(@RequestBody AsicMachineParamsVo asicMachineParamsVo) {
        return leaseMachineService.updateAsicMachine(asicMachineParamsVo);
    }

    @ApiOperation("卖家页面--- 批量修改GPU矿机 和 批量上下架")
    @PostMapping("/updateGpuMachine")
    public Result<String> updateGpuMachine(@RequestBody List<GpuMachineParamsVo> gpuMachineParamsVoList) {
        return leaseMachineService.updateGpuMachine(gpuMachineParamsVoList);
    }

    @ApiOperation("卖家页面---GPU/ASIC矿机上下架")
    @PostMapping("/updateMachineState")
    public Result<String> updateMachineState(@RequestBody MachineStateVo machineStateVo) {
        return leaseMachineService.updateMachineState(machineStateVo);
    }


    @ApiOperation("卖家页面---根据矿机id删除GPU/ASIC矿机")
    @PostMapping("/deleteMachine")
    public Result<String> deleteMachine(@RequestBody BaseVo baseVo) {
        return leaseMachineService.deleteMachine(baseVo);
    }

    @ApiOperation("获取租赁系统支持的币种")
    @GetMapping("/getSupportCoin")
    public Result<List<String>> getSupportCoin() {
        return leaseMachineService.getSupportCoin();
    }

    @ApiOperation("根据币种获取租赁系统支持的算法")
    @GetMapping("/getSupportAlgo")
    public Result<List<String>> getSupportAlgo(@RequestParam String coin) {
        return leaseMachineService.getSupportAlgo(coin);
    }





}

