package com.engine.kq.cmd.setupwizard;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.bean.RightMenu;
import com.engine.kq.bean.RightMenuType;
import weaver.general.Util;
import weaver.hrm.User;

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

/**
 * 一键开启考勤--获取右键菜单
 */
public class GetRightMenuCmd extends AbstractCommonCommand<Map<String, Object>> {

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

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

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        Map<String, Object> resultMap = new HashMap<String, Object>();

        List<Object> rightMenuList = new ArrayList<Object>();//表示有权限可以看见的菜单List集合
        int languageId = user.getLanguage();//用户选择的语言
        RightMenu rightMenu = null;

        String isInitResult = Util.null2String(params.get("isInitResult"));//是否是初始化结果页签，是的话没有初始化按钮

        if(!isInitResult.equalsIgnoreCase("true")){
            rightMenu = new RightMenu(languageId, RightMenuType.BTN_Initialization, "startInit", true);//开始初始化
            rightMenuList.add(rightMenu);

            rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志
            rightMenuList.add(rightMenu);
        }
        resultMap.put("btnMenu", rightMenuList);
        return resultMap;
    }
}
