package com.jw.app.group.action;

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

import net.sf.json.JSONObject;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils;
import com.jw.app.business.GroupBusiness;

public class dataAction extends BasicAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6083279531948261141L;

	private JSONObject jsonObject = new JSONObject();
	private int rows = 20;// 每页显示的记录数
	private int page = 1;// 当前第几页
	private String dataReturn;
	// output属性
	private InputStream inputStream; // 这个名字和struts.xml中对应，不能写错

	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}

	public JSONObject getJsonObject() {
		return jsonObject;
	}

	public void setJsonObject(JSONObject jsonObject) {
		this.jsonObject = jsonObject;
	}

	public String getDataReturn() {
		return dataReturn;
	}

	public void setDataReturn(String dataReturn) {
		this.dataReturn = dataReturn;
	}

	public int getRows() {
		rows = getPageSize();
		return rows;
	}

	public void setRows(int rows) {
		setPageSize(rows);
		this.rows = getPageSize();
	}

	public int getPage() {
		page = getPageNo();
		return page;
	}

	public void setPage(int page) {
		setPageNo(page);
		this.page = getPageNo();
	}
	
	//人员权限ZTREE查询
	public String listALLModule() throws BusinessException {
		GroupBusiness groupBusiness = BusinessManager.getBusiness(GroupBusiness.class);
		Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("G_ID", query.get("G_ID").toString());
		List<Map<String, Object>> listuser = groupBusiness.listAllModule(map);
//		System.out.println("------list"+listuser);
		List<Map<String, Object>> listunit = groupBusiness.listAllModuleType();
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		list.addAll(listuser);
		list.addAll(listunit);
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("rowSet", list);
		data.put("pageNo", pageNo);
		data.put("pageSize", pageSize);
		data.put("pageCount", pageCount);
		data.put("rows", data.get("rowSet"));
		data.put("total", 1);
		jsonObject = new JSONObject();
		jsonObject.putAll(data);
		return "json";
	}
}
