首页 前端知识 基于javaweb mysql的ssm maven知识库管理系统(java ssm bootstrap jquery mysql jsp)

基于javaweb mysql的ssm maven知识库管理系统(java ssm bootstrap jquery mysql jsp)

2024-02-28 11:02:34 前端知识 前端哥 407 153 我要收藏

基于javaweb+mysql的ssm+maven知识库管理系统(java+ssm+bootstrap+jquery+mysql+jsp)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SSM+Maven知识库管理系统(java+ssm+bootstrap+jquery+mysql+jsp)

项目介绍

文件集中上传:系统支持单文件上传以及批量上传,系统支持zip、rar格式的压缩包导入。亮点创新 多格式文件在线预览 用户可以对所有公共文件进行浏览,支持office,pdf格式以及常见图片格式,音频格式,音频播放以流媒体服务搭载实现边下边播的用户体验。 文档链接:系统支持用户对喜爱的文档进行收藏及发送到常用文档。 文档关联:手动关联:用户可以手动对文件关联相关的文件。 自动关联:系统可以自动关联类似文档 规则使用:系统对用户上传的过大文件(视频)进行压缩来加快用户在线预览打开的速度,对文档自动提取简介和关键词。对视频、office等文件提取缩略图。 系统中可增加词典,增强分词效果 智能检索:系统包含全文检索、多重条件检索、关键词检索。同时还支持对检索结果再次附加条件检索。 用户管理:普通用户可以对自己的文件夹、收藏夹管理。用户可以分享自己的文档到公共资源库中。 管理员可以对系统中的用户管理、公共文件审核,系统分类的管理,一些数据的统计和日志记录的查看 用户评论:用户可以对文档进行评论 文本处理:能够支持中文,人名、组织机构名、时间、地名、目标类型、目标名称等实体识别,能对常见文本格式抽取。 文档推荐:系统使用协同过滤算法推荐用户可能会查看的文档 知识图谱:系统中的知识以树结构存放,可以通过知识图谱快速到达你要找的知识点。对于每个节点都有详细的介绍。 智能提取:系统结合PageRank、TF-IDF等算法组织知识点在我们的库中,用户可以通过半自动化的操作,去提取归纳知识,产生新的文档。 信息统计:系统对文档的数据进行统计分析,以图表的方式呈现。 新建文档:用户可以使用在线多功能编辑器新建文档

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。

2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目:是; 查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;

技术栈

  1. spring+spring mvc+mybatis+bootstrap+jquery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择 maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置 4. 运行项目,在浏览器中输入http://localhost:8080/lib/login 登录 5. 登录账号:11184629 密码:123456

注意事项

需要先安装openoffice,下载地址:http://www.openoffice.org/download/index.html 并在TranslateUtils中修改相关路径;


/**
 * 无需登录的Controller
 * 
 *
 */
@Controller
public class CommonController {
	private final Logger LOG = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private FileManageService fileManageService;

	/**
	 * 得到常用文件流
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/thumbnail/{uuid}", method = RequestMethod.GET)
	public String thumbnail(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			@PathVariable("uuid") String uuid) {
		String path = Const.ROOT_PATH + "thumbnail/" + uuid + ".png";
		try {
			InputStream inputStream = new FileInputStream(path);
			OutputStream os = response.getOutputStream();
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/check", method = { RequestMethod.GET, RequestMethod.POST })
	public String checkRegister(UserInfo user, String repassword, HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		String result = null;
		if (user.getUserEmail() != null) {
			String regex = "^[\\w-]+(\\.[\\w-]+)*\\@([\\.\\w-]+)+$";
			boolean flg = Pattern.matches(regex, user.getUserEmail());
			if (flg) {
				if (userService.checkByEmail(user.getUserEmail())) {
					result = "<font class='am-btn-success'>该邮箱未被注册</font>";
				} else {
					result = "<font  class='am-btn-danger'>该邮箱已被注册</font>";
				}
			} else {
				result = "<font  class='am-btn-danger'>邮箱格式不正确</font>";
			}
		}
		if (user.getUserPassword() != null || user.getUserPassword() != null && repassword != null) {
			String regex = "^\\w{5,12}$";
			boolean flg = Pattern.matches(regex, user.getUserPassword());
			if (flg) {
				result = "<font class='am-btn-success'>正常</font>";
			} else {
				result = "<font  class='am-btn-danger'>密码必须5-12个字符组成 </font>";
			}
		} 
		if (user.getUserPassword() != null && repassword != null) {
			String strConfirm = new String(user.getUserPassword());
			String strPwd = new String(repassword);

			if (strConfirm.equals(strPwd)) {
				result = "<font class='am-btn-success'>密码一致</font>";
			} else {
				result = "<font  class='am-btn-danger'>两次密码输入不一致,请重新输入</font>";
			}
		}
		if (user.getUserName() != null) {
			result = "<font class='am-btn-success'>正常</font>";
		}
		response.setContentType("text/html; charset=UTF-8");
		response.getWriter().print(result);
		return null;
	}
}

		response.getWriter().print(result);
		return null;
	}
}

/**
 * 后台登录
 * 
 *
 */
@Controller
@RequestMapping("/admin")
public class SystemController {
	public static void main(String[] args) throws Exception {
		String url = "http://yyf.tunnel.qydev.com/lib/user/index";
		URL u = new URL(url);
		
	}
}

	}
}

/**
 * 后台数据统计
 * 
 *
 */
@Controller
@RequestMapping("/admin")
public class CountMainController {
	
	@Autowired
	private CountService countService;
	
	@RequestMapping(value = "/count-ui", method = RequestMethod.GET)
	public String indexui() {

		return "admin/index";
	}
	
	@RequestMapping(value = "/count/index", method = RequestMethod.GET)
	public String index() {
		
		return "admin/count-index";
	}
	public @ResponseBody JsonResult findAllByUserId(HttpSession session) {

		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);
		JsonResult jr = new JsonResult(true, "暂存成功");
		List<DocInfo> docInfos = docInfoService.findAllByUserId(Long.valueOf(user.getUserId()));
		if (docInfos.size() == 0) {
			docInfoService.insert("常用收藏", user.getUserId());
			docInfos = docInfoService.findAllByUserId(Long.valueOf(user.getUserId()));
		}
		jr.setData(docInfos);
		return jr;
	}

	/**
	 * 添加收藏夹
	 * 
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "/insertDoc", method = RequestMethod.POST)
	public @ResponseBody JsonResult insertDoc(String docName, HttpSession session) {
		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);
		JsonResult jr = new JsonResult(true, "添加成功");
		List<DocInfo> docInfos = docInfoService.findAllByUserId(user.getUserId());
		for (DocInfo d : docInfos) {
			if (d.getDocName().equals(docName)) {

				jr.setError("添加失败,收藏夹名重复");
				jr.setSuccess(false);
				return jr;
			}

		}
		docInfoService.insert(docName, user.getUserId());
		return jr;
	}

	/**
	 * 删除收藏夹
	 * 
	 * @param session
	 * @return
	/**
	 * 跳转到上传页面
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/upload", method = RequestMethod.GET)
	public String upload(Model model, HttpSession session) {
		session.removeAttribute(Const.SESSION_UPLOADS);
		List<String> list = new ArrayList<>();
		session.setAttribute(Const.SESSION_UPLOADS, list);
		return "file/upload";
	}

	/**
	 * 跳转到新建页面
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/newfile", method = RequestMethod.GET)
	public String newfile(Model model) {

		return "file/newfile";
	}

	/**
	 * 跳转上传完成页面
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/upload-complete", method = RequestMethod.GET)
	public String uploadFinish(Model model, HttpSession session) {
		@SuppressWarnings("unchecked")

		List<String> uploadfiles = (List<String>) session.getAttribute(Const.SESSION_UPLOADS);
		if (uploadfiles != null) {
			List<FileInfoVO> list = new ArrayList<>();
			for (String u : uploadfiles) {
				try {
					FileInfoVO e = fileInfoService.getFileInfoByUuid(u);
					list.add(e);
				} catch (Exception e) {
				}
			}

			model.addAttribute("files", list);
		}
	 * @return
	 */
	@RequestMapping(value = "/user-manage-ui/{pageNo}", method = {RequestMethod.GET,RequestMethod.POST})
	public String userManageUI(Model model,@PathVariable("pageNo") Integer pageNo, HttpSession session, String searchValue,
			String searchNULL) {
		try {
			if (pageNo == null) {
				pageNo = 1;
			}

			if (searchNULL != null) {
				searchValue = "";
			}
			if (searchValue == null) {
//				searchValue = (String) session.getAttribute("searchValue");
				if (searchValue == null) {
					searchValue = "";
				}
			}
//			session.setAttribute("searchValue", searchValue);
			PageInfo<UserInfo> pagedResult = userService.queryByPage(pageNo, searchNULL, searchValue);
			model.addAttribute("page", pagedResult);
		} catch (Exception e) {

		}
		return "admin/user-manage";
	}

	/**
	 * 文件管理主页
	 * 
	 * @return
	 */
	// @RequestMapping(value = "/file-manage-ui", method = RequestMethod.GET)
	// public String ManageUI() {
	//
	// return "admin/file-manage";
	// }

	@RequestMapping(value = "/user-manage", method = RequestMethod.GET)
	public @ResponseBody JsonResult<List<FileInfo>> test() {

		return null;
	}

	@RequestMapping(value = "/file-freeze/{uuid}", method = RequestMethod.POST)
	public @ResponseBody Integer changeState(@PathVariable("uuid") String uuid) {
		FileInfoVO f = fileInfoService.getFileInfoByUuid(uuid);

/**
 * 前台登录
 * 
 *
 */
@Controller
public class LoginAndRegisterController {
	@Autowired
	private UserService userService;

	@Autowired
	private UserRegisterService urService;
	
	private final Logger LOG = LoggerFactory.getLogger(this.getClass());

	// @Autowired
	//
	/**
		return res;
	}

	/**
	 * 分类管理主页
	 * 
	 * @return
	 */
	@RequestMapping(value = "/class-manage-ui", method = RequestMethod.GET)
	public String ManageUI() {
		return "admin/class-manage";
	}

}

/**
 * 主要拦截器
 * 
 *
 */
public class UserInterceptor implements HandlerInterceptor {
	@Autowired
	private UserService userService;
	//private final Logger LOG = LoggerFactory.getLogger(this.getClass());

	// 执行Handler完成执行此方法
	// 应用场景:统一异常处理,统一日志处理
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object,
			Exception exception) throws Exception {
	}

	// 进入Handler方法之后,返回modelAndView之前执行
	// 应用场景从模型出发 公用model数据(菜单导航)在这里传到视图,也可以在这里统一指定视图
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object,
		Boolean compressState = (Boolean) session.getAttribute(Const.SESSION_IS_COMPRESSING);
		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);
		String uuid = StringValueUtil.getUUID();
		String fileName = files[0].getOriginalFilename();
		String ext = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());

		String userFilePath = "users/" + user.getUserId() + "/files/";
		String filePath = Const.ROOT_PATH + userFilePath + uuid + "." + ext;

		// 解压文件
		if (JudgeUtils.isCompressFile(ext)) {
			if (compressState != null && compressState == true) {
				String tempPath = Const.ROOT_PATH + "temp/";
				File dir = new File(tempPath);
				if (!dir.exists()) {
					dir.mkdirs();
				}

				FileUtils.writeByteArrayToFile(new File(tempPath + uuid + "." + ext), files[0].getBytes());
				List<String> filesUuid = fileInfoService.compressFile(tempPath + uuid + "." + ext, user);
				if (filesUuid != null) {
					for (String fuuid : filesUuid) {
						uploadfiles.add(fuuid);
						// 处理文件
						//new Thread() {
						//	public void run() {
								try {
									fileInfoService.translateFile(fuuid);
								} catch (IOException e) {
									LOG.error(fuuid + "文件处理失败");
								}
						//	};
						//}.start();
					}
				}

				return "success";
			}
		}

		// 保存刚刚上传的文件
		uploadfiles.add(uuid);

		try {
			jsonResult = new JsonResult(true, "error");
		}
		return jsonResult;
	}
	/**
	 * 初始化密码
	 * @param userId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/refresh-userpwd", method ={ RequestMethod.POST,RequestMethod.GET})
	public JsonResult refreshUserPassword(Long userId){
		JsonResult jsonResult = null;
		try{
			UserInfo user = userService.getUserAllInfo(userId);
			user.setUserPassword(StringValueUtil.getMD5("12345"));
			 userService.updateUserPwd(user);
			jsonResult = new JsonResult(true, "success");
			jsonResult.setData("success");
		}catch(Exception e){
			jsonResult = new JsonResult(false, "error");
		}
		return jsonResult;
	}
	
	@ResponseBody
	@RequestMapping(value = "/change-usertype", method ={ RequestMethod.POST,RequestMethod.GET})
	public JsonResult changeUserType(Long userId,Integer userType){
		JsonResult jsonResult = null;
		try{
			UserInfo user = userService.getUserAllInfo(userId);
			user.setUserType(userType);
			 userService.updateUserType(user);
			jsonResult = new JsonResult(true, "success");
			jsonResult.setData("success");
		}catch(Exception e){
			jsonResult = new JsonResult(false, "error");
		}
		return jsonResult;
	}
}
					try {
						fileInfoService.translateFile(uuid);
					} catch (IOException e) {
						LOG.error(uuid + "文件处理失败");
					}
				};
			}.start();
		} catch (Exception e) {

		} finally {

		}
		return "success";
	}

	/**
	 * 文件下载
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/download/{uuid}/{ext}", method = RequestMethod.GET)
	public String download(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			@PathVariable("uuid") String uuid, @PathVariable("ext") String ext) {
		FileInfo fileInfo = fileInfoService.getFileInfoByUuid(uuid);
		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);
		String path = Const.ROOT_PATH + fileInfo.getFilePath() + "." + ext;

		response.setCharacterEncoding("utf-8");
		response.setContentType("multipart/form-data");
		String fileAllName = fileInfo.getFileName() + "." + fileInfo.getFileExt();
		try {
			fileAllName = new String(fileAllName.getBytes("UTF-8"), "iso-8859-1");
		} catch (UnsupportedEncodingException e1) {
		}
		response.setHeader("Content-Disposition", "attachment;fileName=" + fileAllName);
		try {
			InputStream inputStream = new FileInputStream(path);
			OutputStream os = response.getOutputStream();
			byte[] b = new byte[2048];
			int length;
			while ((length = inputStream.read(b)) > 0) {
				os.write(b, 0, length);
			}
			// 这里主要关闭。
			os.close();
			inputStream.close();
		} catch (FileNotFoundException e) {
			LOG.error("文件没有找到" + path);
		jr.setData(docInfos);
		return jr;
	}

	/**
	 * 添加收藏夹
	 * 
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "/insertDoc", method = RequestMethod.POST)
	public @ResponseBody JsonResult insertDoc(String docName, HttpSession session) {
		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);
		JsonResult jr = new JsonResult(true, "添加成功");
		List<DocInfo> docInfos = docInfoService.findAllByUserId(user.getUserId());
		for (DocInfo d : docInfos) {
			if (d.getDocName().equals(docName)) {

				jr.setError("添加失败,收藏夹名重复");
				jr.setSuccess(false);
				return jr;
			}

		}
		docInfoService.insert(docName, user.getUserId());
		return jr;
	}

	/**
	 * 删除收藏夹
	 * 
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "/deleteDoc", method = RequestMethod.POST)
	public @ResponseBody JsonResult deleteDoc(Long docId, HttpSession session) {
		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);
		JsonResult jr = new JsonResult(true, "删除成功");
		docInfoService.delete(docId);
		return jr;
	}

				os.write(b, 0, length);
			}
			// 这里主要关闭。
			os.close();
			inputStream.close();
		} catch (FileNotFoundException e) {
			LOG.error("文件没有找到" + path);
		} catch (IOException e) {
		}
		return null;
	}

	/**
	 * 文件流
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/thumbnail/{uuid}/{ext}", method = RequestMethod.GET)
	public String thumbnail(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			@PathVariable("uuid") String uuid, @PathVariable("ext") String ext) {
		FileInfoVO fileInfo = fileInfoService.getFileInfoByUuid(uuid);
		UserInfo user = (UserInfo) session.getAttribute(Const.SESSION_USER);

		String path = Const.ROOT_PATH + fileInfo.getFilePath() + "." + ext;

		try {
			InputStream inputStream = new FileInputStream(path);
			OutputStream os = response.getOutputStream();
			byte[] b = new byte[2048];
			int length;
			while ((length = inputStream.read(b)) > 0) {
				os.write(b, 0, length);
			}
			// 这里主要关闭。
			os.close();
			inputStream.close();
		} catch (FileNotFoundException e) {
			LOG.error("文件没有找到" + path);
		} catch (IOException e) {
		}
		List<RelationInfo> res = fileInfoService.getRelations(mainFileId);
		JsonResult<List<RelationInfo>> jr = null;
		jr = new JsonResult<List<RelationInfo>>(true, res);
		return jr;
	}

	@RequestMapping(value = "/del-relations/{mainFileId}/{relationFileId}", method = RequestMethod.DELETE)
	public @ResponseBody JsonResult<Integer> delRelations(@PathVariable("mainFileId") Long mainFileId,
			@PathVariable("relationFileId") Long relationFileId) {
		int res = fileInfoService.delRelations(mainFileId, relationFileId);
		JsonResult<Integer> jr = null;
		jr = new JsonResult<Integer>(true, res);
		return jr;
	}

}


/**
 * 主要页面跳转
 * 
 *
 */
@Controller
@RequestMapping("/user")
public class MainController {
	@Autowired
	private FileManageService fileManageService;
	@Autowired
	private UserService userService;
	@Autowired
	private AdminCountService countService;
	@Autowired
	private CountService ctService;
	private final Logger LOG = LoggerFactory.getLogger(this.getClass());

	/**
	 * 获取今日的录入文件数量
	 * 
	 * @return
	 */
	@RequestMapping(value = "/count-today", method = RequestMethod.GET)
	public @ResponseBody JsonResult<Long> getTodaysUpload() {
		Long count = countService.getTodaysUpload();
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/count/click-times", method = RequestMethod.GET)
	public JsonResult< List<Long>> getClickTims(){
		JsonResult< List<Long>> jr = null;
		try{
			 List<Long> list = countService.getClickTimesByTime();
			 Collections.reverse(list);//倒序排列
			jr = new JsonResult< List<Long>>(true, list);
		}catch (Exception e) {
			jr = new JsonResult< List<Long>>(false, "获取失败");
		}
		return jr;
	}
}

/**
 * 后台处理文件的Controller
 * 
 *
 */
@Controller
@RequestMapping("/admin")
public class ManageController {
	@Autowired

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

转载请注明出处或者链接地址:https://www.qianduange.cn//article/2904.html
评论
会员中心 联系我 留言建议 回顶部
复制成功!