源码获取:博客首页 "资源" 里下载!

一、项目介绍

环境配置:

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电子书在线阅读_layui_02


java书在线阅读 java电子书在线阅读_java书在线阅读_03


java书在线阅读 java电子书在线阅读_java书在线阅读_04


java书在线阅读 java电子书在线阅读_spring boot_05


读者用户控制器:

@ControllerpublicclassReaderController {
    @Autowiredprivate ReaderService readerService;


    @RequestMapping("/duzhe")public String duzhe(){
        return"loginreader";
    }

    @RequestMapping("/book/getByType?bookType=1")public String xiangqing(){
        return"front/personal";
    }



    /**
     * 登陆操作
     * @return
     */@RequestMapping("/loginreader")@ResponseBodypublic ResultData login1(Reader reader,HttpServletRequest request){
            // 登陆操作ResultDataresultData= readerService.login1(reader);
            // 判断登陆成功,将用户数据保存到 session中// 如何获取session对象?if(resultData.getCode() == 200){
                HttpSessionsession= request.getSession();
                session.setAttribute("reader",resultData.getData());
            }

            return resultData;
        }


   @RequestMapping("/loginOut")@ResponseBodypublic 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")@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){
        Readerdbreadder= 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";//        }Readerreader= readerService.findById(1 );
        model.addAttribute("reader",reader);
        return"front/center";
    }



}

图书管理控制层:

@ControllerpublicclassBookController {

    @Autowiredprivate 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")@ResponseBodypublic ResultData add(Book book) {
       return bookService.add(book);
    }

//    编辑小说状态@RequestMapping("/book/editCondition")@ResponseBodypublic ResultData editCondition(Integer bookId, Integer condition){
        return bookService.updateStatus(bookId,condition);
    }

//    编辑页面@RequestMapping("/book/editPage")public String editPage(Model model, Integer bookId){
        BookdbBook= bookService.findById(bookId);
        model.addAttribute("book",dbBook);

        return"book/book-edit";
    }
//更新基本信息@RequestMapping("/book/edit")@ResponseBodypublic ResultData edit(Book book){
        return  bookService.edit(book);
    }


//    批量删除@RequestMapping("/book/deleteAll")@ResponseBodypublic 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/search1")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";
    }

}

图书订单管理控制层:

@ControllerpublicclassBookOrderController {
    @Autowiredprivate BookOrderService bookOrderService;
    @Autowiredprivate 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)@ResponseBodypublic ResultData add(BookOrder bookOrder, HttpSession session) {
        Readerreader= (Reader)session.getAttribute("reader");
        if(reader==null){
            returnnewResultData(2001,"用户未登陆",null);
        }
        intreaderId= reader.getReaderId();
        bookOrder.setUserId(1);
        bookOrder.setDiscountId(1);
        bookOrder.setOrderDate(newTimestamp(System.currentTimeMillis()));
        bookOrder.setOrderStatus(1);
        bookOrder.setPayStatus(1);
        ResultDataresultData= 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")@ResponseBodypublic  ResultData delete(Integer orderid,Integer orderStatus){
        return  bookOrderService.delete(orderid,orderStatus);
    }


    @RequestMapping("/bookOrder/toOrder")public  String delete(Integer bookId,Model model){
        Bookbook= 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();*/intreaderId=1;

        List<BookOrder> bookOrderList = bookOrderService.getAll(readerId);
        model.addAttribute("bookOrderList",bookOrderList);
        return"front/orderCenter";
    }


}


角色管理控制层:

@ControllerpublicclassAuthorController {
    @Autowiredprivate AuthorService authorService;


    @RequestMapping("/zuozhe")public String duzhe(){
        return"loginauthor";
    }


    @RequestMapping("/zuoping")public String zuoping(){
        return"index11";
    }

    /**
     * 登陆操作
     * @return
     */@RequestMapping("/loginauthor")@ResponseBodypublic 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")@ResponseBodypublic ResultData add(Author author){
        return authorService.add(author);
    }

    /**
     * 编辑作者状态信息
     * @param authorId : 当前作者Id
     * @param authorStatus: 作者当前状态
     * @return
     */@RequestMapping("/author/editStatus")@ResponseBodypublic ResultData editStatus(Integer authorId, Integer authorStatus){
        return authorService.updateStatus(authorId, authorStatus);
    }

    /**
     * 编辑作者
     * @param
     * @param
     * @return
     */@RequestMapping("/author/editPage")public String editPage(Model model, Integer authorId){
        Authordbreadder= authorService.findById(authorId);
        model.addAttribute("author",dbreadder);
        return"author/author-edit";
    }

    /**
     * 更新作者基本信息的方法
     * @param author
     * @return
     */@RequestMapping("/author/edit")@ResponseBodypublic ResultData edit(Author author){
        return authorService.edit(author);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */@RequestMapping("/author/deleteAll")@ResponseBodypublic ResultData deleteAll(@RequestParam(name = "ids") String ids){
//        将ids转换成数组
        String[] idArr=ids.split(",");
        return authorService.batchDelete(idArr);
    };

    /**
     * 批量恢复
     * @param ids
     * @return
     */@RequestMapping("/author/huifuAll")@ResponseBodypublic ResultData huifuDelete(@RequestParam(name = "ids") String ids){
//        将ids转换成数组
        String[] idArr=ids.split(",");
        return authorService.huifuDelete(idArr);
    };

    @RequestMapping("/author/delete")@ResponseBodypublic ResultData deleteAuthor(Integer authorId, Integer authorStatus){
        return authorService.deleteauthor(authorId,authorStatus);
    }



}

历史控制层:

@ControllerpublicclassHistoryController {
    @Autowiredprivate 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")@ResponseBodypublic 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")@ResponseBodypublic ResultData deleteAll(@RequestParam(name="ids") String ids){
        //将ids转为数组
        String[] idArr = ids.split(",");
        //将字符串数组转为int数组return historyService.batchDelete(idArr);

    }

}