Compare commits

...

12 Commits

22 changed files with 810 additions and 38 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ Thumbs.db
/.mvn/ /.mvn/
/**/target/ /**/target/
!src/**/target/keepme.txt # 可选:防止误删有用文件夹 !src/**/target/keepme.txt # 可选:防止误删有用文件夹
pom.xml.versionsBackup
# Maven Wrapper # Maven Wrapper
mvnw mvnw

6
db/data_role.sql Normal file
View 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
View 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
View 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;

View File

@ -82,10 +82,3 @@ CREATE TABLE approvals
decision TINYINT NOT NULL, decision TINYINT NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
); );
-- 初始角色数据
INSERT INTO roles (code, name)
VALUES ('ADMIN', '系统管理员'),
('LEADER', '团队负责人'),
('DEVICE_ADMIN', '设备管理员'),
('USER', '普通用户');

View File

@ -10,7 +10,7 @@
</parent> </parent>
<groupId>github.benjamin</groupId> <groupId>github.benjamin</groupId>
<artifactId>equip-reserve-backend</artifactId> <artifactId>equip-reserve-backend</artifactId>
<version>1.0.1</version> <version>1.0.2-SNAPSHOT</version>
<name>equip-reserve-backend</name> <name>equip-reserve-backend</name>
<description>equip-reserve-backend</description> <description>equip-reserve-backend</description>
<url/> <url/>

View File

@ -5,7 +5,7 @@ import lombok.Getter;
@Getter @Getter
public enum ReservationStatus { public enum ReservationStatus {
PENDING_LEADER("团队负责人审批中"), PENDING_LEADER("团队负责人审批中"),
PENDING_DEVICE_ADMIN("设备负责人审批中"), PENDING_DEVICE_ADMIN("设备管理员审批中"),
APPROVED("通过"), APPROVED("通过"),
APPROVED_ASSIST("通过,需要协助实验"), APPROVED_ASSIST("通过,需要协助实验"),
REJECTED("不通过"); REJECTED("不通过");

View File

@ -6,11 +6,7 @@ import github.benjamin.equipreservebackend.entity.Device;
import github.benjamin.equipreservebackend.response.ResponseResult; import github.benjamin.equipreservebackend.response.ResponseResult;
import github.benjamin.equipreservebackend.service.DeviceService; import github.benjamin.equipreservebackend.service.DeviceService;
import github.benjamin.equipreservebackend.service.ReservationService; import github.benjamin.equipreservebackend.service.ReservationService;
import github.benjamin.equipreservebackend.vo.DeviceAdminVO; import github.benjamin.equipreservebackend.vo.*;
import github.benjamin.equipreservebackend.vo.DeviceStatsVO;
import github.benjamin.equipreservebackend.vo.DeviceUserVO;
import github.benjamin.equipreservebackend.vo.TimeRangeVO;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -34,7 +30,7 @@ public class DeviceController {
private final ReservationService reservationService; private final ReservationService reservationService;
@PreAuthorize("hasRole('USER')") @PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
@GetMapping @GetMapping
public ResponseResult<Page<DeviceUserVO>> getUserDevices(@RequestParam(defaultValue = "1") Integer page, public ResponseResult<Page<DeviceUserVO>> getUserDevices(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size, @RequestParam(defaultValue = "10") Integer size,
@ -44,7 +40,7 @@ public class DeviceController {
return ResponseResult.success(res); return ResponseResult.success(res);
} }
@PreAuthorize("hasRole('USER')") @PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
@GetMapping("/unavailable-times/{id}") @GetMapping("/unavailable-times/{id}")
public ResponseResult<List<TimeRangeVO>> getUnavailableTimes(@PathVariable Long id) { public ResponseResult<List<TimeRangeVO>> getUnavailableTimes(@PathVariable Long id) {
List<TimeRangeVO> res = reservationService.getUnavailableTimes(id); List<TimeRangeVO> res = reservationService.getUnavailableTimes(id);
@ -120,4 +116,30 @@ public class DeviceController {
.sheet("设备使用统计") .sheet("设备使用统计")
.doWrite(data); .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);
}
} }

View File

@ -2,11 +2,9 @@ package github.benjamin.equipreservebackend.controller;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import github.benjamin.equipreservebackend.constant.ReservationStatus;
import github.benjamin.equipreservebackend.entity.Reservation; import github.benjamin.equipreservebackend.entity.Reservation;
import github.benjamin.equipreservebackend.response.ResponseResult; import github.benjamin.equipreservebackend.response.ResponseResult;
import github.benjamin.equipreservebackend.service.ReservationService; import github.benjamin.equipreservebackend.service.ReservationService;
import github.benjamin.equipreservebackend.vo.DeviceStatsVO;
import github.benjamin.equipreservebackend.vo.ReservationStatsVO; import github.benjamin.equipreservebackend.vo.ReservationStatsVO;
import github.benjamin.equipreservebackend.vo.ReservationVO; import github.benjamin.equipreservebackend.vo.ReservationVO;
import github.benjamin.equipreservebackend.vo.UserReservationVO; import github.benjamin.equipreservebackend.vo.UserReservationVO;
@ -22,6 +20,7 @@ import java.nio.charset.StandardCharsets;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/reservation") @RequestMapping("/reservation")
@ -30,14 +29,14 @@ public class ReservationController {
private final ReservationService reservationService; private final ReservationService reservationService;
@PreAuthorize("hasRole('USER')") @PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
@PostMapping @PostMapping
public ResponseResult<?> addReservation(@RequestBody Reservation reservation) { public ResponseResult<?> addReservation(@RequestBody Reservation reservation) {
reservationService.addReservation(reservation); reservationService.addReservation(reservation);
return ResponseResult.success(); return ResponseResult.success();
} }
@PreAuthorize("hasRole('USER')") @PreAuthorize("hasAnyRole('USER', 'LEADER', 'DEVICE_ADMIN')")
@GetMapping("/{userId}") @GetMapping("/{userId}")
public ResponseResult<Page<UserReservationVO>> getUserReservation(@PathVariable("userId") Long userId, public ResponseResult<Page<UserReservationVO>> getUserReservation(@PathVariable("userId") Long userId,
@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "1") Integer page,
@ -83,4 +82,12 @@ public class ReservationController {
.doWrite(data); .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();
}
} }

View File

@ -68,4 +68,10 @@ public class UserController {
userService.deleteById(userId); userService.deleteById(userId);
return ResponseResult.success(); return ResponseResult.success();
} }
@PreAuthorize("hasRole('ADMIN')")
@GetMapping("/user-team/{teamId}")
public ResponseResult<List<String>> getTeamUsers(@PathVariable Long teamId) {
return ResponseResult.success(userService.getTeamUsers(teamId));
}
} }

View File

@ -2,8 +2,16 @@ package github.benjamin.equipreservebackend.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import github.benjamin.equipreservebackend.entity.User; import github.benjamin.equipreservebackend.entity.User;
import org.apache.ibatis.annotations.MapKey;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository @Repository
public interface UserMapper extends BaseMapper<User> { public interface UserMapper extends BaseMapper<User> {
@MapKey("teamId")
Map<Long, User> selectLeaderByTeamIds(List<Long> teamIds);
} }

View File

@ -2,10 +2,7 @@ package github.benjamin.equipreservebackend.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import github.benjamin.equipreservebackend.entity.Reservation; import github.benjamin.equipreservebackend.entity.Reservation;
import github.benjamin.equipreservebackend.vo.ReservationStatsVO; import github.benjamin.equipreservebackend.vo.*;
import github.benjamin.equipreservebackend.vo.ReservationVO;
import github.benjamin.equipreservebackend.vo.TimeRangeVO;
import github.benjamin.equipreservebackend.vo.UserReservationVO;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
@ -23,4 +20,8 @@ public interface ReservationService {
Page<ReservationVO> getReservationVO(Long userId, Integer page, Integer size); Page<ReservationVO> getReservationVO(Long userId, Integer page, Integer size);
List<ReservationStatsVO> getReservationStats(LocalDate start, LocalDate end); List<ReservationStatsVO> getReservationStats(LocalDate start, LocalDate end);
List<DeviceDetailStatsVO> getDeviceDetailStats(Long deviceId, LocalDate start, LocalDate end);
void updateEndTime(Long reservationId, LocalDate endTime);
} }

View File

@ -6,6 +6,8 @@ import github.benjamin.equipreservebackend.entity.User;
import github.benjamin.equipreservebackend.security.SecurityUser; import github.benjamin.equipreservebackend.security.SecurityUser;
import github.benjamin.equipreservebackend.vo.UserVO; import github.benjamin.equipreservebackend.vo.UserVO;
import java.util.List;
public interface UserService { public interface UserService {
User login(String username, String password); User login(String username, String password);
@ -21,4 +23,6 @@ public interface UserService {
void deleteById(Long userId); void deleteById(Long userId);
void addUser(UserDTO dto); void addUser(UserDTO dto);
List<String> getTeamUsers(Long teamId);
} }

View File

@ -1,17 +1,18 @@
package github.benjamin.equipreservebackend.service.impl; package github.benjamin.equipreservebackend.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import github.benjamin.equipreservebackend.constant.ReservationStatus; 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.exception.ApiException;
import github.benjamin.equipreservebackend.mapper.*; import github.benjamin.equipreservebackend.mapper.*;
import github.benjamin.equipreservebackend.service.ReservationService; import github.benjamin.equipreservebackend.service.ReservationService;
import github.benjamin.equipreservebackend.utils.PageUtil; import github.benjamin.equipreservebackend.utils.PageUtil;
import github.benjamin.equipreservebackend.vo.ReservationStatsVO; import github.benjamin.equipreservebackend.vo.*;
import github.benjamin.equipreservebackend.vo.ReservationVO;
import github.benjamin.equipreservebackend.vo.TimeRangeVO;
import github.benjamin.equipreservebackend.vo.UserReservationVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -86,6 +87,10 @@ public class ReservationServiceImpl implements ReservationService {
.stream() .stream()
.collect(Collectors.toMap(Device::getId, Function.identity())); .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() List<Long> deviceAdminIDs = reservations.getRecords().stream()
.map(Reservation::getDeviceAdminId) .map(Reservation::getDeviceAdminId)
@ -93,7 +98,6 @@ public class ReservationServiceImpl implements ReservationService {
.distinct() .distinct()
.toList(); .toList();
List<UserReservationVO> vos; List<UserReservationVO> vos;
Map<Long, User> deviceAdminMap = userMapper.selectList(new LambdaQueryWrapper<User>() Map<Long, User> deviceAdminMap = userMapper.selectList(new LambdaQueryWrapper<User>()
.in(User::getId, deviceAdminIDs)) .in(User::getId, deviceAdminIDs))
@ -101,7 +105,7 @@ public class ReservationServiceImpl implements ReservationService {
.collect(Collectors.toMap(User::getId, Function.identity())); .collect(Collectors.toMap(User::getId, Function.identity()));
vos = reservations.getRecords().stream() vos = reservations.getRecords().stream()
.map(reservation -> new UserReservationVO(reservation, deviceNameMap, deviceAdminMap)) .map(reservation -> new UserReservationVO(reservation, deviceNameMap, deviceAdminMap, teamLeaderMap))
.toList(); .toList();
res.setRecords(vos); res.setRecords(vos);
return res; return res;
@ -125,6 +129,9 @@ public class ReservationServiceImpl implements ReservationService {
List<Device> devices = deviceMapper.selectList(new LambdaQueryWrapper<Device>() List<Device> devices = deviceMapper.selectList(new LambdaQueryWrapper<Device>()
.eq(Device::getTeamId, user.getTeamId()) .eq(Device::getTeamId, user.getTeamId())
.select()); .select());
if (devices.isEmpty()) {
return (Page<ReservationVO>) PageUtil.EMPTY_PAGE;
}
List<Role> userRole = roleMapper.selectRoleByUserId(userId); List<Role> userRole = roleMapper.selectRoleByUserId(userId);
ReservationStatus status; ReservationStatus status;
if (userRole.stream().anyMatch(r -> r.getCode().equals("LEADER"))) { 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) { public List<ReservationStatsVO> getReservationStats(LocalDate start, LocalDate end) {
return reservationMapper.getReservationStats(start, 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));
}
} }

View File

@ -136,4 +136,14 @@ public class UserServiceImpl implements UserService {
userMapper.insert(user); userMapper.insert(user);
userRoleMapper.insert(new UserRole(user.getId(), dto.getRoleId())); 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();
}
} }

View File

@ -2,8 +2,13 @@ package github.benjamin.equipreservebackend.utils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Collections;
public class PageUtil { 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) { public static <T> Page<T> copyPage(Page<?> page) {
return new Page<T>(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount()); return new Page<T>(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
} }

View File

@ -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();
}
}

View File

@ -9,6 +9,8 @@ import java.time.LocalDate;
@Data @Data
public class LeaderApprovalVO { public class LeaderApprovalVO {
@JsonSerialize(using = ToStringSerializer.class)
private Long reservationId;
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long approvalId; private Long approvalId;
private String applicantName; private String applicantName;

View File

@ -22,12 +22,13 @@ public class UserReservationVO {
private LocalDate startTime; private LocalDate startTime;
private LocalDate endTime; private LocalDate endTime;
private String statusLabel; private String statusLabel;
private String deviceLeaderName;
private String deviceLeaderContact;
private String deviceAdminName; private String deviceAdminName;
private String deviceAdminContact; private String deviceAdminContact;
private LocalDateTime createdTime; private LocalDateTime createdTime;
public UserReservationVO(Reservation r, Map<Long, Device> deviceMap, Map<Long, User> deviceAdminMap, Map<Long, User> teamLeaderMap) {
public UserReservationVO(Reservation r, Map<Long, Device> deviceMap, Map<Long, User> deviceAdminMap) {
this.reservationId = r.getId().toString(); this.reservationId = r.getId().toString();
this.deviceName = deviceMap.get(r.getDeviceId()).getName(); this.deviceName = deviceMap.get(r.getDeviceId()).getName();
this.startTime = r.getStartTime(); this.startTime = r.getStartTime();
@ -41,6 +42,14 @@ public class UserReservationVO {
this.deviceAdminName = "该管理员不存在,请联系设备相关人员"; this.deviceAdminName = "该管理员不存在,请联系设备相关人员";
this.deviceAdminContact = ""; 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(); this.createdTime = r.getCreatedTime();
} }

View File

@ -5,7 +5,7 @@
<mapper namespace="github.benjamin.equipreservebackend.mapper.ApprovalMapper"> <mapper namespace="github.benjamin.equipreservebackend.mapper.ApprovalMapper">
<select id="getApproval" resultType="github.benjamin.equipreservebackend.vo.LeaderApprovalVO"> <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 FROM approvals a
LEFT JOIN reservations r ON a.reservation_id = r.id LEFT JOIN reservations r ON a.reservation_id = r.id
LEFT JOIN devices d ON r.device_id = d.id LEFT JOIN devices d ON r.device_id = d.id

View File

@ -14,7 +14,7 @@
JOIN devices d ON r.device_id = d.id JOIN devices d ON r.device_id = d.id
WHERE r.status IN ('APPROVED', 'APPROVED_ASSIST') WHERE r.status IN ('APPROVED', 'APPROVED_ASSIST')
AND r.start_time >= #{start} AND r.start_time >= #{start}
AND r.end_time &lt; #{end} AND r.end_time &lt;= #{end}
GROUP BY d.id GROUP BY d.id
ORDER BY totalUsageDays DESC ORDER BY totalUsageDays DESC
</select> </select>

View 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>