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

📄 iuserserviceimpl.java

📁 struts+spring+jdbc权限管理 菜单树实现
💻 JAVA
字号:
package com.hiiso.crm.common.authority.impl;

import java.util.Iterator;
import java.util.List;

import com.hiiso.crm.common.authority.IUser;
import com.hiiso.crm.common.authority.IUserService;
import com.hiiso.crm.common.exception.AuthorityException;
import com.hiiso.crm.common.exception.AuthorityServiceExp;
import com.hiiso.crm.common.pojo.User;
import com.hiiso.crm.common.union.Parameters;

/*************************************************************************
* SYSTEM:       基金CRM系统
* SUBSYS:       CRM权限管理模块
* DESCRIPTION:  CRM菜单管理接口用户服务实现
* AUTHOR:       YAOYI
* CREATE DATE:  2008/11/18
* COPYRIGHT:    (c)Copyright 2008 HISUN Corporation. All rights reserved.
* VERSION:      V1.0G
* EDIT HISTORY:
*************************************************************************/

public class IUserServiceImpl implements IUserService {

	private IUser userDao;
	private Parameters param;

	public IUser getUserDao() {
		return userDao;
	}

	public void setUserDao(IUser userDao) {
		this.userDao = userDao;
	}
	
	public Parameters getParam() {
		return param;
	}

	public void setParam(Parameters param) {
		this.param = param;
	}

	//添加用户
	public void addUser(User user) throws AuthorityServiceExp {
		// TODO Auto-generated method stub

	}

	//注销用户
	public void cancel(String userId) throws AuthorityServiceExp {
		// TODO Auto-generated method stub

	}

	//删除用户
	public void delete(String userId) throws AuthorityServiceExp {
		// TODO Auto-generated method stub

	}

	//获取所有用户,树形结构展示
	public StringBuffer getAllUser(String rootId) throws AuthorityServiceExp {
		List list = null;
		StringBuffer buffer = new StringBuffer();
		try {
			 list = userDao.getAllUser();
		} catch (AuthorityException e) {
			throw new AuthorityServiceExp("err.allUser",e,"");
		}
		
		try {
			rootId = param.GetProperties("adminUser.id");
		} catch (Exception e) {
			throw new AuthorityServiceExp("err.adminUser",e,rootId);
		}
		buffer.append("var tree"+rootId+" = new TreeItem(\""+rootId+"\",\"主菜单\"); \r\n");
		buildTreeEdit(buffer,rootId,list);
		buffer.append("document.write(tree"+rootId+".menuShow());");
		return buffer;
	}
	
	//拼接字符串
	public void buildTreeEdit(StringBuffer buffer,String parentId,List list){
		Iterator iter = list.iterator();
		while(iter.hasNext()){
			User user = (User)iter.next();
			if(user.getParentId().equals(parentId)){
				buffer.append("var tree"+user.getUserId()+" = new TreeItem(\""+user.getUserId()+"\",\"<a href=\\\"javascript:editTree('"+user.getUserId()+"','"+user.getUserName()+"','"+user.getPosition()+"');\\\">"+user.getUserName()+"</a>\");\r\n");
				buffer.append("tree"+parentId+".add(tree"+user.getUserId()+");\r\n");
				buildTreeEdit(buffer,user.getUserId(),list);
			}
		}
	}

	//获取角色编号
	public String getRoleId(String userId) throws AuthorityServiceExp {
		String role = null;
		try {
			 role = userDao.getRoleId(userId);
		} catch (AuthorityException e) {
			throw new AuthorityServiceExp("err.getRoleId",e,userId);
		}
		
		return role;
	}

	//根据父编号获取子用户
	public List getUserByPId(String parentId) throws AuthorityServiceExp {
		// TODO Auto-generated method stub
		return null;
	}

	//登陆
	public User login(String userName,String password) throws AuthorityServiceExp {
		User userDo = null;
		try {
			 userDo = userDao.getLoginUser(userName);
		} catch (AuthorityException e) {
			throw new AuthorityServiceExp("err.getUser",e,userName);
		}

		if(!password.equals(userDo.getPassword())){
			throw new AuthorityServiceExp("err.password",userName);
		}
		return userDo;
	}

	public void editUser(User user,String oldId) throws AuthorityServiceExp {
		User nowUser = null;
		try {
			 userDao.getLoginUser(user.getUserId());
		} catch (AuthorityException e) {
			throw new AuthorityServiceExp("err.idExit",e,user.getUserId());
		}
		
		try {
			nowUser = userDao.getLoginUser(oldId);
		} catch (AuthorityException e) {
			throw new AuthorityServiceExp("err.getUser",e,user.getUserName());
		}
		if(null!=user.getUserId()&&!user.getUserId().equals("")){
			nowUser.setUserId(user.getUserId());
		}
		if(null!=user.getUserName()&&!user.getUserName().equals("")){
			nowUser.setUserName(user.getUserName());
		}
		if(null!=user.getPosition()&&!user.getPosition().equals("")){
			nowUser.setPosition(user.getPosition());
		}
		try {
			 userDao.editUser(nowUser,oldId);
		} catch (AuthorityException e) {
			throw new AuthorityServiceExp("err.editUser",e,user.getUserId());
		}
	}
}

⌨️ 快捷键说明

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