package com.laoxie.auto.api.flow;

import com.zhuchi.zcii.framework.common.pojo.CommonResult;
import com.zhuchi.zcii.module.bpm.api.task.FlowStatusApi;
import com.zhuchi.zcii.module.bpm.api.task.dto.BpmProcessInstanceNotifyReqDTO;
import com.laoxie.auto.enums.flow.FlowEnum;
import com.laoxie.auto.service.demo.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class FlowStatusApiImpl implements FlowStatusApi {

    @Resource
    private DemoService demoService;
    @Override
    public CommonResult<Boolean> notify(BpmProcessInstanceNotifyReqDTO reqDTO) {
        log.info("收到审核结果：{}", reqDTO);
        switch (FlowEnum.byType(reqDTO.getProcessDefinitionKey())) {
            case DEMO://合同
                demoService.updateAuditStatus(Long.parseLong(reqDTO.getBusinessKey()), reqDTO.getStatus());
                break;
            default:
                break;
        }
        return CommonResult.success(true);
    }
}
