package com.ebo.taskManager.taskDispatchBtnEnhance;

import com.ebo.entity.WorkOrderEntity;
import com.ebo.framework.common.exception.ServerException;
import com.ebo.mapper.WorkOrderMapper;
import com.ebo.module.fast.common.BtnServerEnhanceJavaInter;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.net.MalformedURLException;
import java.util.Map;

@Service
@Slf4j
public class taskDispatchNewlyAddBtnEnhance implements BtnServerEnhanceJavaInter {
    @Resource
    private WorkOrderMapper workOrderMapper;
    @Override
    public void executeBefore(String tableName, String buttonCode, Map data) throws ServerException {

    }

    @Override
    public void executeAfter(String tableName, String buttonCode, Map data) throws ServerException, MalformedURLException {
        log.info("-----任务调用保存按钮增强-----{}",data);
        String idValue = (String) data.get("id");
        WorkOrderEntity workOrderEntity = workOrderMapper.selectById(idValue);
        if(workOrderEntity.getStatus().equals("1")){
            workOrderEntity.setStatus("2");
        }
        workOrderMapper.updateById(workOrderEntity);

    }
}
