diff --git a/sql/SAMS_localhost-2025_02_19_10_58_38-dump.sql b/sql/SAMS_localhost-2025_02_19_10_58_38-dump.sql deleted file mode 100644 index 476ed044..00000000 --- a/sql/SAMS_localhost-2025_02_19_10_58_38-dump.sql +++ /dev/null @@ -1,435 +0,0 @@ --- MySQL dump 10.13 Distrib 8.0.41, for Linux (x86_64) --- --- Host: 127.0.0.1 Database: SAMS --- ------------------------------------------------------ --- Server version 8.0.41-0ubuntu0.22.04.1 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!50503 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `ams_activity` --- - -DROP TABLE IF EXISTS `ams_activity`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `ams_activity` ( - `act_id` bigint NOT NULL AUTO_INCREMENT COMMENT '活动ID', - `title` varchar(100) NOT NULL COMMENT '活动标题', - `description` text COMMENT '活动描述', - `start_time` datetime NOT NULL COMMENT '开始时间', - `end_time` datetime NOT NULL COMMENT '结束时间', - `location` varchar(255) DEFAULT NULL COMMENT '地点', - `budget` decimal(10,2) DEFAULT '0.00' COMMENT '预算', - `max_participants` int DEFAULT NULL COMMENT '最大参与人数', - `creator_id` bigint NOT NULL COMMENT '创建者ID', - `club_id` bigint DEFAULT NULL COMMENT '所属社团ID', - `visibility` enum('public','private') DEFAULT 'public' COMMENT '是否公开', - `status` enum('draft','pending_approval','approved','ongoing','completed','cancelled') DEFAULT 'draft' COMMENT '活动状态', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', - PRIMARY KEY (`act_id`), - KEY `creator_id` (`creator_id`), - KEY `club_id` (`club_id`), - CONSTRAINT `ams_activity_ibfk_1` FOREIGN KEY (`creator_id`) REFERENCES `sys_user` (`user_id`), - CONSTRAINT `ams_activity_ibfk_2` FOREIGN KEY (`club_id`) REFERENCES `sms_club` (`club_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='活动表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ams_activity` --- - -LOCK TABLES `ams_activity` WRITE; -/*!40000 ALTER TABLE `ams_activity` DISABLE KEYS */; -/*!40000 ALTER TABLE `ams_activity` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `ams_approval` --- - -DROP TABLE IF EXISTS `ams_approval`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `ams_approval` ( - `appr_id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批ID', - `act_id` bigint NOT NULL COMMENT '活动ID', - `user_id` bigint NOT NULL COMMENT '发起者ID', - `approver_id` bigint NOT NULL COMMENT '审批人ID', - `status` tinyint(1) DEFAULT '0' COMMENT '审批状态 (0: 待审批, 1: 通过, 2: 拒绝)', - `reason` text COMMENT '拒绝原因(如果适用)', - `approved_at` datetime DEFAULT NULL COMMENT '审批时间', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`appr_id`), - KEY `act_id` (`act_id`), - KEY `user_id` (`user_id`), - KEY `approver_id` (`approver_id`), - CONSTRAINT `ams_approval_ibfk_1` FOREIGN KEY (`act_id`) REFERENCES `ams_activity` (`act_id`), - CONSTRAINT `ams_approval_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`), - CONSTRAINT `ams_approval_ibfk_3` FOREIGN KEY (`approver_id`) REFERENCES `sys_user` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='活动审批表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ams_approval` --- - -LOCK TABLES `ams_approval` WRITE; -/*!40000 ALTER TABLE `ams_approval` DISABLE KEYS */; -/*!40000 ALTER TABLE `ams_approval` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `ams_comment` --- - -DROP TABLE IF EXISTS `ams_comment`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `ams_comment` ( - `comment_id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论ID', - `user_id` bigint NOT NULL COMMENT '用户ID', - `act_id` bigint NOT NULL COMMENT '活动ID', - `parent_comment_id` bigint DEFAULT NULL COMMENT '父评论ID(为空表示是顶级评论)', - `content` text NOT NULL COMMENT '评论内容', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '评论时间', - PRIMARY KEY (`comment_id`), - KEY `user_id` (`user_id`), - KEY `act_id` (`act_id`), - KEY `ams_comment_ibfk_3` (`parent_comment_id`), - CONSTRAINT `ams_comment_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`) ON DELETE CASCADE, - CONSTRAINT `ams_comment_ibfk_2` FOREIGN KEY (`act_id`) REFERENCES `ams_activity` (`act_id`) ON DELETE CASCADE, - CONSTRAINT `ams_comment_ibfk_3` FOREIGN KEY (`parent_comment_id`) REFERENCES `ams_comment` (`comment_id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='活动评论表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ams_comment` --- - -LOCK TABLES `ams_comment` WRITE; -/*!40000 ALTER TABLE `ams_comment` DISABLE KEYS */; -/*!40000 ALTER TABLE `ams_comment` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `ams_reaction` --- - -DROP TABLE IF EXISTS `ams_reaction`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `ams_reaction` ( - `reaction_id` bigint NOT NULL AUTO_INCREMENT COMMENT '点赞/点踩ID', - `user_id` bigint NOT NULL COMMENT '用户ID', - `act_id` bigint NOT NULL COMMENT '活动ID', - `reaction_type` enum('like','dislike') NOT NULL COMMENT '反应类型(like: 点赞, dislike: 点踩)', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '反应时间', - PRIMARY KEY (`reaction_id`), - UNIQUE KEY `uniq_user_activity_reaction` (`user_id`,`act_id`), - KEY `act_id` (`act_id`), - CONSTRAINT `ams_reaction_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`) ON DELETE CASCADE, - CONSTRAINT `ams_reaction_ibfk_2` FOREIGN KEY (`act_id`) REFERENCES `ams_activity` (`act_id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='活动点赞/点踩表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ams_reaction` --- - -LOCK TABLES `ams_reaction` WRITE; -/*!40000 ALTER TABLE `ams_reaction` DISABLE KEYS */; -/*!40000 ALTER TABLE `ams_reaction` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `ams_registration` --- - -DROP TABLE IF EXISTS `ams_registration`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `ams_registration` ( - `reg_id` bigint NOT NULL AUTO_INCREMENT COMMENT '报名ID', - `act_id` bigint NOT NULL COMMENT '活动ID', - `user_id` bigint NOT NULL COMMENT '用户ID', - `status` enum('registered','cancelled','attended','absent') DEFAULT 'registered' COMMENT '报名状态', - `register_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '报名时间', - `attend_time` datetime DEFAULT NULL COMMENT '参与时间', - PRIMARY KEY (`reg_id`), - KEY `act_id` (`act_id`), - KEY `user_id` (`user_id`), - CONSTRAINT `ams_registration_ibfk_1` FOREIGN KEY (`act_id`) REFERENCES `ams_activity` (`act_id`), - CONSTRAINT `ams_registration_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='活动报名表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ams_registration` --- - -LOCK TABLES `ams_registration` WRITE; -/*!40000 ALTER TABLE `ams_registration` DISABLE KEYS */; -/*!40000 ALTER TABLE `ams_registration` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_club` --- - -DROP TABLE IF EXISTS `sms_club`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sms_club` ( - `club_id` bigint NOT NULL AUTO_INCREMENT COMMENT '社团ID', - `club_name` varchar(50) NOT NULL COMMENT '社团名称', - `description` text COMMENT '社团简介', - `category` enum('文化艺术','学术科技','社会公益','其他') NOT NULL COMMENT '社团类型', - `college_id` bigint NOT NULL COMMENT '所属院系', - `leader_id` bigint DEFAULT NULL COMMENT '负责人ID', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`club_id`), - KEY `college_id` (`college_id`), - KEY `leader_id` (`leader_id`), - CONSTRAINT `sms_club_ibfk_1` FOREIGN KEY (`college_id`) REFERENCES `sms_college` (`college_id`), - CONSTRAINT `sms_club_ibfk_2` FOREIGN KEY (`leader_id`) REFERENCES `sys_user` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='社团表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_club` --- - -LOCK TABLES `sms_club` WRITE; -/*!40000 ALTER TABLE `sms_club` DISABLE KEYS */; -INSERT INTO `sms_club` VALUES (1,'编程爱好者协会','学习编程、算法与开发','学术科技',2,2,'2025-02-13 11:43:50'),(2,'篮球社','喜欢打篮球的同学们','其他',3,3,'2025-02-13 11:43:50'); -/*!40000 ALTER TABLE `sms_club` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_college` --- - -DROP TABLE IF EXISTS `sms_college`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sms_college` ( - `college_id` bigint NOT NULL AUTO_INCREMENT COMMENT '院系ID', - `college_name` varchar(255) NOT NULL COMMENT '名称(高校或院系)', - `parent_id` bigint DEFAULT NULL COMMENT '父院系ID(高校此值为空)', - `email` varchar(50) DEFAULT '' COMMENT '邮箱', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`college_id`), - KEY `parent_id` (`parent_id`), - CONSTRAINT `sms_college_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `sms_college` (`college_id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='高校及院系表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_college` --- - -LOCK TABLES `sms_college` WRITE; -/*!40000 ALTER TABLE `sms_college` DISABLE KEYS */; -INSERT INTO `sms_college` VALUES (1,'山东建筑大学',NULL,'contact@sdu.edu.cn','2025-02-13 11:40:45'),(2,'计算机科学与技术学院',1,'cs@sdu.edu.cn','2025-02-13 11:40:45'),(3,'土木工程学院',1,'civil@sdu.edu.cn','2025-02-13 11:40:45'),(4,'管理工程学院',1,'contact4@sdu.edu.cn','2025-02-13 11:51:12'),(5,'热能工程学院',1,'contact5@sdu.edu.cn','2025-02-13 11:51:12'),(6,'市政与环境工程学院',1,'contact6@sdu.edu.cn','2025-02-13 11:51:12'),(7,'机电工程学院',1,'contact7@sdu.edu.cn','2025-02-13 11:51:12'),(8,'理学院',1,'contact8@sdu.edu.cn','2025-02-13 11:51:12'),(9,'商学院',1,'contact9@sdu.edu.cn','2025-02-13 11:51:12'),(10,'交通工程学院',1,'contact10@sdu.edu.cn','2025-02-13 11:51:12'),(11,'艺术学院',1,'contact11@sdu.edu.cn','2025-02-13 11:51:12'),(12,'法学院',1,'contact12@sdu.edu.cn','2025-02-13 11:51:12'),(13,'外国语学院',1,'contact13@sdu.edu.cn','2025-02-13 11:51:12'),(20,'山东大学',NULL,'contact@su.edu.cn','2025-02-13 11:52:27'),(21,'计算机科学与技术学院',2,'cs@sdu.edu.cn','2025-02-13 11:52:48'),(22,'土木工程学院',2,'civil@sdu.edu.cn','2025-02-13 11:52:48'),(23,'管理工程学院',2,'contact4@sdu.edu.cn','2025-02-13 11:52:48'),(24,'热能工程学院',2,'contact5@sdu.edu.cn','2025-02-13 11:52:48'),(25,'市政与环境工程学院',2,'contact6@sdu.edu.cn','2025-02-13 11:52:48'),(26,'机电工程学院',2,'contact7@sdu.edu.cn','2025-02-13 11:52:48'),(27,'理学院',2,'contact8@sdu.edu.cn','2025-02-13 11:52:48'),(28,'商学院',2,'contact9@sdu.edu.cn','2025-02-13 11:52:48'),(29,'交通工程学院',2,'contact10@sdu.edu.cn','2025-02-13 11:52:48'),(30,'艺术学院',2,'contact11@sdu.edu.cn','2025-02-13 11:52:48'),(31,'法学院',2,'contact12@sdu.edu.cn','2025-02-13 11:52:48'),(32,'外国语学院',2,'contact13@sdu.edu.cn','2025-02-13 11:52:48'); -/*!40000 ALTER TABLE `sms_college` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_college_leader` --- - -DROP TABLE IF EXISTS `sms_college_leader`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sms_college_leader` ( - `college_id` bigint NOT NULL COMMENT '院系ID', - `user_id` bigint NOT NULL COMMENT '负责人ID', - `assigned_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '指派时间', - PRIMARY KEY (`college_id`,`user_id`), - KEY `user_id` (`user_id`), - CONSTRAINT `sms_college_leader_ibfk_1` FOREIGN KEY (`college_id`) REFERENCES `sms_college` (`college_id`) ON DELETE CASCADE, - CONSTRAINT `sms_college_leader_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='院系负责人表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_college_leader` --- - -LOCK TABLES `sms_college_leader` WRITE; -/*!40000 ALTER TABLE `sms_college_leader` DISABLE KEYS */; -/*!40000 ALTER TABLE `sms_college_leader` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_user_club` --- - -DROP TABLE IF EXISTS `sms_user_club`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sms_user_club` ( - `suc_id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', - `user_id` bigint NOT NULL COMMENT '用户ID', - `club_id` bigint NOT NULL COMMENT '社团ID', - `role_id` bigint NOT NULL COMMENT '角色ID', - `is_active` tinyint(1) DEFAULT '1' COMMENT '是否活跃', - `join_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '加入日期', - PRIMARY KEY (`suc_id`), - UNIQUE KEY `uniq_user_club` (`user_id`,`club_id`), - KEY `club_id` (`club_id`), - KEY `role_id` (`role_id`), - CONSTRAINT `sms_user_club_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`), - CONSTRAINT `sms_user_club_ibfk_2` FOREIGN KEY (`club_id`) REFERENCES `sms_club` (`club_id`), - CONSTRAINT `sms_user_club_ibfk_3` FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`role_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户社团关系表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_user_club` --- - -LOCK TABLES `sms_user_club` WRITE; -/*!40000 ALTER TABLE `sms_user_club` DISABLE KEYS */; -/*!40000 ALTER TABLE `sms_user_club` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sys_logs` --- - -DROP TABLE IF EXISTS `sys_logs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sys_logs` ( - `log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志ID', - `user_id` bigint NOT NULL COMMENT '用户ID', - `action` varchar(255) NOT NULL COMMENT '操作类型', - `description` text COMMENT '描述', - `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间', - PRIMARY KEY (`log_id`), - KEY `idx_user_id` (`user_id`), - CONSTRAINT `sys_logs_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统日志表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sys_logs` --- - -LOCK TABLES `sys_logs` WRITE; -/*!40000 ALTER TABLE `sys_logs` DISABLE KEYS */; -/*!40000 ALTER TABLE `sys_logs` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sys_notification` --- - -DROP TABLE IF EXISTS `sys_notification`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sys_notification` ( - `notification_id` bigint NOT NULL AUTO_INCREMENT COMMENT '通知ID', - `title` varchar(255) NOT NULL COMMENT '通知标题', - `content` text NOT NULL COMMENT '通知内容', - `receiver_id` bigint NOT NULL COMMENT '接收者ID', - `is_read` tinyint(1) DEFAULT '0' COMMENT '是否已读', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`notification_id`), - KEY `idx_receiver_id` (`receiver_id`), - CONSTRAINT `sys_notification_ibfk_1` FOREIGN KEY (`receiver_id`) REFERENCES `sys_user` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统通知表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sys_notification` --- - -LOCK TABLES `sys_notification` WRITE; -/*!40000 ALTER TABLE `sys_notification` DISABLE KEYS */; -/*!40000 ALTER TABLE `sys_notification` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sys_role` --- - -DROP TABLE IF EXISTS `sys_role`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sys_role` ( - `role_id` bigint NOT NULL AUTO_INCREMENT COMMENT '角色ID', - `role_name` varchar(30) NOT NULL COMMENT '角色名称', - `role_key` varchar(64) NOT NULL COMMENT '角色标识', - `role_desc` varchar(255) DEFAULT NULL COMMENT '角色描述', - `status` enum('active','inactive') DEFAULT 'active' COMMENT '状态', - PRIMARY KEY (`role_id`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户角色表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sys_role` --- - -LOCK TABLES `sys_role` WRITE; -/*!40000 ALTER TABLE `sys_role` DISABLE KEYS */; -INSERT INTO `sys_role` VALUES (0,'系统管理员','admin','最高权限,管理所有用户与活动','active'),(1,'参与者','participant','普通用户,可以报名活动、评论、点赞','active'),(2,'管理员','leader','管理活动和人员','active'); -/*!40000 ALTER TABLE `sys_role` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sys_user` --- - -DROP TABLE IF EXISTS `sys_user`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `sys_user` ( - `user_id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID', - `role_id` bigint NOT NULL COMMENT '用户角色', - `nick_name` varchar(30) DEFAULT '' COMMENT '用户昵称', - `user_name` varchar(30) NOT NULL COMMENT '真实姓名', - `password` varchar(100) NOT NULL COMMENT '用户密码', - `school_id` char(12) NOT NULL COMMENT '学号/教职工号', - `college_id` bigint DEFAULT NULL COMMENT '所属院系', - `email` varchar(50) DEFAULT '' COMMENT '用户邮箱', - `avatar` varchar(100) DEFAULT '' COMMENT '头像地址', - `status` enum('active','inactive','banned') DEFAULT 'active' COMMENT '账号状态', - PRIMARY KEY (`user_id`), - KEY `role_id` (`role_id`), - CONSTRAINT `sys_user_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`role_id`) -) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统用户表'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sys_user` --- - -LOCK TABLES `sys_user` WRITE; -/*!40000 ALTER TABLE `sys_user` DISABLE KEYS */; -INSERT INTO `sys_user` VALUES (1,1,'张三','zhangsan','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511110001',2,'zhangsan@example.com','avatar1.jpg','active'),(2,2,'李四','lisi','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511110002',2,'lisi@example.com','avatar2.jpg','active'),(3,2,'王五','wangwu','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511110003',2,'wangwu@example.com','avatar3.jpg','active'),(4,1,'赵六','zhaoliu','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511110004',3,'zhaoliu@example.com','avatar4.jpg','active'),(6,1,'用户6','user6','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202588456301',4,'user6@example.com','avatar6.jpg','active'),(7,1,'用户7','user7','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202598705123',5,'user7@example.com','avatar7.jpg','active'),(8,1,'用户8','user8','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202556098765',6,'user8@example.com','avatar8.jpg','active'),(9,1,'用户9','user9','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202512340987',7,'user9@example.com','avatar9.jpg','active'),(10,1,'用户10','user10','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202599888222',8,'user10@example.com','avatar10.jpg','active'),(11,1,'用户11','user11','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202533665588',9,'user11@example.com','avatar11.jpg','active'),(12,1,'用户12','user12','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202500112233',10,'user12@example.com','avatar12.jpg','active'),(13,1,'用户13','user13','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511122233',11,'user13@example.com','avatar13.jpg','active'),(14,1,'用户14','user14','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202522334455',12,'user14@example.com','avatar14.jpg','active'),(15,1,'用户15','user15','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202544556677',13,'user15@example.com','avatar15.jpg','active'),(16,1,'用户16','user16','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202566778899',4,'user16@example.com','avatar16.jpg','active'),(17,1,'用户17','user17','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202577889900',5,'user17@example.com','avatar17.jpg','active'),(18,1,'用户18','user18','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202500998877',6,'user18@example.com','avatar18.jpg','active'),(19,1,'用户19','user19','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511223344',7,'user19@example.com','avatar19.jpg','active'),(20,1,'用户20','user20','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202522334455',8,'user20@example.com','avatar20.jpg','active'),(21,1,'用户21','user21','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202533445566',9,'user21@example.com','avatar21.jpg','active'),(22,1,'用户22','user22','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202544556677',10,'user22@example.com','avatar22.jpg','active'),(23,1,'用户23','user23','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202555667788',11,'user23@example.com','avatar23.jpg','active'),(24,1,'用户24','user24','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202566778899',12,'user24@example.com','avatar24.jpg','active'),(25,1,'用户25','user25','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202577889900',13,'user25@example.com','avatar25.jpg','active'),(26,1,'用户26','user26','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202588990011',4,'user26@example.com','avatar26.jpg','active'),(27,1,'用户27','user27','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202599001122',5,'user27@example.com','avatar27.jpg','active'),(28,1,'用户28','user28','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202511223344',6,'user28@example.com','avatar28.jpg','active'),(29,1,'用户29','user29','$2a$10$e/hB5Ps/op5jkDtMZXyRo.53CKoXUkOLVvCvlqGktaMqKspJo0WGW','202522334455',7,'user29@example.com','avatar29.jpg','active'),(30,1,'用户30','user30','$2a$10$CwTycUXWue0Thq9StjUM0uJ6j6U8zIN4MyFfJqz7eZyPq5JwZWjG2','202533445566',8,'user30@example.com','avatar30.jpg','active'); -/*!40000 ALTER TABLE `sys_user` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2025-02-19 10:58:38 diff --git a/src/main/java/com/bruce/sams/common/annotation/DataPermission.java b/src/main/java/com/bruce/sams/common/annotation/DataPermission.java new file mode 100644 index 00000000..beaa98e3 --- /dev/null +++ b/src/main/java/com/bruce/sams/common/annotation/DataPermission.java @@ -0,0 +1,28 @@ +package com.bruce.sams.common.annotation; + +import java.lang.annotation.*; +import org.springframework.security.access.prepost.PreAuthorize; + +/** + * 自定义数据权限注解 + * 适用于 Spring Security 6,结合 `@PreAuthorize` 进行权限控制 + */ +@Target({ElementType.METHOD}) // 作用于方法 +@Retention(RetentionPolicy.RUNTIME) // 运行时生效 +@Documented +@PreAuthorize("@dataPermissionEvaluator.hasPermission(authentication, #field, #type)") +public @interface DataPermission { + + /** + * 数据权限字段,比如 "creator_id" 或 "club_id" + */ + String field() default "user_id"; + + /** + * 数据权限类型: + * - USER: 只能访问当前用户的数据 + * - CLUB: 只能访问当前社团的数据 + * - ADMIN: 允许访问所有数据 + */ + String type() default "USER"; +} diff --git a/src/main/java/com/bruce/sams/common/config/SecurityConfig.java b/src/main/java/com/bruce/sams/common/config/SecurityConfig.java index f6ab0a67..7bdd82d9 100644 --- a/src/main/java/com/bruce/sams/common/config/SecurityConfig.java +++ b/src/main/java/com/bruce/sams/common/config/SecurityConfig.java @@ -1,10 +1,11 @@ package com.bruce.sams.common.config; -import com.bruce.sams.filters.JwtAuthFilter; +import com.bruce.sams.common.security.JwtAuthFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; @@ -19,11 +20,11 @@ public class SecurityConfig { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .csrf(csrf -> csrf.disable()) + .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(auth -> auth .requestMatchers("/api/auth/login").permitAll() .requestMatchers("/api/admin/**").hasAuthority("leader") .requestMatchers("/api/user/**").hasAuthority("participant") - .requestMatchers("/api/activity/**").authenticated() .anyRequest().authenticated() ) .addFilterBefore(new JwtAuthFilter(), UsernamePasswordAuthenticationFilter.class); diff --git a/src/main/java/com/bruce/sams/exception/AccountDisabledException.java b/src/main/java/com/bruce/sams/common/exception/AccountDisabledException.java similarity index 87% rename from src/main/java/com/bruce/sams/exception/AccountDisabledException.java rename to src/main/java/com/bruce/sams/common/exception/AccountDisabledException.java index 5c9c7d25..64095df3 100644 --- a/src/main/java/com/bruce/sams/exception/AccountDisabledException.java +++ b/src/main/java/com/bruce/sams/common/exception/AccountDisabledException.java @@ -1,4 +1,4 @@ -package com.bruce.sams.exception; +package com.bruce.sams.common.exception; import com.bruce.sams.common.constant.HttpStatus; diff --git a/src/main/java/com/bruce/sams/exception/CustomException.java b/src/main/java/com/bruce/sams/common/exception/CustomException.java similarity index 86% rename from src/main/java/com/bruce/sams/exception/CustomException.java rename to src/main/java/com/bruce/sams/common/exception/CustomException.java index dea9214d..31a625a2 100644 --- a/src/main/java/com/bruce/sams/exception/CustomException.java +++ b/src/main/java/com/bruce/sams/common/exception/CustomException.java @@ -1,4 +1,4 @@ -package com.bruce.sams.exception; +package com.bruce.sams.common.exception; import lombok.Getter; diff --git a/src/main/java/com/bruce/sams/exception/NoPermissionException.java b/src/main/java/com/bruce/sams/common/exception/NoPermissionException.java similarity index 90% rename from src/main/java/com/bruce/sams/exception/NoPermissionException.java rename to src/main/java/com/bruce/sams/common/exception/NoPermissionException.java index 9d21421c..59896cf9 100644 --- a/src/main/java/com/bruce/sams/exception/NoPermissionException.java +++ b/src/main/java/com/bruce/sams/common/exception/NoPermissionException.java @@ -1,4 +1,4 @@ -package com.bruce.sams.exception; +package com.bruce.sams.common.exception; import com.bruce.sams.common.constant.HttpStatus; import lombok.Getter; diff --git a/src/main/java/com/bruce/sams/exception/PasswordIncorrectException.java b/src/main/java/com/bruce/sams/common/exception/PasswordIncorrectException.java similarity index 64% rename from src/main/java/com/bruce/sams/exception/PasswordIncorrectException.java rename to src/main/java/com/bruce/sams/common/exception/PasswordIncorrectException.java index cf40f45f..4e356ddc 100644 --- a/src/main/java/com/bruce/sams/exception/PasswordIncorrectException.java +++ b/src/main/java/com/bruce/sams/common/exception/PasswordIncorrectException.java @@ -1,4 +1,4 @@ -package com.bruce.sams.exception; +package com.bruce.sams.common.exception; import com.bruce.sams.common.constant.HttpStatus; @@ -9,8 +9,4 @@ public class PasswordIncorrectException extends CustomException { public PasswordIncorrectException() { super(HttpStatus.UNAUTHORIZED, "账号或密码错误"); } - - public PasswordIncorrectException(String message) { - super(HttpStatus.UNAUTHORIZED, message); - } } diff --git a/src/main/java/com/bruce/sams/exception/UserNotFoundException.java b/src/main/java/com/bruce/sams/common/exception/UserNotFoundException.java similarity index 85% rename from src/main/java/com/bruce/sams/exception/UserNotFoundException.java rename to src/main/java/com/bruce/sams/common/exception/UserNotFoundException.java index b40c4d38..c13175a1 100644 --- a/src/main/java/com/bruce/sams/exception/UserNotFoundException.java +++ b/src/main/java/com/bruce/sams/common/exception/UserNotFoundException.java @@ -1,4 +1,4 @@ -package com.bruce.sams.exception; +package com.bruce.sams.common.exception; import com.bruce.sams.common.constant.HttpStatus; diff --git a/src/main/java/com/bruce/sams/common/security/DataPermissionEvaluator.java b/src/main/java/com/bruce/sams/common/security/DataPermissionEvaluator.java new file mode 100644 index 00000000..448b190c --- /dev/null +++ b/src/main/java/com/bruce/sams/common/security/DataPermissionEvaluator.java @@ -0,0 +1,85 @@ +package com.bruce.sams.common.security; + +import com.bruce.sams.domain.entity.LoginUser; +import org.springframework.security.access.PermissionEvaluator; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.stereotype.Component; +import java.io.Serializable; +import java.util.List; + +/** + * 数据权限评估器 + * 负责解析 `@DataPermission` 逻辑,并执行数据权限校验 + */ +@Component +public class DataPermissionEvaluator implements PermissionEvaluator { + + @Override + public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) { + return false; // 这里我们不处理 Object 级别的权限 + } + + /** + * 解析 `@DataPermission` 逻辑,判断用户是否有访问权限 + * + * @param authentication 当前用户认证信息 + * @param field 需要进行数据权限控制的字段(如 creator_id, club_id) + * @param type 数据权限类型(USER, CLUB, ADMIN) + * @return boolean 是否有访问权限 + */ + public boolean hasPermission(Authentication authentication, String field, String type) { + // 获取当前登录用户 + LoginUser loginUser = (LoginUser) authentication.getPrincipal(); + Long userId = loginUser.getUserId(); + List roles = loginUser.getAuthorities().stream() + .map(GrantedAuthority::getAuthority) + .toList(); + + // 如果用户是管理员,直接放行 + if (roles.contains("ROLE_ADMIN") || "ADMIN".equals(type)) { + return true; + } + + // 如果 type = "USER",只允许访问自己的数据 + if ("USER".equals(type)) { + return checkUserDataPermission(userId, field); + } + + // 如果 type = "CLUB",只允许访问自己所属社团的数据 + if ("CLUB".equals(type)) { + Long clubId = getUserClubId(userId); // 通过用户ID获取社团ID + return checkClubDataPermission(clubId, field); + } + + return false; + } + + /** + * 检查用户是否有权限访问自己的数据 + */ + private boolean checkUserDataPermission(Long userId, String field) { + return field.equals("creator_id") && userId != null; // 用户只能访问自己创建的数据 + } + + /** + * 检查用户是否有权限访问社团数据 + */ + private boolean checkClubDataPermission(Long clubId, String field) { + return field.equals("club_id") && clubId != null; // 只能访问所属社团的数据 + } + + /** + * 通过用户ID查询社团ID(可使用 MyBatis-Plus 查询数据库) + * todo 完善该内容 + */ +// private Long getUserClubId(Long userId) { +// return userMapper.getUserClubId(userId); // 假设 UserMapper 里有方法查询用户所属社团 +// } + + @Override + public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission) { + return false; // 这里不做特殊处理 + } +} + diff --git a/src/main/java/com/bruce/sams/filters/GlobalExceptionHandler.java b/src/main/java/com/bruce/sams/common/security/GlobalExceptionHandler.java similarity index 88% rename from src/main/java/com/bruce/sams/filters/GlobalExceptionHandler.java rename to src/main/java/com/bruce/sams/common/security/GlobalExceptionHandler.java index a3117d67..0f3f281c 100644 --- a/src/main/java/com/bruce/sams/filters/GlobalExceptionHandler.java +++ b/src/main/java/com/bruce/sams/common/security/GlobalExceptionHandler.java @@ -1,6 +1,6 @@ -package com.bruce.sams.filters; +package com.bruce.sams.common.security; -import com.bruce.sams.exception.CustomException; +import com.bruce.sams.common.exception.CustomException; import com.bruce.sams.utils.AjaxResult; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; diff --git a/src/main/java/com/bruce/sams/filters/JwtAuthFilter.java b/src/main/java/com/bruce/sams/common/security/JwtAuthFilter.java similarity index 97% rename from src/main/java/com/bruce/sams/filters/JwtAuthFilter.java rename to src/main/java/com/bruce/sams/common/security/JwtAuthFilter.java index 4090bbfa..473a8adf 100644 --- a/src/main/java/com/bruce/sams/filters/JwtAuthFilter.java +++ b/src/main/java/com/bruce/sams/common/security/JwtAuthFilter.java @@ -1,4 +1,4 @@ -package com.bruce.sams.filters; +package com.bruce.sams.common.security; import com.bruce.sams.utils.TokenUtil; import jakarta.servlet.FilterChain; @@ -9,7 +9,6 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; - import java.io.IOException; /** diff --git a/src/main/java/com/bruce/sams/controller/sys/AuthController.java b/src/main/java/com/bruce/sams/controller/AuthController.java similarity index 95% rename from src/main/java/com/bruce/sams/controller/sys/AuthController.java rename to src/main/java/com/bruce/sams/controller/AuthController.java index 56089c0d..76934deb 100644 --- a/src/main/java/com/bruce/sams/controller/sys/AuthController.java +++ b/src/main/java/com/bruce/sams/controller/AuthController.java @@ -1,4 +1,4 @@ -package com.bruce.sams.controller.sys; +package com.bruce.sams.controller; import com.bruce.sams.domain.entity.LoginRequest; import com.bruce.sams.service.AuthService; diff --git a/src/main/java/com/bruce/sams/controller/sys/UserController.java b/src/main/java/com/bruce/sams/controller/UserController.java similarity index 95% rename from src/main/java/com/bruce/sams/controller/sys/UserController.java rename to src/main/java/com/bruce/sams/controller/UserController.java index e3c22d89..6f08f367 100644 --- a/src/main/java/com/bruce/sams/controller/sys/UserController.java +++ b/src/main/java/com/bruce/sams/controller/UserController.java @@ -1,4 +1,4 @@ -package com.bruce.sams.controller.sys; +package com.bruce.sams.controller; import com.bruce.sams.domain.sys.User; import com.bruce.sams.utils.AjaxResult; @@ -20,7 +20,7 @@ public class UserController { /** * 批量导入用户 - * todo 准备引入Excel导入机制 + * * @param users 用户列表 * @return 操作结果 */ diff --git a/src/main/java/com/bruce/sams/controller/sys/UserProfileController.java b/src/main/java/com/bruce/sams/controller/UserProfileController.java similarity index 86% rename from src/main/java/com/bruce/sams/controller/sys/UserProfileController.java rename to src/main/java/com/bruce/sams/controller/UserProfileController.java index 84b3670d..77b53c83 100644 --- a/src/main/java/com/bruce/sams/controller/sys/UserProfileController.java +++ b/src/main/java/com/bruce/sams/controller/UserProfileController.java @@ -1,4 +1,4 @@ -package com.bruce.sams.controller.sys; +package com.bruce.sams.controller; import com.bruce.sams.domain.sys.User; import com.bruce.sams.utils.AjaxResult; @@ -18,10 +18,6 @@ public class UserProfileController { /** * 修改密码 - * - * @param userId - * @param oldPassword - * @param newPassword */ @PutMapping("/change-password") public AjaxResult changePassword(@RequestAttribute Long userId, @@ -33,10 +29,6 @@ public class UserProfileController { /** * 修改个人信息 - * - * @param userId - * @param user - * @return */ @PutMapping("/update") public AjaxResult updateProfile(@RequestAttribute Long userId, @RequestBody User user) { diff --git a/src/main/java/com/bruce/sams/controller/sms/ClubController.java b/src/main/java/com/bruce/sams/controller/sms/ClubController.java deleted file mode 100644 index 6a94236e..00000000 --- a/src/main/java/com/bruce/sams/controller/sms/ClubController.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.bruce.sams.controller.sms; - - -import com.bruce.sams.utils.AjaxResult; -import com.bruce.sams.domain.sms.Club; -import com.bruce.sams.service.ClubService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -/** - * 社团管理控制器 - */ -@RestController -@RequestMapping("/api/club") -public class ClubController { - - @Autowired - private ClubService clubService; - - @GetMapping("/list") - public AjaxResult getAllClubs() { - return AjaxResult.success("查询成功", clubService.getAllClubs()); - } - - @GetMapping("/{clubId}") - public AjaxResult getClubById(@PathVariable Long clubId) { - return AjaxResult.success("查询成功", clubService.getClubById(clubId)); - } - - @PostMapping("/add") - public AjaxResult addClub(@RequestBody Club club) { - clubService.addClub(club); - return AjaxResult.success("社团添加成功"); - } - - @PutMapping("/update") - public AjaxResult updateClub(@RequestBody Club club) { - clubService.updateClub(club); - return AjaxResult.success("社团信息更新成功"); - } - - @DeleteMapping("/delete/{clubId}") - public AjaxResult deleteClub(@PathVariable Long clubId) { - clubService.deleteClub(clubId); - return AjaxResult.success("社团删除成功"); - } - - @PostMapping("/join/{clubId}") - public AjaxResult joinClub(@RequestAttribute Long userId, @PathVariable Long clubId) { - clubService.joinClub(userId, clubId); - return AjaxResult.success("加入社团成功"); - } - - @DeleteMapping("/leave/{clubId}") - public AjaxResult leaveClub(@RequestAttribute Long userId, @PathVariable Long clubId) { - clubService.leaveClub(userId, clubId); - return AjaxResult.success("退出社团成功"); - } - - @GetMapping("/{clubId}/members") - public AjaxResult getClubMembers(@PathVariable Long clubId) { - return AjaxResult.success("查询成功", clubService.getClubMembers(clubId)); - } -} diff --git a/src/main/java/com/bruce/sams/controller/sms/CollegeController.java b/src/main/java/com/bruce/sams/controller/sms/CollegeController.java deleted file mode 100644 index ceb9e994..00000000 --- a/src/main/java/com/bruce/sams/controller/sms/CollegeController.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.bruce.sams.controller.sms; - -import com.bruce.sams.domain.sms.CollegeLeader; -import com.bruce.sams.utils.AjaxResult; -import com.bruce.sams.domain.sms.College; -import com.bruce.sams.service.CollegeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 高校院系管理控制器 - */ -@RestController -@RequestMapping("/api/admin/college") -public class CollegeController { - - @Autowired - private CollegeService collegeService; - - /** - * 获取所有高校 - */ - @GetMapping("/universities") - public AjaxResult getAllUniversities() { - List universities = collegeService.getAllUniversities(); - return AjaxResult.success("查询成功", universities); - } - - /** - * 获取某高校的所有院系 - */ - @GetMapping("/{universityId}/departments") - public AjaxResult getDepartments(@PathVariable Long universityId) { - List departments = collegeService.getDepartmentsByUniversity(universityId); - return AjaxResult.success("查询成功", departments); - } - - /** - * 获取某院系的详细信息 - */ - @GetMapping("/{collegeId}") - public AjaxResult getCollegeById(@PathVariable Long collegeId) { - College college = collegeService.getCollegeById(collegeId); - return college != null ? AjaxResult.success("查询成功", college) : AjaxResult.error("院系不存在"); - } - - /** - * 添加高校或院系 - */ - @PostMapping("/add") - public AjaxResult addCollege(@RequestBody College college) { - collegeService.addCollege(college); - return AjaxResult.success("添加成功"); - } - - /** - * 更新高校或院系信息 - */ - @PutMapping("/update") - public AjaxResult updateCollege(@RequestBody College college) { - collegeService.updateCollege(college); - return AjaxResult.success("更新成功"); - } - - /** - * 删除高校或院系 - */ - @DeleteMapping("/delete/{collegeId}") - public AjaxResult deleteCollege(@PathVariable Long collegeId) { - collegeService.deleteCollege(collegeId); - return AjaxResult.success("删除成功"); - } - - /** - * 查询高校/院系负责人 - */ - @GetMapping("/{collegeId}") - public AjaxResult getCollegeLeader(@PathVariable Long collegeId) { - CollegeLeader leader = collegeService.getCollegeLeader(collegeId); - return leader != null ? AjaxResult.success("查询成功", leader) : AjaxResult.error("未找到负责人"); - } - - /** - * 指派负责人 - */ - @PostMapping("/assign") - public AjaxResult assignLeader(@RequestAttribute Long adminUserId, - @RequestParam Long collegeId, - @RequestParam Long userId) { - collegeService.assignLeader(collegeId, userId, adminUserId); - return AjaxResult.success("指派成功"); - } - - /** - * 移除负责人 - */ - @DeleteMapping("/remove/{collegeId}") - public AjaxResult removeLeader(@RequestAttribute Long adminUserId, @PathVariable Long collegeId) { - collegeService.removeLeader(collegeId, adminUserId); - return AjaxResult.success("负责人移除成功"); - } -} diff --git a/src/main/java/com/bruce/sams/domain/ams/Activity.java b/src/main/java/com/bruce/sams/domain/ams/Activity.java deleted file mode 100644 index b1729f61..00000000 --- a/src/main/java/com/bruce/sams/domain/ams/Activity.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.bruce.sams.domain.ams; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.math.BigDecimal; -import java.util.Date; -import lombok.Data; - -/** - * 活动表 - * @TableName ams_activity - */ -@TableName(value ="ams_activity") -@Data -public class Activity { - /** - * 活动ID - */ - @TableId(type = IdType.AUTO) - private Long actId; - - /** - * 活动标题 - */ - private String title; - - /** - * 活动描述 - */ - private String description; - - /** - * 开始时间 - */ - private Date startTime; - - /** - * 结束时间 - */ - private Date endTime; - - /** - * 地点 - */ - private String location; - - /** - * 预算 - */ - private BigDecimal budget; - - /** - * 最大参与人数 - */ - private Integer maxParticipants; - - /** - * 创建者ID - */ - private Long creatorId; - - /** - * 所属院系ID - */ - private Long collegeId; - - /** - * 所属社团ID - */ - private Long clubId; - - /** - * 是否公开 - */ - private Object visibility; - - /** - * 活动状态 - */ - private Object status; - - /** - * 创建时间 - */ - private Date createdAt; - - /** - * 最后更新时间 - */ - private Date updatedAt; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - Activity other = (Activity) that; - return (this.getActId() == null ? other.getActId() == null : this.getActId().equals(other.getActId())) - && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle())) - && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription())) - && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime())) - && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime())) - && (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation())) - && (this.getBudget() == null ? other.getBudget() == null : this.getBudget().equals(other.getBudget())) - && (this.getMaxParticipants() == null ? other.getMaxParticipants() == null : this.getMaxParticipants().equals(other.getMaxParticipants())) - && (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId())) - && (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId())) - && (this.getClubId() == null ? other.getClubId() == null : this.getClubId().equals(other.getClubId())) - && (this.getVisibility() == null ? other.getVisibility() == null : this.getVisibility().equals(other.getVisibility())) - && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) - && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())) - && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getActId() == null) ? 0 : getActId().hashCode()); - result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode()); - result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode()); - result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode()); - result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode()); - result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode()); - result = prime * result + ((getBudget() == null) ? 0 : getBudget().hashCode()); - result = prime * result + ((getMaxParticipants() == null) ? 0 : getMaxParticipants().hashCode()); - result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode()); - result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode()); - result = prime * result + ((getClubId() == null) ? 0 : getClubId().hashCode()); - result = prime * result + ((getVisibility() == null) ? 0 : getVisibility().hashCode()); - result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); - result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); - result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode()); - return result; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getClass().getSimpleName()); - sb.append(" ["); - sb.append("Hash = ").append(hashCode()); - sb.append(", actId=").append(actId); - sb.append(", title=").append(title); - sb.append(", description=").append(description); - sb.append(", startTime=").append(startTime); - sb.append(", endTime=").append(endTime); - sb.append(", location=").append(location); - sb.append(", budget=").append(budget); - sb.append(", maxParticipants=").append(maxParticipants); - sb.append(", creatorId=").append(creatorId); - sb.append(", collegeId=").append(collegeId); - sb.append(", clubId=").append(clubId); - sb.append(", visibility=").append(visibility); - sb.append(", status=").append(status); - sb.append(", createdAt=").append(createdAt); - sb.append(", updatedAt=").append(updatedAt); - sb.append("]"); - return sb.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/ams/Approval.java b/src/main/java/com/bruce/sams/domain/ams/Approval.java deleted file mode 100644 index eaa4a0cd..00000000 --- a/src/main/java/com/bruce/sams/domain/ams/Approval.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.bruce.sams.domain.ams; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 活动审批表 - * @TableName ams_approval - */ -@TableName(value ="ams_approval") -@Data -public class Approval { - /** - * 审批ID - */ - @TableId(type = IdType.AUTO) - private Long apprId; - - /** - * 活动ID - */ - private Long actId; - - /** - * 发起者ID - */ - private Long userId; - - /** - * 审批人ID - */ - private Long approverId; - - /** - * 审批状态 (0: 待审批, 1: 通过, 2: 拒绝) - */ - private Integer status; - - /** - * 拒绝原因(如果适用) - */ - private String reason; - - /** - * 审批时间 - */ - private Date approvedAt; - - /** - * 创建时间 - */ - private Date createdAt; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - Approval other = (Approval) that; - return (this.getApprId() == null ? other.getApprId() == null : this.getApprId().equals(other.getApprId())) - && (this.getActId() == null ? other.getActId() == null : this.getActId().equals(other.getActId())) - && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getApproverId() == null ? other.getApproverId() == null : this.getApproverId().equals(other.getApproverId())) - && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) - && (this.getReason() == null ? other.getReason() == null : this.getReason().equals(other.getReason())) - && (this.getApprovedAt() == null ? other.getApprovedAt() == null : this.getApprovedAt().equals(other.getApprovedAt())) - && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getApprId() == null) ? 0 : getApprId().hashCode()); - result = prime * result + ((getActId() == null) ? 0 : getActId().hashCode()); - result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getApproverId() == null) ? 0 : getApproverId().hashCode()); - result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); - result = prime * result + ((getReason() == null) ? 0 : getReason().hashCode()); - result = prime * result + ((getApprovedAt() == null) ? 0 : getApprovedAt().hashCode()); - result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", apprId=" + apprId + - ", actId=" + actId + - ", userId=" + userId + - ", approverId=" + approverId + - ", status=" + status + - ", reason=" + reason + - ", approvedAt=" + approvedAt + - ", createdAt=" + createdAt + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/ams/Comment.java b/src/main/java/com/bruce/sams/domain/ams/Comment.java deleted file mode 100644 index b839e1d0..00000000 --- a/src/main/java/com/bruce/sams/domain/ams/Comment.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.bruce.sams.domain.ams; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 活动评论表 - * @TableName ams_comment - */ -@TableName(value ="ams_comment") -@Data -public class Comment { - /** - * 评论ID - */ - @TableId(type = IdType.AUTO) - private Long commentId; - - /** - * 用户ID - */ - private Long userId; - - /** - * 活动ID - */ - private Long actId; - - /** - * 父评论ID(为空表示是顶级评论) - */ - private Long parentCommentId; - - /** - * 评论内容 - */ - private String content; - - /** - * 评论时间 - */ - private Date createdAt; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - Comment other = (Comment) that; - return (this.getCommentId() == null ? other.getCommentId() == null : this.getCommentId().equals(other.getCommentId())) - && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getActId() == null ? other.getActId() == null : this.getActId().equals(other.getActId())) - && (this.getParentCommentId() == null ? other.getParentCommentId() == null : this.getParentCommentId().equals(other.getParentCommentId())) - && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent())) - && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getCommentId() == null) ? 0 : getCommentId().hashCode()); - result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getActId() == null) ? 0 : getActId().hashCode()); - result = prime * result + ((getParentCommentId() == null) ? 0 : getParentCommentId().hashCode()); - result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode()); - result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", commentId=" + commentId + - ", userId=" + userId + - ", actId=" + actId + - ", parentCommentId=" + parentCommentId + - ", content=" + content + - ", createdAt=" + createdAt + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/ams/Reaction.java b/src/main/java/com/bruce/sams/domain/ams/Reaction.java deleted file mode 100644 index 322c35fd..00000000 --- a/src/main/java/com/bruce/sams/domain/ams/Reaction.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.bruce.sams.domain.ams; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 活动点赞/点踩表 - * @TableName ams_reaction - */ -@TableName(value ="ams_reaction") -@Data -public class Reaction { - /** - * 点赞/点踩ID - */ - @TableId(type = IdType.AUTO) - private Long reactionId; - - /** - * 用户ID - */ - private Long userId; - - /** - * 活动ID - */ - private Long actId; - - /** - * 反应类型(like: 点赞, dislike: 点踩) - */ - private Object reactionType; - - /** - * 反应时间 - */ - private Date createdAt; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - Reaction other = (Reaction) that; - return (this.getReactionId() == null ? other.getReactionId() == null : this.getReactionId().equals(other.getReactionId())) - && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getActId() == null ? other.getActId() == null : this.getActId().equals(other.getActId())) - && (this.getReactionType() == null ? other.getReactionType() == null : this.getReactionType().equals(other.getReactionType())) - && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getReactionId() == null) ? 0 : getReactionId().hashCode()); - result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getActId() == null) ? 0 : getActId().hashCode()); - result = prime * result + ((getReactionType() == null) ? 0 : getReactionType().hashCode()); - result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", reactionId=" + reactionId + - ", userId=" + userId + - ", actId=" + actId + - ", reactionType=" + reactionType + - ", createdAt=" + createdAt + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/ams/Registration.java b/src/main/java/com/bruce/sams/domain/ams/Registration.java deleted file mode 100644 index f8b6659b..00000000 --- a/src/main/java/com/bruce/sams/domain/ams/Registration.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.bruce.sams.domain.ams; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 活动报名表 - * @TableName ams_registration - */ -@TableName(value ="ams_registration") -@Data -public class Registration { - /** - * 报名ID - */ - @TableId(type = IdType.AUTO) - private Long regId; - - /** - * 活动ID - */ - private Long actId; - - /** - * 用户ID - */ - private Long userId; - - /** - * 角色(organizer: 组织者, participant: 参与者) - */ - private Object role; - - /** - * 报名状态 - */ - private Object status; - - /** - * 报名时间 - */ - private Date registerTime; - - /** - * 参与时间 - */ - private Date attendTime; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - Registration other = (Registration) that; - return (this.getRegId() == null ? other.getRegId() == null : this.getRegId().equals(other.getRegId())) - && (this.getActId() == null ? other.getActId() == null : this.getActId().equals(other.getActId())) - && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getRole() == null ? other.getRole() == null : this.getRole().equals(other.getRole())) - && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) - && (this.getRegisterTime() == null ? other.getRegisterTime() == null : this.getRegisterTime().equals(other.getRegisterTime())) - && (this.getAttendTime() == null ? other.getAttendTime() == null : this.getAttendTime().equals(other.getAttendTime())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getRegId() == null) ? 0 : getRegId().hashCode()); - result = prime * result + ((getActId() == null) ? 0 : getActId().hashCode()); - result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getRole() == null) ? 0 : getRole().hashCode()); - result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); - result = prime * result + ((getRegisterTime() == null) ? 0 : getRegisterTime().hashCode()); - result = prime * result + ((getAttendTime() == null) ? 0 : getAttendTime().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", regId=" + regId + - ", actId=" + actId + - ", userId=" + userId + - ", role=" + role + - ", status=" + status + - ", registerTime=" + registerTime + - ", attendTime=" + attendTime + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/entity/LoginUser.java b/src/main/java/com/bruce/sams/domain/entity/LoginUser.java new file mode 100644 index 00000000..33ef4534 --- /dev/null +++ b/src/main/java/com/bruce/sams/domain/entity/LoginUser.java @@ -0,0 +1,56 @@ +package com.bruce.sams.domain.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LoginUser implements UserDetails { + + private Long userId; // 用户ID + private String username; // 用户名 + private String password; // 用户密码 + private List authorities; // 用户角色权限 + + @Override + public Collection getAuthorities() { + return authorities; + } + + @Override + public String getPassword() { + return password; + } + + @Override + public String getUsername() { + return username; + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } +} diff --git a/src/main/java/com/bruce/sams/domain/sms/Club.java b/src/main/java/com/bruce/sams/domain/sms/Club.java deleted file mode 100644 index 778c2832..00000000 --- a/src/main/java/com/bruce/sams/domain/sms/Club.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.bruce.sams.domain.sms; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 社团表 - * @TableName sms_club - */ -@TableName(value ="sms_club") -@Data -public class Club { - /** - * 社团ID - */ - @TableId(type = IdType.AUTO) - private Long clubId; - - /** - * 社团名称 - */ - private String clubName; - - /** - * 社团简介 - */ - private String description; - - /** - * 社团类型 - */ - private String category; - - /** - * 所属院系 - */ - private Long collegeId; - - /** - * 负责人ID - */ - private Long leaderId; - - /** - * 创建时间 - */ - private Date createdAt; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - Club other = (Club) that; - return (this.getClubId() == null ? other.getClubId() == null : this.getClubId().equals(other.getClubId())) - && (this.getClubName() == null ? other.getClubName() == null : this.getClubName().equals(other.getClubName())) - && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription())) - && (this.getCategory() == null ? other.getCategory() == null : this.getCategory().equals(other.getCategory())) - && (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId())) - && (this.getLeaderId() == null ? other.getLeaderId() == null : this.getLeaderId().equals(other.getLeaderId())) - && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getClubId() == null) ? 0 : getClubId().hashCode()); - result = prime * result + ((getClubName() == null) ? 0 : getClubName().hashCode()); - result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode()); - result = prime * result + ((getCategory() == null) ? 0 : getCategory().hashCode()); - result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode()); - result = prime * result + ((getLeaderId() == null) ? 0 : getLeaderId().hashCode()); - result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", clubId=" + clubId + - ", clubName=" + clubName + - ", description=" + description + - ", category=" + category + - ", collegeId=" + collegeId + - ", leaderId=" + leaderId + - ", createdAt=" + createdAt + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/sms/College.java b/src/main/java/com/bruce/sams/domain/sms/College.java deleted file mode 100644 index 09aaf5f6..00000000 --- a/src/main/java/com/bruce/sams/domain/sms/College.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.bruce.sams.domain.sms; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 高校及院系表 - * @TableName sms_college - */ -@TableName(value ="sms_college") -@Data -public class College { - /** - * 院系ID - */ - @TableId(type = IdType.AUTO) - private Long collegeId; - - /** - * 名称(高校或院系) - */ - private String collegeName; - - /** - * 父院系ID(高校此值为空) - */ - private Long parentId; - - /** - * 邮箱 - */ - private String email; - - /** - * 创建时间 - */ - private Date createdAt; - - /** - * 判断是否有上级单位 - * @return 有T无F - */ - public boolean hasParent() { - return parentId != null; - } - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - College other = (College) that; - return (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId())) - && (this.getCollegeName() == null ? other.getCollegeName() == null : this.getCollegeName().equals(other.getCollegeName())) - && (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId())) - && (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail())) - && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode()); - result = prime * result + ((getCollegeName() == null) ? 0 : getCollegeName().hashCode()); - result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode()); - result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode()); - result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", collegeId=" + collegeId + - ", collegeName=" + collegeName + - ", parentId=" + parentId + - ", email=" + email + - ", createdAt=" + createdAt + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/sms/CollegeLeader.java b/src/main/java/com/bruce/sams/domain/sms/CollegeLeader.java deleted file mode 100644 index b1330ce4..00000000 --- a/src/main/java/com/bruce/sams/domain/sms/CollegeLeader.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.bruce.sams.domain.sms; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 院系负责人表 - * @TableName sms_college_leader - */ -@TableName(value ="sms_college_leader") -@Data -public class CollegeLeader { - /** - * 院系ID - */ - @TableId - private Long collegeId; - - /** - * 负责人ID - */ - @TableId - private Long userId; - - /** - * 指派时间 - */ - private Date assignedAt; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - CollegeLeader other = (CollegeLeader) that; - return (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId())) - && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getAssignedAt() == null ? other.getAssignedAt() == null : this.getAssignedAt().equals(other.getAssignedAt())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode()); - result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getAssignedAt() == null) ? 0 : getAssignedAt().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", collegeId=" + collegeId + - ", userId=" + userId + - ", assignedAt=" + assignedAt + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/sms/UserClub.java b/src/main/java/com/bruce/sams/domain/sms/UserClub.java deleted file mode 100644 index 29304fb6..00000000 --- a/src/main/java/com/bruce/sams/domain/sms/UserClub.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.bruce.sams.domain.sms; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; -import lombok.Data; - -/** - * 用户社团关系表 - * @TableName sms_user_club - */ -@TableName(value ="sms_user_club") -@Data -public class UserClub { - /** - * ID - */ - @TableId(type = IdType.AUTO) - private Long sucId; - - /** - * 用户ID - */ - private Long userId; - - /** - * 社团ID - */ - private Long clubId; - - /** - * 角色ID - */ - private Long roleId; - - /** - * 是否活跃 - */ - private Integer isActive; - - /** - * 加入日期 - */ - private Date joinDate; - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - UserClub other = (UserClub) that; - return (this.getSucId() == null ? other.getSucId() == null : this.getSucId().equals(other.getSucId())) - && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getClubId() == null ? other.getClubId() == null : this.getClubId().equals(other.getClubId())) - && (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId())) - && (this.getIsActive() == null ? other.getIsActive() == null : this.getIsActive().equals(other.getIsActive())) - && (this.getJoinDate() == null ? other.getJoinDate() == null : this.getJoinDate().equals(other.getJoinDate())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getSucId() == null) ? 0 : getSucId().hashCode()); - result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getClubId() == null) ? 0 : getClubId().hashCode()); - result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); - result = prime * result + ((getIsActive() == null) ? 0 : getIsActive().hashCode()); - result = prime * result + ((getJoinDate() == null) ? 0 : getJoinDate().hashCode()); - return result; - } - - @Override - public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", sucId=" + sucId + - ", userId=" + userId + - ", clubId=" + clubId + - ", roleId=" + roleId + - ", isActive=" + isActive + - ", joinDate=" + joinDate + - "]"; - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/sys/Role.java b/src/main/java/com/bruce/sams/domain/sys/Role.java index 98045225..7c4d3913 100644 --- a/src/main/java/com/bruce/sams/domain/sys/Role.java +++ b/src/main/java/com/bruce/sams/domain/sys/Role.java @@ -71,14 +71,16 @@ public class Role { @Override public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", roleId=" + roleId + - ", roleName=" + roleName + - ", roleKey=" + roleKey + - ", roleDesc=" + roleDesc + - ", status=" + status + - "]"; + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", roleId=").append(roleId); + sb.append(", roleName=").append(roleName); + sb.append(", roleKey=").append(roleKey); + sb.append(", roleDesc=").append(roleDesc); + sb.append(", status=").append(status); + sb.append("]"); + return sb.toString(); } } \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/sys/User.java b/src/main/java/com/bruce/sams/domain/sys/User.java index 977dafc1..21ebaf6f 100644 --- a/src/main/java/com/bruce/sams/domain/sys/User.java +++ b/src/main/java/com/bruce/sams/domain/sys/User.java @@ -1,6 +1,7 @@ package com.bruce.sams.domain.sys; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -18,11 +19,6 @@ public class User { @TableId(type = IdType.AUTO) private Long userId; - /** - * 用户角色 - */ - private Long roleId; - /** * 用户昵称 */ @@ -76,7 +72,6 @@ public class User { } User other = (User) that; return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) - && (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId())) && (this.getNickName() == null ? other.getNickName() == null : this.getNickName().equals(other.getNickName())) && (this.getUserName() == null ? other.getUserName() == null : this.getUserName().equals(other.getUserName())) && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword())) @@ -92,7 +87,6 @@ public class User { final int prime = 31; int result = 1; result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); - result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); result = prime * result + ((getNickName() == null) ? 0 : getNickName().hashCode()); result = prime * result + ((getUserName() == null) ? 0 : getUserName().hashCode()); result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode()); @@ -106,19 +100,20 @@ public class User { @Override public String toString() { - return getClass().getSimpleName() + - " [" + - "Hash = " + hashCode() + - ", userId=" + userId + - ", roleId=" + roleId + - ", nickName=" + nickName + - ", userName=" + userName + - ", password=" + password + - ", schoolId=" + schoolId + - ", collegeId=" + collegeId + - ", email=" + email + - ", avatar=" + avatar + - ", status=" + status + - "]"; + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", userId=").append(userId); + sb.append(", nickName=").append(nickName); + sb.append(", userName=").append(userName); + sb.append(", password=").append(password); + sb.append(", schoolId=").append(schoolId); + sb.append(", collegeId=").append(collegeId); + sb.append(", email=").append(email); + sb.append(", avatar=").append(avatar); + sb.append(", status=").append(status); + sb.append("]"); + return sb.toString(); } } \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/domain/sys/UserRole.java b/src/main/java/com/bruce/sams/domain/sys/UserRole.java new file mode 100644 index 00000000..968d8397 --- /dev/null +++ b/src/main/java/com/bruce/sams/domain/sys/UserRole.java @@ -0,0 +1,64 @@ +package com.bruce.sams.domain.sys; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * 用户和角色关联表 + * @TableName sys_user_role + */ +@TableName(value ="sys_user_role") +@Data +public class UserRole { + /** + * 用户ID + */ + @TableId + private Long userId; + + /** + * 角色ID + */ + @TableId + private Long roleId; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + UserRole other = (UserRole) that; + return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", userId=").append(userId); + sb.append(", roleId=").append(roleId); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/mapper/ActivityMapper.java b/src/main/java/com/bruce/sams/mapper/ActivityMapper.java deleted file mode 100644 index b149bb9e..00000000 --- a/src/main/java/com/bruce/sams/mapper/ActivityMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.ams.Activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -/** -* @author bruce -* @description 针对表【ams_activity(活动表)】的数据库操作Mapper -* @createDate 2025-02-19 12:41:24 -* @Entity com.bruce.sams.domain.ams.Activity -*/ -@Mapper -public interface ActivityMapper extends BaseMapper { - - /** - * 获取某高校及下辖院系的活动(校级管理员) - */ - @Select("SELECT * FROM ams_activity WHERE college_id IN (SELECT college_id FROM sms_college WHERE parent_id = #{collegeId} OR college_id = #{collegeId})") - List getActivitiesByCollegeAndSubColleges(Long collegeId); - - /** - * 获取某院系的活动(院级管理员) - */ - @Select("SELECT * FROM ams_activity WHERE college_id = #{collegeId}") - List getActivitiesByCollege(Long collegeId); - - /** - * 获取某社团的活动(社团管理员) - */ - @Select("SELECT * FROM ams_activity WHERE club_id = #{clubId}") - List getActivitiesByClub(Long clubId); -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/ApprovalMapper.java b/src/main/java/com/bruce/sams/mapper/ApprovalMapper.java deleted file mode 100644 index ce09d9af..00000000 --- a/src/main/java/com/bruce/sams/mapper/ApprovalMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.ams.Approval; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author bruce -* @description 针对表【ams_approval(活动审批表)】的数据库操作Mapper -* @createDate 2025-02-19 11:22:24 -* @Entity com.bruce.sams.domain.ams.Approval -*/ -@Mapper -public interface ApprovalMapper extends BaseMapper { - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/ClubMapper.java b/src/main/java/com/bruce/sams/mapper/ClubMapper.java deleted file mode 100644 index e1b31839..00000000 --- a/src/main/java/com/bruce/sams/mapper/ClubMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.sms.Club; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author bruce -* @description 针对表【sms_club(社团表)】的数据库操作Mapper -* @createDate 2025-02-15 14:13:32 -* @Entity com.bruce.sams.domain.sms.Club -*/ -@Mapper -public interface ClubMapper extends BaseMapper { - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/CollegeLeaderMapper.java b/src/main/java/com/bruce/sams/mapper/CollegeLeaderMapper.java deleted file mode 100644 index bc893a1d..00000000 --- a/src/main/java/com/bruce/sams/mapper/CollegeLeaderMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.sms.CollegeLeader; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Delete; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -/** -* @author bruce -* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Mapper -* @createDate 2025-02-14 14:46:05 -* @Entity com.bruce.sams.domain.sms.CollegeLeader -*/ -@Mapper -public interface CollegeLeaderMapper extends BaseMapper { - /** - * 查询某个高校/院系的负责人 - */ - @Select("SELECT * FROM sms_college_leader WHERE college_id = #{collegeId}") - CollegeLeader findLeaderByCollegeId(Long collegeId); - - /** - * 查询某人负责的院系 - */ - @Select("SELECT * FROM sms_college_leader WHERE user_id = #{userId}") - CollegeLeader findCollegeByUser(Long userId); - - /** - * 移除某个高校/院系的负责人 - */ - @Delete("DELETE FROM sms_college_leader WHERE college_id = #{collegeId}") - void removeLeaderByCollegeId(Long collegeId); - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/CollegeMapper.java b/src/main/java/com/bruce/sams/mapper/CollegeMapper.java deleted file mode 100644 index 45483a3f..00000000 --- a/src/main/java/com/bruce/sams/mapper/CollegeMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.sms.College; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -/** -* @author bruce -* @description 针对表【sms_college(高校及院系表)】的数据库操作Mapper -* @createDate 2025-02-14 13:18:44 -* @Entity com.bruce.sams.domain.sms.College -*/ -@Mapper -public interface CollegeMapper extends BaseMapper { - /** - * 查询某个高校的所有院系 - */ - @Select("SELECT * FROM sms_college WHERE parent_id = #{collegeId}") - List findDepartmentsByUniversityId(Long collegeId); - - /** - * 获取所有高校 - */ - @Select("SELECT * FROM sms_college WHERE parent_id IS NULL") - List findAllUniversities(); - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/CommentMapper.java b/src/main/java/com/bruce/sams/mapper/CommentMapper.java deleted file mode 100644 index ef33adc4..00000000 --- a/src/main/java/com/bruce/sams/mapper/CommentMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.ams.Comment; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author bruce -* @description 针对表【ams_comment(活动评论表)】的数据库操作Mapper -* @createDate 2025-02-19 11:22:39 -* @Entity com.bruce.sams.domain.ams.Comment -*/ -@Mapper -public interface CommentMapper extends BaseMapper { - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/ReactionMapper.java b/src/main/java/com/bruce/sams/mapper/ReactionMapper.java deleted file mode 100644 index f071862d..00000000 --- a/src/main/java/com/bruce/sams/mapper/ReactionMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.ams.Reaction; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author bruce -* @description 针对表【ams_reaction(活动点赞/点踩表)】的数据库操作Mapper -* @createDate 2025-02-19 11:22:49 -* @Entity com.bruce.sams.domain.ams.Reaction -*/ -@Mapper -public interface ReactionMapper extends BaseMapper { - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/RegistrationMapper.java b/src/main/java/com/bruce/sams/mapper/RegistrationMapper.java deleted file mode 100644 index 8ea00890..00000000 --- a/src/main/java/com/bruce/sams/mapper/RegistrationMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.ams.Registration; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author bruce -* @description 针对表【ams_registration(活动报名表)】的数据库操作Mapper -* @createDate 2025-02-19 11:23:27 -* @Entity com.bruce.sams.domain.ams.Registration -*/ -@Mapper -public interface RegistrationMapper extends BaseMapper { - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/UserClubMapper.java b/src/main/java/com/bruce/sams/mapper/UserClubMapper.java deleted file mode 100644 index d73a10cb..00000000 --- a/src/main/java/com/bruce/sams/mapper/UserClubMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.bruce.sams.mapper; - -import com.bruce.sams.domain.sms.UserClub; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** -* @author bruce -* @description 针对表【sms_user_club(用户社团关系表)】的数据库操作Mapper -* @createDate 2025-02-15 15:00:18 -* @Entity com.bruce.sams.domain.sms.UserClub -*/ -@Mapper -public interface UserClubMapper extends BaseMapper { - -} - - - - diff --git a/src/main/java/com/bruce/sams/mapper/UserMapper.java b/src/main/java/com/bruce/sams/mapper/UserMapper.java index 2caefb0f..37490e65 100644 --- a/src/main/java/com/bruce/sams/mapper/UserMapper.java +++ b/src/main/java/com/bruce/sams/mapper/UserMapper.java @@ -3,8 +3,11 @@ package com.bruce.sams.mapper; import com.bruce.sams.domain.sys.User; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import java.util.List; + @Mapper public interface UserMapper extends BaseMapper { @@ -19,6 +22,12 @@ public interface UserMapper extends BaseMapper { // 通过邮箱查询用户 @Select("SELECT * FROM sys_user WHERE email = #{identifier}") User findByEmail(String identifier); + + @Select("SELECT r.role_key FROM sys_role r " + + "JOIN sys_user_role ur ON r.role_id = ur.role_id " + + "WHERE ur.user_id = #{userId}") + List findRolesByUserId(@Param("userId") Long userId); + } diff --git a/src/main/java/com/bruce/sams/mapper/UserRoleMapper.java b/src/main/java/com/bruce/sams/mapper/UserRoleMapper.java new file mode 100644 index 00000000..eb4a10fa --- /dev/null +++ b/src/main/java/com/bruce/sams/mapper/UserRoleMapper.java @@ -0,0 +1,25 @@ +package com.bruce.sams.mapper; + +import com.bruce.sams.domain.sys.UserRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** +* @author bruce +* @description 针对表【sys_user_role(用户和角色关联表)】的数据库操作Mapper +* @createDate 2025-02-19 18:45:11 +* @Entity com.bruce.sams.domain.sys.UserRole +*/ +@Mapper +public interface UserRoleMapper extends BaseMapper { + + +} + + + + diff --git a/src/main/java/com/bruce/sams/service/ActivityService.java b/src/main/java/com/bruce/sams/service/ActivityService.java deleted file mode 100644 index 8376b816..00000000 --- a/src/main/java/com/bruce/sams/service/ActivityService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.ams.Activity; -import com.baomidou.mybatisplus.extension.service.IService; -import com.bruce.sams.domain.sys.User; - -import java.util.List; - -/** -* @author bruce -* @description 针对表【ams_activity(活动表)】的数据库操作Service -* @createDate 2025-02-19 12:41:24 -*/ -public interface ActivityService extends IService { - - /** - * 根据用户角色获取可以管理的活动 - * - * @param user 当前用户 - * @return 活动列表 - */ - List getActivitiesForCollegeOrClub(User user); - - - -} diff --git a/src/main/java/com/bruce/sams/service/ApprovalService.java b/src/main/java/com/bruce/sams/service/ApprovalService.java deleted file mode 100644 index 5658df44..00000000 --- a/src/main/java/com/bruce/sams/service/ApprovalService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.ams.Approval; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author bruce -* @description 针对表【ams_approval(活动审批表)】的数据库操作Service -* @createDate 2025-02-19 11:22:24 -*/ -public interface ApprovalService extends IService { - -} diff --git a/src/main/java/com/bruce/sams/service/AuthService.java b/src/main/java/com/bruce/sams/service/AuthService.java index 892e512c..be8a5f73 100644 --- a/src/main/java/com/bruce/sams/service/AuthService.java +++ b/src/main/java/com/bruce/sams/service/AuthService.java @@ -12,5 +12,5 @@ public interface AuthService { * @param loginRequest 登录请求体(包含 username / schoolId / email + password) * @return JWT 令牌(成功)或 null(失败) */ - String authenticate(LoginRequest loginRequest); + public String authenticate(LoginRequest loginRequest); } diff --git a/src/main/java/com/bruce/sams/service/ClubService.java b/src/main/java/com/bruce/sams/service/ClubService.java deleted file mode 100644 index ac9b4666..00000000 --- a/src/main/java/com/bruce/sams/service/ClubService.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.sms.Club; -import com.baomidou.mybatisplus.extension.service.IService; -import com.bruce.sams.domain.sms.UserClub; - -import java.util.List; - -/** -* @author bruce -* @description 针对表【sms_club(社团表)】的数据库操作Service -* @createDate 2025-02-15 14:13:32 -*/ -public interface ClubService extends IService { - - /** - * 获取所有社团 - */ - List getAllClubs(); - - /** - * 获取社团详情 - */ - Club getClubById(Long clubId); - - /** - * 添加社团 - */ - void addClub(Club club); - - /** - * 更新社团信息 - */ - void updateClub(Club club); - - /** - * 删除社团 - */ - void deleteClub(Long clubId); - - /** - * 加入社团 - */ - void joinClub(Long userId, Long clubId); - - /** - * 退出社团 - */ - void leaveClub(Long userId, Long clubId); - - /** - * 获取社团成员 - */ - List getClubMembers(Long clubId); -} diff --git a/src/main/java/com/bruce/sams/service/CollegeService.java b/src/main/java/com/bruce/sams/service/CollegeService.java deleted file mode 100644 index c5851f39..00000000 --- a/src/main/java/com/bruce/sams/service/CollegeService.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.sms.College; -import com.baomidou.mybatisplus.extension.service.IService; -import com.bruce.sams.domain.sms.CollegeLeader; - -import java.util.List; - -/** -* @author bruce -* @description 针对表【sms_college(高校及院系表)】的数据库操作Service -* @createDate 2025-02-14 13:18:44 -*/ -public interface CollegeService extends IService { - /** - * 查询所有高校 - */ - List getAllUniversities(); - - /** - * 查询某高校的所有院系 - */ - List getDepartmentsByUniversity(Long universityId); - - /** - * 查询院系详情 - */ - College getCollegeById(Long collegeId); - - /** - * 添加高校或院系 - */ - void addCollege(College college); - - /** - * 更新高校/院系信息 - */ - void updateCollege(College college); - - /** - * 删除高校/院系 - */ - void deleteCollege(Long collegeId); - - /** - * 查询高校/院系负责人 - */ - CollegeLeader getCollegeLeader(Long collegeId); - - /** - * 查询某人负责的院系 - */ - public CollegeLeader findCollegeByUser(Long userId); - - /** - * 指派高校/院系负责人(系统管理员 或 学校管理员) - */ - void assignLeader(Long collegeId, Long userId, Long adminUserId); - - /** - * 移除负责人 - */ - void removeLeader(Long collegeId, Long adminUserId); - -} diff --git a/src/main/java/com/bruce/sams/service/CommentService.java b/src/main/java/com/bruce/sams/service/CommentService.java deleted file mode 100644 index 37a3d4d2..00000000 --- a/src/main/java/com/bruce/sams/service/CommentService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.ams.Comment; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author bruce -* @description 针对表【ams_comment(活动评论表)】的数据库操作Service -* @createDate 2025-02-19 11:22:39 -*/ -public interface CommentService extends IService { - -} diff --git a/src/main/java/com/bruce/sams/service/ReactionService.java b/src/main/java/com/bruce/sams/service/ReactionService.java deleted file mode 100644 index 1edf8946..00000000 --- a/src/main/java/com/bruce/sams/service/ReactionService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.ams.Reaction; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author bruce -* @description 针对表【ams_reaction(活动点赞/点踩表)】的数据库操作Service -* @createDate 2025-02-19 11:22:50 -*/ -public interface ReactionService extends IService { - -} diff --git a/src/main/java/com/bruce/sams/service/RegistrationService.java b/src/main/java/com/bruce/sams/service/RegistrationService.java deleted file mode 100644 index c9a1c753..00000000 --- a/src/main/java/com/bruce/sams/service/RegistrationService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.bruce.sams.service; - -import com.bruce.sams.domain.ams.Registration; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author bruce -* @description 针对表【ams_registration(活动报名表)】的数据库操作Service -* @createDate 2025-02-19 11:23:27 -*/ -public interface RegistrationService extends IService { - -} diff --git a/src/main/java/com/bruce/sams/service/UserRoleService.java b/src/main/java/com/bruce/sams/service/UserRoleService.java new file mode 100644 index 00000000..0ac7be41 --- /dev/null +++ b/src/main/java/com/bruce/sams/service/UserRoleService.java @@ -0,0 +1,13 @@ +package com.bruce.sams.service; + +import com.bruce.sams.domain.sys.UserRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author bruce +* @description 针对表【sys_user_role(用户和角色关联表)】的数据库操作Service +* @createDate 2025-02-19 18:45:11 +*/ +public interface UserRoleService extends IService { + +} diff --git a/src/main/java/com/bruce/sams/service/impl/ActivityServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/ActivityServiceImpl.java deleted file mode 100644 index d8c32790..00000000 --- a/src/main/java/com/bruce/sams/service/impl/ActivityServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.domain.ams.Activity; -import com.bruce.sams.domain.sms.College; -import com.bruce.sams.domain.sms.CollegeLeader; -import com.bruce.sams.domain.sms.UserClub; -import com.bruce.sams.domain.sys.User; -import com.bruce.sams.exception.NoPermissionException; -import com.bruce.sams.mapper.UserClubMapper; -import com.bruce.sams.service.ActivityService; -import com.bruce.sams.mapper.ActivityMapper; -import com.bruce.sams.service.CollegeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** -* @author bruce -* @description 针对表【ams_activity(活动表)】的数据库操作Service实现 -* @createDate 2025-02-19 12:41:24 -*/ -@Service -public class ActivityServiceImpl extends ServiceImpl - implements ActivityService{ - @Autowired - private ActivityMapper activityMapper; - - @Autowired - private CollegeService collegeService; - - @Autowired - private UserClubMapper userClubMapper; - - /** - * 根据用户角色获取可以管理的活动 - * - * @param user 当前用户 - * @return 活动列表 - */ - @Override - public List getActivitiesForCollegeOrClub(User user) { - CollegeLeader collegeLeader = collegeService.findCollegeByUser(user.getUserId()); - - if (collegeLeader != null) { - // 如果是院级管理员 - College college = collegeService.getCollegeById(collegeLeader.getCollegeId()); - if (college.hasParent()) { - return activityMapper.getActivitiesByCollege(college.getCollegeId()); - } else { - // 如果是高校管理员 - return activityMapper.getActivitiesByCollegeAndSubColleges(college.getCollegeId()); - } - } else { - // 如果用户是社团管理员 - UserClub userClub = userClubMapper.selectOne(new LambdaQueryWrapper().eq(UserClub::getUserId, user.getUserId())); - if (userClub != null) { - return activityMapper.getActivitiesByClub(userClub.getClubId()); - } else { - throw new NoPermissionException("用户无权限查看该活动"); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/service/impl/ApprovalServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/ApprovalServiceImpl.java deleted file mode 100644 index 10d925fc..00000000 --- a/src/main/java/com/bruce/sams/service/impl/ApprovalServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.domain.ams.Approval; -import com.bruce.sams.service.ApprovalService; -import com.bruce.sams.mapper.ApprovalMapper; -import org.springframework.stereotype.Service; - -/** -* @author bruce -* @description 针对表【ams_approval(活动审批表)】的数据库操作Service实现 -* @createDate 2025-02-19 11:22:24 -*/ -@Service -public class ApprovalServiceImpl extends ServiceImpl - implements ApprovalService{ - -} - - - - diff --git a/src/main/java/com/bruce/sams/service/impl/AuthServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/AuthServiceImpl.java index 2d51418c..63e418aa 100644 --- a/src/main/java/com/bruce/sams/service/impl/AuthServiceImpl.java +++ b/src/main/java/com/bruce/sams/service/impl/AuthServiceImpl.java @@ -2,9 +2,9 @@ package com.bruce.sams.service.impl; import com.bruce.sams.domain.entity.LoginRequest; import com.bruce.sams.domain.sys.User; -import com.bruce.sams.exception.AccountDisabledException; -import com.bruce.sams.exception.PasswordIncorrectException; -import com.bruce.sams.exception.UserNotFoundException; +import com.bruce.sams.common.exception.AccountDisabledException; +import com.bruce.sams.common.exception.PasswordIncorrectException; +import com.bruce.sams.common.exception.UserNotFoundException; import com.bruce.sams.mapper.RoleMapper; import com.bruce.sams.mapper.UserMapper; import com.bruce.sams.service.AuthService; @@ -58,9 +58,6 @@ public class AuthServiceImpl implements AuthService { throw new AccountDisabledException(); } - // 获取角色信息 - String role = roleMapper.findByRoleId(user.getRoleId()).getRoleKey(); - // 生成 JWT 令牌 return TokenUtil.generateToken(user); } diff --git a/src/main/java/com/bruce/sams/service/impl/ClubServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/ClubServiceImpl.java deleted file mode 100644 index 6b5eeb45..00000000 --- a/src/main/java/com/bruce/sams/service/impl/ClubServiceImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.domain.sms.Club; -import com.bruce.sams.domain.sms.UserClub; -import com.bruce.sams.mapper.UserClubMapper; -import com.bruce.sams.service.ClubService; -import com.bruce.sams.mapper.ClubMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** -* @author bruce -* @description 针对表【sms_club(社团表)】的数据库操作Service实现 -* @createDate 2025-02-15 14:13:32 -*/ -@Service -public class ClubServiceImpl extends ServiceImpl - implements ClubService{ - @Autowired - private ClubMapper clubMapper; - - @Autowired - private UserClubMapper userClubMapper; - - /** - * 获取所有社团 - */ - public List getAllClubs() { - return clubMapper.selectList(null); - } - - /** - * 获取社团详情 - */ - public Club getClubById(Long clubId) { - return clubMapper.selectById(clubId); - } - - /** - * 添加社团 - */ - public void addClub(Club club) { - clubMapper.insert(club); - } - - /** - * 更新社团信息 - */ - public void updateClub(Club club) { - clubMapper.updateById(club); - } - - /** - * 删除社团 - */ - public void deleteClub(Long clubId) { - clubMapper.deleteById(clubId); - } - - /** - * 加入社团 - */ - public void joinClub(Long userId, Long clubId) { - UserClub userClub = new UserClub(); - userClub.setUserId(userId); - userClub.setClubId(clubId); - userClub.setRoleId(0L); // 普通成员 - userClub.setIsActive(1); - userClub.setJoinDate(new Date(System.currentTimeMillis())); - userClubMapper.insert(userClub); - } - - /** - * 退出社团 - */ - public void leaveClub(Long userId, Long clubId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(UserClub::getUserId, userId).eq(UserClub::getClubId, clubId); - userClubMapper.delete(wrapper); - } - - /** - * 获取社团成员 - */ - public List getClubMembers(Long clubId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(UserClub::getClubId, clubId); - return userClubMapper.selectList(wrapper); - } -} - - - - diff --git a/src/main/java/com/bruce/sams/service/impl/CollegeServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/CollegeServiceImpl.java deleted file mode 100644 index 8d483eaf..00000000 --- a/src/main/java/com/bruce/sams/service/impl/CollegeServiceImpl.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.common.constant.HttpStatus; -import com.bruce.sams.domain.sms.College; -import com.bruce.sams.domain.sms.CollegeLeader; -import com.bruce.sams.domain.sys.User; -import com.bruce.sams.exception.AccountDisabledException; -import com.bruce.sams.exception.CustomException; -import com.bruce.sams.exception.UserNotFoundException; -import com.bruce.sams.mapper.CollegeLeaderMapper; -import com.bruce.sams.mapper.UserMapper; -import com.bruce.sams.service.CollegeService; -import com.bruce.sams.mapper.CollegeMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -@Service -public class CollegeServiceImpl extends ServiceImpl - implements CollegeService{ - - @Autowired - private CollegeMapper collegeMapper; - - @Autowired - private CollegeLeaderMapper collegeLeaderMapper; - - @Autowired - private UserMapper userMapper; - - /** - * 查询所有高校 - */ - public List getAllUniversities() { - return collegeMapper.findAllUniversities(); - } - - /** - * 查询某高校的所有院系 - */ - public List getDepartmentsByUniversity(Long universityId) { - return collegeMapper.findDepartmentsByUniversityId(universityId); - } - - /** - * 查询院系详情 - */ - public College getCollegeById(Long collegeId) { - return collegeMapper.selectById(collegeId); - } - - /** - * 添加高校或院系 - */ - public void addCollege(College college) { - collegeMapper.insert(college); - } - - /** - * 更新高校/院系信息 - */ - public void updateCollege(College college) { - collegeMapper.updateById(college); - } - - /** - * 删除高校/院系 - */ - public void deleteCollege(Long collegeId) { - collegeMapper.deleteById(collegeId); - } - - /** - * 查询高校/院系负责人 - */ - @Override - public CollegeLeader getCollegeLeader(Long collegeId) { - return collegeLeaderMapper.findLeaderByCollegeId(collegeId); - } - - /** - * 查询某人负责的院系 - */ - @Override - public CollegeLeader findCollegeByUser(Long userId) { - return collegeLeaderMapper.findCollegeByUser(userId); - } - - /** - * 指派高校/院系负责人(系统管理员 或 学校管理员) - */ - @Override - public void assignLeader(Long collegeId, Long userId, Long adminUserId) { - // 查询用户是否存在 - User user = userMapper.selectById(userId); - if (user == null) { - throw new UserNotFoundException(); - } - - // 检查是否禁用 - if ("banned".equals(user.getStatus())) { - throw new AccountDisabledException(); - } - - // 检查指派权限(系统管理员只能指派学校管理员,学校管理员只能指派学院管理员) - User adminUser = userMapper.selectById(adminUserId); - if (adminUser == null || adminUser.getRoleId() > 1) { // roleId=0 为系统管理员,roleId=1 为学校管理员 - throw new CustomException(HttpStatus.FORBIDDEN, "无权指派负责人"); - } - - // 如果已存在负责人,先移除 - collegeLeaderMapper.removeLeaderByCollegeId(collegeId); - - // 指派新负责人 - CollegeLeader leader = new CollegeLeader(); - leader.setCollegeId(collegeId); - leader.setUserId(userId); - leader.setAssignedAt(new Date()); - - collegeLeaderMapper.insert(leader); - } - - /** - * 移除负责人 - */ - public void removeLeader(Long collegeId, Long adminUserId) { - User adminUser = userMapper.selectById(adminUserId); - if (adminUser == null || adminUser.getRoleId() > 1) { - throw new CustomException(HttpStatus.FORBIDDEN, "无权移除负责人"); - } - - collegeLeaderMapper.removeLeaderByCollegeId(collegeId); - } -} - - - - diff --git a/src/main/java/com/bruce/sams/service/impl/CommentServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/CommentServiceImpl.java deleted file mode 100644 index f9db1b63..00000000 --- a/src/main/java/com/bruce/sams/service/impl/CommentServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.domain.ams.Comment; -import com.bruce.sams.service.CommentService; -import com.bruce.sams.mapper.CommentMapper; -import org.springframework.stereotype.Service; - -/** -* @author bruce -* @description 针对表【ams_comment(活动评论表)】的数据库操作Service实现 -* @createDate 2025-02-19 11:22:39 -*/ -@Service -public class CommentServiceImpl extends ServiceImpl - implements CommentService{ - -} - - - - diff --git a/src/main/java/com/bruce/sams/service/impl/CustomUserDetailsService.java b/src/main/java/com/bruce/sams/service/impl/CustomUserDetailsService.java new file mode 100644 index 00000000..d6a5d5f1 --- /dev/null +++ b/src/main/java/com/bruce/sams/service/impl/CustomUserDetailsService.java @@ -0,0 +1,42 @@ +package com.bruce.sams.service.impl; + +import com.bruce.sams.domain.entity.LoginUser; +import com.bruce.sams.domain.sys.User; +import com.bruce.sams.mapper.UserMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class CustomUserDetailsService implements UserDetailsService { + + @Autowired + private UserMapper userMapper; + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + // 查询用户信息 + User user = userMapper.findByUsername(username); + if (user == null) { + throw new UsernameNotFoundException("用户不存在"); + } + + // 查询用户角色 + List roles = userMapper.findRolesByUserId(user.getUserId()); + + // 转换角色为 Spring Security 需要的格式 + List authorities = roles.stream() + .map(role -> new SimpleGrantedAuthority("ROLE_" + role)) + .collect(Collectors.toList()); + + // 返回 LoginUser,符合 Spring Security 的 UserDetails + return new LoginUser(user.getUserId(), user.getUserName(), user.getPassword(), authorities); + } +} \ No newline at end of file diff --git a/src/main/java/com/bruce/sams/service/impl/ReactionServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/ReactionServiceImpl.java deleted file mode 100644 index e779e3eb..00000000 --- a/src/main/java/com/bruce/sams/service/impl/ReactionServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.domain.ams.Reaction; -import com.bruce.sams.service.ReactionService; -import com.bruce.sams.mapper.ReactionMapper; -import org.springframework.stereotype.Service; - -/** -* @author bruce -* @description 针对表【ams_reaction(活动点赞/点踩表)】的数据库操作Service实现 -* @createDate 2025-02-19 11:22:49 -*/ -@Service -public class ReactionServiceImpl extends ServiceImpl - implements ReactionService{ - -} - - - - diff --git a/src/main/java/com/bruce/sams/service/impl/RegistrationServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/RegistrationServiceImpl.java deleted file mode 100644 index 9e65b21d..00000000 --- a/src/main/java/com/bruce/sams/service/impl/RegistrationServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.bruce.sams.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.bruce.sams.domain.ams.Registration; -import com.bruce.sams.service.RegistrationService; -import com.bruce.sams.mapper.RegistrationMapper; -import org.springframework.stereotype.Service; - -/** -* @author bruce -* @description 针对表【ams_registration(活动报名表)】的数据库操作Service实现 -* @createDate 2025-02-19 11:23:27 -*/ -@Service -public class RegistrationServiceImpl extends ServiceImpl - implements RegistrationService{ - -} - - - - diff --git a/src/main/java/com/bruce/sams/service/impl/UserRoleServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/UserRoleServiceImpl.java new file mode 100644 index 00000000..72ab5ea3 --- /dev/null +++ b/src/main/java/com/bruce/sams/service/impl/UserRoleServiceImpl.java @@ -0,0 +1,22 @@ +package com.bruce.sams.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bruce.sams.domain.sys.UserRole; +import com.bruce.sams.service.UserRoleService; +import com.bruce.sams.mapper.UserRoleMapper; +import org.springframework.stereotype.Service; + +/** +* @author bruce +* @description 针对表【sys_user_role(用户和角色关联表)】的数据库操作Service实现 +* @createDate 2025-02-19 18:45:11 +*/ +@Service +public class UserRoleServiceImpl extends ServiceImpl + implements UserRoleService{ + +} + + + + diff --git a/src/main/java/com/bruce/sams/service/impl/UserServiceImpl.java b/src/main/java/com/bruce/sams/service/impl/UserServiceImpl.java index 819957f3..837ef81b 100644 --- a/src/main/java/com/bruce/sams/service/impl/UserServiceImpl.java +++ b/src/main/java/com/bruce/sams/service/impl/UserServiceImpl.java @@ -3,8 +3,8 @@ package com.bruce.sams.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bruce.sams.domain.sys.User; -import com.bruce.sams.exception.PasswordIncorrectException; -import com.bruce.sams.exception.UserNotFoundException; +import com.bruce.sams.common.exception.PasswordIncorrectException; +import com.bruce.sams.common.exception.UserNotFoundException; import com.bruce.sams.mapper.UserMapper; import com.bruce.sams.service.UserService; import com.bruce.sams.utils.PasswordUtil; @@ -83,7 +83,7 @@ public class UserServiceImpl extends ServiceImpl // 验证旧密码 if (!PasswordUtil.matches(oldPassword, user.getPassword())) { - throw new PasswordIncorrectException("原密码错误"); + throw new PasswordIncorrectException(); } // 更新新密码(加密存储) @@ -92,10 +92,10 @@ public class UserServiceImpl extends ServiceImpl } /** - * 修改个人信息(昵称、邮箱、头像) + * 用户修改个人信息(昵称、邮箱、头像) * - * @param userId 用户ID - * @param updatedUser 用户提交的新信息 + * @param userId 用户ID(从 JWT 获取) + * @param updatedUser 用户提交的新信息(昵称、邮箱、头像) */ public void updateProfile(Long userId, User updatedUser) { User user = userMapper.selectById(userId); diff --git a/src/main/java/com/bruce/sams/utils/AjaxResult.java b/src/main/java/com/bruce/sams/utils/AjaxResult.java index bfe52c24..0baa2738 100644 --- a/src/main/java/com/bruce/sams/utils/AjaxResult.java +++ b/src/main/java/com/bruce/sams/utils/AjaxResult.java @@ -23,8 +23,19 @@ public class AjaxResult extends HashMap /** 数据对象 */ public static final String DATA_TAG = "data"; - public AjaxResult() {} + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResult() + { + } + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + */ public AjaxResult(int code, String msg) { super.put(CODE_TAG, code); diff --git a/src/main/java/com/bruce/sams/utils/TokenUtil.java b/src/main/java/com/bruce/sams/utils/TokenUtil.java index ffa76d2a..af3042b8 100644 --- a/src/main/java/com/bruce/sams/utils/TokenUtil.java +++ b/src/main/java/com/bruce/sams/utils/TokenUtil.java @@ -29,7 +29,6 @@ public class TokenUtil { */ public static String generateToken(User user) { HashMap claims = new HashMap<>(); - claims.put("role", user.getRoleId()); return Jwts.builder() .subject(String.valueOf(user.getUserId())) .claims(claims) diff --git a/src/main/resources/mapper/ActivityMapper.xml b/src/main/resources/mapper/ActivityMapper.xml deleted file mode 100644 index 8dfdc5a5..00000000 --- a/src/main/resources/mapper/ActivityMapper.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - act_id,title,description,start_time,end_time,location, - budget,max_participants,creator_id,college_id,club_id, - visibility,status,created_at,updated_at - - diff --git a/src/main/resources/mapper/ApprovalMapper.xml b/src/main/resources/mapper/ApprovalMapper.xml deleted file mode 100644 index 646aafed..00000000 --- a/src/main/resources/mapper/ApprovalMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - appr_id,act_id,user_id,approver_id,status,reason, - approved_at,created_at - - diff --git a/src/main/resources/mapper/ClubMapper.xml b/src/main/resources/mapper/ClubMapper.xml deleted file mode 100644 index ef4affcd..00000000 --- a/src/main/resources/mapper/ClubMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - club_id,club_name,description,category,college_id,leader_id, - created_at - - diff --git a/src/main/resources/mapper/CollegeLeaderMapper.xml b/src/main/resources/mapper/CollegeLeaderMapper.xml deleted file mode 100644 index cc67deb1..00000000 --- a/src/main/resources/mapper/CollegeLeaderMapper.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - college_id,user_id,assigned_at - - diff --git a/src/main/resources/mapper/CollegeMapper.xml b/src/main/resources/mapper/CollegeMapper.xml deleted file mode 100644 index 534e9c5b..00000000 --- a/src/main/resources/mapper/CollegeMapper.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - college_id,college_name,parent_id,email,created_at - - diff --git a/src/main/resources/mapper/CommentMapper.xml b/src/main/resources/mapper/CommentMapper.xml deleted file mode 100644 index f7094c72..00000000 --- a/src/main/resources/mapper/CommentMapper.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - comment_id,user_id,act_id,parent_comment_id,content,created_at - - diff --git a/src/main/resources/mapper/ReactionMapper.xml b/src/main/resources/mapper/ReactionMapper.xml deleted file mode 100644 index 19c3e1a0..00000000 --- a/src/main/resources/mapper/ReactionMapper.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - reaction_id,user_id,act_id,reaction_type,created_at - - diff --git a/src/main/resources/mapper/RegistrationMapper.xml b/src/main/resources/mapper/RegistrationMapper.xml deleted file mode 100644 index 16768d10..00000000 --- a/src/main/resources/mapper/RegistrationMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - reg_id,act_id,user_id,role,status,register_time, - attend_time - - diff --git a/src/main/resources/mapper/UserClubMapper.xml b/src/main/resources/mapper/UserClubMapper.xml deleted file mode 100644 index 273dc58d..00000000 --- a/src/main/resources/mapper/UserClubMapper.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - suc_id,user_id,club_id,role_id,is_active,join_date - - diff --git a/src/main/resources/mapper/UserRoleMapper.xml b/src/main/resources/mapper/UserRoleMapper.xml new file mode 100644 index 00000000..64a60c6f --- /dev/null +++ b/src/main/resources/mapper/UserRoleMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + user_id,role_id + +