package com.zt.plat.module.qms.api.task;

import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.spring.SpringUtils;
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
import com.zt.plat.module.qms.api.task.dto.QmsBpmDTO;
import com.alibaba.fastjson.JSONObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.zt.plat.module.qms.enums.QmsBpmConstant.BPM_CALLBACK_BEAN_NAME;


@RestController
@Validated
@DeptDataPermissionIgnore(enable = "true")
public class QmsApiImpl implements QmsApi{

    @Override
    public CommonResult<JSONObject> bpmCallback(QmsBpmDTO reqDTO) {
        JSONObject variables = reqDTO.getVariables();
        String beanName = variables.getString(BPM_CALLBACK_BEAN_NAME);
        BMPCallbackInterface bean = SpringUtils.getBean(beanName);
        return bean.callback(reqDTO);
    }
}
