基于javaweb+mysql的springboot在线电子书小说阅读系统(java+layui+springboot+maven+mysql+html)

基于javaweb+mysql的springboot在线电子书小说阅读系统(java+layui+springboot+maven+mysql+html)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot在线电子书小说阅读系统(java+layui+springboot+maven+mysql+html)

一、项目介绍 环境配置:

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

项目技术:

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

        List<BookChapterDTO> chapter = frReadingService.showReadingChapter(bId,cTitle);
        Map<String,List> map = new HashMap<>();
        map.put("types",types);
        map.put("chapter",chapter);
        return Result.success(map);
    }

    /**
     * reading页面的翻页
     * @return map
     * @param  bId
     */
    @GetMapping("/frNextOrPrevious")
    public Result frNextOrPrevious(Integer bId, String eTime, String compare){
        if ("".equals(compare)){
            return Result.success(frReadingService.showNextOrPrevious(bId,eTime,null));
        }
        return Result.success(frReadingService.showNextOrPrevious(bId,eTime,compare));
    }

}

/**
 */
public class FrLoginController {

    @Resource
    FrLoginService frLoginService;

    /**
     * 注册用户
     */
    @PostMapping("/addOne")
    public Result addOne(UserPO user){
        return Result.success(frLoginService.addOne(user));
    }

    /**
     * 用户登录
     */
    @GetMapping("/showOne")
    public Result showOne(String uAccount,String uPassword){
        return Result.success(frLoginService.showOne(uAccount,uPassword));
    }

    /**
     * 查重用户名
     */
    @GetMapping("/showByUAccount")
    public Result showByUAccount(String uAccount){
        return Result.success(frLoginService.showByUAccount(uAccount));
    }

}

/**
 */
@RequestMapping("/after/chapter")

/**
 * 通过aop拦截请求 记录运行信息
 *
 */
@Aspect
@Component
public class HttpAspect {

    private static long startTime;
    private static long endTime;

    private static final Logger log = LoggerFactory.getLogger(zl.readCloud.aop.HttpAspect.class);

    /**
     * 切点表达式
     */
    @Pointcut("execution(public * zl.readCloud.controller..*.*(..))")

    /**
     * 切点签名
     */
    public void print() {

    }

    /**
     * @Before注解表示在具体的方法之前执行
     * @param joinPoint
     */
    @Before("print()")
    public void before(JoinPoint joinPoint) {
        startTime = System.currentTimeMillis();
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        String requestURI = request.getRequestURI();
        String remoteAddr = "127.0.0.1";
        String requestMethod = request.getMethod();
        String declaringTypeNamepeName = joinPoint.getSignature().getDeclaringTypeName();
        String methodName = joinPoint.getSignature().getName();
     *
     * @param book
     * @return int
     */
    @PostMapping("/updateOne")
    public Result updateOne(@RequestBody BookPO book) {
        return Result.success(afBookService.updateOne(book));
    }

    /**
     * detail: 添加章节内容
     *
     * @param chapter
     * @return int
     */
    @PostMapping("/addChap")
    public Result addChap(ChapterPO chapter){
        //获取一个当前时间,精确到毫秒,确保添加时间不会重,为后面客户端页面排序做准备
        //创建一个date对象保存当前时间
        // Date date = new Date();
        // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        //format()方法将Date转换成指定格式的String
        // String dateStr = simpleDateFormat.format(date);
        chapter.setETime(DateUtils.getCurrentTime());
        Integer bId = chapter.getBId();
        afBookService.updateByBId(bId,DateUtils.getCurrentTime());
        afBookService.deleteById(bId,1);
        return Result.success(afBookService.addChap(chapter));
    }

    /**
     * detail: 根据小说bId查询小说的所有条数,进而得出下一章的数字
     *
     * @param bId
     * @return int
     */
    @GetMapping("/showByBId")
    public Result showByBId(Integer bId){
        return Result.success(afBookService.showByBId(bId).size());
    }

    @GetMapping("/showByBTitle")
        Integer count = afBannerService.getBannerListCount();
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setBaPicture(ToolsUtils.getImgPath(list.get(i).getBaPicture()));
        }
        return Result.success(Result.SUCCESS, count, list);
    }

    @PostMapping("/addBanner")
    public Result addBanner(@RequestBody BannerDTO bannerDTO ) {
        BookPO book = afBookService.showByBTitle(bannerDTO.getBTitle());
        BannerPO banner = new BannerPO();
        banner.setBaId(bannerDTO.getBaId());
        banner.setBaLevel(bannerDTO.getBaLevel());
        banner.setBaPicture(bannerDTO.getBaPicture());
        banner.setBId(book.getBId());
        banner.setStartDt(bannerDTO.getStartDt());
        banner.setEndDt(bannerDTO.getEndDt());
        return Result.success(afBannerService.addBanner(banner));
    }

    @PostMapping("/updateBanner")
    public Result updateBanner(@RequestBody BannerPO banner) {
        return Result.success(afBannerService.updateBanner(banner));
    }

    @GetMapping("/deleteBanner")
    public Result deleteBanner(@RequestParam("baId")Integer baId) {
        return Result.success(afBannerService.deleteBanner(baId));
    }

}

    public void after() {
        endTime = System.currentTimeMillis() - startTime;
    }

    /**
     * @AfterReturning注解用于获取方法的返回值
     * @param object
     */
    @AfterReturning(pointcut = "print()", returning = "object")
    public void getAfterReturn(Object object) {
        log.info("本次接口耗时={}ms", endTime);
    }
}

/**
 * @Description:
 */
@RequestMapping("/banner")
@RestController
public class AfBannerController {

    @Autowired
    private AfBannerServiceImpl afBannerService;

    @Autowired

    /**
     * index页面的所有数据
     * @return map
     * @param lastNnm 最近更新章节的条数
     * @param lastBookNum 最近上架书籍的条数
     */
    @GetMapping("/frIndex")
    public Result frIndex(Integer lastNnm, Integer lastBookNum){
        Date time = new Date();
        SimpleDateFormat sdf = new  SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String nowDate = sdf.format(time);
        List<TypePO> types = frIndexService.showTypeAll();
        List<BannerPO> banners = frIndexService.getBannerList2(nowDate);
        for (BannerPO banner : banners) {
            banner.setBaPicture(ToolsUtils.getImgPath(banner.getBaPicture()));
        }
        List<BookPO> hotRec = frIndexService.showByHotRec(null);
        for (BookPO book : hotRec) {
            book.setBPicture(ToolsUtils.getImgPath(book.getBPicture()) );
        }
        List<BookChapterDTO> lastChapter = frIndexService.showLastUpdate(lastNnm,null);
        List<BookChapterDTO> lastBook = frIndexService.showLastUpdateBook(lastBookNum);
        Map<String,List> map = new HashMap<>();
        map.put("types",types);
        map.put("banners",banners);
        map.put("hotRec",hotRec);
        map.put("lastChapter",lastChapter);
        map.put("lastBook",lastBook);
        return Result.success(map);
    }

    /**
     * type页面的所有数据
     * @return map
     * @param cate 类型
     * @param lastNnm 最近更新章节的条数
     */
    @GetMapping("/frType")
    public Result frType(Integer lastNnm, String cate){
        List<TypePO> types = frIndexService.showTypeAll();
        List<BookPO> hotRec = frIndexService.showByHotRec(cate);
        for (BookPO bookPO : hotRec) {
            bookPO.setBPicture(ToolsUtils.getImgPath(bookPO.getBPicture()));
        }
        List<BookChapterDTO> lastChapter = frIndexService.showLastUpdate(lastNnm,cate);
        Map<String,List> map = new HashMap<>();
        map.put("types",types);
        map.put("hotRec",hotRec);
        map.put("lastChapter",lastChapter);
        return Result.success(map);
    }

/**
 */
@RequestMapping("/front")
@RestController
public class FrController {

    // 首页banner图的数量
    private static final Integer BANNER_COUNT = 5;

    @Resource
    FrIndexService frIndexService;

    @Resource
    FrDetailsService frDetailsService;

    @Resource
    FrReadingService frReadingService;

    /**
     * 头部的搜索功能
     * @return list<book>
     * @param bTitle 输入的书籍名称,模糊查询
     */
    @GetMapping("/frSearch")
    public Result frSearch(String bTitle){
        List<TypePO> types = frIndexService.showTypeAll();
        List<BookPO> books = frIndexService.showBTitleByLike(bTitle);
        if (books.size() == 0) {

}

/**
 */
@RequestMapping("/front/login")
@RestController
public class FrLoginController {

    @Resource
    FrLoginService frLoginService;

    /**
     * 注册用户
     */
    @PostMapping("/addOne")
    public Result addOne(UserPO user){
        return Result.success(frLoginService.addOne(user));
    }

    /**
     * 用户登录
     */
    @GetMapping("/showOne")
    public Result showOne(String uAccount,String uPassword){
        return Result.success(frLoginService.showOne(uAccount,uPassword));
    }

    /**
     * 查重用户名
     */
    @GetMapping("/showByUAccount")
    public Result showByUAccount(String uAccount){
        return Result.success(frLoginService.showByUAccount(uAccount));
    }

}

        return Result.success(Result.SUCCESS, count, list);
    }

    @PostMapping("/addBanner")
    public Result addBanner(@RequestBody BannerDTO bannerDTO ) {
        BookPO book = afBookService.showByBTitle(bannerDTO.getBTitle());
        BannerPO banner = new BannerPO();
        banner.setBaId(bannerDTO.getBaId());
        banner.setBaLevel(bannerDTO.getBaLevel());
        banner.setBaPicture(bannerDTO.getBaPicture());
        banner.setBId(book.getBId());
        banner.setStartDt(bannerDTO.getStartDt());
        banner.setEndDt(bannerDTO.getEndDt());
        return Result.success(afBannerService.addBanner(banner));
    }

    @PostMapping("/updateBanner")
    public Result updateBanner(@RequestBody BannerPO banner) {
        return Result.success(afBannerService.updateBanner(banner));
    }

    @GetMapping("/deleteBanner")
    public Result deleteBanner(@RequestParam("baId")Integer baId) {
        return Result.success(afBannerService.deleteBanner(baId));
    }

}

/**
 */

@RequestMapping("/after/admin")
@RestController
public class AfAdminController {

/**
 */
@Transactional
@RequestMapping("/after/book")
@RestController
public class AfBookController {

    @Resource
    AfBookService afBookService;

    /**
     * detail: 分页展示所有书籍,条件查询
     */
    @PostMapping("/showAll")
    public Result showAll(Integer page, Integer limit, BookPO book) {
        if ("".equals(book.getAuthor())) {
            book.setAuthor(null);
        }
        if ("".equals(book.getBTitle())) {
            book.setBTitle(null);
        }
        if ("".equals(book.getCate())) {
            book.setCate(null);
        }
        // integer类型,前台传值时为空,转化为null
        if (book.getAuthor() == null && book.getBTitle() == null
                && book.getCate() == null && book.getGoodNum() == null
                && book.getReadNum() == null) {
            Integer pages = (page - 1) * limit;
            List<BookPO> list = afBookService.showAll(pages, limit);
            for (int i = 0; i < list.size(); i++) {
                list.get(i).setBPicture(ToolsUtils.getImgPath(list.get(i).getBPicture()));
            }
            Integer count = afBookService.showAllItem().size();
            return Result.success(Result.SUCCESS, count, list);
        }
        List<BookPO> list = afBookService.showScreen(book);
/**
 */
@Transactional
@RequestMapping("/after/book")
@RestController
public class AfBookController {

    @Resource
    AfBookService afBookService;

    /**
     * detail: 分页展示所有书籍,条件查询
     */
    @PostMapping("/showAll")
    public Result showAll(Integer page, Integer limit, BookPO book) {
        if ("".equals(book.getAuthor())) {
            book.setAuthor(null);
        }
        if ("".equals(book.getBTitle())) {
            book.setBTitle(null);
        }
        if ("".equals(book.getCate())) {
            book.setCate(null);
        }
        // integer类型,前台传值时为空,转化为null
        if (book.getAuthor() == null && book.getBTitle() == null
                && book.getCate() == null && book.getGoodNum() == null
                && book.getReadNum() == null) {
            Integer pages = (page - 1) * limit;
            List<BookPO> list = afBookService.showAll(pages, limit);
            for (int i = 0; i < list.size(); i++) {
                list.get(i).setBPicture(ToolsUtils.getImgPath(list.get(i).getBPicture()));
            }
            Integer count = afBookService.showAllItem().size();
            return Result.success(Result.SUCCESS, count, list);
        }
        List<BookPO> list = afBookService.showScreen(book);
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setBPicture(ToolsUtils.getImgPath(list.get(i).getBPicture()));
        }
        LoggerFactory.getLogger(AfBookController.class).info(list.toString());
        return Result.success(list);
    }

    /**
     * detail: 添加书籍
@RestController
public class AfTypeController {

    @Resource
    AfTypeService afTypeService;

    @PostMapping("/addType")
    public Result addType(String cate) {
        if (afTypeService.showByType(cate) == null){
            return Result.success(200,"添加成功",0,afTypeService.addType(cate));
        }
        return Result.success(200,"该分类已存在,请添加新分类",0,0);
    }

    @PostMapping("/showAll")
    public Result showAll() {
        return Result.success(Result.SUCCESS, afTypeService.showAll().size(),afTypeService.showAll());
    }

    @GetMapping("/updateById")
    public Result updateById(@RequestBody TypePO type) {
        return Result.success(afTypeService.updateById(type));
    }

    @PostMapping("/deleteById")
    public Result deleteById(Integer tId) {
        return Result.success(afTypeService.deleteById(tId));
    }

}

/**

    /**
     * detail: 添加章节内容
     *
     * @param chapter
     * @return int
     */
    @PostMapping("/addChap")
    public Result addChap(ChapterPO chapter){
        //获取一个当前时间,精确到毫秒,确保添加时间不会重,为后面客户端页面排序做准备
        //创建一个date对象保存当前时间
        // Date date = new Date();
        // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        //format()方法将Date转换成指定格式的String
        // String dateStr = simpleDateFormat.format(date);
        chapter.setETime(DateUtils.getCurrentTime());
        Integer bId = chapter.getBId();
        afBookService.updateByBId(bId,DateUtils.getCurrentTime());
        afBookService.deleteById(bId,1);
        return Result.success(afBookService.addChap(chapter));
    }

    /**
     * detail: 根据小说bId查询小说的所有条数,进而得出下一章的数字
     *
     * @param bId
     * @return int
     */
    @GetMapping("/showByBId")
    public Result showByBId(Integer bId){
        return Result.success(afBookService.showByBId(bId).size());
    }

    @GetMapping("/showByBTitle")
    public Result showByBTitle(String bTitle) {
        BookPO book = afBookService.showByBTitle(bTitle);
        if (book != null) {
            return Result.success(Result.SUCCESS,1,book);
        }
        return Result.success(Result.SUCCESS,0,null);
    }
     */
    @PostMapping("/addChap")
    public Result addChap(ChapterPO chapter){
        //获取一个当前时间,精确到毫秒,确保添加时间不会重,为后面客户端页面排序做准备
        //创建一个date对象保存当前时间
        // Date date = new Date();
        // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        //format()方法将Date转换成指定格式的String
        // String dateStr = simpleDateFormat.format(date);
        chapter.setETime(DateUtils.getCurrentTime());
        Integer bId = chapter.getBId();
        afBookService.updateByBId(bId,DateUtils.getCurrentTime());
        afBookService.deleteById(bId,1);
        return Result.success(afBookService.addChap(chapter));
    }

    /**
     * detail: 根据小说bId查询小说的所有条数,进而得出下一章的数字
     *
     * @param bId
     * @return int
     */
    @GetMapping("/showByBId")
    public Result showByBId(Integer bId){
        return Result.success(afBookService.showByBId(bId).size());
    }

    @GetMapping("/showByBTitle")
    public Result showByBTitle(String bTitle) {
        BookPO book = afBookService.showByBTitle(bTitle);
        if (book != null) {
            return Result.success(Result.SUCCESS,1,book);
        }
        return Result.success(Result.SUCCESS,0,null);
    }
}

/**
 */
@RequestMapping("/after/user")
@RestController
public class AfUserController {

        return Result.success(afUserService.updateByUAccount(uPassword,uAccount));
    }

    /**
     * detail: 通过账号查询
     * @param uAccount
     * @return int
     */
    @GetMapping("/showByUAccount")
    Result showByUAccount(String uAccount){
        return Result.success(afUserService.showByUAccount(uAccount));
    }

    /**
     * detail: 添加用户
     * @param user
     * @return int
     */
    @PostMapping("/addOne")
    Result addOne(@RequestBody UserPO user){
        return Result.success(afUserService.addOne(user));
    }

    /**
     * detail: 编辑用户基本信息
     * @param user
     * @return int
     */
    @PostMapping("/updateById")
    Result updateById(@RequestBody UserPO user){
        return Result.success(afUserService.updateById(user));
    }
}

/**
 * 通过aop拦截请求 记录运行信息
 *
 */
@Aspect
        return Result.success(map);
    }

    /**
     * details页面的所有数据
     * @return map
     * @param  bId
     */
    @GetMapping("/frDetail")
    public Result frDetail(Integer bId){
        List<TypePO> types = frIndexService.showTypeAll();
        BookPO book = frDetailsService.showBookByBId(bId);
        book.setBPicture(ToolsUtils.getImgPath(book.getBPicture()));
        List<BookPO> list = new ArrayList<>();
        list.add(book);
        List<ChapterPO> chapters = frDetailsService.showChapterByBId(bId);
        Map<String,List> map = new HashMap<>();
        map.put("types",types);
        map.put("book",list);
        map.put("chapters", chapters);
        return Result.success(map);
    }

    /**
     * reading页面的所有数据
     * @return map
     * @param  bId
     */
    @GetMapping("/frReading")
    public Result frReading(Integer bId,String cTitle){
        List<TypePO> types = frIndexService.showTypeAll();
        List<BookChapterDTO> chapter = frReadingService.showReadingChapter(bId,cTitle);
        Map<String,List> map = new HashMap<>();
        map.put("types",types);
        map.put("chapter",chapter);
        return Result.success(map);
    }

    /**
     * reading页面的翻页

    }

    /**
     * detail: 注销用户,启用用户
     * @param uId
     * @return int
     */
    @PostMapping("/deleteById")
    Result deleteById(Integer uId,Integer status){
        if (status == 1){
            return Result.success(200,"注销成功",200,afUserService.deleteById(uId,0));
        }
        return Result.success(200,"启用成功",200,afUserService.deleteById(uId,1));
    }

    /**
     * detail: 批量注销用户
     * @param uIds
     * @return int
     */
    @PostMapping("/deleteByIds")
    Result deleteByIds(Integer[] uIds){
        return Result.success(afUserService.deleteByIds(uIds));
    }

    /**
     * detail: 验证用户,账号和密码
     * @param uAccount
     * @param uPassword
     * @return int
     */
    @GetMapping("/showOne")
    Result showOne(String uAccount,String uPassword){
        return Result.success(afUserService.showOne(uAccount,uPassword));
    }

    /**
     * detail: 修改密码操作:
     *           第一步,showOne,验证通过后,才可以修改密码
     *           第二步,根据已登录的用户名修改密码
     * @param uPassword
     * @param uAccount
     * @return int
     */
    @GetMapping("/updateByUAccount")

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值