Javaプロジェクト:ブック管理システム(java + SpringBoot + jpa + html + swagger + maven + mysql)

ソースコードを入手する:ブログのホームページの「リソース」からダウンロードしてください。

プロジェクト紹介

プロジェクトはシンプルでエレガントなインターフェースとシンプルな機能を備えています。Java初心者やコースデザインに適した3つのテーブルしかありません。
主な機能は次のとおりです。
ホームページカルーセルマップ
本の管理:本のリスト、本の棚、
ローンの管理:本の検索、本を借りる、本を返す;
読者の管理:読者リスト、読者の追加;

ユーザーセンター:個人情報、ユーザー管理、管理者の追加。

環境ニーズ

1.動作環境:できればjava jdk 1.8、このプラットフォームで実行しています。他のバージョンも理論的には可能です。
2. IDE環境:IDEA、Eclipse、Myeclipseを使用できます。IDEAをお勧めします;
3。Tomcat環境:Tomcat 7.x、8.x、9.xバージョンが利用可能です
4.ハードウェア環境:1G以上のメモリを搭載したWindows7/8/10;またはMacOS;
5. Mavenプロジェクト:はい;pom.xmlがソースコードディレクトリに含まれているかどうかを確認します。含まれている場合はmavenプロジェクトであり、含まれていない場合は非mavenプロジェクトです。

6.データベース:MySqlバージョン5.7;

テクノロジースタック

1.バックエンド:springboot + jpa + mybatis + springsecurity + swagger +

2.フロントエンド:html + javaex

使用説明書

1. Navicatまたは他のツールを使用して、mysqlに対応する名前のデータベースを作成し、プロジェクトのsqlファイルをインポートします。2。book
-managerを開発ツール(idea / eclipse)にインポートできます
-アイデア:ソースを開きますfile directフォルダー、pomファイルが配置されているディレクトリを覚えておいてください
-eclipse:direct import-既存のインポートmavenプロジェクトを選択します
-mavenが正しく構成されているかどうかを確認します。Alibabaクラウドアクセラレーションを使用することをお勧めします。したがって、待機時間は比較的短くなります
3 。プロジェクトにapplication.yml構成ファイルを設定します。データベース構成を独自の構成に変更します
。4。プロジェクトを実行し、localhost:8080と入力してログイン
します。5。管理者ユーザー名:adminパスワード:123

 

 

 

 

 

 

書籍カテゴリ処理制御レイヤー:

/**

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

    /**
     * 添加 图书类目
     *
     * @param category 图书类目信息
     * @param session  添加人
     * @return url
     * @author hiseico
     */
    @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";
    }

    /**
     * 修改 类目关系
     *
     * @param category
     * @return
     */
    @RequestMapping(value = "/updateCategory", method = RequestMethod.POST)
    public String updateCategory(TbCategory category) {

        return "redirect:/admin/ch/loan_BookClassify.action";
    }

    @RequestMapping("/toUpdatePage")
    @ResponseBody
    public TbCategory toUpdatePage(int id) {
        return libraryCategoryService.getCategoryById(id);
    }
}

ブック操作制御レイヤー: 

/**
 * @description: 图书操作
 */
@Controller
@RequestMapping("/admin/ch")
public class LibraryController {
    //注入
    @Autowired
    private LibraryService libraryService;



    /**
     * 修改图书信息
     *
     * @param uploadFile 上传图片
     * @param library    图书信息
     * @return
     */
    @RequestMapping(value = "/updateBook", method = RequestMethod.POST)
    public String updateBook(MultipartFile uploadFile, TbLibrary library, HttpServletRequest request) {
        try {
            libraryService.updateOrSaveLibrary(uploadFile, library,request);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "redirect:/admin/ch/loan_bookList.action";
    }

    /**
     * 添加图书
     *
     * @param uploadFile 上传图片
     * @param library    图书信息
     * @return
     */
    @RequestMapping(value = "/addBook", method = RequestMethod.POST)
    public String addBook(MultipartFile uploadFile, TbLibrary library, HttpSession session,HttpServletRequest request) {
        ActiveAdmin activeAdmin = (ActiveAdmin) session.getAttribute("activeAdmin");
        library.setManagerId(activeAdmin.getUserid());
        try {
            libraryService.updateOrSaveLibrary(uploadFile, library,request);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "redirect:/admin/ch/loan_bookList.action";
    }

    /**
     * 根据 图书id  删除 图书
     *
     * @param id 图书id
     * @return
     */
    @RequestMapping("/delBookById")
    public String delBook(int id) {
        libraryService.delBookById(id);
        return "redirect:/admin/ch/loan_bookList.action";
    }

}

フロントページリストの表示処理:

/**
 * @description: 前台页面列表显示处理
 */

@Controller
@RequestMapping("/user/ch")
public class UserBookController {
    // 注入
    @Autowired
    private LibraryService libraryService;
    @Autowired
    private LibraryCategoryService libraryCategoryService;
    @Autowired
    private CommentService commentService;

    @Autowired
    private TbOrderMapper orderMapper;
    @Autowired
    private TbRecordMapper recordMapper;

    @Value("${LOGIN_USER}")
    private String LOGIN_USER;  // 当前登录用户的 session 存储 属性名

    @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 获取 回复信息
        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());
        order.setUserId(tbUser.getId());

        // 插入数据
        libraryService.jieyueBookById(order);

        return "redirect:/user/ch/bookId.action?id=" + order.getBookId();
    }


    @RequestMapping("/commitInfo")
    @ResponseBody
    public String commitComment(HttpSession session, TbComment comment) {
        // 获取 session 中的用户信息
        ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");
        TbUser tbUser = new TbUser();
        tbUser.setId(activeUser.getUserid());

        comment.setUserId(tbUser.getId());
        libraryService.addCommentInfo(comment);

        return "ok";
    }
}

ソースコードを入手する:ブログのホームページの「リソース」からダウンロードしてください。 

おすすめ

転載: blog.csdn.net/yuyecsdn/article/details/124364472