📄 roleaction.java
字号:
/*
* Created on 2007-2-24
* Last modified on 2007-8-22
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.controller.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.yeqiangwei.club.service.ServiceLocator;
import com.yeqiangwei.club.service.ServiceWrapper;
import com.yeqiangwei.club.service.model.RoleModel;
import com.yeqiangwei.club.service.security.RoleService;
import com.yeqiangwei.club.util.BeanUtils;
import com.yeqiangwei.club.util.MessageUtils;
import com.yeqiangwei.club.controller.form.RoleForm;
import com.yeqiangwei.club.controller.form.build.RoleBuild;
import com.yeqiangwei.club.exception.ClubException;
import com.yeqiangwei.util.HttpServletUtils;
import com.yeqiangwei.util.ParamUtils;
public class RoleAction{
private static final Logger logger = Logger.getLogger(RoleAction.class);
public RoleAction(){
}
public void createOrUpdate(HttpServletRequest request,HttpServletResponse response){
RoleForm roleForm = new RoleBuild(request).building();
RoleModel roleModel = new RoleModel();
BeanUtils.copyProperties(roleModel,roleForm);
request.setAttribute("RoleForm",roleForm);
try {
this.getRoleService().createOrUpdate(roleModel);
request.setAttribute("message", MessageUtils.getMessage("success"));
} catch (ClubException e) {
request.setAttribute("message", e.toString());
logger.debug(e.toString());
}
HttpServletUtils.forward(request,response,"/club/admin/role.jsp");
}
public void delete(HttpServletRequest request,HttpServletResponse response){
int roleId = ParamUtils.getIntParameter(request,"roleId");
if(roleId>0){
try {
RoleModel roleModel = new RoleModel();
roleModel.setRoleId(roleId);
this.getRoleService().delete(roleModel);
request.setAttribute("message", MessageUtils.getMessage("success"));
} catch (ClubException e) {
request.setAttribute("message", e.toString());
}
}else{
request.setAttribute("message", MessageUtils.getMessage("error_parameter"));
}
HttpServletUtils.forward(request,response,"/club/admin/roles.jsp");
}
public RoleService getRoleService() {
return ServiceWrapper.<RoleService>getSingletonInstance(ServiceLocator.ROLE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -