package cn.iocoder.yudao.module.chain.api.blockcertificate;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.chain.api.blockcertificate.dto.*;
import cn.iocoder.yudao.module.chain.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Api(tags = "RPC 服务 - 区块证书")
public interface BlockCertificateApi {

    String PREFIX = ApiConstants.PREFIX + "/block-certificate";

    @PostMapping(PREFIX + "/getBlockCertificate")
    @PermitAll // 无需登陆
    @ApiOperation("获得区块证书信息")
    @OperateLog(enable = false) // 不记录操作日志
    CommonResult<List<BlockCertificateRespDTO>> getBlockCertificateList(@Valid @RequestBody BlockCertificateReqDTO blockCertificate);

    @PostMapping(PREFIX + "/createBlockCertificateBatch")
    @ApiOperation("批量新增区块证书")
    @OperateLog(enable = false) // 不记录操作日志
    CommonResult<List<BlockCertificateRespDTO>> createBlockCertificateBatch(@Valid @RequestBody List<BlockCertificateCreateReqDTO> blockCertificates);

    @PutMapping(PREFIX + "/updateBlockCertificateBatch")
    @ApiOperation("批量更新区块证书")
    @OperateLog(enable = false) // 不记录操作日志
    CommonResult<Boolean> updateBlockCertificateBatch(@Valid @RequestBody List<BlockCertificateUpdateReqDTO> blockCertificates);

    @DeleteMapping(PREFIX + "/deleteBlockCertificateBatch")
    @ApiOperation("批量删除区块证书")
    @ApiImplicitParam(name = "ids", value = "id集合", required = true, dataTypeClass = List.class)
    @OperateLog(enable = false) // 不记录操作日志
    CommonResult<Boolean> deleteBlockCertificateBatch(@RequestParam("ids") List<Long> ids);

    @PostMapping(PREFIX + "/createAndUpChainBatch")
    @ApiOperation("批量新增并上链区块证书")
    @OperateLog(enable = false) // 不记录操作日志
    CommonResult<List<BlockCertificateRespDTO>> createAndUpChainBatch(@Valid @RequestBody BlockCertificateUpChainReqDTO blockCertificate);

    @PutMapping(PREFIX + "/updateStatus")
    @ApiOperation("修改状态（激活/冻结）")
    @OperateLog(enable = false) // 不记录操作日志
    CommonResult<Boolean> updateStatusBatch(@Valid @RequestBody List<UpdateStatusReqDTO> updateReqDTOS);

}
