package com.engine.kq.cmd.hrmAttProcSet;

import com.api.hrm.bean.RightMenu;
import com.api.hrm.bean.RightMenuType;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

/**
 * 获取考勤流程设置的右键菜单
 * @author pzy
 *
 */
public class GetStateRightMenuCmd extends AbstractCommonCommand<Map<String, Object>>{
	
	public GetStateRightMenuCmd(Map<String, Object> params, User user) {
		this.user = user;
		this.params = params;
	}

	@Override
	public BizLogContext getLogContext() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Map<String, Object> execute(CommandContext commandContext) {
		Map<String,Object> retmap = new HashMap<String,Object>();
		String type = Util.null2String((String)params.get("type"));
		int id = Util.getIntValue((String)params.get("id"));
		String pageid = Util.null2String(params.get("pageid"));//页面标识
		List<Object>  rightMenu = new ArrayList<Object>();
		try {
			if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){
				retmap.put("hasRight", false);
			}else{
				retmap.put("hasRight", true);
			}
			rightMenu = getListMenu(type, id, pageid, user);
		} catch (Exception e) {
			writeLog(e);
		}
		retmap.put("status", "1");
		retmap.put("rightMenu", rightMenu);
		retmap.put("hasDpIcon", true);
		return retmap;
	}

	/**
	 * 获取考勤流程设置的菜单
	 * @param type
	 * @param id
	 * @param pageid
	 * @param user
	 * @return
	 */
	public static List<Object> getListMenu(String type, int id, String pageid, User user){
		List<Object>  rightMenu = new ArrayList<Object>();

		rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_Addnew, "showContent", true));
		rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_BatchDelete, "doDel", true, true));
		
		return rightMenu;
	}
}
