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

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

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 删除按钮执行者
 */
public class ButtonReceiverDel implements IButtonCommandReceiver<ExecuteEnhanceModel> {


    private String pluginKey;

    private ButtonParamDel param;

    public ButtonReceiverDel(ButtonParamDel param) {
        this.param = param;
    }

    /**
     * 执行命令
     * @return
     */
    @Override
    public ExecuteEnhanceModel receiver() {
        IFrameService frameService = SpringUtils.getBean(IFrameService.class);
        Long dbformId = param.getDbFormId();
        List<Long> dataIdList = param.getDataIdList();

        Map<String,Object> params=new HashMap<>();
        params.put("dataIdList",dataIdList);
        params.put("whereFieldCode","id");

        //逻辑删除
        ExecuteEnhanceModel enhanceModel = frameService.delData(dbformId, params);
        return enhanceModel;
    }
}
