Forder.java
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.oa.module.folder;
- import java.io.File;
- import com.oa.module.folder.bean.FolderBean;
- import com.oa.module.folder.dao.FolderDao;
- import com.oa.util.ToolUtil;
- /**
- * 用户注册成功则为每个用户创建一个文件夹
- *
- * @author MY-PC
- *
- */
- public class Forder {
- private FolderDao dao;
- /**
- * 为每一个用户创建一个默认的文件夹
- *
- * @param username
- */
- public boolean buildSystemForder(String userid, String username, String path) {
- File forder = new File(path);
- String fordername = "";
- FolderBean bean = null;
- FolderBean temp = null;
- if (!forder.exists())
- forder.mkdir();
- fordername = path + "/" + username + "," + userid;
- forder = new File(fordername);
- forder.mkdir();
- bean = new FolderBean();
- bean.setCreatetime(ToolUtil.getNowDate());
- bean.setFatherid("0");
- bean.setFordername(username+","+userid);
- bean.setUserid(userid);
- bean.setUsername(username);
- bean.setVirtualfordername(username+","+userid);
- dao.addnewForder(bean);
- temp = dao.getFatherForderByUserName(userid, username);
- fordername =path + "/" + username + "," + userid + "/我的音乐";
- forder = new File(fordername);
- forder.mkdir();
- bean = new FolderBean();
- bean.setCreatetime(ToolUtil.getNowDate());
- bean.setFatherid(temp.getForder());
- bean.setFordername("我的音乐");
- bean.setUserid(userid);
- bean.setUsername(username);
- bean.setVirtualfordername("我的音乐");
- dao.addnewForder(bean);
- forder = new File(path + "/" + username + "," + userid + "/我的文档");
- forder.mkdir();
- bean = new FolderBean();
- bean.setCreatetime(ToolUtil.getNowDate());
- bean.setFatherid(temp.getForder());
- bean.setFordername("我的文档");
- bean.setUserid(userid);
- bean.setUsername(username);
- bean.setVirtualfordername("我的文档");
- dao.addnewForder(bean);
- forder = new File(path + "/" + username + "," + userid + "/我的图片");
- forder.mkdir();
- bean = new FolderBean();
- bean.setCreatetime(ToolUtil.getNowDate());
- bean.setFatherid(temp.getForder());
- bean.setFordername("我的图片");
- bean.setUserid(userid);
- bean.setUsername(username);
- bean.setVirtualfordername("我的图片");
- boolean flag = dao.addnewForder(bean);
- return flag;
- }
- /**
- * 用户自己创建文件夹
- *
- * @param userId
- * @param forderName
- */
- public boolean buildUserForder(String userId, String username,String forderName, String path) {
- FolderBean bean = null;
- FolderBean temp = null;
- temp = dao.getFatherForderByUserName(userId, username);
- File forder = new File(path + "/" + username + "," + userId + "/"
- + forderName);
- forder.mkdir();
- bean = new FolderBean();
- bean.setCreatetime(ToolUtil.getNowDate());
- bean.setFatherid(temp.getForder());
- bean.setFordername(forderName);
- bean.setUserid(userId);
- bean.setUsername(username);
- bean.setVirtualfordername(forderName);
- boolean flag = dao.addnewForder(bean);
- return flag;
- }
- public FolderDao getDao() {
- return dao;
- }
- public void setDao(FolderDao dao) {
- this.dao = dao;
- }
- }