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

📄 groupjsp.java

📁 这是一款最新的野蔷薇论坛源码,有需要的朋友可以尽情下载
💻 JAVA
字号:
/* 
 * Created on 2007-2-24
 * Last modified on 2007-3-6
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.view.jsp;

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

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yeqiangwei.club.param.GroupParameter;
import com.yeqiangwei.club.service.ServiceLocator;
import com.yeqiangwei.club.service.ServiceWrapper;
import com.yeqiangwei.club.service.model.GroupModel;
import com.yeqiangwei.club.service.model.RoleModel;
import com.yeqiangwei.club.service.security.GroupService;
import com.yeqiangwei.club.service.security.RoleService;
import com.yeqiangwei.club.util.BeanLocator;
import com.yeqiangwei.club.util.BeanUtils;
import com.yeqiangwei.util.Validator;
import com.yeqiangwei.club.controller.form.GroupForm;
import com.yeqiangwei.club.view.model.GroupView;
import com.yeqiangwei.club.view.model.RoleView;
import com.yeqiangwei.util.ParamUtils;
import com.yeqiangwei.util.StringHelper;
import com.yeqiangwei.util.TypeChange;

/*
import com.yeqiangwei.club.log.LogFactory;
import com.yeqiangwei.club.log.Logger;
*/

public class GroupJsp  extends BaseJsp{
	
	private GroupService groupService;
	
	private RoleService roleService;

	public GroupJsp(HttpServletRequest request, HttpServletResponse response) {
		super(request, response);
	}
	
	//private static final Logger logger = Logger.getLogger(GroupJsp.class);
	
	@SuppressWarnings("unchecked")
	public List<GroupView> findAll(){
		//List<GroupView> vlist = new ArrayList<GroupView>();
		GroupParameter param = new GroupParameter();
		List list = this.getGroupService().findByParameter(param); 
		BeanUtils.copyListProperties(list,BeanLocator.GROUPVIEW);
		/*
		if(!Validator.isEmpty(list)){
			for(int i=0; i<list.size(); i++){
				Group item = list.get(i);
				GroupView v = new GroupView();
				BeanUtils.copyProperties(v,item);
				vlist.add(v);
			}
		}
		*/
		return list;
	}
	
	/**
	 * 查找用户组下包含的所有用户角色
	 * @param groupView
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<RoleView> findRolesByRoleIds(String roleIds){
		/*
		if(Validator.isEmpty(groupView)){
			int groupId = ParamUtils.getIntParameter(request,"groupId");
			if(groupId>0){
				Group item = this.getGroupService().findById(groupId);
				if(!Validator.isEmpty(item)){
					BeanUtils.copyProperties(groupView,item);
				}
			}
		}
		*/
		List<RoleView> vlist = new ArrayList<RoleView>();
		List<String> ids = StringHelper.stringToList(roleIds,"|");
		if(!Validator.isEmpty(ids)){
			for(int i=0; i<ids.size(); i++){
				int id = TypeChange.stringToInt(ids.get(i));
				RoleModel model = this.getRoleService().findById(id);
				if(!Validator.isEmpty(model)){
					RoleView roleView = new RoleView();
					BeanUtils.copyProperties(roleView,model);
					vlist.add(roleView);
				}
			}
		}
		return vlist;
	}
	
	public GroupForm getGroupForm(){
		int groupId = ParamUtils.getIntParameter(request,"groupId");
		GroupForm f = new GroupForm();
		GroupModel model = null;
		if(groupId>0){
			model = this.getGroupService().findById(groupId);
		}
		if(Validator.isEmpty(model)){
			Object obj =  ParamUtils.getAttribute(request,"GroupForm");
			if(!Validator.isEmpty(obj)){
				f = (GroupForm) obj;
			}
		}else{
			BeanUtils.copyProperties(f,model);
		}
		return f;
	}

	public GroupService getGroupService() {
		if(Validator.isEmpty(groupService)){
			groupService = (GroupService)ServiceWrapper.getSingletonInstance(ServiceLocator.GROUP);
		}
		return groupService;
	}

	public RoleService getRoleService() {
		if(Validator.isEmpty(roleService)){
			roleService = (RoleService)ServiceWrapper.getSingletonInstance(ServiceLocator.ROLE);
		}
		return roleService;
	}
}

⌨️ 快捷键说明

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