文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Java怎么实现在线小说阅读系统

2023-06-29 00:40

关注

本篇文章给大家分享的是有关Java怎么实现在线小说阅读系统,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

环境配置

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术

Layui+Springboot+ SpringMVC + HTML + FTP+ JavaScript + JQuery + Ajax + maven等等。

效果图

Java怎么实现在线小说阅读系统

Java怎么实现在线小说阅读系统

Java怎么实现在线小说阅读系统

Java怎么实现在线小说阅读系统

Java怎么实现在线小说阅读系统

读者用户控制器

@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";    }           @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){          PageInfo<Reader> pageInfo = 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<Reader> 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<Reader> 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);    }         @RequestMapping("/reader/editStatus")    @ResponseBody    public ResultData editStatus(Integer readerId, Integer readerStatus){        return readerService.updateStatus(readerId, readerStatus);    }         @RequestMapping("/reader/editPage")    public String editPage(Model model, Integer readerId){        Reader dbreadder = readerService.findById(readerId);        model.addAttribute("reader",dbreadder);        return "reader/reader-edit";    }         @RequestMapping("/reader/edit")    @ResponseBody    public ResultData edit(Reader reader){        return readerService.edit(reader);    }         @RequestMapping("/reader/deleteAll")    @ResponseBody    public ResultData deleteAll(@RequestParam(name = "ids") String ids){//        将ids转换成数组        String[] idArr=ids.split(",");        return readerService.batchDelete(idArr);    };         @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) {        PageInfo<Book> pageInfo=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<Book> 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<Book> 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<Book> bookList = bookService.findByType(bookType);        List<Book> 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<Book> bookList = bookService.findByLikeName(likeName);        List<Book> 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) {        PageInfo<BookOrder> pageInfo = 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<BookOrder> 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){                  int readerId = 1;         List<BookOrder> 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";    }         @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){          PageInfo<Author> pageInfo = 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<Author> 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<Author> 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);    }         @RequestMapping("/author/editStatus")    @ResponseBody    public ResultData editStatus(Integer authorId, Integer authorStatus){        return authorService.updateStatus(authorId, authorStatus);    }         @RequestMapping("/author/editPage")    public String editPage(Model model, Integer authorId){        Author dbreadder = authorService.findById(authorId);        model.addAttribute("author",dbreadder);        return "author/author-edit";    }         @RequestMapping("/author/edit")    @ResponseBody    public ResultData edit(Author author){        return authorService.edit(author);    }         @RequestMapping("/author/deleteAll")    @ResponseBody    public ResultData deleteAll(@RequestParam(name = "ids") String ids){//        将ids转换成数组        String[] idArr=ids.split(",");        return authorService.batchDelete(idArr);    };         @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) {        PageInfo<History> 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")    @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<History> 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怎么实现在线小说阅读系统,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注编程网行业资讯频道。

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯