package cn.iocoder.yudao.module.product.controller.app.harvestbatch;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.controller.admin.harvestbatch.vo.BlockCertificateSaveReqVO;
import cn.iocoder.yudao.module.product.controller.admin.harvestbatch.vo.PreviewRespVO;
import cn.iocoder.yudao.module.product.service.harvestbatch.HarvestBatchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

@Api(tags = "APP移动端 - 采收批次")
@RestController
@RequestMapping("/product/harvest-batch")
@Validated
public class HarvestBatchAppController {

    @Resource
    private HarvestBatchService harvestBatchService;

    @GetMapping("/getHarvestData")
    @PermitAll // 无需登陆
    @ApiOperation("获得采收信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batchId", value = "批次编码", required = true, example = "HABTBC20230523105238FFGHG94N", dataTypeClass = String.class),
            @ApiImplicitParam(name = "languageTypeId", value = "语言类型ID", example = "1", dataTypeClass = Long.class)
    })
    public CommonResult<PreviewRespVO> getHarvestData(@RequestParam("batchId") String batchId, @RequestParam(value = "languageTypeId", required = false) Long languageTypeId) {
        return CommonResult.success(harvestBatchService.getPreviewData(batchId, languageTypeId));
    }

    @GetMapping("/getJobData")
    @PermitAll // 无需登陆
    @ApiOperation("获得作业信息")
    @ApiImplicitParam(name = "chainOperateId", value = "批次编码", required = true, example = "COCD20230605170621IE78X99C", dataTypeClass = String.class)
    public CommonResult<List<BlockCertificateSaveReqVO>> getJobData(@RequestParam("chainOperateId") String chainOperateId) {
        return CommonResult.success(harvestBatchService.gatJobData(chainOperateId));
    }

}
