Java|Java 实战项目之小说在线阅读系统的实现流程
一、项目简述
功能包括(管理员和游客角色):
1:用户及主要操作功能 游客可以浏览网站的主页,但是需要注册为会员后部分小 说才能对网络小说进免费行阅读或阅读。用户可以收藏书 架,留言评论,上次阅读,阅读历史,章节选择等等功 能。
2:管理模块 网络小说管理模块包括不同网络小说类别的添加,删除以 及网络小说的上传,删除管理。可以包括武侠小书,都市 言情,穿越小书等各个类等等功能。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax等等。
文章图片
文章图片
文章图片
文章图片
【Java|Java 实战项目之小说在线阅读系统的实现流程】
文章图片
读者操作业务控制层:
@Controllerpublic class ReaderController {@Autowiredprivate ReaderService readerService; @RequestMapping("/duzhe")public String duzhe(){return "loginreader"; } @RequestMapping("/book/getByType?bookType=1")public String xiangqing(){return "front/personal"; } /*** 登陆操作* @return*/@RequestMapping("/loginreader")@ResponseBody public ResultData login1(Reader reader,HttpServletRequest request){// 登陆操作ResultData resultData = https://www.it610.com/article/readerService.login1(reader); // 判断登陆成功,将用户数据保存到 session中// 如何获取session对象?if(resultData.getCode() == 200){HttpSession session = request.getSession(); session.setAttribute("reader",resultData.getData()); } return resultData; } @RequestMapping("/loginOut")@ResponseBody public String loginOut(HttpServletRequest request){// 只需要去将保存到session的数据干掉即可request.getSession().setAttribute("reader",null); // 重定向和转发的区别?// 重定向: 1. 客户端行为 2. 两次请求 3. 不能携带前一次请求的数据// 转发: 1. 服务器端行为 2. 一次请求 3. 能够携带前一次请求的数据return "redirect:/loginPage"; } //@RequestMapping("/login")//@ResponseBody// 该方法返回的是json字符串//public ResultData login(Admin admin,HttpServletRequest request){//// 登陆操作//ResultData resultData = https://www.it610.com/article/adminService.login(admin); //// 判断登陆成功,将用户数据保存到 session中//// 如何获取session对象?//if(resultData.getCode() == 200){//HttpSession session = request.getSession(); //session.setAttribute("admin",resultData.getData()); //}////return resultData; //}////读者列表@RequestMapping("/reader/list")public String list(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/5") Integer pageSize){ PageInfopageInfo = readerService.list(page,pageSize); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "reader/reader-list"; } //搜索读者显示列表@RequestMapping("/reader/search")public String searchList(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/5") Integer pageSize,String keyword){ PageInfo pageInfo = readerService.searchList(page, pageSize, keyword); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "reader/reader-list"; } //读者删除列表@RequestMapping("/reader/deleteList")public String deleteList(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/5") Integer pageSize){ PageInfo pageInfo = readerService.DeleteList(page,pageSize); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "reader/reader-del"; } //添加读者@RequestMapping("/reader/addPage")public String addPage(){return "front/register"; } //添加读者的方法@RequestMapping("/reader/add")@ResponseBodypublic ResultData add(Reader reader){return readerService.add(reader); } /*** 编辑读者状态信息* @param readerId : 当前读者Id* @param readerStatus: 读者当前状态* @return*/@RequestMapping("/reader/editStatus")@ResponseBodypublic ResultData editStatus(Integer readerId, Integer readerStatus){return readerService.updateStatus(readerId, readerStatus); } /*** 编辑读者* @param* @param* @return*/@RequestMapping("/reader/editPage")public String editPage(Model model, Integer readerId){Reader dbreadder = readerService.findById(readerId); model.addAttribute("reader",dbreadder); return "reader/reader-edit"; } /*** 更新读者基本信息的方法* @param reader* @return*/@RequestMapping("/reader/edit")@ResponseBodypublic ResultData edit(Reader reader){return readerService.edit(reader); } /*** 批量删除* @param ids* @return*/@RequestMapping("/reader/deleteAll")@ResponseBodypublic ResultData deleteAll(@RequestParam(name = "ids") String ids){//将ids转换成数组String[] idArr=ids.split(","); return readerService.batchDelete(idArr); }; /*** 批量恢复* @param ids* @return*/@RequestMapping("/reader/huifuAll")@ResponseBodypublic ResultData huifuDelete(@RequestParam(name = "ids") String ids){//将ids转换成数组String[] idArr=ids.split(","); return readerService.huifuDelete(idArr); }; @RequestMapping("/reader/delete")@ResponseBodypublic ResultData deleteReader(Integer readerId, Integer readerStatus){return readerService.deletereader(readerId,readerStatus); } @RequestMapping("/reader/toCenter")public String toCenter(HttpSession session, Model model){//Reader reader = (Reader)session.getAttribute("reader"); //if(reader==null){//return"login"; //}Reader reader = readerService.findById(1 ); model.addAttribute("reader",reader); return "front/center"; } }
留言信息控制层:
@Controllerpublic class MessageController {@Autowiredprivate MessageService messageService; @Autowiredprivate BookService bookService; @RequestMapping("/message/list")public String list(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/5") Integer pageSize){ PageInfopageInfo=messageService.list(page,pageSize); //将数据转发到页面model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "message/message-list"; }@RequestMapping("/message/addMessage")publicString addMessage(){return"message/message-add"; } //搜索留言显示列表@RequestMapping("/message/search")public String searchList(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/5") Integer pageSize,String keyword){PageInfo pageInfo=messageService.searchList(page,pageSize,keyword); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "message/message-list"; }//添加留言@RequestMapping(value = "https://www.it610.com/message/add",method = RequestMethod.POST)public Stringadd(Message message, HttpSession session,Model model){/*Reader reader= (Reader)session.getAttribute("reader"); message.setReaderId(reader.getReaderId()); */message.setReaderId(2); ResultData resultData = https://www.it610.com/article/messageService.add(message); Book book = bookService.findById(message.getBookId()); List messageList = messageService.findByBookId(message.getBookId()); model.addAttribute("book",book); model.addAttribute("messageList",messageList); return "novel"; } //留言编辑页面@RequestMapping("/message/editPage")public String editPage(Model model,Integer id){//从数据库查询到的数据Message dbMessage = messageService.findById(id); model.addAttribute("message",dbMessage); return "message/message-edit"; } //更新留言信息的方法@RequestMapping("/message/edit")@ResponseBodypublic ResultData edit(Message message){ return messageService.edit(message); } //批量删除@RequestMapping("/message/deleteAll")@ResponseBodypublic ResultData deleteAll(@RequestParam(name = "ids") String ids){//将ids转换成数组String[] idArr=ids.split(","); return messageService.mesDelete(idArr); }}
图书列表控制层:
@Controllerpublic class BookOrderController {@Autowiredprivate BookOrderService bookOrderService; @Autowiredprivate BookService bookService; @RequestMapping("/bookorder/bookorderlist")public String bookorderlist(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/3") Integer pageSize) {PageInfopageInfo = bookOrderService.list(page, pageSize); //将数据转发到页面model.addAttribute("list", pageInfo.getList()); model.addAttribute("pageInfo", pageInfo); return "bookorder/bookorder-list"; } @RequestMapping("/bookorder/orderSearch")public String searchList(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/3") Integer pageSize,String keyword) {PageInfo pageInfo = bookOrderService.searchList(page,pageSize,keyword); //将数据转发到页面model.addAttribute("list", pageInfo.getList()); model.addAttribute("pageInfo", pageInfo); return "bookorder/bookorder-list"; } @RequestMapping("/bookorder/bookorderadd")public String bookorderadd() {return "bookorder/bookorder-add"; } @RequestMapping(value = "https://www.it610.com/bookorder/add",method = RequestMethod.POST)@ResponseBodypublic ResultData add(BookOrder bookOrder, HttpSession session) {Reader reader = (Reader)session.getAttribute("reader"); if(reader==null){returnnew ResultData(2001,"用户未登陆",null); }int readerId = reader.getReaderId(); bookOrder.setUserId(1); bookOrder.setDiscountId(1); bookOrder.setOrderDate(new Timestamp(System.currentTimeMillis())); bookOrder.setOrderStatus(1); bookOrder.setPayStatus(1); ResultData resultData = https://www.it610.com/article/bookOrderService.add(bookOrder); return resultData; } @RequestMapping("/bookorder/editStatus")@ResponseBodypublic ResultData editStatus(Integer id, Integer status) {return bookOrderService.updateStatus(id,status); }@RequestMapping("/bookorder/deleteAll")@ResponseBodypublic ResultData deleteAll(@RequestParam(name = "ids") String ids){// 将ids转换成数组String[] idArr = ids.split(","); return bookOrderService.batchDelete(idArr); } @RequestMapping("/bookorder/delete")@ResponseBodypublicResultData delete(Integer orderid,Integer orderStatus){returnbookOrderService.delete(orderid,orderStatus); } @RequestMapping("/bookOrder/toOrder")publicString delete(Integer bookId,Model model){Book book = bookService.findById(bookId); model.addAttribute("book",book); return"front/order"; } @RequestMapping("/bookOrder/toOrderCenter")publicString toOrderCenter(HttpSession session,Model model){/*Reader reader = (Reader)session.getAttribute("reader"); if(reader==null){returnnew ResultData(2001,"用户未登陆",null); }int readerId = reader.getReaderId(); */int readerId = 1; List bookOrderList = bookOrderService.getAll(readerId); model.addAttribute("bookOrderList",bookOrderList); return"front/orderCenter"; } }
历史浏览控制层:
@Controllerpublic class HistoryController {@Autowiredprivate HistoryService historyService; //列表@RequestMapping("/history/list")public String list(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/3") Integer pageSize) {PageInfo pageInfo=historyService.list(page,pageSize); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "history/history-list"; }//添加@RequestMapping("/history/addPage")public String addPage(){return "history/history-add"; } //添加@RequestMapping("/history/add")@ResponseBodypublic ResultData add(History history){return historyService.add(history); } //search@RequestMapping("/history/search")public String searchList(Model model,@RequestParam(defaultValue = "https://www.it610.com/article/1") Integer page,@RequestParam(defaultValue = "https://www.it610.com/article/3") Integer pageSize,String keyword) {PageInfo pageInfo=historyService.searchList(page,pageSize,keyword); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return"history/history-list"; } //批量删除@RequestMapping("/history/deleteAll")@ResponseBodypublic ResultData deleteAll(@RequestParam(name="ids") String ids){//将ids转为数组String[] idArr = ids.split(","); //将字符串数组转为int数组return historyService.batchDelete(idArr); } }
到此这篇关于Java 实战项目之小说在线阅读系统的实现流程的文章就介绍到这了,更多相关Java 小说在线阅读系统内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
推荐阅读
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- 事件代理
- Java|Java OpenCV图像处理之SIFT角点检测详解
- java中如何实现重建二叉树
- 数组常用方法一
- 【Hadoop踩雷】Mac下安装Hadoop3以及Java版本问题
- Java|Java基础——数组
- 17|17 关山松 第二课作业#公众号项目# D20
- RxJava|RxJava 在Android项目中的使用(一)
- java之static、static|java之static、static final、final的区别与应用