package com.yc.ship.module.trade.api.contract;

import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.module.trade.api.contract.dto.ContractApplyReqDTO;
import com.yc.ship.module.trade.api.contract.dto.QueryContractRespDTO;
import com.yc.ship.module.trade.service.contract.ContractService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Validated
public class ContractApiImpl implements ContractApi {

    @Resource
    private ContractService contractService;

    @Override
    public CommonResult<?> applyContract(ContractApplyReqDTO reqDTO) {
        return contractService.applyContract(reqDTO);
    }

    @Override
    public CommonResult<Boolean> cancelContractByOrder(Long orderId) {
        return CommonResult.success(contractService.cancel(orderId));
    }

    @Override
    public CommonResult<Integer> queryStatus(Long contractId) {
        return CommonResult.success(contractService.queryContractStatus(contractId));
    }

    @Override
    public CommonResult<QueryContractRespDTO> queryContract(Long contractId) {

        return CommonResult.success(contractService.queryContract(contractId));
    }
}
