基于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+mysql的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 +等等。

        //实例化包装类(包装类中在原有类的基础上添加的column(列名称)和keyword(搜索关键字)两个字段)
        tbOrderL.setColumn(searchSelect);
        tbOrderL.setKeyWord(searchKeyWord);
        //将查询结果保存到list集合并通过model将对象集合放入request域中
        //查询数据和分页,并返回
        pageL pageL = this.loan_management.getLoanOutStanding(tbOrderL);
        List<TbRecordL> outStandingList = (List<TbRecordL>) pageL.getPo();

        model.addAttribute("pageL", pageL);
        model.addAttribute("outStandingList", outStandingList);
        return "admin/loan_outstanding";
    }

    //    归还图书
    @RequestMapping("/loan/returnBook")
    public String returnBook(Model model, String id) throws Exception {
        //将借阅id和状态码存入 扩展类中
        loanStatusL loanStatusL = new loanStatusL();
        loanStatusL.setId(id);
        loanStatusL.setStatus("1");
        //调用更改借阅状态的service方法
        this.loan_management.changLoanStatus(loanStatusL);

        return "redirect:/admin/loan/outStanding.action";
    }

}

/**


/**
 * @description: 列表页面显示
 */

@Controller
@RequestMapping("/admin/ch")
public class PageController {
    // 注入
    @Autowired
    private LibraryService libraryService;
    @Autowired
    private LibraryCategoryService libraryCategoryService;

    /**
     * 查询图书列表
     *
     * @param model
     * @param tbLibraryQuery
     * @param pageCount
     * @return
     */
    @RequestMapping(value = "/loan_bookList", method = RequestMethod.GET)
    public String showBookListPage(Model model, TbLibraryQuery tbLibraryQuery, PageCount pageCount) {
        // 判断数据有效性
        if (tbLibraryQuery != null) {
            tbLibraryQuery.setCateId(0);
        }

        PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(tbLibraryQuery, pageCount);
        model.addAttribute("libraryPageCount", libraryPageCount);

        return "/admin/loan_bookList";
    }

    /**
     * 图书编辑页面跳转
     *
     * @param model
     * @param id
     * @return
        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代表挂失
            recordMapper.updateByPrimaryKey(tbRecord);
            model.addAttribute("successMsg", "图书挂失成功");
            return "errorMsg";
        }

        if (null != oid) {
            TbRecord tbOrder = recordMapper.selectByPrimaryKey(Integer.valueOf(oid));
            // 插入数据
            tbOrder.setBackdate(tbOrder.getBackdate() + 3 * 30 * 24 * 60 * 60);
            recordMapper.updateByPrimaryKey(tbOrder);
            model.addAttribute("successMsg", "续借三个月成功");
            return "errorMsg";
        }
        // 获取 session 中的用户信息
        ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");
        TbUser tbUser = new TbUser();
        tbUser.setId(activeUser.getUserid());
@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";
        }
        //判断两次输入的密码是否正确
        if (!newPassword.equals(newPassword2)) {
            msg = "两次新密码不一致";
            url = "/user/user_resetPassword.action";
            model.addAttribute("msg", msg);
            model.addAttribute("url", url);
            return "user/error";
        }
        //如果都正确,传入旧密码和新密码到service层进行校验
        TbUserRestInfoL tbUserRestInfoL = new TbUserRestInfoL();
        tbUserRestInfoL.setPassword(oldPassword);
        tbUserRestInfoL.setNewPassword(newPassword);
        tbUserRestInfoL.setId(id);

        int result = this.user_userSystem.updateUserPassword(tbUserRestInfoL);
        //返回值0 表示通过传入的id为找到用户
        if (0 == result) {
            msg = "未找到该用户!";
            url = "/user/user_resetPassword.action";
            model.addAttribute("msg", msg);
            model.addAttribute("url", url);
            return "user/error";
        }

        //返回值2 用户输入的旧密码和数据库中的密码不匹配
        if (2 == result) {
                //判断用户身份在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 {

    }

    //执行handler之后执行此方法
    //作系统 统一异常处理,进行方法执行性能监控,在preHandle中设置一个时间点,在afterCompletion设置一个时间,两个时间点的差就是执行时长
    //实现 系统 统一日志记录
        category.setIsParent(false);

        // 获取 添加 类目的 父类目
        int parentId = category.getParentId();
        if (parentId != 0) {
            // 创建 父类目 对象
            TbCategory parentCategory = new TbCategory();
            parentCategory.setId(parentId);
            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);
        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();
            // 封装数据
            categoryExt.setTbCategory(tbCategory);
            //if (tbCategory.getParentId() != null) {
            if (tbCategory.getParentId() != 0) {
                // 获取类目 父id 的 类目信息
                TbCategory parentCategory = categoryMapper.selectByPrimaryKey(tbCategory.getParentId());
                // 将信息 设置到 扩展 pojo
                categoryExt.setParentName(parentCategory.getCatname());
                //}
            } else {
                categoryExt.setParentName(NOT_PAREN_CATEGORY_INFO);
            }

            // 添加到集合中
            categoryExts.add(categoryExt);
        }

        // 将 集合 设置到 pageCount
        pageCount.setContentList(categoryExts);

        return pageCount;
    }

    @Override
    public void addBookCategory(TbCategory category, HttpSession session) {
/*
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;
    }
}

            }
        }

        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多的天数
     *
     * @param date1
     * @param date2
     * @return
     */
    public static int differentDays(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);

        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);
        int day1 = cal1.get(Calendar.DAY_OF_YEAR);
        int day2 = cal2.get(Calendar.DAY_OF_YEAR);

        int year1 = cal1.get(Calendar.YEAR);
        int year2 = cal2.get(Calendar.YEAR);
        if (year1 != year2)   //同一年
        {
            int timeDistance = 0;
            for (int i = year1; i < year2; i++) {
                if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)    //闰年
                {
                    timeDistance += 366;
                } else    //不是闰年
                {
        if (currentPage != null) {
            tbOrderL.setCurrentPage(currentPage);
        }
        //实例化包装类(包装类中在原有类的基础上添加的column(列名称)和keyword(搜索关键字)两个字段)
        tbOrderL.setColumn(searchSelect);
        tbOrderL.setKeyWord(searchKeyWord);
        //将查询结果保存到list集合并通过model将对象集合放入request域中
        //查询数据和分页,并返回
        pageL pageL = this.loan_management.getLoanOutStanding(tbOrderL);
        List<TbRecordL> outStandingList = (List<TbRecordL>) pageL.getPo();

        model.addAttribute("pageL", pageL);
        model.addAttribute("outStandingList", outStandingList);
        return "admin/loan_outstanding";
    }

    //    归还图书
    @RequestMapping("/loan/returnBook")
    public String returnBook(Model model, String id) throws Exception {
        //将借阅id和状态码存入 扩展类中
        loanStatusL loanStatusL = new loanStatusL();
        loanStatusL.setId(id);
        loanStatusL.setStatus("1");
        //调用更改借阅状态的service方法
        this.loan_management.changLoanStatus(loanStatusL);

        return "redirect:/admin/loan/outStanding.action";
    }

}

        if (i > 0) {
            return "redirect:loan_userList.action";
        }
        //进行数据回显
        model.addAttribute("tbUser", tbUser);
        return "admin/loan_editUser";
    }

    //用户删除
    @RequestMapping("/loan_deleteUser")
    public String loan_deleteUser(Integer id) {
        int i = loan_userInfoList.deleteUser(id);
        if (i > 0) {
            return "redirect:loan_userList.action";
        }
        return "redirect:loan_userList.action";
    }

    //用户添加
    @RequestMapping("/loan_addUser")
    public String addUser(TbUser tbUser) {
        //注册时间
        tbUser.setRegisterdate(System.currentTimeMillis());
        //not online
        tbUser.setIsonline(0);
        tbUser.setPassword(tbUser.getUsername());
        int i = loan_userInfoList.addUser(tbUser);
        if (i > 0) {
            System.out.println("添加成功!");
            return "redirect:loan_userList.action";
        }

        return "redirect:loan_userList.action";
    }

    //用户列表模糊查询用户信息(用户名)
    @RequestMapping("/loan_selectLikeName")
    public String Loan_selectLikeName(TbUser tbUser, Model model) {
        Integer online = null;
        TbUserQueryVo tbUserQueryVo = new TbUserQueryVo();
        tbUserQueryVo.setTbUser(tbUser);
        tbUserQueryVo.setOnline(online);
        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代表挂失
            recordMapper.updateByPrimaryKey(tbRecord);
            model.addAttribute("successMsg", "图书挂失成功");
            return "errorMsg";
        }

        if (null != oid) {
            TbRecord tbOrder = recordMapper.selectByPrimaryKey(Integer.valueOf(oid));
            // 插入数据
            tbOrder.setBackdate(tbOrder.getBackdate() + 3 * 30 * 24 * 60 * 60);
            recordMapper.updateByPrimaryKey(tbOrder);
            model.addAttribute("successMsg", "续借三个月成功");
            return "errorMsg";

@Controller
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);
        // 获取当前类目的 父类目
        if (category.getParentId() != null) {
            parentId = category.getParentId();
        }
        // 获取 父类目下所有的 子类目信息
        TbCategoryExample categoryExample = new TbCategoryExample();
        categoryExample.createCriteria().andParentIdEqualTo(parentId);

        return categoryMapper.selectByExample(categoryExample);
    }
}

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

@Service
public class LibraryServiceImpl implements LibraryService {
        //        从配置文件中取出公共访问地址
        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 {

    }

    //执行handler之后执行此方法
    //作系统 统一异常处理,进行方法执行性能监控,在preHandle中设置一个时间点,在afterCompletion设置一个时间,两个时间点的差就是执行时长
    //实现 系统 统一日志记录
    @Override
    @RequestMapping("/user_bookList")
    public String toLibraryListByCid(TbLibraryQuery libraryQuery, PageCount pageCount, Model model, HttpSession session) {
        if (libraryQuery == null || libraryQuery.getCateId() == null) {
            libraryQuery = new TbLibraryQuery();
            libraryQuery.setCateId((Integer) session.getAttribute("currentCategory"));
        }
        // 根据 类目 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);

        // 通过 图书id 获取 回复信息

            libraryMapper.insert(library);
        }
        return fileSavePath;
    }

    @Override
    public void delBookById(int id) {
        // 删除 订单表
        TbOrderExample orderExample = new TbOrderExample();
        orderExample.createCriteria().andBookIdEqualTo(id);
        orderMapper.deleteByExample(orderExample);

        // 删除 预约表
        TbRecordExample recordExample = new TbRecordExample();
        recordExample.createCriteria().andBookIdEqualTo(id);
        recordMapper.deleteByExample(recordExample);

        // 查询 评论表,图书表关联评论表
        TbCommentExample commentExample = new TbCommentExample();
        commentExample.createCriteria().andBookIdEqualTo(id);
        // 获取 评论集合
        List<TbComment> commentList = commentMapper.selectByExample(commentExample);
        // 遍历
        for (TbComment tbComment : commentList) {
            TbReplyExample replyExample = new TbReplyExample();
            replyExample.createCriteria().andCommentIdEqualTo(tbComment.getId());
            // 删除 评论数据关联 的 reply 表数据
            replyMapper.deleteByExample(replyExample);
        }
        // 删除 评论数据
        commentMapper.deleteByExample(commentExample);

        // 删除图书
        libraryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public BookExt getBookInfoById(int id) {
        TbLibrary library = libraryMapper.selectByPrimaryKey(id);

        // 判断图书的有效性

/**

 * @description: 图书类别处理
 */
@Controller
@RequestMapping("/admin/ch/category")
public class CategoryController {
    //注入
    @Autowired
    private LibraryCategoryService libraryCategoryService;

    /**
     * 添加 图书类目
     *
     * @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";
    }

    /**
     * 删除类目信息
        //如果传入的有页面
        if (currentPage != null) {
            tbOrderL.setCurrentPage(currentPage);
        }
        //实例化包装类(包装类中在原有类的基础上添加的column(列名称)和keyword(搜索关键字)两个字段)
        tbOrderL.setColumn(searchSelect);
        tbOrderL.setKeyWord(searchKeyWord);
        pageL pageL = new pageL();
        pageL = this.loan_management.getBespeakRecord(tbOrderL);
        List<TbOrderL> BespeakList = (List<TbOrderL>) pageL.getPo();
        model.addAttribute("pageL", pageL);
        model.addAttribute("BespeakList", BespeakList);
        return "admin/loan_bespeak";
    }

    //    领取操作
    @RequestMapping("/loan/getBespeak")
    public String getBespeak(Model model, Integer id, Integer bookid, Integer userid) throws Exception {
        //通过bookid和userid 借阅表插入借阅记录
        TbRecord tbRecord = new TbRecord();
        tbRecord.setBookId(bookid);
        tbRecord.setUserId(userid);
        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";
    }
}

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值