Java怎么实现在线小说阅读系统
发表于:2024-11-30 作者:千家信息网编辑
千家信息网最后更新 2024年11月30日,本篇文章给大家分享的是有关Java怎么实现在线小说阅读系统,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。环境配置Jdk1.8 + Tom
千家信息网最后更新 2024年11月30日Java怎么实现在线小说阅读系统
本篇文章给大家分享的是有关Java怎么实现在线小说阅读系统,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
环境配置
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术
Layui+Springboot+ SpringMVC + HTML + FTP+ JavaScript + JQuery + Ajax + maven等等。
效果图
读者用户控制器
@Controllerpublic class ReaderController { @Autowired private 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 = 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 = 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 = "1") Integer page, @RequestParam(defaultValue = "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 = "1") Integer page, @RequestParam(defaultValue = "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 = "1") Integer page, @RequestParam(defaultValue = "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") @ResponseBody public ResultData add(Reader reader){ return readerService.add(reader); } /** * 编辑读者状态信息 * @param readerId : 当前读者Id * @param readerStatus: 读者当前状态 * @return */ @RequestMapping("/reader/editStatus") @ResponseBody public 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") @ResponseBody public ResultData edit(Reader reader){ return readerService.edit(reader); } /** * 批量删除 * @param ids * @return */ @RequestMapping("/reader/deleteAll") @ResponseBody public ResultData deleteAll(@RequestParam(name = "ids") String ids){// 将ids转换成数组 String[] idArr=ids.split(","); return readerService.batchDelete(idArr); }; /** * 批量恢复 * @param ids * @return */ @RequestMapping("/reader/huifuAll") @ResponseBody public ResultData huifuDelete(@RequestParam(name = "ids") String ids){// 将ids转换成数组 String[] idArr=ids.split(","); return readerService.huifuDelete(idArr); }; @RequestMapping("/reader/delete") @ResponseBody public 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 BookController { @Autowired private BookService bookService; // @Autowired// private BookService bookService; //小说列表 @RequestMapping("/book/list") public String list(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "3") Integer pageSize) { PageInfopageInfo=bookService.list(page,pageSize); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "book/book-list"; } //小说添加 @RequestMapping("/book/addPage") public String addPage() { return "book/book-add"; }//// // 添加小说 @RequestMapping("/book/add") @ResponseBody public ResultData add(Book book) { return bookService.add(book); } // 编辑小说状态 @RequestMapping("/book/editCondition") @ResponseBody public ResultData editCondition(Integer bookId, Integer condition){ return bookService.updateStatus(bookId,condition); } // 编辑页面 @RequestMapping("/book/editPage") public String editPage(Model model, Integer bookId){ Book dbBook = bookService.findById(bookId); model.addAttribute("book",dbBook); return "book/book-edit"; }//更新基本信息 @RequestMapping("/book/edit") @ResponseBody public ResultData edit(Book book){ return bookService.edit(book); } // 批量删除 @RequestMapping("/book/deleteAll") @ResponseBody public ResultData deleteAll(@RequestParam(name="ids") String ids){ //将ids转为数组 String[] idArr = ids.split(","); //将字符串数组转为int数组 return bookService.batchDelete(idArr); } // search @RequestMapping("/book/search") public String searchList(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "3") Integer pageSize, String keyword) { PageInfo pageInfo=bookService.searchList(page,pageSize,keyword); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "book/book-list"; } @RequestMapping("/book/search2") public String searchList1(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "3") Integer pageSize, String keyword1) { PageInfo pageInfo=bookService.searchList1(page,pageSize,keyword1); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "book/book-list"; } @RequestMapping(value = "/book/getByType",method = RequestMethod.GET) public String getByType(Integer bookType, Model model, HttpSession session){ List bookList = bookService.findByType(bookType); List randList = bookService.findRandList(); //将字符串数组转为int数组 session.setAttribute("bookList",bookList); session.setAttribute("randList",randList); return "/front/personal"; } @RequestMapping(value = "/book/getByName",method = RequestMethod.POST) public String getByName(String likeName, Model model, HttpSession session) throws UnsupportedEncodingException { // String likeName1 = new String(likeName.getBytes("ISO-8859-1"),"utf-8"); List bookList = bookService.findByLikeName(likeName); List randList = bookService.findRandList(); //将字符串数组转为int数组 session.setAttribute("bookList",bookList); session.setAttribute("randList",randList); return "/front/personal"; } }
图书订单管理控制层
@Controllerpublic class BookOrderController { @Autowired private BookOrderService bookOrderService; @Autowired private BookService bookService; @RequestMapping("/bookorder/bookorderlist") public String bookorderlist(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "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 = "1") Integer page, @RequestParam(defaultValue = "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 = "/bookorder/add",method = RequestMethod.POST) @ResponseBody public ResultData add(BookOrder bookOrder, HttpSession session) { Reader reader = (Reader)session.getAttribute("reader"); if(reader==null){ return new 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 = bookOrderService.add(bookOrder); return resultData; } @RequestMapping("/bookorder/editStatus") @ResponseBody public ResultData editStatus(Integer id, Integer status) { return bookOrderService.updateStatus(id,status); } @RequestMapping("/bookorder/deleteAll") @ResponseBody public ResultData deleteAll(@RequestParam(name = "ids") String ids){ // 将ids转换成数组 String[] idArr = ids.split(","); return bookOrderService.batchDelete(idArr); } @RequestMapping("/bookorder/delete") @ResponseBody public ResultData delete(Integer orderid,Integer orderStatus){ return bookOrderService.delete(orderid,orderStatus); } @RequestMapping("/bookOrder/toOrder") public String delete(Integer bookId,Model model){ Book book = bookService.findById(bookId); model.addAttribute("book",book); return "front/order"; } @RequestMapping("/bookOrder/toOrderCenter") public String toOrderCenter(HttpSession session,Model model){ /*Reader reader = (Reader)session.getAttribute("reader"); if(reader==null){ return new ResultData(2001,"用户未登陆",null); } int readerId = reader.getReaderId();*/ int readerId = 1; List bookOrderList = bookOrderService.getAll(readerId); model.addAttribute("bookOrderList",bookOrderList); return "front/orderCenter"; } }
角色管理控制层
@Controllerpublic class AuthorController { @Autowired private AuthorService authorService; @RequestMapping("/zuozhe") public String duzhe(){ return "loginauthor"; } @RequestMapping("/zuoping") public String zuoping(){ return "index11"; } /** * 登陆操作 * @return */ @RequestMapping("/loginauthor") @ResponseBody public ResultData login2(Author author){ ResultData resultData=authorService.login2(author); return resultData; } //作者列表 @RequestMapping("/author/list") public String list(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5") Integer pageSize){ PageInfopageInfo = authorService.list(page,pageSize); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "author/author-list"; } //搜索作者显示列表 @RequestMapping("/author/search") public String searchList(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5") Integer pageSize, String keyword){ PageInfo pageInfo = authorService.searchList(page, pageSize, keyword); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "author/author-list"; } //作者删除列表 @RequestMapping("/author/deleteList") public String deleteList(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5") Integer pageSize){ PageInfo pageInfo = authorService.DeleteList(page,pageSize); model.addAttribute("list",pageInfo.getList()); model.addAttribute("pageInfo",pageInfo); return "author/author-del"; } //添加作者 @RequestMapping("/author/addPage") public String addPage(){ return "author/author-add"; } // 添加作者的方法 @RequestMapping("/author/add") @ResponseBody public ResultData add(Author author){ return authorService.add(author); } /** * 编辑作者状态信息 * @param authorId : 当前作者Id * @param authorStatus: 作者当前状态 * @return */ @RequestMapping("/author/editStatus") @ResponseBody public ResultData editStatus(Integer authorId, Integer authorStatus){ return authorService.updateStatus(authorId, authorStatus); } /** * 编辑作者 * @param * @param * @return */ @RequestMapping("/author/editPage") public String editPage(Model model, Integer authorId){ Author dbreadder = authorService.findById(authorId); model.addAttribute("author",dbreadder); return "author/author-edit"; } /** * 更新作者基本信息的方法 * @param author * @return */ @RequestMapping("/author/edit") @ResponseBody public ResultData edit(Author author){ return authorService.edit(author); } /** * 批量删除 * @param ids * @return */ @RequestMapping("/author/deleteAll") @ResponseBody public ResultData deleteAll(@RequestParam(name = "ids") String ids){// 将ids转换成数组 String[] idArr=ids.split(","); return authorService.batchDelete(idArr); }; /** * 批量恢复 * @param ids * @return */ @RequestMapping("/author/huifuAll") @ResponseBody public ResultData huifuDelete(@RequestParam(name = "ids") String ids){// 将ids转换成数组 String[] idArr=ids.split(","); return authorService.huifuDelete(idArr); }; @RequestMapping("/author/delete") @ResponseBody public ResultData deleteAuthor(Integer authorId, Integer authorStatus){ return authorService.deleteauthor(authorId,authorStatus); } }
历史控制层
@Controllerpublic class HistoryController { @Autowired private HistoryService historyService; //列表 @RequestMapping("/history/list") public String list(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "3") Integer pageSize) { PageInfopageInfo=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") @ResponseBody public ResultData add(History history){ return historyService.add(history); } // search @RequestMapping("/history/search") public String searchList(Model model, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "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") @ResponseBody public ResultData deleteAll(@RequestParam(name="ids") String ids){ //将ids转为数组 String[] idArr = ids.split(","); //将字符串数组转为int数组 return historyService.batchDelete(idArr); } }
以上就是Java怎么实现在线小说阅读系统,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。
数组
读者
作者
登陆
数据
小说
信息
字符
字符串
方法
状态
用户
控制
页面
更新
管理
系统
在线
成功
图书
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
三本可以进的软件开发公司
网络安全管理的本质是什么
四川服务器电源哪里便宜
网络安全信息责任
apex服务器更换
网络安全专项整治行动总结
信息网络安全与应用技术
数据库上的模型和语言
steam注册服务器无法连接
php 数组 数据库
db数据库物品代码
重庆双桥蔬菜配送软件开发
珠海软件开发平台
方舟联机服务器怎么样
学院网络安全工作思路
java数据库加减乘除
1号店的数据库设计
主修网络安全辅修金融还是法学
易安卓数据库操作
西城区省电软件开发推荐
云服务器vt
信息安全网络安全与隐私保护考试
锐思数据库的主权信用评级
怎样处理调查问卷数据库
网络安全风险分级
软件开发需要报什么科
龙海应用软件开发
阿里国产化数据库
建筑和软件开发哪个学校好
数据库取字符串后3位