IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> Java项目:在线电子书小说阅读系统(java+Layui+Springboot+Maven+mysql+HTML+FTP) -> 正文阅读

[Java知识库]Java项目:在线电子书小说阅读系统(java+Layui+Springboot+Maven+mysql+HTML+FTP)

一、项目介绍

环境配置:

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

项目技术:

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

?

?

读者用户控制器:

@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 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/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";
    }

}


?

图书订单管理控制层:

@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 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){


        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);
    }

    /**
     * 编辑作者状态信息
     * @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);
    }



}

历史控制层:

@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知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章      下一篇文章      查看所有文章
加:2022-01-28 11:45:25  更:2022-01-28 11:45:32 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 9:32:50-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码