欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Java 实战项目之小说在线阅读系统的实现流程

程序员文章站 2022-08-06 18:23:10
一、项目简述功能包括(管理员和游客角色):1:用户及主要操作功能 游客可以浏览网站的主页,但是需要注册为会员后部分小 说才能对网络小说进免费行阅读或阅读。用户可以收藏书 架,留言评论,上次阅读,阅读历...

一、项目简述

功能包括(管理员和游客角色):

1:用户及主要操作功能 游客可以浏览网站的主页,但是需要注册为会员后部分小 说才能对网络小说进免费行阅读或阅读。用户可以收藏书 架,留言评论,上次阅读,阅读历史,章节选择等等功 能。

2:管理模块 网络小说管理模块包括不同网络小说类别的添加,删除以 及网络小说的上传,删除管理。可以包括武侠小书,都市 言情,穿越小书等各个类等等功能。

二、项目运行

环境配置: jdk1.8 + tomcat8.5 + mysql + eclispe (intellij idea,eclispe,myeclispe,sts 都支持)

项目技术: jsp +spring + springmvc + mybatis + html+ css + javascript + jquery + ajax等等。

Java 实战项目之小说在线阅读系统的实现流程

Java 实战项目之小说在线阅读系统的实现流程

Java 实战项目之小说在线阅读系统的实现流程

Java 实战项目之小说在线阅读系统的实现流程

Java 实战项目之小说在线阅读系统的实现流程

读者操作业务控制层:

@controller
public 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){
 
 
        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);
    }
 
    /**
     * 编辑读者状态信息
     * @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";
    }
 
 
 
}

留言信息控制层:

@controller
public class messagecontroller {
    @autowired
    private messageservice messageservice;
 
    @autowired
    private bookservice bookservice;
 
    @requestmapping("/message/list")
    public string list(model model,
                       @requestparam(defaultvalue = "1") integer page,
                       @requestparam(defaultvalue = "5") integer pagesize){
 
        pageinfo<message> pageinfo=messageservice.list(page,pagesize);
 
 
//将数据转发到页面
        model.addattribute("list",pageinfo.getlist());
        model.addattribute("pageinfo",pageinfo);
 
 
        return "message/message-list";
    }
    @requestmapping("/message/addmessage")
    public  string addmessage(){
        return  "message/message-add";
    }
 
 
 
//    搜索留言显示列表
    @requestmapping("/message/search")
    public string searchlist(model model,@requestparam(defaultvalue = "1") integer page,
                             @requestparam(defaultvalue = "5") integer pagesize,
                             string keyword){
        pageinfo<message> pageinfo=messageservice.searchlist(page,pagesize,keyword);
        model.addattribute("list",pageinfo.getlist());
        model.addattribute("pageinfo",pageinfo);
 
        return "message/message-list";
    }
//    添加留言
    @requestmapping(value = "/message/add",method = requestmethod.post)
    public string  add(message message, httpsession session,model model){
        /*reader reader  = (reader)session.getattribute("reader");
        message.setreaderid(reader.getreaderid());*/
        message.setreaderid(2);
        resultdata resultdata = messageservice.add(message);
 
        book book = bookservice.findbyid(message.getbookid());
        list<message> 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")
    @responsebody
    public resultdata edit(message message){
 
        return messageservice.edit(message);
 
    }
 
 
//    批量删除
    @requestmapping("/message/deleteall")
    @responsebody
    public resultdata deleteall(@requestparam(name = "ids") string ids){
//        将ids转换成数组
        string[] idarr=ids.split(",");
        return messageservice.mesdelete(idarr);
    }
}

图书列表控制层:

@controller
public 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){
         /*reader reader = (reader)session.getattribute("reader");
        if(reader==null){
            return  new resultdata(2001,"用户未登陆",null);
        }
        int readerid = reader.getreaderid();*/
         int readerid = 1;
 
        list<bookorder> bookorderlist = bookorderservice.getall(readerid);
        model.addattribute("bookorderlist",bookorderlist);
        return  "front/ordercenter";
    }
 
 
}

历史浏览控制层:

@controller
public 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 实战项目之小说在线阅读系统的实现流程的文章就介绍到这了,更多相关java 小说在线阅读系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!