package com.action;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.entity.File;
import com.entity.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.service.FileService;
import com.service.UserService;
public class FileAction extends ActionSupport implements ModelDriven<File> {
/**
*
*/
private static final long serialVersionUID = 1L;
private java.io.File uploadFile;
private String uploadFileFileName;
private String uploadFileContentType;
private File file;
private FileService fileService;
private UserService userService;
private String downFileName;
private Integer downloadFileId;
private Date startDate;
private Date endDate;
private String name;
@SuppressWarnings("deprecation")
public String addFile() {
if (file.getFileName().trim().equals("")) {
ServletActionContext.getRequest().setAttribute("error", "文件名不能为空!");
return ERROR;
}
Map<String, Object> session = ActionContext.getContext().getSession();
Integer folderId = (Integer) session.get("folderId");
User u = (User) session.get("loginedUser");
file.setCreateTime(new java.util.Date());
file.setCreateUserId(u.getId());
file.setFolderId(folderId);
file.setLength(0);
file.setUpdateMessage(file.getCreateTime().toLocaleString() + " " + u.getName());
file.setFileName(file.getFileName() + "." + file.getType());
if (!fileService.add(file)) {
ServletActionContext.getRequest().setAttribute("error", "当前文件夹下该文件已存在!");
return ERROR;
}
if (folderId != null) {
session.put("fileList", fileService.queryByFolderId(folderId));
}
return SUCCESS;
}
public String renameFile() {
HttpServletRequest request = ServletActionContext.getRequest();
Integer id = (Integer) request.getAttribute("id");
File file = fileService.query(id);
fileService.rename(file, name);
Map<String, Object> session = ActionContext.getContext().getSession();
Integer folderId = (Integer) session.get("folderId");
session.put("fileList", fileService.queryByFolderId(folderId));
return SUCCESS;
}
public String searchFile() {
String keyword = file.getKeyword();
String fileName = file.getFileName();
String fileTheme = file.getFileTheme();
Integer createUserId = file.getCreateUserId();
if (fileName.trim().equals("") && fileTheme.trim().equals("") && keyword.trim().equals("") && createUserId == -1
&& startDate == null && endDate == null) {
ServletActionContext.getRequest().setAttribute("error", "请输入查询信息!");
return INPUT;
} else if (startDate != null && endDate != null) {
if (startDate.compareTo(endDate) > 0) {
ServletActionContext.getRequest().setAttribute("error", "开始时间不能超过结束时间!");
return INPUT;
}
}
Map<String, Object> session = ActionContext.getContext().getSession();
User u = (User) session.get("loginedUser");
List<File> searchedFile = fileService.searchFile(file, startDate, endDate);
session.put("fileList", searchedFile);
session.remove("folderList");
session.remove("folderId");
session.put("currentPath", u.getName() + "/");
return SUCCESS;
}
public String viewFile() {
File viewedFile = fileService.query(file.getId());
User u = userService.query(viewedFile.getCreateUserId());
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("viewedFile", viewedFile);
request.setAttribute("creatorName", u.getName());
return SUCCESS;
}
@SuppressWarnings("deprecation")
public String uploadFile() throws IOException {
if (uploadFile == null) {
ServletActionContext.getRequest().setAttribute("error", "请选择文件!");
return ERROR;
}
file.setFileName(uploadFileFileName);
file.setType(
uploadFileFileName.substring(uploadFileFileName.lastIndexOf(".") + 1, uploadFileFileName.length()));
file.setLength((int) uploadFile.length() / 1024);
Map<String, Object> session = ActionContext.getContext().getSession();
Integer folderId = (Integer) session.get("folderId");
User u = (User) session.get("loginedUser");
file.setCreateTime(new java.util.Date());
file.setCreateUserId(u.getId());
file.setFolderId(folderId);
file.setUpdateMessage(file.getCreateTime().toLocaleString() + " " + u.getName());
if (!fileService.uploadFile(file, uploadFile)) {
ServletActionContext.getRequest().setAttribute("error", "当前文件夹下该文件已存在!");
return ERROR;
}
if (folderId != null) {
session.put("fileList", fileService.queryByFolderId(folderId));
}
return SUCCESS;
}
public InputStream getDownloadFile() throws IOException {
File downloadFile = fileService.query(downloadFileId);
this.downFileName = new String(downloadFile.getFileName().getBytes(), "ISO8859-1");
return fileService.downloadFile(downloadFile);
}
public FileService getFileService() {
return fileService;
}
public void setFileService(FileService fileService) {
this.fileService = fileService;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public java.io.File getUploadFile() {
return uploadFile;
}
public void setUploadFile(java.io.File uploadFile) {
this.uploadFile = uploadFile;
}
public String getUploadFileFileName() {
return uploadFileFileName;
}
public void setUploadFileFileName(String uploadFileFileName) {
this.uploadFileFileName = uploadFileFileName;
}
public String getUploadFileContentType() {
return uploadFileContentType;
}
public void setUploadFileContentType(String uploadFileContentType) {
this.uploadFileContentType = uploadFileContentType;
}
public String getDownFileName() {
return downFileName;
}
public void setDownFileName(String downFileName) {
this.downFileName = downFileName;
}
public Integer getDownloadFileId() {
return downloadFileId;
}
public void setDownloadFileId(Integer downloadFileId) {
this.downloadFileId = downloadFileId;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
@Override
public File getModel() {
return file;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于javaEE的文档管理系统.zip
共187个文件
jar:59个
java:33个
class:33个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 63 浏览量
2022-06-26
18:11:41
上传
评论
收藏 29.45MB ZIP 举报
温馨提示
基于javaEE的文档管理系统.zip 大学生课程设计 基于Java的课程设计 自己大二写的课程设计
资源推荐
资源详情
资源评论
收起资源包目录
基于javaEE的文档管理系统.zip (187个子文件)
FileAction.class 8KB
FolderAction.class 6KB
FileServiceImpl.class 6KB
FolderServiceImpl.class 5KB
FileDaoImpl.class 4KB
DeleteAction.class 4KB
UserServiceImpl.class 3KB
FolderDaoImpl.class 3KB
UserDaoImpl.class 3KB
UserAction.class 3KB
FileAspect.class 3KB
OptRecordAction.class 3KB
File.class 3KB
FolderAspect.class 3KB
BaseDaoImpl.class 2KB
OptRecordDaoImpl.class 2KB
LoginInterceptor.class 2KB
Folder.class 2KB
test.class 1KB
OptRecord.class 1KB
BaseServiceImpl.class 1KB
User.class 1KB
FileService.class 931B
OptRecordServiceImpl.class 854B
UserService.class 804B
FileDao.class 671B
FolderService.class 607B
FolderDao.class 527B
UserDao.class 405B
OptRecordService.class 395B
OptRecordDao.class 375B
BaseService.class 280B
BaseDao.class 273B
.classpath 6KB
org.eclipse.wst.common.component 482B
org.eclipse.wst.jsdt.ui.superType.container 49B
zTreeStyle.css 6KB
fileManage.css 4KB
zTreeStandard.gif 5KB
loading.gif 381B
line_conn.gif 45B
hibernate-core-5.3.7.Final.jar 6.65MB
byte-buddy-1.8.17.jar 2.86MB
com.springsource.org.aspectj.weaver-1.7.2.RELEASE.jar 1.76MB
struts2-core-2.5.17.jar 1.56MB
log4j-core-2.10.0.jar 1.52MB
freemarker-2.3.26-incubating.jar 1.43MB
spring-web-5.1.2.RELEASE.jar 1.31MB
spring-core-5.1.2.RELEASE.jar 1.23MB
spring-context-5.1.2.RELEASE.jar 1.05MB
mysql-connector-java-5.1.46-bin.jar 981KB
spring-webmvc-5.1.2.RELEASE.jar 780KB
javassist-3.23.1-GA.jar 752KB
javassist-3.20.0-GA.jar 733KB
spring-webflux-5.1.2.RELEASE.jar 715KB
spring-beans-5.1.2.RELEASE.jar 656KB
spring-test-5.1.2.RELEASE.jar 604KB
mchange-commons-java-0.2.11.jar 592KB
commons-collections-3.1.jar 546KB
c3p0-0.9.5.2.jar 486KB
commons-lang3-3.6.jar 483KB
antlr-2.7.7.jar 435KB
spring-websocket-5.1.2.RELEASE.jar 407KB
spring-jdbc-5.1.2.RELEASE.jar 392KB
spring-messaging-5.1.2.RELEASE.jar 374KB
spring-aop-5.1.2.RELEASE.jar 360KB
dom4j-2.1.1.jar 316KB
json-lib-2.1-jdk15.jar 293KB
spring-expression-5.1.2.RELEASE.jar 273KB
commons-lang-2.5.jar 273KB
spring-jms-5.1.2.RELEASE.jar 254KB
spring-tx-5.1.2.RELEASE.jar 250KB
log4j-api-2.10.0.jar 249KB
ognl-3.1.15.jar 230KB
commons-io-2.5.jar 204KB
spring-orm-5.1.2.RELEASE.jar 195KB
commons-beanutils-1.7.0.jar 184KB
jandex-2.0.5.Final.jar 183KB
spring-context-support-5.1.2.RELEASE.jar 177KB
javax.persistence-api-2.2.jar 161KB
struts2-json-plugin-2.5.17.jar 78KB
ezmorph-1.0.3.jar 76KB
hibernate-commons-annotations-5.0.4.Final.jar 74KB
spring-oxm-5.1.2.RELEASE.jar 70KB
commons-fileupload-1.3.3.jar 69KB
jboss-logging-3.3.2.Final.jar 65KB
classmate-1.3.4.jar 64KB
commons-logging-1.2.jar 60KB
javax.activation-api-1.2.0.jar 55KB
asm-5.2.jar 52KB
spring-aspects-5.1.2.RELEASE.jar 46KB
asm-commons-5.2.jar 46KB
commons-logging.jar 44KB
asm-tree-5.2.jar 29KB
jboss-transaction-api_1.2_spec-1.1.1.Final.jar 26KB
spring-context-indexer-5.1.2.RELEASE.jar 23KB
spring-jcl-5.1.2.RELEASE.jar 23KB
struts2-spring-plugin-2.5.17.jar 22KB
spring-instrument-5.1.2.RELEASE.jar 7KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
共 187 条
- 1
- 2
资源评论
- 北城以念42023-11-15发现一个宝藏资源,资源有很高的参考价值,赶紧学起来~
我慢慢地也过来了
- 粉丝: 5830
- 资源: 3759
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功