📄 departmenteditaction.java
字号:
package com.seavision.PermissionManage.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.seavision.PermissionManage.components.DepartmentManage;
import com.seavision.PermissionManage.components.LogManage;
import com.seavision.PermissionManage.components.UrlBalanceManage;
import com.seavision.PermissionManage.help.DaoFectory;
import com.seavision.PermissionManage.common.BaseAction;
import com.seavision.PermissionManage.vo.DepartmentVO;
import com.seavision.PermissionManage.vo.UserLoginVO;
import com.seavision.PermissionManage.vo.UserVO;
public class DepartmentEditAction extends BaseAction {
/**
* @author 尚渊杰
* @param String departmentId String departmentName String department_p
* String companyId String departmentPhone String departmentAuthority
* String departmentState String departmentType
* @功能 编辑部门action
* @功能描述: 根据页面传来的参数编辑部门相应的信息,进行页面跳转,
* 成功返回SUCCESS 失败返回FALSE
*/
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) {
try {
// 初始化Action
String departmentId = "";
String departmentName = "";
String department_p = "";
String companyId = "";
String departmentPhone = "";
String departmentAuthority = "";
String departmentState = "";
String departmentType = "";
String ipAddress = ""; // ip地址
String operator = ""; // 操作人
// boolean b = false; // 用于判断用户权限
String b1 = ""; // 用于跳转页面
String url = "";
String message = "";
this.initializeAction(request, "DepartmentEditAction");
// 获取参数
UserLoginVO userLoginVO = new UserLoginVO();
userLoginVO = (UserLoginVO)this.getAttribute("userLoginVO");
operator = userLoginVO.getUserName();
// request获取参数
departmentId = request.getParameter("departmentId");
departmentName = request.getParameter("departmentName");
department_p = request.getParameter("department");
companyId = request.getParameter("company");
departmentPhone = request.getParameter("departmentPhone");
departmentAuthority = request.getParameter("departmentAuthority");
departmentState = request.getParameter("departmentState");
departmentType = request.getParameter("departmentType");
// url = request.getParameter("url");
ipAddress = request.getRemoteAddr();
url = request.getRequestURI();
// session校验参数校验
if (this.check(userLoginVO)) {
message += "您还没有登录或您离开系统时间太久,请重新登录!";
// 返回到登录页面
return this.moveToFailure(message, "logon", actionMapping);
}
// 判断用户权限
// UrlBalanceManage ubm = new UrlBalanceManage();
// b = ubm.urlBalance(url);
// if (!b) {
// message += "您没有此权限";
// return this.moveToFailure(message, "FALSE", actionMapping);
// }
// 判断部门名是否为null
if (check(departmentName)) {
message += "部门名称不能为空!";
return this.moveToFailure(message, "FALSE", actionMapping);
}
// 判断上级部门编号是否为null
if (check(department_p)) {
department_p = "0";
}
// 判断公司编号是否为null
if (check(companyId)) {
message = "公司编号不能为空!";
return this.moveToFailure(message, "FALSE", actionMapping);
}
// 判断部门电话是否为null
if (check(departmentPhone)) {
departmentPhone = "";
}
// 判断部门负责人是否为null
if (check(departmentAuthority)||departmentAuthority.trim().equals("请选择")) {
departmentAuthority = "0";
}
// 判断部门状态标记是否为null
if (check(departmentState)) {
departmentState = "";
}
// 判断部门类型是否为null
if (check(departmentType)) {
departmentType = "";
}
// 判断url是否为null
if (check(url)) {
message = "url不能为空!";
return this.moveToFailure(message, "FALSE", actionMapping);
}
// 判断ip地址不能为空
if (check(ipAddress)) {
message = "ip地址不能为空!";
return this.moveToFailure(message, "FALSE", actionMapping);
}
// 判断操作人不能为空
if (check(operator)) {
message = "操作人不能为空!";
return this.moveToFailure(message, "FALSE", actionMapping);
}
DepartmentVO department = new DepartmentVO();
department.setDepartmentId(Integer.parseInt(departmentId));
department.setDepartmentName(departmentName);
department.setDepartment_p(Integer.parseInt(department_p));
department.setCompanyId(Integer.parseInt(companyId));
department.setDepartmentPhone(departmentPhone);
department.setDepartmentAuthority(Integer.parseInt(departmentAuthority));
department.setDepartmentState(Integer.parseInt(departmentState));
department.setDepartmentType(departmentType);
// 调用组件方法,进行业务逻辑处理
DepartmentManage dm = DaoFectory.getDepantManage();
b1 = dm.updateDepartment(department);
// 写入日志
LogManage lm = DaoFectory.getLogManage();
lm.addLog(operator, url, ipAddress, "newDepartment");
// 通过返回值进行判断页面跳转
if (b1.equals("success")) {
return this.moveToSuccess("SUCCESS", actionMapping);
} else {
return this.moveToFailure("新增失败", "FALSE", actionMapping);
}
} catch (Exception e) {
return this.moveToError(e.getMessage(), "error", actionMapping);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -