首页>代码>Spring+Spring mvc + Mabatis 开发的oa办公系统实例>/fcoaSSM_RJ1/src/com/controller/treeController.java
package com.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.Service.treeService;
import com.entity.Employee;
import com.entity.Tree;

@Controller
@RequestMapping("tree")
public class treeController {
	@Autowired
	private treeService treeService;
	@RequestMapping("gettree")
	@ResponseBody
	public List<Tree> gettree(HttpSession session){
		List<Tree> lt = treeService.findTree();
		List<Tree> children1 = new ArrayList<Tree>();
		List<Tree> children2 = new ArrayList<Tree>();
		List<Tree> child1 = new ArrayList<Tree>();
		List<Tree> child = new ArrayList<Tree>();
		for(Tree t:lt){
			if(t.getLv()==5){
				children1.add(new Tree(t.getId(),t.getText(), t.getUrl()));
			}else if(t.getLv()==7){
				children2.add(new Tree(t.getId(),t.getText(), t.getUrl()));
			}else if(t.getLv()==2){
				child1.add(new Tree(t.getId(),t.getText(), children1));	
			}else if(t.getLv()==3){
				child1.add(new Tree(t.getId(),t.getText(), children2));	
			}else if(t.getLv()==1){
				child.add(new Tree(t.getId(),t.getText(), child1));
			}		
		}
		Employee emp = (Employee) session.getAttribute("emp");
		if (emp.getPositionId()!=null && emp.getPositionId()==1||emp.getPositionId()==2) {
			for(Tree t:lt){
				if(t.getLv()==4){
					children1.add(new Tree(t.getId(),t.getText(), t.getUrl()));
				}else if(t.getLv()==6){
					children2.add(new Tree(t.getId(),t.getText(), t.getUrl()));
				}
			}
		} 

		return child;
		
	}
	
	

}
最近下载更多
xfcxzks  LV1 5月2日
yangyuer  LV1 2024年4月26日
kkkaaaa  LV3 2023年5月18日
wanglinddad  LV55 2022年2月24日
bin2337  LV4 2021年11月24日
1294800221  LV1 2021年8月30日
zhangx105888  LV1 2021年7月28日
01  LV1 2021年7月13日
457229171  LV7 2021年7月3日
xufei123  LV4 2021年6月2日
最近浏览更多
xfcxzks  LV1 5月1日
暂无贡献等级
唐唐丶  LV34 2024年9月12日
krispeng  LV15 2024年8月12日
李朝磊  LV18 2024年6月28日
yunsgui  LV1 2024年6月25日
happySuperman  LV2 2024年6月4日
李俊雄  LV3 2024年5月8日
educationAAA  LV11 2024年5月2日
yangyuer  LV1 2024年4月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友