roleaction.java

来自「struts2 spring2.5 jpa hibernate 权限管理系统源代」· Java 代码 · 共 116 行

JAVA
116
字号
package sunyang.role.action;

import java.util.*;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import sunyang.functions.domain.Function;
import sunyang.role.domain.Role;
import sunyang.role.service.IRoleFacade;

import com.opensymphony.xwork2.Action;

public class RoleAction {
	// 针对于页面的成员变量
	private Role r;
	private List<Role> lr;
	private List<Function> lf;
	private List<Integer> fid;
	private IRoleFacade irf;

	// 构造方法,用于对成员变量赋初值
	public RoleAction() {
		fid = new ArrayList<Integer>();
		r = new Role();
	}

	// getter和setter方法
	public Role getR() {
		return r;
	}

	public void setR(Role r) {
		this.r = r;
	}

	public List<Role> getLr() {
		return lr;
	}

	public void setLr(List<Role> lr) {
		this.lr = lr;
	}

	public List<Function> getLf() {
		return lf;
	}

	public void setLf(List<Function> lf) {
		this.lf = lf;
	}

	public List<Integer> getFid() {
		return fid;
	}

	public void setFid(List<Integer> fid) {
		this.fid = fid;
	}

	public IRoleFacade getIrf() {
		return irf;
	}

	public void setIrf(IRoleFacade irf) {
		this.irf = irf;
	}

	// 处理operateRole请求的方法
	public String operateRole() {
		lr = irf.operateRole();
		return Action.SUCCESS;
	}

	// 处理newRole请求的方法
	public String newRole() {
		irf.newRole(r);
		return Action.SUCCESS;
	}

	// 处理findSingleRole请求的方法
	public String findSingleRole() {
		r = irf.findSingleRole(r);
		return Action.SUCCESS;
	}

	// 处理modifyRole请求的方法
	public String modifyRole() {
		irf.modifyRole(r);
		return Action.SUCCESS;
	}

	// 处理removeRole请求的方法
	public String removeRole() {
		irf.removeRole(r);
		return Action.SUCCESS;
	}

	// 处理authorization请求的方法
	public String authorization() {
		ServletActionContext.getRequest().setAttribute("had", irf.hadRole(r));
		HttpSession hs = ServletActionContext.getRequest().getSession();
		hs.setAttribute("r", r);
		lf = irf.authorization(r);
		return Action.SUCCESS;
	}

	// 处理changeRf请求的方法
	public String changeRf() {
		HttpSession hs = ServletActionContext.getRequest().getSession();
		irf.changeRf(fid, (Role) hs.getAttribute("r"));
		return Action.SUCCESS;
	}
}

⌨️ 快捷键说明

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