📄 adminaction.java
字号:
HttpServletResponse response) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'activeEmployee' method");
}
DynaActionForm dynaForm = (DynaActionForm) form;
Employee employee = (Employee) dynaForm.get("employeeBean");
AdminService service = (AdminService) getBean("adminService");
request.setAttribute("noSelectRoleList", service.searchNotAssignedRoles(employee.getId()));
request.setAttribute("selectRoleList", service.searchAssignedRoles(employee.getId()));
request.setAttribute("employeeBean", employee);
service.activeEmployee(employee.getId(), getUserId(request));
return mapping.findForward("success");
}
public ActionForward changePassword(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'changePassword' method");
}
String userId = getUserId(request).toString();
DynaActionForm dynaForm = (DynaActionForm) form;
String oldPassword = (String) dynaForm.get("oldPassword");
String newPassword1 = (String) dynaForm.get("newPassword1");
String newPassword2 = (String) dynaForm.get("newPassword2");
AdminService service = (AdminService) getBean("adminService");
if (userId == null) {
return mapping.findForward("failure");
}
Map map = new HashMap();
map.put("userId", userId);
map.put("oldPassword", oldPassword);
map.put("newPassword1", newPassword1);
map.put("newPassword2", newPassword2);
service.resetPasswordBySelf(map);
saveActionTripMessage(request, "message.update");
return mapping.findForward("success");
}
// Department Managerment: ----------------------------------------
public ActionForward searchDepartment(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'listDepartment' method");
}
AdminService service = (AdminService) getBean("adminService");
Pagination pageObj = new Pagination(request, "pagination");
Map paraMap = new HashMap();
Pagination pagination = service.searchDepartment(pageObj, paraMap);
request.setAttribute("pagination", pagination);
return mapping.findForward("success");
}
// Role Managerment: ----------------------------------------
public ActionForward searchRole(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'searchRole' method");
}
DynaActionForm dynaForm = (DynaActionForm) form;
Map paraMap = new HashMap();
paraMap.put("searchBean", dynaForm.get("searchBean"));
Pagination pageObj = new Pagination(request, "pagination");
AdminService mgr = (AdminService) getBean("adminService");
Pagination pagination = mgr.getRoles(paraMap, pageObj);
request.setAttribute("pagination", pagination);
return mapping.findForward("success");
}
public ActionForward initAddRole(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'searchRole' method");
}
DynaActionForm dynaForm = (DynaActionForm) form;
Role roleBean = new Role();
roleBean.setStatus(GlobalConstants.EMP_STATUS_ACTIVE);
dynaForm.set("roleBean", roleBean);
request.setAttribute("roleRes", new ArrayList());
return mapping.findForward("success");
}
public ActionForward initEditRole(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm dynaForm = (DynaActionForm) form;
AdminService service = (AdminService) getBean("adminService");
Role roleBean = (Role) dynaForm.get("roleBean");
Role resultBean = service.getRole(roleBean.getId());
dynaForm.set("roleBean", resultBean);
List role_resList = service.getRoleResource(roleBean.getId());
request.setAttribute("roleRes", role_resList);
return mapping.findForward("success");
}
public ActionForward editRole(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm dynaForm = (DynaActionForm) form;
Role roleBean = (Role) dynaForm.get("roleBean");
String adminModule = (String) dynaForm.get("adminModule");
String supplyChainModule = (String) dynaForm.get("supplyChainModule");
String financeModule = (String) dynaForm.get("financeModule");
String syncModule = (String) dynaForm.get("syncModule");
String[] resource = (String[]) dynaForm.get("resource");
Map paraMap = new HashMap();
List roleRes = new ArrayList();
if (!"".equals(adminModule))
roleRes.add(adminModule);
if (!"".equals(supplyChainModule))
roleRes.add(supplyChainModule);
if (!"".equals(financeModule))
roleRes.add(financeModule);
if (!"".equals(syncModule))
roleRes.add(syncModule);
for (int i = 0; i < resource.length; i++)
roleRes.add(resource[i]);
paraMap.put("roleBean", roleBean);
paraMap.put("roleRes", roleRes);
boolean isAdd = false;
if (roleBean.getId() == null) {
isAdd = true;
}
if (isAdd) {
AdminService service = (AdminService) getBean("adminService");
roleBean.populateCreateBean(getUserId(request));
service.addRoleWithResource(paraMap);
saveActionTripMessage(request, "message.add", null);
} else {
AdminService service = (AdminService) getBean("adminService");
roleBean.populateUpdateBean(getUserId(request));
service.updateRoleWithResource(paraMap);
saveActionTripMessage(request, "message.update");
}
return mapping.findForward("success");
}
public ActionForward deleteRole(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'delete' method");
}
DynaActionForm dynaForm = (DynaActionForm) form;
String[] splitString = (String[]) dynaForm.get("idArr");
AdminService mgr = (AdminService) getBean("adminService");
mgr.removeRole(splitString);
saveActionTripMessage(request, "message.delete");
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -