Compare commits
12 Commits
0fef82c9f2
...
2befbac54a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2befbac54a | |||
| 9a64513ec2 | |||
| 999c399dd8 | |||
| ec9a40be88 | |||
| 1b2753c9a3 | |||
| bbf03e2254 | |||
| a94ab466d2 | |||
| 13d18bd3ab | |||
| b4d3bd36f8 | |||
| 8696bbaf5a | |||
| 3485614a84 | |||
| 4cba5029c6 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,6 +25,7 @@ Thumbs.db
|
||||
/.mvn/
|
||||
/**/target/
|
||||
!src/**/target/keepme.txt # 可选:防止误删有用文件夹
|
||||
pom.xml.versionsBackup
|
||||
|
||||
# Maven Wrapper
|
||||
mvnw
|
||||
|
||||
6
db/data_role.sql
Normal file
6
db/data_role.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- 初始角色数据
|
||||
INSERT INTO roles (id, code, name)
|
||||
VALUES (1, 'ADMIN', '系统管理员'),
|
||||
(2, 'LEADER', '团队负责人'),
|
||||
(3, 'DEVICE_ADMIN', '设备管理员'),
|
||||
(4, 'USER', '用户');
|
||||
9
db/data_teams.sql
Normal file
9
db/data_teams.sql
Normal file
@ -0,0 +1,9 @@
|
||||
INSERT INTO teams (id, name) VALUES (1, '绝缘(电缆)');
|
||||
INSERT INTO teams (id, name) VALUES (2, '绝缘(电容器)');
|
||||
INSERT INTO teams (id, name) VALUES (3, '磁性(超薄硅钢)');
|
||||
INSERT INTO teams (id, name) VALUES (4, '磁性(高磁感硅钢)');
|
||||
INSERT INTO teams (id, name) VALUES (5, '导体');
|
||||
INSERT INTO teams (id, name) VALUES (6, '防护(降噪)');
|
||||
INSERT INTO teams (id, name) VALUES (7, '防护(腐蚀)');
|
||||
INSERT INTO teams (id, name) VALUES (8, '交叉(实验室)');
|
||||
INSERT INTO teams (id, name) VALUES (9, '交叉(环氧)');
|
||||
610
db/data_users.sql
Normal file
610
db/data_users.sql
Normal file
@ -0,0 +1,610 @@
|
||||
START TRANSACTION;
|
||||
-- 用户数据与角色关联
|
||||
|
||||
-- 管理员
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('admin', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '总管理员', '', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 1);
|
||||
|
||||
-- 用户: 李文鹏
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liwenpeng', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '李文鹏', '15300341553', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 史晓宁
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('shixiaoning', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '史晓宁', '18611951666', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 赵维佳
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhaoweijia', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '赵维佳', '13693020532', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 李石琨
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('lishikun', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '李石琨', '13020095677', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘英健
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liuyingjian', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘英健', '18810085301', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 周洋
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhouyang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '周洋', '15910777276', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 毕舒馨
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('bishuxin', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '毕舒馨', '17888803487', 1);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 邢照亮
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('xingzhaoliang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '邢照亮', '15811444029', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 郭少玮
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('guoshaowei', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '郭少玮', '18810702981', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 苏尧天
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('suyaotian', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '苏尧天', '15369275910', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘炬阳
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liujuyang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘炬阳', '17602637613', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 王博
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('wangbo', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '王博', '13621001394', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 杨博
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('yangbo', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '杨博', '15510260661', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张兆天
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangzhaotian', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张兆天', '19912458230', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘天兴
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liutianxing', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘天兴', '13466589533', 2);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 杨富尧
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('yangfuyao', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '杨富尧', '18612978836', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 高洁
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('gaojie', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '高洁', '18500972707', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 刘洋
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liuyang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘洋', '18612694337', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 王聪
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('wangcong', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '王聪', '13264467237', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 孙浩
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('sunhao', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '孙浩', '15101136606', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘成宇
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liuchengyu', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘成宇', '13840525697', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 李伟
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liwei', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '李伟', '18660898500', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 尚以磊
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('shangyilei', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '尚以磊', '15998820462', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 时宇新
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('shiyuxin', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '时宇新', '15321306918', 3);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 马光
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('maguang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '马光', '13811679926', 4);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 何承绪
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('hechengxu', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '何承绪', '18813056867', 4);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 田丛宽
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('tiancongkuan', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '田丛宽', '18810561393', 4);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 邓凯伟
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('dengkaiwei', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '邓凯伟', '13613213772', 4);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 丁一
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('dingyi', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '丁一', '13693265696', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 陈保安
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('chenbaoan', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '陈保安', '15001236907', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘倓
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liutan', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘倓', '15201243807', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 庞震
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('pangzhen', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '庞震', '17810288985', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 高健峰
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('gaojianfeng', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '高健峰', '18801251185', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 赵兴雨
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhaoxingyu', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '赵兴雨', '18611572588', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张丛睿
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangcongrui', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张丛睿', '18613838958', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 李梦琳
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('limenglin1', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '李梦琳', '18811505739', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张捷欣
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangjiexin', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张捷欣', '15071109936', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘文杰
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liuwenjie', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘文杰', '18810393772', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 陈瑞
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('chenrui1', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '陈瑞', '18801183169', 5);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 聂京凯
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('niejingkai1', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '聂京凯', '13811205510', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 何强
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('heqiang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '何强', '15810868821', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张一铭
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangyiming', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张一铭', '18519696605', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 田一
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('tianyi', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '田一', '18501949381', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 樊超
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('fanchao', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '樊超', '13681563658', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘晓圣
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liuxiaosheng', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘晓圣', '18811345505', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 侯东
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('houdong', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '侯东', '15101052027', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 姬军
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('jijun', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '姬军', '15201457665', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 刘浩
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('liuhao', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '刘浩', '17716537109', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 尹航
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('yinhang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '尹航', '18500738660', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张世乘
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangshicheng', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张世乘', '13231339242', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 田辰
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('tianchen', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '田辰', '13844645059', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张陈博凡
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangchen', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张陈博凡', '13284227163', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 何兴
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('hexing', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '何兴', '17717154888', 6);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张强
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangqiang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张强', '13601210056', 7);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 王晓芳
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('wangxiaofang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '王晓芳', '13811432198', 7);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 陈云
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('chenyun', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '陈云', '13651214286', 7);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 杨丙坤
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('yangbingkun', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '杨丙坤', '15711469923', 7);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 卢壹梁
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('luyiliang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '卢壹梁', '15270852029', 7);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 赵广耀
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhaoguangyao', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '赵广耀', '15210674244', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 潘学东
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('panxuedong', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '潘学东', '13426432632', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 姚佳康
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('yaojiakang', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '姚佳康', '15226501286', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 郭玉龙
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('guoyulong', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '郭玉龙', '13146654667', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 赵蕊
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhaorui1', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '赵蕊', '13621012074', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 肖永明
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('xiaoyongming', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '肖永明', '15901504096', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 杨立新
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('yanglixin', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '杨立新', '13488882505', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 程娜
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('chengna', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '程娜', '15201461257', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 赵哲惠
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhaozhehui', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '赵哲惠', '18101123770', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 张思行
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhangsixing', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '张思行', '15521305044', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 李震
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('lzh', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '李震', '18612978848', 8);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 崔惠泽
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('cuihuize', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '崔惠泽', '13669234892', 9);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 2);
|
||||
|
||||
|
||||
-- 用户: 陈铄
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('chenshuo', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '陈铄', '18222779112', 9);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 3);
|
||||
|
||||
|
||||
-- 用户: 郭瑞鲁
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('guoruilu', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '郭瑞鲁', '18810663757', 9);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 罗楚濛
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('luochumeng', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '罗楚濛', '18810793857', 9);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 赵超锋
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('zhaochaofeng', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '赵超锋', '18810078180', 9);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
|
||||
-- 用户: 顾雯雯
|
||||
INSERT INTO users (username, password, name, phone, team_id)
|
||||
VALUES ('guwenwen', '$2a$10$U64Wy8Yz4BlrtmrZG8xXSu9r/NUuoGv2ZVqu.A.gUqNolxZgDHGtq', '顾雯雯', '13141308181', 9);
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id)
|
||||
VALUES (LAST_INSERT_ID(), 4);
|
||||
|
||||
COMMIT;
|
||||
@ -82,10 +82,3 @@ CREATE TABLE approvals
|
||||
decision TINYINT NOT NULL,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- 初始角色数据
|
||||
INSERT INTO roles (code, name)
|
||||
VALUES ('ADMIN', '系统管理员'),
|
||||
('LEADER', '团队负责人'),
|
||||
('DEVICE_ADMIN', '设备管理员'),
|
||||
('USER', '普通用户');
|
||||
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>github.benjamin</groupId>
|
||||
<artifactId>equip-reserve-backend</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<name>equip-reserve-backend</name>
|
||||
<description>equip-reserve-backend</description>
|
||||
<url/>
|
||||
|
||||
@ -5,7 +5,7 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum ReservationStatus {
|
||||
PENDING_LEADER("团队负责人审批中"),
|
||||
PENDING_DEVICE_ADMIN("设备负责人审批中"),
|
||||
PENDING_DEVICE_ADMIN("设备管理员审批中"),
|
||||
APPROVED("通过"),
|
||||
APPROVED_ASSIST("通过,需要协助实验"),
|
||||
REJECTED("不通过");
|
||||
|
||||
@ -6,11 +6,7 @@ import github.benjamin.equipreservebackend.entity.Device;
|
||||
import github.benjamin.equipreservebackend.response.ResponseResult;
|
||||
import github.benjamin.equipreservebackend.service.DeviceService;
|
||||
import github.benjamin.equipreservebackend.service.ReservationService;
|
||||
import github.benjamin.equipreservebackend.vo.DeviceAdminVO;
|
||||
import github.benjamin.equipreservebackend.vo.DeviceStatsVO;
|
||||
import github.benjamin.equipreservebackend.vo.DeviceUserVO;
|
||||
import github.benjamin.equipreservebackend.vo.TimeRangeVO;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import github.benjamin.equipreservebackend.vo.*;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@ -34,7 +30,7 @@ public class DeviceController {
|
||||
|
||||
private final ReservationService reservationService;
|
||||
|
||||
@PreAuthorize("hasRole('USER')")
|
||||
@PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
|
||||
@GetMapping
|
||||
public ResponseResult<Page<DeviceUserVO>> getUserDevices(@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@ -44,7 +40,7 @@ public class DeviceController {
|
||||
return ResponseResult.success(res);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('USER')")
|
||||
@PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
|
||||
@GetMapping("/unavailable-times/{id}")
|
||||
public ResponseResult<List<TimeRangeVO>> getUnavailableTimes(@PathVariable Long id) {
|
||||
List<TimeRangeVO> res = reservationService.getUnavailableTimes(id);
|
||||
@ -54,7 +50,7 @@ public class DeviceController {
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
@PostMapping("/{userId}")
|
||||
public ResponseResult<DeviceAdminVO> addDevice(@PathVariable("userId") Long userId,
|
||||
@RequestBody Device device) {
|
||||
@RequestBody Device device) {
|
||||
deviceService.addDevice(userId, device);
|
||||
return ResponseResult.success(new DeviceAdminVO(device));
|
||||
}
|
||||
@ -69,7 +65,7 @@ public class DeviceController {
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
@PutMapping("/{id}")
|
||||
public ResponseResult<DeviceAdminVO> updateDevice(@PathVariable("id") Long id,
|
||||
@RequestBody Device device) {
|
||||
@RequestBody Device device) {
|
||||
device.setId(id);
|
||||
Device updatedDevice = deviceService.updateDevice(device);
|
||||
return ResponseResult.success(new DeviceAdminVO(updatedDevice));
|
||||
@ -120,4 +116,30 @@ public class DeviceController {
|
||||
.sheet("设备使用统计")
|
||||
.doWrite(data);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@GetMapping("/detail-stats")
|
||||
public ResponseResult<List<DeviceDetailStatsVO>> getDeviceDetailStats(@RequestParam Long deviceId,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate start,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {
|
||||
return ResponseResult.success(reservationService.getDeviceDetailStats(deviceId, start, end));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@GetMapping("/detail-stats/export")
|
||||
public void exportDeviceDetailStats(@RequestParam Long deviceId,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate start,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end,
|
||||
HttpServletResponse response) throws IOException {
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
||||
// 查询数据
|
||||
List<DeviceDetailStatsVO> data = reservationService.getDeviceDetailStats(deviceId, start, end);
|
||||
|
||||
// 使用EasyExcel写入response流
|
||||
EasyExcel.write(response.getOutputStream(), DeviceDetailStatsVO.class)
|
||||
.sheet("设备使用详情")
|
||||
.doWrite(data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,11 +2,9 @@ package github.benjamin.equipreservebackend.controller;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.constant.ReservationStatus;
|
||||
import github.benjamin.equipreservebackend.entity.Reservation;
|
||||
import github.benjamin.equipreservebackend.response.ResponseResult;
|
||||
import github.benjamin.equipreservebackend.service.ReservationService;
|
||||
import github.benjamin.equipreservebackend.vo.DeviceStatsVO;
|
||||
import github.benjamin.equipreservebackend.vo.ReservationStatsVO;
|
||||
import github.benjamin.equipreservebackend.vo.ReservationVO;
|
||||
import github.benjamin.equipreservebackend.vo.UserReservationVO;
|
||||
@ -22,6 +20,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/reservation")
|
||||
@ -30,14 +29,14 @@ public class ReservationController {
|
||||
|
||||
private final ReservationService reservationService;
|
||||
|
||||
@PreAuthorize("hasRole('USER')")
|
||||
@PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
|
||||
@PostMapping
|
||||
public ResponseResult<?> addReservation(@RequestBody Reservation reservation) {
|
||||
reservationService.addReservation(reservation);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('USER')")
|
||||
@PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
|
||||
@GetMapping("/{userId}")
|
||||
public ResponseResult<Page<UserReservationVO>> getUserReservation(@PathVariable("userId") Long userId,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@ -83,4 +82,12 @@ public class ReservationController {
|
||||
.doWrite(data);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
@PostMapping("/endTime/{reservationId}")
|
||||
public ResponseResult<?> updateEndTime(@PathVariable Long reservationId,
|
||||
@RequestBody Map<String, String> body) {
|
||||
LocalDate endTime = LocalDate.parse(body.get("endTime"));
|
||||
reservationService.updateEndTime(reservationId, endTime);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,4 +68,10 @@ public class UserController {
|
||||
userService.deleteById(userId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@GetMapping("/user-team/{teamId}")
|
||||
public ResponseResult<List<String>> getTeamUsers(@PathVariable Long teamId) {
|
||||
return ResponseResult.success(userService.getTeamUsers(teamId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,16 @@ package github.benjamin.equipreservebackend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import github.benjamin.equipreservebackend.entity.User;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Repository
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
@MapKey("teamId")
|
||||
Map<Long, User> selectLeaderByTeamIds(List<Long> teamIds);
|
||||
|
||||
}
|
||||
|
||||
@ -2,10 +2,7 @@ package github.benjamin.equipreservebackend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.entity.Reservation;
|
||||
import github.benjamin.equipreservebackend.vo.ReservationStatsVO;
|
||||
import github.benjamin.equipreservebackend.vo.ReservationVO;
|
||||
import github.benjamin.equipreservebackend.vo.TimeRangeVO;
|
||||
import github.benjamin.equipreservebackend.vo.UserReservationVO;
|
||||
import github.benjamin.equipreservebackend.vo.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
@ -23,4 +20,8 @@ public interface ReservationService {
|
||||
Page<ReservationVO> getReservationVO(Long userId, Integer page, Integer size);
|
||||
|
||||
List<ReservationStatsVO> getReservationStats(LocalDate start, LocalDate end);
|
||||
|
||||
List<DeviceDetailStatsVO> getDeviceDetailStats(Long deviceId, LocalDate start, LocalDate end);
|
||||
|
||||
void updateEndTime(Long reservationId, LocalDate endTime);
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import github.benjamin.equipreservebackend.entity.User;
|
||||
import github.benjamin.equipreservebackend.security.SecurityUser;
|
||||
import github.benjamin.equipreservebackend.vo.UserVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
User login(String username, String password);
|
||||
@ -21,4 +23,6 @@ public interface UserService {
|
||||
void deleteById(Long userId);
|
||||
|
||||
void addUser(UserDTO dto);
|
||||
|
||||
List<String> getTeamUsers(Long teamId);
|
||||
}
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
package github.benjamin.equipreservebackend.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.constant.ReservationStatus;
|
||||
import github.benjamin.equipreservebackend.entity.*;
|
||||
import github.benjamin.equipreservebackend.entity.Device;
|
||||
import github.benjamin.equipreservebackend.entity.Reservation;
|
||||
import github.benjamin.equipreservebackend.entity.Role;
|
||||
import github.benjamin.equipreservebackend.entity.User;
|
||||
import github.benjamin.equipreservebackend.exception.ApiException;
|
||||
import github.benjamin.equipreservebackend.mapper.*;
|
||||
import github.benjamin.equipreservebackend.service.ReservationService;
|
||||
import github.benjamin.equipreservebackend.utils.PageUtil;
|
||||
import github.benjamin.equipreservebackend.vo.ReservationStatsVO;
|
||||
import github.benjamin.equipreservebackend.vo.ReservationVO;
|
||||
import github.benjamin.equipreservebackend.vo.TimeRangeVO;
|
||||
import github.benjamin.equipreservebackend.vo.UserReservationVO;
|
||||
import github.benjamin.equipreservebackend.vo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -86,6 +87,10 @@ public class ReservationServiceImpl implements ReservationService {
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Device::getId, Function.identity()));
|
||||
|
||||
List<Long> teamIds = deviceNameMap.values().stream().map(Device::getTeamId).toList();
|
||||
|
||||
Map<Long, User> teamLeaderMap = userMapper.selectLeaderByTeamIds(teamIds);
|
||||
|
||||
// 获取设备管理员信息
|
||||
List<Long> deviceAdminIDs = reservations.getRecords().stream()
|
||||
.map(Reservation::getDeviceAdminId)
|
||||
@ -93,7 +98,6 @@ public class ReservationServiceImpl implements ReservationService {
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
|
||||
List<UserReservationVO> vos;
|
||||
Map<Long, User> deviceAdminMap = userMapper.selectList(new LambdaQueryWrapper<User>()
|
||||
.in(User::getId, deviceAdminIDs))
|
||||
@ -101,7 +105,7 @@ public class ReservationServiceImpl implements ReservationService {
|
||||
.collect(Collectors.toMap(User::getId, Function.identity()));
|
||||
|
||||
vos = reservations.getRecords().stream()
|
||||
.map(reservation -> new UserReservationVO(reservation, deviceNameMap, deviceAdminMap))
|
||||
.map(reservation -> new UserReservationVO(reservation, deviceNameMap, deviceAdminMap, teamLeaderMap))
|
||||
.toList();
|
||||
res.setRecords(vos);
|
||||
return res;
|
||||
@ -125,6 +129,9 @@ public class ReservationServiceImpl implements ReservationService {
|
||||
List<Device> devices = deviceMapper.selectList(new LambdaQueryWrapper<Device>()
|
||||
.eq(Device::getTeamId, user.getTeamId())
|
||||
.select());
|
||||
if (devices.isEmpty()) {
|
||||
return (Page<ReservationVO>) PageUtil.EMPTY_PAGE;
|
||||
}
|
||||
List<Role> userRole = roleMapper.selectRoleByUserId(userId);
|
||||
ReservationStatus status;
|
||||
if (userRole.stream().anyMatch(r -> r.getCode().equals("LEADER"))) {
|
||||
@ -152,4 +159,21 @@ public class ReservationServiceImpl implements ReservationService {
|
||||
public List<ReservationStatsVO> getReservationStats(LocalDate start, LocalDate end) {
|
||||
return reservationMapper.getReservationStats(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceDetailStatsVO> getDeviceDetailStats(Long deviceId, LocalDate start, LocalDate end) {
|
||||
return reservationMapper.selectList(new LambdaQueryWrapper<Reservation>()
|
||||
.eq(Reservation::getDeviceId, deviceId)
|
||||
.in(Reservation::getStatus, List.of("APPROVED", "APPROVED_ASSIST"))
|
||||
.ge(Reservation::getStartTime, start)
|
||||
.le(Reservation::getEndTime, end)
|
||||
.orderByAsc(Reservation::getApplicantName, Reservation::getStartTime)).stream().map(DeviceDetailStatsVO::new).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEndTime(Long reservationId, LocalDate endTime) {
|
||||
reservationMapper.update(new LambdaUpdateWrapper<Reservation>()
|
||||
.eq(Reservation::getId, reservationId)
|
||||
.set(Reservation::getEndTime, endTime));
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,4 +136,14 @@ public class UserServiceImpl implements UserService {
|
||||
userMapper.insert(user);
|
||||
userRoleMapper.insert(new UserRole(user.getId(), dto.getRoleId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTeamUsers(Long teamId) {
|
||||
return userMapper.selectList(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getTeamId, teamId)
|
||||
.orderByAsc(User::getName))
|
||||
.stream()
|
||||
.map(User::getName)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,13 @@ package github.benjamin.equipreservebackend.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class PageUtil {
|
||||
|
||||
public static final Page<?> EMPTY_PAGE = new Page<>(1, 10, 0)
|
||||
.setRecords(Collections.emptyList());
|
||||
|
||||
public static <T> Page<T> copyPage(Page<?> page) {
|
||||
return new Page<T>(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package github.benjamin.equipreservebackend.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import github.benjamin.equipreservebackend.entity.Reservation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceDetailStatsVO {
|
||||
|
||||
@ExcelProperty("使用人")
|
||||
@ColumnWidth(15)
|
||||
private String applicantName;
|
||||
|
||||
@ExcelProperty("所属团队")
|
||||
@ColumnWidth(15)
|
||||
private String applicantTeam;
|
||||
|
||||
@ExcelProperty("开始日期")
|
||||
@ColumnWidth(15)
|
||||
private LocalDate startDay;
|
||||
|
||||
@ExcelProperty("结束日期")
|
||||
@ColumnWidth(15)
|
||||
private LocalDate endDay;
|
||||
|
||||
public DeviceDetailStatsVO(Reservation r) {
|
||||
this.applicantName = r.getApplicantName();
|
||||
this.applicantTeam = r.getApplicantTeam();
|
||||
this.startDay = r.getStartTime();
|
||||
this.endDay = r.getEndTime();
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,8 @@ import java.time.LocalDate;
|
||||
@Data
|
||||
public class LeaderApprovalVO {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long reservationId;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long approvalId;
|
||||
private String applicantName;
|
||||
|
||||
@ -22,12 +22,13 @@ public class UserReservationVO {
|
||||
private LocalDate startTime;
|
||||
private LocalDate endTime;
|
||||
private String statusLabel;
|
||||
private String deviceLeaderName;
|
||||
private String deviceLeaderContact;
|
||||
private String deviceAdminName;
|
||||
private String deviceAdminContact;
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
|
||||
public UserReservationVO(Reservation r, Map<Long, Device> deviceMap, Map<Long, User> deviceAdminMap) {
|
||||
public UserReservationVO(Reservation r, Map<Long, Device> deviceMap, Map<Long, User> deviceAdminMap, Map<Long, User> teamLeaderMap) {
|
||||
this.reservationId = r.getId().toString();
|
||||
this.deviceName = deviceMap.get(r.getDeviceId()).getName();
|
||||
this.startTime = r.getStartTime();
|
||||
@ -41,6 +42,14 @@ public class UserReservationVO {
|
||||
this.deviceAdminName = "该管理员不存在,请联系设备相关人员";
|
||||
this.deviceAdminContact = "";
|
||||
}
|
||||
User teamLeader = teamLeaderMap.get(deviceMap.get(r.getDeviceId()).getTeamId());
|
||||
if (Objects.nonNull(teamLeader)) {
|
||||
this.deviceLeaderName = teamLeader.getName();
|
||||
this.deviceLeaderContact = teamLeader.getPhone();
|
||||
} else {
|
||||
this.deviceLeaderName = "该负责人不存在,请联系设备相关人员";
|
||||
this.deviceLeaderContact = "";
|
||||
}
|
||||
this.createdTime = r.getCreatedTime();
|
||||
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<mapper namespace="github.benjamin.equipreservebackend.mapper.ApprovalMapper">
|
||||
|
||||
<select id="getApproval" resultType="github.benjamin.equipreservebackend.vo.LeaderApprovalVO">
|
||||
SELECT a.id as approvalId, r.applicant_name, r.applicant_team, r.applicant_contact, d.name as deviceName, r.start_time, r.end_time, a.decision, r.status
|
||||
SELECT r.id as reservation_id, a.id as approval_id, r.applicant_name, r.applicant_team, r.applicant_contact, d.name as deviceName, r.start_time, r.end_time, a.decision, r.status
|
||||
FROM approvals a
|
||||
LEFT JOIN reservations r ON a.reservation_id = r.id
|
||||
LEFT JOIN devices d ON r.device_id = d.id
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
JOIN devices d ON r.device_id = d.id
|
||||
WHERE r.status IN ('APPROVED', 'APPROVED_ASSIST')
|
||||
AND r.start_time >= #{start}
|
||||
AND r.end_time < #{end}
|
||||
AND r.end_time <= #{end}
|
||||
GROUP BY d.id
|
||||
ORDER BY totalUsageDays DESC
|
||||
</select>
|
||||
|
||||
16
src/main/resources/mapper/UserMapper.xml
Normal file
16
src/main/resources/mapper/UserMapper.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="github.benjamin.equipreservebackend.mapper.UserMapper">
|
||||
|
||||
<select id="selectLeaderByTeamIds" resultType="github.benjamin.equipreservebackend.entity.User">
|
||||
SELECT u.* FROM users u LEFT JOIN user_roles ur ON u.id = ur.user_id
|
||||
where ur.role_id = 2
|
||||
AND u.team_id in
|
||||
<foreach collection="teamIds" open="(" separator="," close=")" item="teamId">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user