
package com.jeelowcode.core.framework.config.btncommand.receiver;

import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamEdit;
import com.jeelowcode.core.framework.service.IFrameService;

import java.util.Map;

/**
 * 编辑按钮执行者
 */
public class ButtonReceiverEdit implements IButtonCommandReceiver<ExecuteEnhanceModel> {


    private String pluginKey;

    private ButtonParamEdit param;

    public ButtonReceiverEdit(ButtonParamEdit param) {
        this.param = param;
    }

    /**
     * 执行命令
     * @return
     */
    @Override
    public ExecuteEnhanceModel receiver() {
        IFrameService frameService = SpringUtils.getBean(IFrameService.class);
        Long dbformId = param.getDbFormId();
        Long dataId = param.getDataId();
        Map<String, Object> params = param.getParams();

        ExecuteEnhanceModel enhanceModel = frameService.editData(dbformId, dataId, params);

        return enhanceModel;
    }
}
