⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 organizationservice.java

📁 Ajax开发精要——概念、案例与框架.很适合初学者学习。
💻 JAVA
字号:
package com.ajaxlab.ajax;

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

public class OrganizationService {
	private Map organizations = new HashMap();
	private Map departments = new HashMap();
	private Map positions = new HashMap();
	private Map staffes = new HashMap();
	
	public OrganizationService() {
		Organization org1 = new Organization("O001","Ajaxlab公司");
		this.organizations.put(org1.getId(),org1);
		Department dept1 = new Department("D001","O001","","营运中心");
		Department dept2 = new Department("D002","O001","","研发中心");
		this.departments.put(dept1.getId(),dept1);
		this.departments.put(dept2.getId(),dept2);
		Position pos1 = new Position("P001","D001","总经理");
		Position pos2 = new Position("P002","D001","副总经理");
		Position pos3 = new Position("P003","D002","总工程师");
		Position pos4 = new Position("P004","D002","软件工程师");
		this.positions.put(pos1.getId(),pos1);
		this.positions.put(pos2.getId(),pos2);
		this.positions.put(pos3.getId(),pos3);
		this.positions.put(pos4.getId(),pos4);
		Staff staff1 = new Staff("S001","P001","许庆");
		Staff staff2 = new Staff("S002","P002","王安");
		Staff staff3 = new Staff("S003","P003","丁忠");
		Staff staff4 = new Staff("S004","P004","张也");
		this.staffes.put(staff1.getId(),staff1);
		this.staffes.put(staff2.getId(),staff2);
		this.staffes.put(staff3.getId(),staff3);
		this.staffes.put(staff4.getId(),staff4);
	}
	public Map getAllOrganization() {
		return this.organizations;
	}
	public Map getAllDepartment() {
		return this.departments;
	}
	public Map getAllPosition() {
		return this.positions;
	}
	public Map getAllStaff() {
		return this.staffes;
	}
	
	public Map getDeptByOrg(String orgId) {
		if(orgId==null) return null;
		HashMap depts = new HashMap();
		Iterator iter = this.departments.values().iterator();
		do{
			Department dept = (Department)iter.next();
			if(orgId.equalsIgnoreCase(dept.getOrgId())) depts.put(dept.getId(),dept);
		}while(iter.hasNext());
		return depts;
	}
	
	public Map getPosByDept(String deptId) {
		if(deptId==null) return null;
		HashMap posis = new HashMap();
		Iterator iter = this.positions.values().iterator();
		do{
			Position pos = (Position)iter.next();
			if(deptId.equalsIgnoreCase(pos.getDeptId())) posis.put(pos.getId(),pos);
		}while(iter.hasNext());
		return posis;
	}
	
	public Map getStaffByPos(String posId) {
		if(posId==null) return null;
		HashMap staffes = new HashMap();
		Iterator iter = this.staffes.values().iterator();
		do{
			Staff staff = (Staff)iter.next();
			if(posId.equalsIgnoreCase(staff.getPosId())) staffes.put(staff.getId(),staff);
		}while(iter.hasNext());
		return staffes;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -