Forder.java
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package com.oa.module.folder;
  2. import java.io.File;
  3. import com.oa.module.folder.bean.FolderBean;
  4. import com.oa.module.folder.dao.FolderDao;
  5. import com.oa.util.ToolUtil;
  6. /**
  7.  * 用户注册成功则为每个用户创建一个文件夹
  8.  * 
  9.  * @author MY-PC
  10.  * 
  11.  */
  12. public class Forder {
  13. private FolderDao dao;
  14. /**
  15.  * 为每一个用户创建一个默认的文件夹
  16.  * 
  17.  * @param username
  18.  */
  19. public  boolean buildSystemForder(String userid, String username, String path) {
  20. File forder = new File(path);
  21. String fordername = "";
  22. FolderBean bean = null;
  23. FolderBean temp = null;
  24. if (!forder.exists())
  25. forder.mkdir();
  26. fordername = path + "/" + username + "," + userid;
  27. forder = new File(fordername);
  28. forder.mkdir();
  29. bean = new FolderBean();
  30. bean.setCreatetime(ToolUtil.getNowDate());
  31. bean.setFatherid("0");
  32. bean.setFordername(username+","+userid);
  33. bean.setUserid(userid);
  34. bean.setUsername(username);
  35. bean.setVirtualfordername(username+","+userid);
  36. dao.addnewForder(bean);
  37. temp = dao.getFatherForderByUserName(userid, username);
  38. fordername =path + "/" + username + "," + userid + "/我的音乐";
  39. forder = new File(fordername);
  40. forder.mkdir();
  41. bean = new FolderBean();
  42. bean.setCreatetime(ToolUtil.getNowDate());
  43. bean.setFatherid(temp.getForder());
  44. bean.setFordername("我的音乐");
  45. bean.setUserid(userid);
  46. bean.setUsername(username);
  47. bean.setVirtualfordername("我的音乐");
  48. dao.addnewForder(bean);
  49. forder = new File(path + "/" + username + "," + userid + "/我的文档");
  50. forder.mkdir();
  51. bean = new FolderBean();
  52. bean.setCreatetime(ToolUtil.getNowDate());
  53. bean.setFatherid(temp.getForder());
  54. bean.setFordername("我的文档");
  55. bean.setUserid(userid);
  56. bean.setUsername(username);
  57. bean.setVirtualfordername("我的文档");
  58. dao.addnewForder(bean);
  59. forder = new File(path + "/" + username + "," + userid + "/我的图片");
  60. forder.mkdir();
  61. bean = new FolderBean();
  62. bean.setCreatetime(ToolUtil.getNowDate());
  63. bean.setFatherid(temp.getForder());
  64. bean.setFordername("我的图片");
  65. bean.setUserid(userid);
  66. bean.setUsername(username);
  67. bean.setVirtualfordername("我的图片");
  68. boolean flag = dao.addnewForder(bean);
  69. return flag;
  70. }
  71. /**
  72.  * 用户自己创建文件夹
  73.  * 
  74.  * @param userId
  75.  * @param forderName
  76.  */
  77. public  boolean buildUserForder(String userId, String username,String forderName, String path) {
  78. FolderBean bean = null;
  79. FolderBean temp = null;
  80. temp = dao.getFatherForderByUserName(userId, username);
  81. File forder = new File(path + "/" + username + "," + userId + "/"
  82. + forderName);
  83. forder.mkdir();
  84. bean = new FolderBean();
  85. bean.setCreatetime(ToolUtil.getNowDate());
  86. bean.setFatherid(temp.getForder());
  87. bean.setFordername(forderName);
  88. bean.setUserid(userId);
  89. bean.setUsername(username);
  90. bean.setVirtualfordername(forderName);
  91. boolean flag = dao.addnewForder(bean);
  92. return flag;
  93. }
  94. public FolderDao getDao() {
  95. return dao;
  96. }
  97. public void setDao(FolderDao dao) {
  98. this.dao = dao;
  99. }
  100. }