package com.iwtxokhtd.test.action.employee;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import com.iwtxokhtd.test.PageView;
import com.iwtxokhtd.test.privilege.PrivilegeGroup;
import com.iwtxokhtd.test.utils.MD5;
import com.iwtxokhtd.test.action.base.BaseAction;
import com.iwtxokhtd.test.action.privilege.Privilege;
import com.iwtxokhtd.test.bean.employee.Employee;
public class EmployeeAction extends BaseAction{
/**
*
*/
private static final long serialVersionUID = -4450021706217821543L;
private String username;//用户名
private String password;//密码
private String password2;//确认密码
private String newpassword;//新密码,修改密码时备用
private String realname;//名字
private String phone;//联系电话
private String email;//电子邮件
private String gender;// 性别
private String degree;//学历
private File picture;//上传照片
private String pictureFileName; //文件名,注意命名规则
private String pictureContentType; //文件类型,注意命名规则
private String address;//身份证地址
private Integer[] privilegegroupids;//权限组
private String[] employeeids;//员工
//列出员工
@Privilege(model="employee", privilegeValue="view")
public String employeeList(){
PageView<Employee> pageView = new PageView<Employee>(5, getPage());
//取得用户名
String username=(String)request.getSession().getAttribute("username");
int firstindex = (pageView.getCurrentpage()-1)* pageView.getMaxresult();
LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
orderby.put("visiable", "desc");
orderby.put("username", "desc");
//不能查看到自己
StringBuffer jpql = new StringBuffer("o.username is not ?1");
List<Object> params = new ArrayList<Object>();
if(username!=null&&!"".equals(username)){
params.add(username);
}
pageView.setQueryResult(employeeDao.getScrollData(Employee.class, firstindex,
pageView.getMaxresult(),jpql.toString(),params.toArray(), orderby));
request.setAttribute("pageView", pageView);
return "listemployee";
}
//员工添加界面
@Privilege(model="employee", privilegeValue="insert")
public String employeeAddUI(){
request.setAttribute("groups", employeeDao.getScrollData(PrivilegeGroup.class).getResultlist());
return "add";
}
/*
//判断用户是否存在
public String exist(){
if(employeeDao.exist(this.getUsername())){
request.setAttribute("message", "<font color='red'>"+this.getUsername()+"--此账号已被注册过,请重新选择账号"+"</font>");
}else{
request.setAttribute("message", "<font color='green'>"+this.getUsername()+"--可以使用"+"</font>");
}
return "usernameIsExsit";
}
//判断密码长度
public String passwordlength(){
if(this.getPassword().trim().length()<6||this.getPassword().trim().length()>15){
request.setAttribute("message", "<font color='red'>密码长度必须大于6小于15</font>");
}else{
request.setAttribute("message", "<font color='green'>密码填写正确</font>");
}
return "usernameIsExsit";
}
//判断确认密码长度
public String password2length(){
if(this.getPassword2().trim().length()<6||this.getPassword2().trim().length()>15){
request.setAttribute("message", "<font color='red'>确认密码长度必须大于6小于15</font>");
}
else{
request.setAttribute("message", "<font color='green'>确认密码填写正确</font>");
}
return "usernameIsExsit";
}*/
//添加员工操作
@Privilege(model="employee", privilegeValue="insert")
public String employeeAdd()throws Exception{
if(!employeeDao.exist(this.getUsername())){
Employee employee = new Employee(this.getUsername().trim(),MD5.MD5Encode(this.getPassword()),
this.getRealname(),this.getAddress(),
this.getPhone(),this.getEmail(),this.getGender(),this.getDegree());
if(this.getPrivilegegroupids()!=null&&this.getPrivilegegroupids().length>0){
for(Integer id : this.getPrivilegegroupids()){
employee.addPrivilegeGroups(new PrivilegeGroup(id));
}
}
if(this.pictureFileName!=null&&!"".equals(this.pictureFileName)){
String pathdir = "images/employee/"+ this.getUsername().trim();
int position = pictureFileName.lastIndexOf(".");
String extension =pictureFileName.substring(position);
String uuidpath=UUID.randomUUID().toString()+ extension;
employee.setPicture(pathdir+"/"+uuidpath);
String realpathdir = request.getSession().getServletContext().getRealPath(pathdir);
File target = new File(realpathdir, uuidpath);
FileUtils.copyFile(picture, target);
}
employeeDao.save(employee);
return "message";
}else{
request.setAttribute("message", "<font color='red'>"+this.getUsername()+"该账号已经存在!</font>");
return "input";
}
}
//员工修改界面
@Privilege(model="employee", privilegeValue="update")
public String employeeEditUI(){
Employee employee = employeeDao.find(Employee.class, this.getUsername());
this.setRealname(employee.getRealname());
request.setAttribute("groups", employeeDao.getScrollData(PrivilegeGroup.class).getResultlist());
request.setAttribute("privgroups", employee.getPrivilegegroups());
this.setDegree(employee.getDegree());
this.setEmail(employee.getEmail());
this.setGender(employee.getGender());
this.setPhone(employee.getPhone());
this.setAddress(employee.getAddress());
request.setAttribute("employee", employee);
return "edit";
}
//修改员工操作
@Privilege(model="employee", privilegeValue="update")
public String employeeEdit()throws Exception{
Employee employee = employeeDao.find(Employee.class, this.getUsername());
if(this.pictureFileName!=null&&!"".equals(this.pictureFileName)){
String pathdir = "images/employee/"+ this.getUsername().trim();
int position = pictureFileName.lastIndexOf(".");
String extension =pictureFileName.substring(position);
String uuidpath=UUID.randomUUID().toString()+ extension;
employee.setPicture(pathdir+"/"+uuidpath);
String realpathdir = request.getSession().getServletContext().getRealPath(pathdir);
File target = new File(realpathdir, uuidpath);
FileUtils.copyFile(picture, target);
}
employee.setDegree(this.getDegree());
employee.setEmail(this.getEmail());
employee.setRealname(this.getRealname());
employee.setGender(this.getGender());
employee.setPhone(this.getPhone());
employee.setAddress(this.getAddress());
if(this.getPrivilegegroupids()!=null&&this.getPrivilegegroupids().length>0){
for(Integer id:this.getPrivilegegroupids()){
PrivilegeGroup group=new PrivilegeGroup(id);
if(!employee.getPrivilegegroups().contains(group)){
employee.addPrivilegeGroups(group);
}
}
}
if(this.getPrivilegegroupids()!=null&&this.getPrivilegegroupids().length>0){
List<PrivilegeGroup> deletegroup = new ArrayList<PrivilegeGroup>();
List<Integer> groupids = Arrays.asList(this.getPrivilegegroupids());//当前被选择的权限组
for(PrivilegeGroup group:employee.getPrivilegegroups()){
if(!groupids.contains(group.getId())){
deletegroup.add(group);
}
}
employee.getPrivilegegroups().removeAll(deletegroup);
}
employeeDao.update(employee);
request.setAttribute("message", "员工信息修改成功");
return "message";
}
//员工登录
public String login(){
String username=this.getUsername();
String password=MD5.MD5Encode(this.getPassword());
Employee employee=new Employee();
employee.setUsername(username);
employee.setPassword(password);
boolean flag=employeeDao.login(employee);
if(flag){
request.getSession().setAttribute("username", employee.getUsername());
Employee emp=employeeDao.find(Employee.class, employee.getUsername());
request.getSession().setAttribute("realname", emp.getRealname());
return "lo
没有合适的资源?快使用搜索试试~ 我知道了~
Struts2,spring2.5与jpa的整合示例
共104个文件
java:27个
class:27个
jsp:16个
需积分: 0 55 下载量 155 浏览量
2009-01-03
15:11:57
上传
评论
收藏 100KB RAR 举报
温馨提示
Struts2,spring2.5与jpa的整合,包括精确到领域对象的权限管理
资源推荐
资源详情
资源评论
收起资源包目录
Struts2,spring2.5与jpa的整合示例 (104个子文件)
EmployeeAction.class 11KB
BaseDAOSupport.class 8KB
PrivilegeGroupAction.class 6KB
Employee.class 6KB
EmployeeDAOBean.class 5KB
AuthorizationInterceptor.class 5KB
PrivilegeGroup.class 3KB
IDCardAction.class 3KB
PageView.class 2KB
BaseAction.class 2KB
SystemPrivilege.class 2KB
IDCard.class 2KB
MD5.class 2KB
BaseDAO.class 2KB
SystemPrivilegePK.class 2KB
SystemPrivilegeDAOBean.class 1KB
QueryResult.class 1KB
SiteUrl.class 1KB
PageIndex.class 751B
GooglePage.class 724B
EmployeeDAO.class 707B
PrivilegeGroupDAOBean.class 599B
IDCardDAOBean.class 576B
Privilege.class 471B
SystemPrivilegeDAO.class 324B
PrivilegeGroupDAO.class 194B
IDCardDAO.class 181B
.classpath 4KB
doctemp.gif 914B
openfld.gif 906B
edit.gif 223B
clsfld.gif 145B
midclosedfolder.gif 135B
midopenedfolder.gif 132B
vertline.gif 103B
lastnodeline.gif 100B
EmployeeAction.java 10KB
BaseDAOSupport.java 6KB
Employee.java 5KB
PrivilegeGroupAction.java 4KB
EmployeeDAOBean.java 4KB
AuthorizationInterceptor.java 4KB
PrivilegeGroup.java 2KB
BaseAction.java 2KB
IDCard.java 2KB
SystemPrivilege.java 2KB
IDCardDAOBean.java 2KB
SystemPrivilegePK.java 2KB
BaseDAO.java 2KB
IDCardAction.java 2KB
PageView.java 1KB
MD5.java 1KB
EmployeeDAO.java 1KB
SystemPrivilegeDAOBean.java 638B
GooglePage.java 628B
PageIndex.java 509B
SiteUrl.java 496B
QueryResult.java 459B
PrivilegeGroupDAOBean.java 420B
Privilege.java 365B
SystemPrivilegeDAO.java 345B
PrivilegeGroupDAO.java 339B
IDCardDAO.java 299B
utils.js 8KB
right.jsp 26KB
list.jsp 6KB
add.jsp 5KB
edit.jsp 4KB
menu.jsp 4KB
list.jsp 4KB
list.jsp 2KB
update.jsp 2KB
add.jsp 2KB
login.jsp 2KB
fenye.jsp 2KB
index.jsp 958B
default.jsp 881B
end.jsp 647B
top.jsp 627B
noprivilege.jsp 612B
MANIFEST.MF 39B
.mymetadata 282B
.project 1KB
messageResource_zh_CN.properties 406B
messageResource_zh_CN.properties 406B
jdbc.properties 197B
jdbc.properties 197B
struts.properties 44B
struts.properties 44B
beans.xml 3KB
beans.xml 3KB
struts_employee.xml 3KB
struts_employee.xml 3KB
struts_privilegegroup.xml 3KB
struts_privilegegroup.xml 3KB
persistence.xml 1KB
persistence.xml 1KB
web.xml 1KB
struts_idcard.xml 914B
struts_idcard.xml 914B
共 104 条
- 1
- 2
资源评论
iwtxokhtd_2008_new
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功