package cn.lanou.staff.action;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import cn.lanou.staff.service.DepartmentServiceInterface;
import cn.lanou.staff.service.PostServiceInterface;
import cn.lanou.staff.service.StaffServiceInterface;
import cn.lanou.util.Util;
public class StaffAction extends ActionSupport implements ServletRequestAware{
@Resource(name=StaffServiceInterface.STAFFSERVICEIMP)
private StaffServiceInterface service;
public void setService(StaffServiceInterface service) {
this.service = service;
}
@Resource(name = PostServiceInterface.POSTSERVICEIMP)
private PostServiceInterface postService;
public void setService(PostServiceInterface service) {
this.postService = service;
}
@Resource(name=DepartmentServiceInterface.DEPARTMENTSERVICEIMP)
private DepartmentServiceInterface departmentService;
public void setDepartmentService(DepartmentServiceInterface departmentService) {
this.departmentService = departmentService;
}
// 跳转首页
public String showList() {
// 查询所有用户
List<StaffVo> ls = this.service.searchAllStaff();
ActionContext.getContext().put("ls", ls);
// 查询所有部门
List<DeptmentVO> deptS = this.departmentService.searchAllDepartment();
ActionContext.getContext().put("deptS", deptS);
return "showList";
}
// 进行编辑
public String editPage() {
String staffId = this.request.getParameter("staffId");
// 根据staffId查询这个员工的信息
StaffVo v = this.service.searchStaffById(staffId);
ActionContext.getContext().put("v", v);
// 查询所有部门
List<DeptmentVO> deptS = this.departmentService.searchAllDepartment();
// 如果去和默认的一样的部门
for(int i = 0; i < deptS.size(); i++) {
if (deptS.get(i).getDepName().equals(v.getDepName())) {
deptS.remove(i);
}
}
// 查询出员工所在部门的所有岗位
List<PostVo> posts = this.postService.searchPostsByDeptId(v.getDepId());
for(int i = 0; i < posts.size();i++) {
if (posts.get(i).getPostName().equals(v.getPostName())) {
posts.remove(i);
}
}
ActionContext.getContext().put("deptS", deptS);
ActionContext.getContext().put("posts", posts);
return "editPage";
}
// 保存编辑
public String saveEdit() {
// 获取到请求的数据
String staffId = this.request.getParameter("staffId");
String loginName = this.request.getParameter("loginName");
String loginPwd = this.request.getParameter("loginPwd");
String oldPassword = this.request.getParameter("oldPassword");
String staffName = this.request.getParameter("staffName");
String gender = this.request.getParameter("gender");
String deptId = this.request.getParameter("deptId");
String PostId = this.request.getParameter("PostId");
String onDutyDate = this.request.getParameter("onDutyDate");
StaffVo vo = new StaffVo();
vo.setStaffId(staffId);
vo.setLoginName(loginName);
vo.setLoginPwd(loginPwd);
vo.setOldPassword(oldPassword);
vo.setStaffName(staffName);
vo.setGender(gender);
vo.setDepId(deptId);
vo.setPostId(PostId);
vo.setOnDutyDate(onDutyDate);
if (!oldPassword.equals(loginPwd)) { // 判断密码是否修改了
// 判断密码是不是合法, 不合法的话回显
Boolean passReg = Util.passwordReg(vo.getLoginPwd(), vo.getLoginName());
if (passReg == false) { // 密码不好使
vo.setLoginPwd(vo.getOldPassword()); // 改成原来的密码
ActionContext.getContext().put("v", vo);
// 查询所有部门
List<DeptmentVO> deptS = this.departmentService.searchAllDepartment();
// 如果去和默认的一样的部门
for(int i = 0; i < deptS.size(); i++) {
if (deptS.get(i).getDepName().equals(vo.getDepName())) {
deptS.remove(i);
}
}
ActionContext.getContext().put("deptS", deptS);
addFieldError("loginPwd", "密码不合符规范");
return "editPage";
}
}
// 进行更新
this.service.updateStaff(vo);
return "saveEdit";
}
// 跳转到保存的界面
public String savePage() {
List<DeptmentVO> deptS = this.departmentService.searchAllDepartment();
ActionContext.getContext().put("deptS", deptS);
return "savePage";
}
// 保存用户
public String saveStaff() {
String loginName = this.request.getParameter("loginName");
String password = this.request.getParameter("password");
String staffName = this.request.getParameter("staffName");
String gender = this.request.getParameter("gender");
String deptId = this.request.getParameter("deptId");
String PostId = this.request.getParameter("PostId");
String onDutyDate = this.request.getParameter("onDutyDate");
StaffVo staffVo = new StaffVo();
staffVo.setLoginName(loginName);
String pass = Util.EncoderByMd5(password);
staffVo.setLoginPwd(pass);
staffVo.setStaffName(staffName);
staffVo.setGender(gender);
staffVo.setDepId(deptId);
staffVo.setPostId(PostId);
staffVo.setOnDutyDate(onDutyDate);
this.service.saveStaff(staffVo);
return "saveStaff";
}
private HttpServletRequest request;
@Override
public void setServletRequest(HttpServletRequest arg0) {
this.request = arg0;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
SSH框架,简单的多表查询 (321个子文件)
StaffServiceImp.class 6KB
StaffAction.class 6KB
PostServiceImp.class 4KB
DepartmentAction.class 4KB
DepartmentServiceImp.class 4KB
PostDaoImp.class 3KB
AjaxAction.class 3KB
PostAction.class 3KB
StaffVo.class 3KB
StaffDaoImp.class 3KB
DeptmentImp.class 3KB
LoginAction.class 2KB
Text.class 2KB
Util.class 2KB
Staff.class 2KB
Post.class 2KB
Student.class 2KB
LoginInterceptor.class 1KB
PostVo.class 1KB
DeptPageBean.class 1KB
Department.class 1KB
Dao.class 1KB
LoginNameAction.class 1019B
DepartmentServiceInterface.class 822B
Test2.class 815B
Test1.class 795B
PostServiceInterface.class 766B
HomeAction.class 758B
DeptmentInterface.class 748B
DeptmentVO.class 743B
Service.class 663B
StaffServiceInterface.class 638B
PostDaoInterface.class 635B
loginAction.class 625B
StaffDaoInterface.class 549B
LoginPageAction.class 488B
.classpath 1KB
org.eclipse.wst.common.component 529B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 2KB
sys.css 2KB
dtree.css 795B
face.gif 2KB
jxtj.gif 1KB
login.gif 1KB
pwd.gif 1KB
exit.gif 1KB
hlsxcp.gif 1KB
calendar.gif 1KB
xzcp.gif 1KB
tjcp.gif 1KB
yfh.gif 1KB
add.gif 1KB
back.gif 1KB
cr.gif 1KB
save.gif 1KB
dy.gif 1KB
globe.gif 1KB
zhengshi.gif 1KB
pa.gif 1KB
reg.gif 1KB
trash.gif 1KB
question.gif 1KB
base.gif 1KB
modif.gif 1KB
td.gif 1010B
gaojichaxun.gif 999B
genjin.gif 987B
result.gif 987B
add_group.gif 985B
zttj.gif 984B
cjyh.gif 939B
scmx.gif 916B
hzwc.gif 898B
quanzhankai.gif 874B
nolines_plus.gif 870B
nolines_minus.gif 861B
bianji.gif 858B
shanchu.gif 853B
shuaxin.gif 846B
quxiao.gif 844B
liuji.gif 839B
gd.gif 839B
tianjia.gif 838B
qr.gif 835B
qd.gif 833B
yijiao.gif 824B
jiuye.gif 823B
shenhe.gif 822B
liushi.gif 820B
shengban.gif 817B
tongji.gif 814B
print.gif 814B
chakan.gif 812B
sh.gif 804B
js.gif 803B
txl.gif 799B
sq.gif 799B
shiye.gif 795B
tuihui.gif 793B
共 321 条
- 1
- 2
- 3
- 4
资源评论
qq_40102339
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功