文末获取源码
开发语言:Java
框架:springboot
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7/8.0
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
一、前言介绍
本文主要论述了如何使用JAVA语言开发一个图书个性化推荐系统,本系统将严格按照软件开发流程进行各个阶段的工作,采用BS架构,面向对象编程思想进行项目开发。在引言中,作者将论述图书个性化推荐系统的当前背景以及系统开发的目的,后续章节将严格按照软件开发流程,对系统进行各个阶段分析设计。
图书个性化推荐系统的主要使用者分为管理员和学生,实现功能包括管理员:首页、个人中心、学生管理、图书分类管理、图书信息管理、图书预约管理、退换图书管理、管理员管理、留言板管理、系统管理,学生:首页、个人中心、图书预约管理、退换图书管理、我的收藏管理,前台首页;首页、图书信息、好书推荐、留言反馈、个人中心、后台管理等功能。由于本系统的功能模块设计比较全面,所以使得整个图书个性化推荐系统信息管理的过程得以实现。
二、系统结构设计
整个系统是由多个功能模块组合而成的,要将所有的功能模块都一一列举出来,然后进行逐个的功能设计,使得每一个模块都有相对应的功能设计,然后进行系统整体的设计。
本图书个性化推荐系统结构图如图
三、前台首页功能模块
3.1首页
图书个性化推荐系统,在前台首页可以查看首页、图书信息、好书推荐、留言反馈、个人中心、后台管理等内容,如图
3.2图书信息
在图书信息页面通过查看图书编号、图书名称、图书类别、图片、作者、出版社、版次、数量、点击次数等信息进行预约、立即提交或点我收藏操作,如图
四、管理员模块
4.1首页
管理员登录进入图书个性化推荐系统可以查看首页、个人中心、学生管理、图书分类管理、图书信息管理、图书预约管理、退换图书管理、管理员管理、留言板管理、系统管理等信息。
4.2学生管理
在学生管理页面中可以通过查看学号、密码、学生姓名、性别、出生日期、联系电话、班级等内容进行修改、删除等操作,如图所示。还可以根据需要对图书分类管理进行修改或删除等详细操作,如图
4.3图书信息管理
在图书信息管理页面中可以查看图书编号、图书名称、图书类别、图片、作者、出版社、版次、数量等信息,并可根据需要对己有图书信息管理进行详情、预约、查看评论、修改或删除等操作,如图
4.4图书预约管理
在图书预约管理页面中可以查看图书编号、图书名称、图书类别、作者、出版社、版次、数量、学号、学生姓名、联系电话、申请日期、审核回复、审核信息等操作,如图
4.5退换图书管理
在退换图书管理页面中可以查看图书编号、图书名称、作者、出版社、版次、数量、学号、退换类型、退换原因、日期、审核回复、审核状态、审核等内容,并且根据需要对己有退换图书管理进行详情,修改或删除等详细操作,如图
4.6管理员管理
在管理员管理页面中可以查看用户名、密码、角色等内容,并且根据需要对已有管理员管理进行详情,修改或删除等详细操作,如图
五、学生功能模块
学生登录进入图书个性化推荐系统可以查看首页、个人中心、图书预约管理、退换图书管理、我的收藏管理等内容。
5.1个人信息
在个人信息页面中通过填写学号、密码、学生姓名、性别、出生日期、联系电话、班级等信息,还可以根据需要对个人信息进行修改等操作、如图
5.2图书预约管理
在图书预约管理页面中可以查看图书编号、图书名称、图书类别、作者、出版社、版次、数量、学号、学生姓名、联系电话、申请日期、审核回复、审核状态等信息内容,并且根据需要对已有图书预约管理进行详情、退换或删除等其他详细操作,如图
六、部分核心代码
/*** 上传文件映射表*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{@Autowiredprivate ConfigService configService;/*** 上传文件*/@RequestMapping("/upload")public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {if (file.isEmpty()) {throw new EIException("上传文件不能为空");}String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);File path = new File(ResourceUtils.getURL("classpath:static").getPath());if(!path.exists()) {path = new File("");}File upload = new File(path.getAbsolutePath(),"/upload/");if(!upload.exists()) {upload.mkdirs();}String fileName = new Date().getTime()+"."+fileExt;File dest = new File(upload.getAbsolutePath()+"/"+fileName);file.transferTo(dest);/*** 如果使用idea或者eclipse重启项目,发现之前上传的图片或者文件丢失,将下面一行代码注释打开* 请将以下的"D:\\springbootq33sd\\src\\main\\resources\\static\\upload"替换成你本地项目的upload路径,* 并且项目路径不能存在中文、空格等特殊字符*/
// FileUtils.copyFile(dest, new File("D:\\springbootq33sd\\src\\main\\resources\\static\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/if(StringUtils.isNotBlank(type) && type.equals("1")) {ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));if(configEntity==null) {configEntity = new ConfigEntity();configEntity.setName("faceFile");configEntity.setValue(fileName);} else {configEntity.setValue(fileName);}configService.insertOrUpdate(configEntity);}return R.ok().put("file", fileName);}/*** 下载文件*/@IgnoreAuth@RequestMapping("/download")public ResponseEntity<byte[]> download(@RequestParam String fileName) {try {File path = new File(ResourceUtils.getURL("classpath:static").getPath());if(!path.exists()) {path = new File("");}File upload = new File(path.getAbsolutePath(),"/upload/");if(!upload.exists()) {upload.mkdirs();}File file = new File(upload.getAbsolutePath()+"/"+fileName);if(file.exists()){/*if(!fileService.canRead(file, SessionManager.getSessionUser())){getResponse().sendError(403);}*/HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentDispositionFormData("attachment", fileName); return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);}} catch (IOException e) {e.printStackTrace();}return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);}}
RestController
@RequestMapping("/kechengchengji")
public class KechengchengjiController {@Autowiredprivate KechengchengjiService kechengchengjiService;/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params,KechengchengjiEntity kechengchengji,HttpServletRequest request){String tableName = request.getSession().getAttribute("tableName").toString();if(tableName.equals("jiaoshi")) {kechengchengji.setJiaoshizhanghao((String)request.getSession().getAttribute("username"));}if(tableName.equals("xuesheng")) {kechengchengji.setXuehao((String)request.getSession().getAttribute("username"));}EntityWrapper<KechengchengjiEntity> ew = new EntityWrapper<KechengchengjiEntity>();PageUtils page = kechengchengjiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, kechengchengji), params), params));return R.ok().put("data", page);}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params,KechengchengjiEntity kechengchengji, HttpServletRequest request){EntityWrapper<KechengchengjiEntity> ew = new EntityWrapper<KechengchengjiEntity>();PageUtils page = kechengchengjiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, kechengchengji), params), params));return R.ok().put("data", page);}/*** 列表*/@RequestMapping("/lists")public R list( KechengchengjiEntity kechengchengji){EntityWrapper<KechengchengjiEntity> ew = new EntityWrapper<KechengchengjiEntity>();ew.allEq(MPUtil.allEQMapPre( kechengchengji, "kechengchengji")); return R.ok().put("data", kechengchengjiService.selectListView(ew));}/*** 查询*/@RequestMapping("/query")public R query(KechengchengjiEntity kechengchengji){EntityWrapper< KechengchengjiEntity> ew = new EntityWrapper< KechengchengjiEntity>();ew.allEq(MPUtil.allEQMapPre( kechengchengji, "kechengchengji")); KechengchengjiView kechengchengjiView = kechengchengjiService.selectView(ew);return R.ok("查询课程成绩成功").put("data", kechengchengjiView);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id){KechengchengjiEntity kechengchengji = kechengchengjiService.selectById(id);return R.ok().put("data", kechengchengji);}/*** 前端详情*/@IgnoreAuth@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id){KechengchengjiEntity kechengchengji = kechengchengjiService.selectById(id);return R.ok().put("data", kechengchengji);}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody KechengchengjiEntity kechengchengji, HttpServletRequest request){kechengchengji.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());//ValidatorUtils.validateEntity(kechengchengji);kechengchengjiService.insert(kechengchengji);return R.ok();}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody KechengchengjiEntity kechengchengji, HttpServletRequest request){kechengchengji.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());//ValidatorUtils.validateEntity(kechengchengji);kechengchengjiService.insert(kechengchengji);return R.ok();}/*** 修改*/@RequestMapping("/update")public R update(@RequestBody KechengchengjiEntity kechengchengji, HttpServletRequest request){//ValidatorUtils.validateEntity(kechengchengji);kechengchengjiService.updateById(kechengchengji);//全部更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Long[] ids){kechengchengjiService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 提醒接口*/@RequestMapping("/remind/{columnName}/{type}")public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) {map.put("column", columnName);map.put("type", type);if(type.equals("2")) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");Calendar c = Calendar.getInstance();Date remindStartDate = null;Date remindEndDate = null;if(map.get("remindstart")!=null) {Integer remindStart = Integer.parseInt(map.get("remindstart").toString());c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart);remindStartDate = c.getTime();map.put("remindstart", sdf.format(remindStartDate));}if(map.get("remindend")!=null) {Integer remindEnd = Integer.parseInt(map.get("remindend").toString());c.setTime(new Date());c.add(Calendar.DAY_OF_MONTH,remindEnd);remindEndDate = c.getTime();map.put("remindend", sdf.format(remindEndDate));}}Wrapper<KechengchengjiEntity> wrapper = new EntityWrapper<KechengchengjiEntity>();if(map.get("remindstart")!=null) {wrapper.ge(columnName, map.get("remindstart"));}if(map.get("remindend")!=null) {wrapper.le(columnName, map.get("remindend"));}String tableName = request.getSession().getAttribute("tableName").toString();if(tableName.equals("jiaoshi")) {wrapper.eq("jiaoshizhanghao", (String)request.getSession().getAttribute("username"));}if(tableName.equals("xuesheng")) {wrapper.eq("xuehao", (String)request.getSession().getAttribute("username"));}int count = kechengchengjiService.selectCount(wrapper);return R.ok().put("count", count);}}