📄 resumeaction.java.svn-base
字号:
package com.dfsz.action;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;import java.sql.Blob;import java.text.MessageFormat;import java.util.HashSet;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;import java.util.Set;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;import org.hibernate.Hibernate;import util.dao.Pagination;import com.dfsz.dao.CitysDao;import com.dfsz.dao.CitysDaoImpl;import com.dfsz.dao.PhotoDao;import com.dfsz.dao.PhotoDaoImpl;import com.dfsz.dao.ProvinceDao;import com.dfsz.dao.ProvinceDaoImpl;import com.dfsz.dao.ResumeDao;import com.dfsz.dao.ResumeDaoImpl;import com.dfsz.dao.WorkTypeDao;import com.dfsz.dao.WorkTypeDaoImpl;import com.dfsz.model.Citys;import com.dfsz.model.Photo;import com.dfsz.model.Province;import com.dfsz.model.Resume;import com.dfsz.model.WorkType;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;@SuppressWarnings("unchecked")public class ResumeAction extends ActionSupport { private static final long serialVersionUID = 1L; private Resume resume; private List<Resume> resumeList; private Long id; private int currentpage; private int pageSum; @SuppressWarnings("unused") private int resumeListSize; private int count; private int order; private Map<Province, List<Citys>> citiesMap = new LinkedHashMap(); private List<WorkType> workTypeList; private Citys city; private Province province; private String contentType; private File upload; private String fileName; private String orderFileName; private Photo photos; private static ResumeDao resumeDao = new ResumeDaoImpl(); private static PhotoDao photoDao = new PhotoDaoImpl(); public Photo getPhotos() { return photos; } public void setPhotos(Photo photos) { this.photos = photos; } Pagination<Resume> paginations = new Pagination<Resume>(); public Pagination<Resume> getPaginations() { return paginations; } public void setPaginations(Pagination<Resume> paginations) { this.paginations = paginations; } public String getOrderFileName() { return orderFileName; } public void setOrderFileName(String orderFileName) { this.orderFileName = orderFileName; } public String getUploadFileName() { return fileName; } public void setUploadFileName(String fileName) { this.fileName = fileName; } public String getUploadContentType() { return contentType; } public void setUploadContentType(String contentType) { this.contentType = contentType; } public File getUpload() { return upload; } public void setUpload(File upload) { this.upload = upload; } public Citys getCity() { return city; } public void setCity(Citys city) { this.city = city; } public Province getProvince() { return province; } public void setProvince(Province province) { this.province = province; } public List<WorkType> getWorkTypeList() { WorkTypeDao workTypeDao = new WorkTypeDaoImpl(); workTypeList = workTypeDao.get(); return workTypeList; } public void setWorkTypeList(List<WorkType> workTypeList) { this.workTypeList = workTypeList; } public Map<Province, List<Citys>> getCitiesMap() { CitysDao citysDao = new CitysDaoImpl(); citiesMap = citysDao.listAddress(); return citiesMap; } public void setCitiesMap(Map<Province, List<Citys>> citiesMap) { this.citiesMap = citiesMap; } public int getOrder() { return order; } public void setOrder(int order) { this.order = order; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } public int getResumeListSize() { return resumeList.size(); } public void setResumeListSize(int resumeListSize) { this.resumeListSize = resumeListSize; } public int getCurrentpage() { return currentpage; } public void setCurrentpage(int currentpage) { this.currentpage = currentpage; } public void setPageSum(int pageSum) { this.pageSum = pageSum; } public int getPageSum() { return pageSum; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public List<Resume> getResumeList() { return resumeList; } public void setResumeList(List<Resume> resumeList) { this.resumeList = resumeList; } public Resume getResume() { return resume; } public void setResume(Resume resume) { this.resume = resume; } public String input() throws Exception { // TODO Auto-generated method stub return "input"; } public String submit() throws Exception { if (upload != null) { Photo photo = new Photo(); Set<Photo> photoSet = new HashSet<Photo>(); InputStream input = new FileInputStream(upload); Blob photoBlob = Hibernate.createBlob(input); photo.setPhoto(photoBlob); photoSet.add(photo); resume.setPhoto(photoSet); } else if (photoDao.findById(photos.getId()) == null) { Photo photo = new Photo(); Blob photoBlob = Hibernate.createBlob(this.getClass() .getResourceAsStream("resume_n.bmp")); photo.setPhoto(photoBlob); resume.getPhoto().add(photo); } else { Set<Photo> photoSet = new HashSet<Photo>(); photoSet.add(photoDao.findById(photos.getId())); resume.setPhoto(photoSet); } resumeDao.saveOrUpdate(resume); return SUCCESS; } public String show() throws Exception { Pagination<Resume> pagination = new Pagination<Resume>(); pagination.setSize(5); if (currentpage == 0) { pagination.setNo(1); } else { pagination.setNo(currentpage); } if (order == 1) { pagination.setDesc(true); } if (order == 0) { pagination.setDesc(false); } pagination.setOrderFieldName(orderFileName); resumeDao.browse(pagination); pageSum = pagination.getPageSum(); resumeList = pagination.getResults(); return "show"; } public String gotoUpdate() throws Exception { photos = resumeDao.findById(resume.getId()).getPhoto().iterator().next(); return "gotoupdate"; } public String delete() throws Exception { resumeDao.delete(resumeDao.findById(id)); return SUCCESS; } public String detileInfo() throws Exception { resume = resumeDao.findById(id); return SUCCESS; } public String addAddress() throws Exception { if (province.getName() != null && !province.getName().equals("")) { ProvinceDao provinceDao = new ProvinceDaoImpl(); provinceDao.create(province); city.setProvince(province); } CitysDao citysDao = new CitysDaoImpl(); citysDao.saveOrUpdate(city); return SUCCESS; } public String gotoNewAddress() throws Exception { return SUCCESS; } public String deleteGroup() throws Exception { ActionContext ctx = ActionContext.getContext(); HttpServletRequest request = (HttpServletRequest) ctx .get(ServletActionContext.HTTP_REQUEST); String count = request.getParameter("count"); int num = 0; Long delid; if (count != null) { num = Integer.parseInt(count); } for (int i = 0; i < num; i++) { String ids = request.getParameter("id" + i); if (ids != null) { delid = Long.parseLong(ids); resume = resumeDao.findById(delid); resumeDao.delete(resume); } } return SUCCESS; } public void validateAddAddress() { if (province.getName() != null && !province.getName().equals("")) { ProvinceDao provinceDao = new ProvinceDaoImpl(); if (!provinceDao.isUniqueName(province.getName())) { this.addFieldError("errorlabel", "该省已存在"); } } } public void validateGotoUpdate() { resume = resumeDao.findById(id); if (this.resume == null) { this.addFieldError("errorlabel", MessageFormat.format( "想修改的城市id({0})不存在", id)); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -