package com.yc.ship.module.trade.controller.app.contract;

import com.yc.ship.framework.operatelog.core.annotations.OperateLog;
import com.yc.ship.module.trade.enums.ApiConstants;
import com.yc.ship.module.trade.service.contract.ContractService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
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.annotation.Resource;
import javax.annotation.security.PermitAll;

import static com.yc.ship.framework.operatelog.core.enums.OperateTypeEnum.API;


/**
 * @author le'yang
 */
@Tag(name = "  合同--外部")
@RestController
@RequestMapping("/trade/contract")
@Validated
public class ContractStandardController {

    @Resource
    private ContractService contractService;


    @PostMapping( "/notify")
    @Operation(summary = "合同回调通知")
    @OperateLog(type = API)
    @PermitAll
    public String callbackNotify( @RequestBody String body){
        if (StringUtils.isBlank(body)){
            return ApiConstants.ERROR;
        }
        return contractService.contractCallBackNotice(body);
    }
}