package com.engine.htsc.savetrip.cmd;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.hrm.User;
import weaver.interfaces.htsc.cus.HTUtil;

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

/**
 * Author:DTY-PC
 * Date:2020/10/21 16:53
 * Description:
 * Copyright:上海泛微网络科技股份有限公司
 */
public class SaveTripCmd extends AbstractCommonCommand<Map<String,Object>> {

    public SaveTripCmd(User user, Map<String,Object> params) {
        this.user = user;
        this.params = params;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        Map<String,Object> apidatas  = new HashMap<>();
        if (null == user){
            apidatas.put("hasRight", false);
            return apidatas;
        }
        apidatas.put("hasRight", true);
        HTUtil htUtil = new HTUtil();
        String res = htUtil.getSaveTripReqString(params);
        if(!"".equals(res)){//
            if(!"-1".equals(res)){//执行接口
                boolean isSucc = htUtil.saveTrip(res);
                res = isSucc+"";
            }
        }
        apidatas.put("res", res);
        return apidatas;
    }
}
