
import com.sdtool.common.api.BusinessExecutor
import com.sdtool.common.datas.ERPModule
import com.sdtool.common.entity.base.InvokeCallParams
import com.sdtool.common.entity.base.InvokeCallResult
import com.dySweetFishPlugin.sql.dao.OperatorWait
import com.dySweetFishPlugin.sql.dao.TunaDaoService
import com.sweetfish.service.RetResult
import groovy.json.JsonSlurper
import org.apache.commons.lang3.StringUtils
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger

import javax.annotation.Resource

@SuppressWarnings("unused")
class BE_System_SqlErrorRemove implements BusinessExecutor<InvokeCallParams, InvokeCallResult> {

    protected final Logger logger = LogManager.getLogger(this.getClass().getSimpleName())


    @Resource
    private TunaDaoService daoService

    @Override
    String scriptName() {
        return "移除错误的SQL"
    }

    @Override
    ERPModule module() {
        return ERPModule.SYSTEM
    }

    @Override
    OperatorWait getAWait(InvokeCallParams s) {
        return OperatorWait.ASNYC
    }

    @Override
    boolean needLogin(InvokeCallParams source) {
        return true
    }

    RetResult<InvokeCallResult> execute(InvokeCallParams source) {
        def jsonSlurper = new JsonSlurper()
        def invokeData = jsonSlurper.parseText(source.params)

        String key = invokeData["errorKey"]
        if (StringUtils.isNotBlank(key)) {
            daoService.removeError(key)
        }

        return RetResult.<InvokeCallResult> successT()
    }
}
