package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.CorpQualificationInfoGateway;
import com.zcloud.basic.info.domain.model.CorpQualificationInfoE;
import com.zcloud.basic.info.dto.CorpQualificationInfoAddCmd;
import com.zcloud.gbscommon.utils.Tools;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author zhaokai
 * @Date 2025-10-29 16:02:45
 */
@Component
@AllArgsConstructor
public class CorpQualificationInfoAddExe {
    private final CorpQualificationInfoGateway corpQualificationInfoGateway;

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(CorpQualificationInfoAddCmd cmd) {
        CorpQualificationInfoE examTypeE = new CorpQualificationInfoE();
        BeanUtils.copyProperties(cmd, examTypeE);
        boolean res = false;
        try {
            res = corpQualificationInfoGateway.add(examTypeE);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (!res) {
            throw new BizException("保存失败");
        }


        return true;
    }
}

