首页>代码>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;
		
	}
	
	

}
最近下载更多
kkkaaaa  LV3 2023年5月18日
wanglinddad  LV54 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日
pengkui  LV14 2021年5月3日
wangyan111111  LV8 2021年3月18日
最近浏览更多
admin_z  LV22 1月29日
shuangfu  LV24 2023年12月2日
wwewww  LV4 2023年11月3日
wykao13 2023年10月12日
暂无贡献等级
czsczd  LV3 2023年9月9日
d851646620000  LV6 2023年7月31日
1289755  LV3 2023年7月29日
zhy1989wz  LV6 2023年7月6日
gecongkai  LV8 2023年6月22日
cunbie  LV4 2023年6月13日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友