/*
 Navicat Premium Dump SQL

 Source Server         : root@localhost
 Source Server Type    : MySQL
 Source Server Version : 80045 (8.0.45)
 Source Host           : 127.0.0.1:3306
 Source Schema         : bookmgr

 Target Server Type    : MySQL
 Target Server Version : 80045 (8.0.45)
 File Encoding         : 65001

 Date: 20/05/2026 16:35:53
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for book
-- ----------------------------
DROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `author` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stock` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of book
-- ----------------------------
BEGIN;
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (1, '深入理解Java虚拟机', '周志明', 5);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (2, 'Spring实战 (第6版)', 'Craig Walls', 3);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (3, '高性能MySQL (第4版)', 'Baron Schwartz', 2);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (4, '数据结构与算法分析', 'Mark Allen Weiss', 4);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (5, 'Redis设计与实现', '黄健宏', 3);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (6, 'Effective Java (第3版)', 'Joshua Bloch', 2);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (7, 'Head First设计模式', 'Eric Freeman', 6);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (8, '算法导论 (第4版)', 'CLRS', 2);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (9, '企业应用架构模式', 'Martin Fowler', 1);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (10, '重构：改善既有代码的设计 (第2版)', 'Martin Fowler', 3);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (11, 'Kotlin实战', 'Dmitry Jemerov', 4);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (12, '微服务架构设计模式', 'Chris Richardson', 2);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (13, '计算机网络：自顶向下方法 (第8版)', 'James Kurose', 3);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (14, '数据库系统概念 (第7版)', 'Abraham Silberschatz', 2);
INSERT INTO `book` (`id`, `name`, `author`, `stock`) VALUES (15, 'Clean Code clean architecture', 'Robert C. Martin', 5);
COMMIT;

-- ----------------------------
-- Table structure for borrow_record
-- ----------------------------
DROP TABLE IF EXISTS `borrow_record`;
CREATE TABLE `borrow_record` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint DEFAULT NULL,
  `book_id` bigint DEFAULT NULL,
  `borrow_time` datetime DEFAULT NULL,
  `return_time` datetime DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of borrow_record
-- ----------------------------
BEGIN;
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (1, 20, 1, '2026-05-01 09:00:00', '2026-05-10 14:30:00', 'RETURNED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (2, 20, 5, '2026-04-20 10:00:00', '2026-05-01 11:00:00', 'RETURNED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (3, 21, 2, '2026-05-05 08:30:00', '2026-05-15 16:00:00', 'RETURNED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (4, 21, 7, '2026-04-25 13:00:00', '2026-05-06 09:00:00', 'RETURNED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (5, 20, 10, '2026-04-15 14:00:00', '2026-04-28 10:00:00', 'RETURNED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (6, 20, 3, '2026-05-12 09:00:00', NULL, 'BORROWED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (7, 20, 8, '2026-05-14 10:00:00', NULL, 'BORROWED');
INSERT INTO `borrow_record` (`id`, `user_id`, `book_id`, `borrow_time`, `return_time`, `status`) VALUES (8, 21, 4, '2026-05-16 11:00:00', NULL, 'BORROWED');
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'USER',
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` (`id`, `username`, `password`, `role`) VALUES (19, 'admin', '$argon2id$v=19$m=16384,t=2,p=1$D+jUHsOZ8AFqxbqDUa+PYA$QjovmIfJuhn4EV2iGV2BX9Jtz61vwGoJGa1XxnYPGqM', 'admin');
INSERT INTO `user` (`id`, `username`, `password`, `role`) VALUES (20, 'user01', '$argon2id$v=19$m=16384,t=2,p=1$ijX5dLM4DGTj3h5y/RLjig$xuruWKz05H19D1xUbiZTC7ScgFbd9j9/VzjQ0hcYoik', 'user');
INSERT INTO `user` (`id`, `username`, `password`, `role`) VALUES (21, 'user02', '$argon2id$v=19$m=16384,t=2,p=1$lu7jTNKaHpOY5PS5XboXgw$e+pyCrLoMJq4sQJLKQ6nzjloPrcuSmIjoeCuc+ze+mU', 'user');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
