📄 functionmanageaction.java
字号:
/**
*
*/
package com.sunwah.baseapp.system.action;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.validation.SkipValidation;
import com.sunwah.baseapp.action.QueryManageAction;
import com.sunwah.baseapp.common.ActionConstants;
import com.sunwah.baseapp.common.Constants;
import com.sunwah.baseapp.common.DictionaryConstants;
import com.sunwah.baseapp.common.SqlConstants;
import com.sunwah.baseapp.service.CommonStatusCodes;
import com.sunwah.baseapp.system.criteria.FunctionQueryCriteria;
import com.sunwah.baseapp.system.model.Functions;
import com.sunwah.baseapp.system.service.FunctionManager;
import com.sunwah.baseapp.system.vo.UserVO;
/**
* 功能管理Action类
*
* @author MARK
*
*/
public class FunctionManageAction extends QueryManageAction {
/**
*
*/
private static final long serialVersionUID = -8017110470528777610L;
private static final Logger logger = Logger
.getLogger(FunctionManageAction.class);
private FunctionManager functionManager;
private Functions function;
private Long functionId;
private FunctionQueryCriteria queryCriteria;
private List menuList = new ArrayList();
@SkipValidation
public String changeFunctionLevel() {
String functionLevel = function.getFunctionLevel();
findMenuList(functionLevel);
return SUCCESS;
}
@SkipValidation
public String findFunctions() {
super.query(SqlConstants.GET_FUNCTIONS,
SqlConstants.GET_FUNCTION_COUNT, queryCriteria);
// 页面资源权限校验
if (queryCriteria != null)
findMenuList(queryCriteria.getFunctionLevel());
super.check(ActionConstants.FUNCTION_MANAGE_FIND_FUNCTIONS,
ActionConstants.FUNCTION_MANAGE_VIEW_FUNCTION,
ActionConstants.FUNCTION_MANAGE_ADD_FUNCTION,
ActionConstants.FUNCTION_MANAGE_EDIT_FUNCTION,
ActionConstants.FUNCTION_MANAGE_DELETE_FUNCTION);
return SUCCESS;
}
private void findMenuList(String aFunctionLevel) {
if (!StringUtils.isEmpty(aFunctionLevel)) {
String functionLevel = null;
if (aFunctionLevel.equals(DictionaryConstants.FUNCTION_LEVEL_FOUR))
functionLevel = DictionaryConstants.FUNCTION_LEVEL_THREE;
if (aFunctionLevel.equals(DictionaryConstants.FUNCTION_LEVEL_THREE))
functionLevel = DictionaryConstants.FUNCTION_LEVEL_TWO;
if (aFunctionLevel.equals(DictionaryConstants.FUNCTION_LEVEL_TWO))
functionLevel = DictionaryConstants.FUNCTION_LEVEL_ONE;
if (aFunctionLevel.equals(DictionaryConstants.FUNCTION_LEVEL_ONE))
functionLevel = DictionaryConstants.FUNCTION_LEVEL_ZERO;
menuList = this.functionManager
.findMenusByFunctionLevel(functionLevel);
}
}
@SkipValidation
public String findFunction() {
function = this.functionManager.findFunction(functionId);
if (function != null) {
return SUCCESS;
} else {
this.addActionError(getText("data.not.exist"));
return ERROR;
}
}
@SkipValidation
public String toCreateFunction() {
function = new Functions();
function.setState(DictionaryConstants.STATE_ENABLED);
return SUCCESS;
}
public String createFunction() {
UserVO userVO = (UserVO) getSession().get(Constants.SESSION_USER);
function.setCreateUserId(userVO.getUserId());
function.setCreateDate(new Date());
function.setModifyUserId(userVO.getUserId());
function.setModifyDate(new Date());
int statusCode = this.functionManager.createFunction(function);
if (statusCode == CommonStatusCodes.NAME_EXIST)
super.addActionError(getText("function.functionName.existed"));
if (super.getActionErrors().size() > 0)
return INPUT;
return SUCCESS;
}
@SkipValidation
public String toUpdateFunction() {
function = this.functionManager.findFunction(functionId);
if (function != null) {
this.findMenuList(function.getFunctionLevel());
return SUCCESS;
} else {
this.addActionError(getText("data.not.exist"));
return ERROR;
}
}
public String updateFunction() {
UserVO user = (UserVO) getSession().get(Constants.SESSION_USER);
function.setModifyUserId(user.getUserId());
function.setModifyDate(new Date());
int statusCode = this.functionManager.updateFunction(function);
if (statusCode == CommonStatusCodes.NAME_EXIST)
super.addActionError(getText("function.functionName.existed"));
if (super.getActionErrors().size() > 0)
return INPUT;
return SUCCESS;
}
@SkipValidation
public String deleteFunction() {
function = this.functionManager.findFunction(functionId);
if (function != null) {
this.functionManager.deleteFunction(functionId);
return SUCCESS;
} else {
this.addActionError(getText("data.not.exist"));
return ERROR;
}
}
@Override
public void validate() {
if ((super.getFieldErrors().size() > 0)
|| (super.getActionErrors().size() > 0)) {
findMenuList(function.getFunctionLevel());
}
super.validate();
}
public Functions getFunction() {
return function;
}
public void setFunction(Functions function) {
this.function = function;
}
public Long getFunctionId() {
return functionId;
}
public void setFunctionId(Long functionId) {
this.functionId = functionId;
}
public List getMenuList() {
return menuList;
}
public void setMenuList(List menuList) {
this.menuList = menuList;
}
public FunctionQueryCriteria getQueryCriteria() {
return queryCriteria;
}
public void setQueryCriteria(FunctionQueryCriteria queryCriteria) {
this.queryCriteria = queryCriteria;
}
public void setFunctionManager(FunctionManager functionManager) {
this.functionManager = functionManager;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -