基于javaweb+mysql的ssm前台+后台精品图书管理系统(java+ssm+jsp+mysql)

基于javaweb+mysql的ssm前台+后台精品图书管理系统(java+ssm+jsp+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb的SSM前台+后台精品图书管理系统(java+ssm+jsp+mysql)

一、项目简述

功能包括: 登录注册,办理借阅。借阅记录,预约借阅,借出未还, 借阅逾期,学生管理,图书管理,书库分类查询搜索。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax +等等。

    public void postHandle(HttpServletRequest request,
                           HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {

    }

    //执行handler之后执行此方法
    //作系统 统一异常处理,进行方法执行性能监控,在preHandle中设置一个时间点,在afterCompletion设置一个时间,两个时间点的差就是执行时长
    //实现 系统 统一日志记录
    @Override
    public void afterCompletion(HttpServletRequest request,
                                HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
    }
}

/**
 * @desc 前台用户功能Controller
 **/
@Controller
@RequestMapping("/user")
public class user_userSystemController {
    @Autowired
    private user_userSystem user_userSystem;

    //重置用户密码
    @RequestMapping("/resetPwd")
    public String resetPassword(Model model, Integer id, String oldPassword, String newPassword, String newPassword2) throws Exception {
        String msg;
        String url;
        //判断输入的值是否为空
        if ("".equals(oldPassword) || oldPassword == null || "".equals(newPassword) || newPassword == null || "".equals(newPassword2) || newPassword2 == null) {
            msg = "不能有空值";
            url = "/user/user_resetPassword.action";
            model.addAttribute("msg", msg);
            model.addAttribute("url", url);
            return "user/error";

    @Override
    public List<TbCategory> getCategoryByParentId(int parentId) {
        // 创建 查询对象
        TbCategoryExample categoryExample = new TbCategoryExample();
        // 添加查询条件
        categoryExample.createCriteria().andParentIdEqualTo(parentId);

        List<TbCategory> subCategoryList = categoryMapper.selectByExample(categoryExample);
        if (subCategoryList == null || subCategoryList.size() < 1) {
            return null;
        }

        return subCategoryList;
    }

    @Override
    public List<TbCategory> getCategoryByCid(int cid) {
        // 若 当前 类目id 为 0
        if (cid == 0) {
            TbCategoryExample categoryExample = new TbCategoryExample();
            return categoryMapper.selectByExample(categoryExample);
        }
        // 根据 类目id 获取 类目信息
        TbCategory category = categoryMapper.selectByPrimaryKey(cid);
        // 判断该 图书是否是 父类目
        if (category.getIsParent()) {
            // 获取 父类目 为当前 类目 的 所有 类目
            TbCategoryExample categoryExample = new TbCategoryExample();
            categoryExample.createCriteria().andParentIdEqualTo(cid);

            return categoryMapper.selectByExample(categoryExample);
        }
        int parentId = 0;
        // 获取当前类目的 父类目
        if (category.getParentId() != null) {
            parentId = category.getParentId();
        }
        // 获取 父类目下所有的 子类目信息
        TbCategoryExample categoryExample = new TbCategoryExample();
        categoryExample.createCriteria().andParentIdEqualTo(parentId);

        return categoryMapper.selectByExample(categoryExample);
    }
}


    @Value("${PAGE_ROWS}")
    private String PAGE_ROWS;               // 默认每页条数

    @Override
    public List<TbCategory> getCategoryAll() {
        // 设置查询条件
        TbCategoryExample categoryExample = new TbCategoryExample();
        // 执行查询
        return categoryMapper.selectByExample(categoryExample);
    }

    @Override
    public PageCount<TbCategoryExt> getCategoryAllWithParentName(PageCount pageCount) {
        // 设置查询条件
        TbCategoryExample categoryExample = new TbCategoryExample();
        // 判断页面参数 是否有效
        if (pageCount.getCurrentPage() == null) {
            pageCount.setCurrentPage(Integer.parseInt(CURRENT_PAGE));
        }
        if (pageCount.getPageRows() == null) {
            pageCount.setPageRows(Integer.parseInt(PAGE_ROWS));
        }

        // 分页插件
        PageHelper.startPage(pageCount.getCurrentPage(), pageCount.getPageRows());

        // 获取列表集合
        List<TbCategory> categoryList = categoryMapper.selectByExample(categoryExample);

        // 获取 分页详细信息
        PageInfo<TbCategory> pageInfo = new PageInfo<>(categoryList);
        // 数据总数
        pageCount.setTotalRows(pageInfo.getTotal());
        // 总页数
        pageCount.setTotalPages(pageInfo.getPages());

        // 扩展 pojo 封装
        List<TbCategoryExt> categoryExts = new ArrayList<>();

        // 遍历结合,进行扩展类的 封装填充
        for (TbCategory tbCategory : categoryList) {
            // 创建 扩展pojo 实例
            TbCategoryExt categoryExt = new TbCategoryExt();
            // 封装数据
        this.loan_management.addLoanList(tbRecord);

        //通过id删除预约记录
        this.loan_management.removeOrderList(id);

        //返回借阅列表
        return "redirect:/admin/loan/bespeakList.action";
    }

    //    删除预约记录
    @RequestMapping("/loan/removeBespeak")
    public String removeBespeak(Integer id) throws Exception {
        this.loan_management.removeOrderList(id);
        return "redirect:/admin/loan/bespeakList.action";
    }
}

/**
 * 用户列表信息
 */

@Controller
@RequestMapping("/admin")
public class Loan_UserInfoController {
    @Autowired
    private Loan_UserInfoList loan_userInfoList;

    //查询用户信息列表
    @RequestMapping("/loan_userList")
    public String userList(Model model) {
        List<TbUser> userList = loan_userInfoList.findUserList();

/**
 * @description: 图书服务实现类
 *
 */

@Service
public class LibraryServiceImpl implements LibraryService {
    // 注入
    @Autowired
    private TbLibraryAndManagerMapper libraryAndManagerMapper;
    @Autowired
    private TbLibraryMapper libraryMapper;
    @Autowired
    private TbCommentMapper commentMapper;
    @Autowired
    private TbOrderMapper orderMapper;
    @Autowired
    private TbRecordMapper recordMapper;
    @Autowired
    private TbReplyMapper replyMapper;

    @Value("${CURRENT_PAGE}")
    private String CURRENT_PAGE;    // 默认 当前页数
    @Value("${PAGE_ROWS}")
    private String PAGE_ROWS;       // 默认 每页显示记录数
    @Value("${FILE_SAVE_PATH}")     // 默认 上传文件保存路径
    private String FILE_SAVE_PATH;


        //遍历公开地址。如果访问的是公开地址就放行
        for (String open_url : open_urls) {
            if (open_url.equals(url)) {
//            如果是公开地址,则放行
                return true;
            }
        }

        //        从配置文件中取出公共访问地址
        List<String> adminCommon_urls = ResourcesUtil.gekeyList("AdmincommonURL");
//        遍历公用地址,如果是公用地址则放行
        for (String common_url : adminCommon_urls) {
            if (common_url.equals(url)) {
                //判断用户身份在session中是否存在
                HttpSession session = request.getSession();
                ActiveAdmin activeAdmin = new ActiveAdmin();
                activeAdmin = (ActiveAdmin) session.getAttribute("activeAdmin");
                //如果用户的身份在session中存在
                if (activeAdmin != null) {
                    return true;
                }
            }
        }

        //        从配置文件中取出公共访问地址
        List<String> userCommon_urls = ResourcesUtil.gekeyList("UsercommonURL");
//        遍历公用地址,如果是公用地址则放行
        for (String common_url : userCommon_urls) {
            if (common_url.equals(url)) {
                //判断用户身份在session中是否存在
                HttpSession session = request.getSession();
                ActiveUser activeUser = new ActiveUser();
                activeUser = (ActiveUser) session.getAttribute("activeUser");
                //如果用户的身份在session中存在
                if (activeUser != null) {
                    return true;
                }
            }
        }
        //执行到这里,进行拦截,跳转到登陆页面,用户进行身份验证
        request.setAttribute("msg", "非法访问!");
        request.setAttribute("url", "/login.action");
        request.getRequestDispatcher("/WEB-INF/jsp/user/error.jsp").forward(request, response);
        return false;
    }

    //在执行handler返回modelAndView之前来执行
    //如果需要向页面提供一些公用 的数据或配置一些视图信息,使用此方法实现 从modelAndView入手
    @Override
    public void postHandle(HttpServletRequest request,
                           HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {
            parentCategory.setIsParent(true);
            // 修改父类目的 isParent 值
            categoryMapper.updateByPrimaryKeySelective(parentCategory);
        }

        //添加当前类目
        categoryMapper.insert(category);
    }

    @Override
    public void delBookCategoryById(int id) {
        // 通过 id 查询该 类目的 信息
        TbCategory category = categoryMapper.selectByPrimaryKey(id);

        // 判断 该类目是否是 父类目
        if (category.getIsParent()) {
            // 查询 当前类目的 子id
            // 创建查询条件
            TbCategoryExample categoryExample = new TbCategoryExample();
            categoryExample.createCriteria().andParentIdEqualTo(category.getId());
            // 进行 查询
            List<TbCategory> categoryList = categoryMapper.selectByExample(categoryExample); // 子类目
            // 遍历 删除子类目
            for (TbCategory tbCategory : categoryList) {
                delBookCategoryById(tbCategory.getId());
            }
        }

        // 获取 该 类目 下的 所有图书
        TbLibraryExample libraryExample = new TbLibraryExample();
        // 添加 条件
        libraryExample.createCriteria().andCateIdEqualTo(id);

        // 该类目下 所有的 图书
        List<TbLibrary> libraryList = libraryMapper.selectByExample(libraryExample);

        // 遍历图书列表 ,删除 关联信息
        for (TbLibrary library : libraryList) {
            // 获取 图书 id
            int libId = library.getId();

            // 删除 order 表中图书关联数据
            TbOrderExample orderExample = new TbOrderExample();
            orderExample.createCriteria().andBookIdEqualTo(libId);
            orderMapper.deleteByExample(orderExample);

            // 删除 record 表中图书关联数据
        }
        // 根据 类目 id
        // 若 当前 类目 为 父类目 则获取 其 下面 的 所有子类目
        // 若 当前 类目 为 子类目 则获取 其 同级 类目
        List<TbCategory> categoryList = libraryCategoryService.getCategoryByCid(libraryQuery.getCateId());

        // 获取当前类目信息
        TbCategory currentCategory = libraryCategoryService.getCategoryById(libraryQuery.getCateId());

        // 按照条件进行查询
        PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(libraryQuery, pageCount);
        // model 将数据设置到域中
        model.addAttribute("subCategoryList", categoryList);
        model.addAttribute("libraryPageCount", libraryPageCount);
        // 默认
        if (currentCategory == null) {
            currentCategory = new TbCategory();
            currentCategory.setId(0);
        }
        session.setAttribute("currentCategory", currentCategory.getId());

        return "/user/user_bookList";
    }

    /**
     * 通过 图书 id 查询 图书详细信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/bookId")
    public String toBookInfo(int id, Model model) {
        BookExt bookInfo = libraryService.getBookInfoById(id);
        // 将 时间戳 进行转换
        Long dateSS = bookInfo.getLibrary().getCreatedate();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

        String formatDate = simpleDateFormat.format(new Date(dateSS * 1000));

        bookInfo.setFormatDate(formatDate);


/**
 * 用户身份拦截器
 */
public class LoginInterceptor implements HandlerInterceptor {

    //在执行handler之前来执行的
    //用于用户认证校验、用户权限校验
    @Override
    public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response, Object handler) throws Exception {

        //得到请求的url
        String url = request.getRequestURI();
        //判断公开地址
        //实际开发中需要公开的地址在配置文件中
        //从配置文件中取出匿名访问的url
        List<String> open_urls = ResourcesUtil.gekeyList("anonymousURL");

        //遍历公开地址。如果访问的是公开地址就放行
        for (String open_url : open_urls) {
            if (open_url.equals(url)) {
//            如果是公开地址,则放行
                return true;
            }
        }

        //        从配置文件中取出公共访问地址
        List<String> adminCommon_urls = ResourcesUtil.gekeyList("AdmincommonURL");
//        遍历公用地址,如果是公用地址则放行
        for (String common_url : adminCommon_urls) {
            if (common_url.equals(url)) {
                //判断用户身份在session中是否存在
                HttpSession session = request.getSession();
                ActiveAdmin activeAdmin = new ActiveAdmin();
                activeAdmin = (ActiveAdmin) session.getAttribute("activeAdmin");
                //如果用户的身份在session中存在
                if (activeAdmin != null) {
                    return true;
                }
            }
        }

        //        从配置文件中取出公共访问地址
public class IframeController {

    @Autowired
    private LibraryCategoryService libraryCategoryService;
    @Autowired
    private LibraryService libraryService;

    @RequestMapping("/admin/{adminPage}")
    public String admin(@PathVariable String adminPage, HttpSession session) throws Exception {
        if (session.getAttribute("categoryAll") == null) {
            // 图书类目 ,设置到 session 中
            List<TbCategory> categoryAll = libraryCategoryService.getCategoryAll();
            session.setAttribute("categoryAll", categoryAll);
        }

        return "admin/" + adminPage;

    }

    @RequestMapping("/user/{userPage}")
    public String user(@PathVariable String userPage, HttpSession session, Model model) throws Exception {
        // 获取图书类目信息
        List<TbCategory> categoryAll = libraryCategoryService.getCategoryAll();
        session.setAttribute("userCategoryAll", categoryAll);

        //
        TbLibraryQuery libraryQuery = new TbLibraryQuery();
        libraryQuery.setCateId(0);
        libraryQuery.setBookname("");
        // 將图书 設置到 域中
        PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(libraryQuery, null);

        // 查询所有 类目 父 id 为 0 的
        List<TbCategory> subCategoryList = libraryCategoryService.getCategoryByParentId(0);

        model.addAttribute("libraryPageCount", libraryPageCount);
        model.addAttribute("subCategoryList", subCategoryList);
        session.setAttribute("currentCategory", 0);

        return "user/" + userPage;
    }

    @RequestMapping("/{loginPage}")
    public String index(@PathVariable String loginPage) throws Exception {
        return loginPage;
    }
}

        }

        //        从配置文件中取出公共访问地址
        List<String> userCommon_urls = ResourcesUtil.gekeyList("UsercommonURL");
//        遍历公用地址,如果是公用地址则放行
        for (String common_url : userCommon_urls) {
            if (common_url.equals(url)) {
                //判断用户身份在session中是否存在
                HttpSession session = request.getSession();
                ActiveUser activeUser = new ActiveUser();
                activeUser = (ActiveUser) session.getAttribute("activeUser");
                //如果用户的身份在session中存在
                if (activeUser != null) {
                    return true;
                }
            }
        }
        //执行到这里,进行拦截,跳转到登陆页面,用户进行身份验证
        request.setAttribute("msg", "非法访问!");
        request.setAttribute("url", "/login.action");
        request.getRequestDispatcher("/WEB-INF/jsp/user/error.jsp").forward(request, response);
        return false;
    }

    //在执行handler返回modelAndView之前来执行
    //如果需要向页面提供一些公用 的数据或配置一些视图信息,使用此方法实现 从modelAndView入手
    @Override
    public void postHandle(HttpServletRequest request,
                           HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {

    }

    //执行handler之后执行此方法
    //作系统 统一异常处理,进行方法执行性能监控,在preHandle中设置一个时间点,在afterCompletion设置一个时间,两个时间点的差就是执行时长
    //实现 系统 统一日志记录
    @Override
    public void afterCompletion(HttpServletRequest request,
                                HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
    }
}
     * 添加 图书类目
     *
     * @param category 图书类目信息
     * @param session  添加人
     * @return url
     */
    @RequestMapping(value = "/addCategory", method = RequestMethod.POST)
    public String addCategory(TbCategory category, HttpSession session, Model model) {
        List<TbCategory> categoryList = libraryCategoryService.getCategoryAll();
        boolean is = false;
        for (TbCategory tbCategory : categoryList) {
            if (category.getCatname().equals(tbCategory.getCatname())) {
                is = true;
                break;
            }
        }
        if (!is) {
            // 添加 数据到 数据库,并 修改 父类目
            libraryCategoryService.addBookCategory(category, session);
        } else {
            model.addAttribute("errorMsg", "类目已经存在");
            return "errorMsg";
        }
        return "redirect:/admin/ch/loan_BookClassify.action";
    }

    /**
     * 删除类目信息
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/delCategory", method = RequestMethod.GET)
    public String delCategory(int id) {

        // 通过 类目id 删除数据
        libraryCategoryService.delBookCategoryById(id);

        return "redirect:/admin/ch/loan_BookClassify.action";
            // 进行 查询
            List<TbCategory> categoryList = categoryMapper.selectByExample(categoryExample); // 子类目
            // 遍历 删除子类目
            for (TbCategory tbCategory : categoryList) {
                delBookCategoryById(tbCategory.getId());
            }
        }

        // 获取 该 类目 下的 所有图书
        TbLibraryExample libraryExample = new TbLibraryExample();
        // 添加 条件
        libraryExample.createCriteria().andCateIdEqualTo(id);

        // 该类目下 所有的 图书
        List<TbLibrary> libraryList = libraryMapper.selectByExample(libraryExample);

        // 遍历图书列表 ,删除 关联信息
        for (TbLibrary library : libraryList) {
            // 获取 图书 id
            int libId = library.getId();

            // 删除 order 表中图书关联数据
            TbOrderExample orderExample = new TbOrderExample();
            orderExample.createCriteria().andBookIdEqualTo(libId);
            orderMapper.deleteByExample(orderExample);

            // 删除 record 表中图书关联数据
            TbRecordExample recordExample = new TbRecordExample();
            recordExample.createCriteria().andBookIdEqualTo(libId);
            recordMapper.deleteByExample(recordExample);

            // 通过 图书 id 查询 comment 中的 数据
            TbCommentExample commentExample = new TbCommentExample();
            commentExample.createCriteria().andBookIdEqualTo(libId);
            // 获取 图书 回复表信息
            List<TbComment> comments = commentMapper.selectByExample(commentExample);

            // 遍历图书 回复表信息
            for (TbComment comment : comments) {
                // 删除 reply 表中 comment 关联数据
                TbReplyExample replyExample = new TbReplyExample();
                replyExample.createCriteria().andCommentIdEqualTo(comment.getId());
                replyMapper.deleteByExample(replyExample);
            }
            // 删除 comment 表中 library 关联数据
            commentMapper.deleteByExample(commentExample);

            // 删除 library 表中的 数据
            libraryMapper.deleteByPrimaryKey(libId);
        }

        // 当前 类目为 子类目
        categoryMapper.deleteByPrimaryKey(id);
    //查询用户借阅列表
    @RequestMapping("/user_MyloanList")
    public String user_MyloanList(HttpSession session, Model model) {
        ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");
        TbUser tbUser = new TbUser();
        tbUser.setId(activeUser.getUserid());
        session.setAttribute("userInfo", tbUser);
        //获取session用户信息
//        TbUser userInfo = (TbUser) session.getAttribute("activeUser");
        TbUser userInfo = (TbUser) session.getAttribute("userInfo");
        //根据用户id查询用户借阅记录
        Integer id = userInfo.getId();
        //预约成功
        List<TbOrderItems> tbOrderItems = loan_userInfoList.selectOrderById(id);
        long l = System.currentTimeMillis() / 1000;

        //借阅中
        List<TbRecordQueryVo> recordRunList = loan_userInfoList.selectRecordRun(id);

        //逾期,未归还
        List<TbRecordQueryVo> recordOverdueList = loan_userInfoList.selectRecordOverdue(id);
        //挂失
        List<TbRecordQueryVo> recordGuashi = loan_userInfoList.selectRecordGuashi(id);

        //已归还
        List<TbRecordQueryVo> recordReturnList = loan_userInfoList.selectRecordReturn(id);

        for (TbRecordQueryVo vo : recordOverdueList) {
            Date nowDate = new Date();
            Long time = vo.getBackdate() * 1000L;
            Date date = new Date(time);
            int days = differentDays(nowDate, date);
            if (days < 0) {
                vo.setTicketffee(0.1f * days);
                recordMapper.updateByPrimaryKey(vo);
            }
        }

        model.addAttribute("recordGuashi", recordGuashi);
        model.addAttribute("tbOrderItems", tbOrderItems);
        model.addAttribute("recordRunList", recordRunList);
        model.addAttribute("recordOverdueList", recordOverdueList);
        model.addAttribute("recordReturnList", recordReturnList);
        TbUser userInfo = (TbUser) session.getAttribute("userInfo");
        //根据用户id查询用户借阅记录
        Integer id = userInfo.getId();
        //预约成功
        List<TbOrderItems> tbOrderItems = loan_userInfoList.selectOrderById(id);
        long l = System.currentTimeMillis() / 1000;

        //借阅中
        List<TbRecordQueryVo> recordRunList = loan_userInfoList.selectRecordRun(id);

        //逾期,未归还
        List<TbRecordQueryVo> recordOverdueList = loan_userInfoList.selectRecordOverdue(id);
        //挂失
        List<TbRecordQueryVo> recordGuashi = loan_userInfoList.selectRecordGuashi(id);

        //已归还
        List<TbRecordQueryVo> recordReturnList = loan_userInfoList.selectRecordReturn(id);

        for (TbRecordQueryVo vo : recordOverdueList) {
            Date nowDate = new Date();
            Long time = vo.getBackdate() * 1000L;
            Date date = new Date(time);
            int days = differentDays(nowDate, date);
            if (days < 0) {
                vo.setTicketffee(0.1f * days);
                recordMapper.updateByPrimaryKey(vo);
            }
        }

        model.addAttribute("recordGuashi", recordGuashi);
        model.addAttribute("tbOrderItems", tbOrderItems);
        model.addAttribute("recordRunList", recordRunList);
        model.addAttribute("recordOverdueList", recordOverdueList);
        model.addAttribute("recordReturnList", recordReturnList);
        model.addAttribute("l", l);
        return "user/user_MyloanList";
    }

    /**
     * date2比date1多的天数
            categoryExample.createCriteria().andParentIdEqualTo(category.getId());
            // 进行 查询
            List<TbCategory> categoryList = categoryMapper.selectByExample(categoryExample); // 子类目
            // 遍历 删除子类目
            for (TbCategory tbCategory : categoryList) {
                delBookCategoryById(tbCategory.getId());
            }
        }

        // 获取 该 类目 下的 所有图书
        TbLibraryExample libraryExample = new TbLibraryExample();
        // 添加 条件
        libraryExample.createCriteria().andCateIdEqualTo(id);

        // 该类目下 所有的 图书
        List<TbLibrary> libraryList = libraryMapper.selectByExample(libraryExample);

        // 遍历图书列表 ,删除 关联信息
        for (TbLibrary library : libraryList) {
            // 获取 图书 id
            int libId = library.getId();

            // 删除 order 表中图书关联数据
            TbOrderExample orderExample = new TbOrderExample();
            orderExample.createCriteria().andBookIdEqualTo(libId);
            orderMapper.deleteByExample(orderExample);

            // 删除 record 表中图书关联数据
            TbRecordExample recordExample = new TbRecordExample();
            recordExample.createCriteria().andBookIdEqualTo(libId);
            recordMapper.deleteByExample(recordExample);

            // 通过 图书 id 查询 comment 中的 数据
            TbCommentExample commentExample = new TbCommentExample();
            commentExample.createCriteria().andBookIdEqualTo(libId);
            // 获取 图书 回复表信息
            List<TbComment> comments = commentMapper.selectByExample(commentExample);

            // 遍历图书 回复表信息
            for (TbComment comment : comments) {

/**
 * @description: 图书服务实现类
 *
 */

@Service
public class LibraryServiceImpl implements LibraryService {
    // 注入
    @Autowired
    private TbLibraryAndManagerMapper libraryAndManagerMapper;
    @Autowired
    private TbLibraryMapper libraryMapper;
    @Autowired
    private TbCommentMapper commentMapper;
    @Autowired
    private TbOrderMapper orderMapper;
    @Autowired
    private TbRecordMapper recordMapper;
    @Autowired
    private TbReplyMapper replyMapper;

    @Value("${CURRENT_PAGE}")
    private String CURRENT_PAGE;    // 默认 当前页数
    @Value("${PAGE_ROWS}")
    private String PAGE_ROWS;       // 默认 每页显示记录数
    @Value("${FILE_SAVE_PATH}")     // 默认 上传文件保存路径
    private String FILE_SAVE_PATH;

    @Override
    public PageCount<TblibraryExt> findLibraryByAll(TbLibraryQuery tbLibraryQuery, PageCount pageCount) {
        // 判断 分页数据的 有效性
     * 通过 图书 id 查询 图书详细信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/bookId")
    public String toBookInfo(int id, Model model) {
        BookExt bookInfo = libraryService.getBookInfoById(id);
        // 将 时间戳 进行转换
        Long dateSS = bookInfo.getLibrary().getCreatedate();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

        String formatDate = simpleDateFormat.format(new Date(dateSS * 1000));

        bookInfo.setFormatDate(formatDate);

        // 通过 图书id 获取 回复信息
        List<CommentExt> commentExts = commentService.findCommentByBookId(id);

        // 将 查询的 图书信息 设置到 域 中
        model.addAttribute("bookInfo", bookInfo);
        // 将 回复信息 设置到 域 汇总
        model.addAttribute("commentExts", commentExts);

        return "/user/bookDetail";
    }

    /**
     * 用于 借阅 图书  操作
     *
     * @param session 用于 取 用户信息
     * @param order   用户借阅关联信息
     * @return
     */
    @RequestMapping("/jieyue_book")
    public String jieyueBook(HttpSession session, Model model, String oid, String kkid, TbOrder order) {

        if (null != kkid) {
            TbRecord tbRecord = recordMapper.selectByPrimaryKey(Integer.valueOf(kkid));
            tbRecord.setReturnbook(2); //2代表挂失

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

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值