v0.2.2 追补院系部分 建立社团部分
parent
c3040562e7
commit
ae69105536
|
|
@ -1,28 +0,0 @@
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.bruce.sams.common.config;
|
package com.bruce.sams.common.config;
|
||||||
|
|
||||||
import com.bruce.sams.common.security.JwtAuthFilter;
|
import com.bruce.sams.common.filter.JwtAuthFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.bruce.sams.common.security;
|
package com.bruce.sams.common.filter;
|
||||||
|
|
||||||
import com.bruce.sams.common.exception.CustomException;
|
import com.bruce.sams.common.exception.CustomException;
|
||||||
import com.bruce.sams.utils.AjaxResult;
|
import com.bruce.sams.common.utils.AjaxResult;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.bruce.sams.common.security;
|
package com.bruce.sams.common.filter;
|
||||||
|
|
||||||
import com.bruce.sams.service.impl.CustomUserDetailsService;
|
import com.bruce.sams.service.impl.CustomUserDetailsService;
|
||||||
import com.bruce.sams.utils.TokenUtil;
|
import com.bruce.sams.common.utils.TokenUtil;
|
||||||
import jakarta.servlet.FilterChain;
|
import jakarta.servlet.FilterChain;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
@ -51,8 +51,4 @@ public class JwtAuthFilter extends OncePerRequestFilter {
|
||||||
return new CustomUserDetailsService(); // 认证逻辑
|
return new CustomUserDetailsService(); // 认证逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DataPermissionEvaluator dataPermissionEvaluator() {
|
|
||||||
return new DataPermissionEvaluator(); // 注册数据权限控制器
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
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<String> 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; // 这里不做特殊处理
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.bruce.sams.utils;
|
package com.bruce.sams.common.utils;
|
||||||
|
|
||||||
import com.bruce.sams.common.constant.HttpStatus;
|
import com.bruce.sams.common.constant.HttpStatus;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.bruce.sams.utils;
|
package com.bruce.sams.common.utils;
|
||||||
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.bruce.sams.utils;
|
package com.bruce.sams.common.utils;
|
||||||
|
|
||||||
import com.bruce.sams.domain.sys.User;
|
import com.bruce.sams.domain.sys.User;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
|
|
@ -2,7 +2,7 @@ package com.bruce.sams.controller;
|
||||||
|
|
||||||
import com.bruce.sams.domain.entity.LoginRequest;
|
import com.bruce.sams.domain.entity.LoginRequest;
|
||||||
import com.bruce.sams.service.AuthService;
|
import com.bruce.sams.service.AuthService;
|
||||||
import com.bruce.sams.utils.AjaxResult;
|
import com.bruce.sams.common.utils.AjaxResult;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
package com.bruce.sams.controller;
|
|
||||||
|
|
||||||
import com.bruce.sams.domain.sys.User;
|
|
||||||
import com.bruce.sams.utils.AjaxResult;
|
|
||||||
import com.bruce.sams.service.UserService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户管理控制器(仅管理员可用)
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/admin/user")
|
|
||||||
public class UserController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量导入用户
|
|
||||||
*
|
|
||||||
* @param users 用户列表
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/import")
|
|
||||||
public AjaxResult importUsers(@RequestBody List<User> users) {
|
|
||||||
userService.importUsers(users);
|
|
||||||
return AjaxResult.success("用户导入成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户列表(可按学号、用户名、邮箱搜索)
|
|
||||||
*
|
|
||||||
* @param keyword 关键字(可选)
|
|
||||||
* @return 用户列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/list")
|
|
||||||
public AjaxResult listUsers(@RequestParam(required = false) String keyword) {
|
|
||||||
return AjaxResult.success("查询成功", userService.listUsers(keyword));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户信息(角色、状态、密码)
|
|
||||||
*
|
|
||||||
* @param user 用户对象
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
@PutMapping("/update")
|
|
||||||
public AjaxResult updateUser(@RequestBody User user) {
|
|
||||||
userService.updateUser(user);
|
|
||||||
return AjaxResult.success("用户信息更新成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除用户(逻辑删除)
|
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/delete/{userId}")
|
|
||||||
public AjaxResult deleteUser(@PathVariable Long userId) {
|
|
||||||
userService.deleteUser(userId);
|
|
||||||
return AjaxResult.success("用户删除成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
package com.bruce.sams.controller;
|
|
||||||
|
|
||||||
import com.bruce.sams.domain.sys.User;
|
|
||||||
import com.bruce.sams.utils.AjaxResult;
|
|
||||||
import com.bruce.sams.service.UserService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 普通用户修改个人信息控制器
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/user/profile")
|
|
||||||
public class UserProfileController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改密码
|
|
||||||
*/
|
|
||||||
@PutMapping("/change-password")
|
|
||||||
public AjaxResult changePassword(@RequestAttribute Long userId,
|
|
||||||
@RequestParam String oldPassword,
|
|
||||||
@RequestParam String newPassword) {
|
|
||||||
userService.changePassword(userId, oldPassword, newPassword);
|
|
||||||
return AjaxResult.success("密码修改成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改个人信息
|
|
||||||
*/
|
|
||||||
@PutMapping("/update")
|
|
||||||
public AjaxResult updateProfile(@RequestAttribute Long userId, @RequestBody User user) {
|
|
||||||
userService.updateProfile(userId, user);
|
|
||||||
return AjaxResult.success("个人信息更新成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,137 @@
|
||||||
|
package com.bruce.sams.controller.sms;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.College;
|
||||||
|
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||||
|
import com.bruce.sams.service.CollegeLeaderService;
|
||||||
|
import com.bruce.sams.service.CollegeService;
|
||||||
|
import com.bruce.sams.common.utils.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学院管理控制器(校级 & 院级权限分类)
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin/college")
|
||||||
|
public class CollegeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CollegeService collegeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CollegeLeaderService collegeLeaderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员:添加学院
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN')")
|
||||||
|
@PostMapping("/add")
|
||||||
|
public AjaxResult addCollege(@RequestBody College college) {
|
||||||
|
collegeService.addCollege(college);
|
||||||
|
return AjaxResult.success("学院添加成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员:更新学院信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN')")
|
||||||
|
@PutMapping("/update")
|
||||||
|
public AjaxResult updateCollege(@RequestBody College college) {
|
||||||
|
collegeService.updateCollege(college);
|
||||||
|
return AjaxResult.success("学院更新成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员:删除学院
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN')")
|
||||||
|
@DeleteMapping("/delete/{collegeId}")
|
||||||
|
public AjaxResult deleteCollege(@PathVariable Long collegeId) {
|
||||||
|
collegeService.deleteCollege(collegeId);
|
||||||
|
return AjaxResult.success("学院删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员:获取学院详情
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN')")
|
||||||
|
@GetMapping("/{collegeId}")
|
||||||
|
public AjaxResult getCollegeById(@PathVariable Long collegeId) {
|
||||||
|
return AjaxResult.success(collegeService.getCollegeById(collegeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 院级管理员:获取所属学院信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('DEPARTMENT_ADMIN')")
|
||||||
|
@GetMapping("/my-college")
|
||||||
|
public AjaxResult getMyCollege(@RequestParam Long userId) {
|
||||||
|
College myCollege = collegeService.getCollegeById(userId); // 这里可以改为通过 `userId` 查询学院
|
||||||
|
return AjaxResult.success(myCollege);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员 & 院级管理员:查询学院列表(校级查询所有,院级只能查自己的)
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN') or hasRole('DEPARTMENT_ADMIN')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult listColleges(@RequestParam(required = false) String keyword, @RequestParam Long userId) {
|
||||||
|
if (userHasRole("ADMIN") || userHasRole("COLLEGE_ADMIN")) {
|
||||||
|
return AjaxResult.success(collegeService.listColleges(keyword));
|
||||||
|
} else if (userHasRole("DEPARTMENT_ADMIN")) {
|
||||||
|
College myCollege = collegeService.getCollegeById(userId); // 查询自己所属学院
|
||||||
|
return AjaxResult.success(List.of(myCollege));
|
||||||
|
}
|
||||||
|
return AjaxResult.error("无权限");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员:指派学院负责人
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN')")
|
||||||
|
@PostMapping("/assign")
|
||||||
|
public AjaxResult assignLeader(@RequestParam Long collegeId, @RequestParam Long userId) {
|
||||||
|
collegeLeaderService.assignLeader(collegeId, userId);
|
||||||
|
return AjaxResult.success("负责人指派成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级管理员:移除学院负责人
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN')")
|
||||||
|
@DeleteMapping("/remove")
|
||||||
|
public AjaxResult removeLeader(@RequestParam Long collegeId, @RequestParam Long userId) {
|
||||||
|
collegeLeaderService.removeLeader(collegeId, userId);
|
||||||
|
return AjaxResult.success("负责人移除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校级 & 院级管理员:获取学院负责人
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasRole('ADMIN') or hasRole('COLLEGE_ADMIN') or hasRole('DEPARTMENT_ADMIN')")
|
||||||
|
@GetMapping("/{collegeId}")
|
||||||
|
public AjaxResult getLeader(@PathVariable Long collegeId, @RequestParam Long userId) {
|
||||||
|
if (userHasRole("ADMIN") || userHasRole("COLLEGE_ADMIN")) {
|
||||||
|
return AjaxResult.success(collegeLeaderService.getLeaderByCollegeId(collegeId));
|
||||||
|
} else if (userHasRole("DEPARTMENT_ADMIN")) {
|
||||||
|
CollegeLeader myLeader = collegeLeaderService.getLeaderByCollegeId(userId); // 只能查询自己学院的负责人
|
||||||
|
return AjaxResult.success(myLeader);
|
||||||
|
}
|
||||||
|
return AjaxResult.error("无权限");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前用户是否具有指定角色
|
||||||
|
*/
|
||||||
|
private boolean userHasRole(String role) {
|
||||||
|
return org.springframework.security.core.context.SecurityContextHolder.getContext()
|
||||||
|
.getAuthentication()
|
||||||
|
.getAuthorities()
|
||||||
|
.stream()
|
||||||
|
.anyMatch(auth -> auth.getAuthority().equals("ROLE_" + role));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.bruce.sams.controller.sys;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sys.User;
|
||||||
|
import com.bruce.sams.service.UserService;
|
||||||
|
import com.bruce.sams.common.utils.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端 - 用户管理控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin/user")
|
||||||
|
public class AdminUserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量导入用户
|
||||||
|
*
|
||||||
|
* @param users 用户列表
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@PostMapping("/import")
|
||||||
|
public AjaxResult importUsers(@RequestBody List<User> users) {
|
||||||
|
userService.importUsers(users);
|
||||||
|
return AjaxResult.success("用户导入成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户列表(支持关键字搜索)
|
||||||
|
*
|
||||||
|
* @param keyword 关键字(用户名、学号、邮箱)
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult listUsers(@RequestParam(required = false) String keyword) {
|
||||||
|
return AjaxResult.success(userService.listUsers(keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员更新用户信息(角色、状态、密码)
|
||||||
|
*
|
||||||
|
* @param user 用户对象
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@PutMapping("/update")
|
||||||
|
public AjaxResult updateUser(@RequestBody User user) {
|
||||||
|
userService.updateUser(user);
|
||||||
|
return AjaxResult.success("用户信息更新成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员重置用户密码(默认123456)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@PutMapping("/reset-password/{userId}")
|
||||||
|
public AjaxResult resetPassword(@PathVariable Long userId) {
|
||||||
|
userService.resetPassword(userId);
|
||||||
|
return AjaxResult.success("密码已重置为 123456");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员封禁用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@PutMapping("/ban/{userId}")
|
||||||
|
public AjaxResult banUser(@PathVariable Long userId) {
|
||||||
|
userService.banUser(userId);
|
||||||
|
return AjaxResult.success("用户已封禁");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员删除用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{userId}")
|
||||||
|
public AjaxResult deleteUser(@PathVariable Long userId) {
|
||||||
|
userService.deleteUser(userId);
|
||||||
|
return AjaxResult.success("用户已删除");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.bruce.sams.controller.sys;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sys.User;
|
||||||
|
import com.bruce.sams.service.UserService;
|
||||||
|
import com.bruce.sams.common.utils.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端 - 个人信息管理控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/user")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户修改密码
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param oldPassword 旧密码
|
||||||
|
* @param newPassword 新密码
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@PutMapping("/change-password")
|
||||||
|
public AjaxResult changePassword(@RequestParam Long userId, @RequestParam String oldPassword, @RequestParam String newPassword) {
|
||||||
|
userService.changePassword(userId, oldPassword, newPassword);
|
||||||
|
return AjaxResult.success("密码修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户修改个人信息(昵称、邮箱、头像)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param updatedUser 用户提交的新信息(昵称、邮箱、头像)
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@PutMapping("/profile")
|
||||||
|
public AjaxResult updateProfile(@RequestParam Long userId, @RequestBody User updatedUser) {
|
||||||
|
userService.updateProfile(userId, updatedUser);
|
||||||
|
return AjaxResult.success("个人信息更新成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户详情(查看个人信息)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return AjaxResult
|
||||||
|
*/
|
||||||
|
@GetMapping("/{userId}")
|
||||||
|
public AjaxResult getUserProfile(@PathVariable Long userId) {
|
||||||
|
return AjaxResult.success(userService.getUserProfile(userId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.bruce.sams.domain.sms;
|
||||||
|
|
||||||
|
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.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 Object 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() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", clubId=").append(clubId);
|
||||||
|
sb.append(", clubName=").append(clubName);
|
||||||
|
sb.append(", description=").append(description);
|
||||||
|
sb.append(", category=").append(category);
|
||||||
|
sb.append(", collegeId=").append(collegeId);
|
||||||
|
sb.append(", leaderId=").append(leaderId);
|
||||||
|
sb.append(", createdAt=").append(createdAt);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.bruce.sams.domain.sms;
|
||||||
|
|
||||||
|
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.util.Date;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社团用户关系表
|
||||||
|
* @TableName sms_club_user
|
||||||
|
*/
|
||||||
|
@TableName(value ="sms_club_user")
|
||||||
|
@Data
|
||||||
|
public class ClubUser {
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
ClubUser other = (ClubUser) 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() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", sucId=").append(sucId);
|
||||||
|
sb.append(", userId=").append(userId);
|
||||||
|
sb.append(", clubId=").append(clubId);
|
||||||
|
sb.append(", roleId=").append(roleId);
|
||||||
|
sb.append(", isActive=").append(isActive);
|
||||||
|
sb.append(", joinDate=").append(joinDate);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.bruce.sams.domain.sms;
|
||||||
|
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
@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() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", collegeId=").append(collegeId);
|
||||||
|
sb.append(", collegeName=").append(collegeName);
|
||||||
|
sb.append(", parentId=").append(parentId);
|
||||||
|
sb.append(", email=").append(email);
|
||||||
|
sb.append(", createdAt=").append(createdAt);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.bruce.sams.domain.sms;
|
||||||
|
|
||||||
|
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.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() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", collegeId=").append(collegeId);
|
||||||
|
sb.append(", userId=").append(userId);
|
||||||
|
sb.append(", assignedAt=").append(assignedAt);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.bruce.sams.mapper;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.Club;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_club(社团表)】的数据库操作Mapper
|
||||||
|
* @createDate 2025-02-19 20:18:22
|
||||||
|
* @Entity com.bruce.sams.domain.sms.Club
|
||||||
|
*/
|
||||||
|
public interface ClubMapper extends BaseMapper<Club> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.bruce.sams.mapper;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.ClubUser;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_club_user(社团用户关系表)】的数据库操作Mapper
|
||||||
|
* @createDate 2025-02-19 20:18:31
|
||||||
|
* @Entity com.bruce.sams.domain.sms.ClubUser
|
||||||
|
*/
|
||||||
|
public interface ClubUserMapper extends BaseMapper<ClubUser> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.bruce.sams.mapper;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Mapper
|
||||||
|
* @createDate 2025-02-19 20:18:55
|
||||||
|
* @Entity com.bruce.sams.domain.sms.CollegeLeader
|
||||||
|
*/
|
||||||
|
public interface CollegeLeaderMapper extends BaseMapper<CollegeLeader> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.bruce.sams.mapper;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.College;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_college(高校及院系表)】的数据库操作Mapper
|
||||||
|
* @createDate 2025-02-19 20:18:40
|
||||||
|
* @Entity com.bruce.sams.domain.sms.College
|
||||||
|
*/
|
||||||
|
public interface CollegeMapper extends BaseMapper<College> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -28,6 +29,17 @@ public interface UserMapper extends BaseMapper<User> {
|
||||||
"WHERE ur.user_id = #{userId}")
|
"WHERE ur.user_id = #{userId}")
|
||||||
List<String> findRolesByUserId(@Param("userId") Long userId);
|
List<String> findRolesByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
@Update("UPDATE sys_user SET nick_name = #{nickName}, email = #{email} WHERE user_id = #{userId}")
|
||||||
|
void updateUser(@Param("userId") Long userId, @Param("nickName") String nickName, @Param("email") String email);
|
||||||
|
|
||||||
|
@Update("UPDATE sys_user SET password = #{password} WHERE user_id = #{userId}")
|
||||||
|
void updatePassword(@Param("userId") Long userId, @Param("password") String password);
|
||||||
|
|
||||||
|
@Update("UPDATE sys_user SET status = #{status} WHERE user_id = #{userId}")
|
||||||
|
void updateStatus(@Param("userId") Long userId, @Param("status") String status);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM sys_user WHERE user_id = #{userId}")
|
||||||
|
User getUserById(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.bruce.sams.service;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.Club;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_club(社团表)】的数据库操作Service
|
||||||
|
* @createDate 2025-02-19 20:18:22
|
||||||
|
*/
|
||||||
|
public interface ClubService extends IService<Club> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.bruce.sams.service;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.ClubUser;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_club_user(社团用户关系表)】的数据库操作Service
|
||||||
|
* @createDate 2025-02-19 20:18:31
|
||||||
|
*/
|
||||||
|
public interface ClubUserService extends IService<ClubUser> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.bruce.sams.service;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Service
|
||||||
|
* @createDate 2025-02-19 20:18:55
|
||||||
|
*/
|
||||||
|
public interface CollegeLeaderService extends IService<CollegeLeader> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指派学院负责人
|
||||||
|
*
|
||||||
|
* @param collegeId 学院ID
|
||||||
|
* @param userId 负责人用户ID
|
||||||
|
*/
|
||||||
|
void assignLeader(Long collegeId, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除学院负责人
|
||||||
|
*
|
||||||
|
* @param collegeId 学院ID
|
||||||
|
* @param userId 负责人用户ID
|
||||||
|
*/
|
||||||
|
void removeLeader(Long collegeId, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据学院ID获取负责人
|
||||||
|
*
|
||||||
|
* @param collegeId 学院ID
|
||||||
|
* @return 负责人对象
|
||||||
|
*/
|
||||||
|
CollegeLeader getLeaderByCollegeId(Long collegeId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.bruce.sams.service;
|
||||||
|
|
||||||
|
import com.bruce.sams.domain.sms.College;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_college(高校及院系表)】的数据库操作Service
|
||||||
|
* @createDate 2025-02-19 20:18:40
|
||||||
|
*/
|
||||||
|
public interface CollegeService extends IService<College> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加学院
|
||||||
|
*
|
||||||
|
* @param college 学院对象
|
||||||
|
*/
|
||||||
|
void addCollege(College college);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新学院信息
|
||||||
|
*
|
||||||
|
* @param college 学院对象
|
||||||
|
*/
|
||||||
|
void updateCollege(College college);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除学院
|
||||||
|
*
|
||||||
|
* @param collegeId 学院ID
|
||||||
|
*/
|
||||||
|
void deleteCollege(Long collegeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取学院详情
|
||||||
|
*
|
||||||
|
* @param collegeId 学院ID
|
||||||
|
* @return 学院对象
|
||||||
|
*/
|
||||||
|
College getCollegeById(Long collegeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询学院列表(支持关键字搜索)
|
||||||
|
*
|
||||||
|
* @param keyword 关键字(学院名称)
|
||||||
|
* @return 学院列表
|
||||||
|
*/
|
||||||
|
List<College> listColleges(String keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -28,6 +28,28 @@ public interface UserService {
|
||||||
*/
|
*/
|
||||||
void updateUser(User user);
|
void updateUser(User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员重置用户密码(管理端)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
*/
|
||||||
|
void resetPassword(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封禁用户(管理端)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
*/
|
||||||
|
void banUser(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户详情(用户端)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户信息
|
||||||
|
*/
|
||||||
|
User getUserProfile(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户修改密码
|
* 用户修改密码
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import com.bruce.sams.common.exception.UserNotFoundException;
|
||||||
import com.bruce.sams.mapper.RoleMapper;
|
import com.bruce.sams.mapper.RoleMapper;
|
||||||
import com.bruce.sams.mapper.UserMapper;
|
import com.bruce.sams.mapper.UserMapper;
|
||||||
import com.bruce.sams.service.AuthService;
|
import com.bruce.sams.service.AuthService;
|
||||||
import com.bruce.sams.utils.PasswordUtil;
|
import com.bruce.sams.common.utils.PasswordUtil;
|
||||||
import com.bruce.sams.utils.TokenUtil;
|
import com.bruce.sams.common.utils.TokenUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bruce.sams.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bruce.sams.domain.sms.Club;
|
||||||
|
import com.bruce.sams.service.ClubService;
|
||||||
|
import com.bruce.sams.mapper.ClubMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_club(社团表)】的数据库操作Service实现
|
||||||
|
* @createDate 2025-02-19 20:18:22
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ClubServiceImpl extends ServiceImpl<ClubMapper, Club>
|
||||||
|
implements ClubService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bruce.sams.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bruce.sams.domain.sms.ClubUser;
|
||||||
|
import com.bruce.sams.service.ClubUserService;
|
||||||
|
import com.bruce.sams.mapper.ClubUserMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_club_user(社团用户关系表)】的数据库操作Service实现
|
||||||
|
* @createDate 2025-02-19 20:18:31
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ClubUserServiceImpl extends ServiceImpl<ClubUserMapper, ClubUser>
|
||||||
|
implements ClubUserService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.bruce.sams.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||||
|
import com.bruce.sams.service.CollegeLeaderService;
|
||||||
|
import com.bruce.sams.mapper.CollegeLeaderMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Service实现
|
||||||
|
* @createDate 2025-02-19 20:18:55
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CollegeLeaderServiceImpl extends ServiceImpl<CollegeLeaderMapper, CollegeLeader> implements CollegeLeaderService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指派学院负责人
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void assignLeader(Long collegeId, Long userId) {
|
||||||
|
CollegeLeader leader = new CollegeLeader();
|
||||||
|
leader.setCollegeId(collegeId);
|
||||||
|
leader.setUserId(userId);
|
||||||
|
leader.setAssignedAt(new Date(System.currentTimeMillis())); // 记录指派时间
|
||||||
|
|
||||||
|
this.save(leader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除学院负责人
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeLeader(Long collegeId, Long userId) {
|
||||||
|
this.removeById(collegeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据学院ID获取负责人
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CollegeLeader getLeaderByCollegeId(Long collegeId) {
|
||||||
|
return this.getById(collegeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
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.College;
|
||||||
|
import com.bruce.sams.service.CollegeService;
|
||||||
|
import com.bruce.sams.mapper.CollegeMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bruce
|
||||||
|
* @description 针对表【sms_college(高校及院系表)】的数据库操作Service实现
|
||||||
|
* @createDate 2025-02-19 20:18:40
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CollegeServiceImpl extends ServiceImpl<CollegeMapper, College> implements CollegeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加学院
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addCollege(College college) {
|
||||||
|
this.save(college);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新学院信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateCollege(College college) {
|
||||||
|
this.updateById(college);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除学院
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteCollege(Long collegeId) {
|
||||||
|
this.removeById(collegeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取学院详情
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public College getCollegeById(Long collegeId) {
|
||||||
|
return this.getById(collegeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询学院列表(支持关键字搜索)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<College> listColleges(String keyword) {
|
||||||
|
LambdaQueryWrapper<College> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyword != null && !keyword.isEmpty()) {
|
||||||
|
query.like(College::getCollegeName, keyword);
|
||||||
|
}
|
||||||
|
return this.list(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ import com.bruce.sams.common.exception.PasswordIncorrectException;
|
||||||
import com.bruce.sams.common.exception.UserNotFoundException;
|
import com.bruce.sams.common.exception.UserNotFoundException;
|
||||||
import com.bruce.sams.mapper.UserMapper;
|
import com.bruce.sams.mapper.UserMapper;
|
||||||
import com.bruce.sams.service.UserService;
|
import com.bruce.sams.service.UserService;
|
||||||
import com.bruce.sams.utils.PasswordUtil;
|
import com.bruce.sams.common.utils.PasswordUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -21,19 +21,21 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量导入用户
|
* 批量导入用户(管理端)
|
||||||
*
|
*
|
||||||
* @param users 用户列表
|
* @param users 用户列表
|
||||||
*/
|
*/
|
||||||
public void importUsers(List<User> users) {
|
public void importUsers(List<User> users) {
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
// 加密用户密码(默认密码123456)
|
// 检查用户是否存在
|
||||||
if (user.getPassword() == null || user.getPassword().isEmpty()) {
|
User existUser = userMapper.selectOne(
|
||||||
user.setPassword(PasswordUtil.encode("123456")); // 默认密码
|
new LambdaQueryWrapper<User>().eq(User::getSchoolId, user.getSchoolId()));
|
||||||
} else {
|
|
||||||
user.setPassword(PasswordUtil.encode(user.getPassword()));
|
if (existUser == null) {
|
||||||
|
// 加密默认密码 123456
|
||||||
|
user.setPassword(PasswordUtil.encode("123456"));
|
||||||
|
userMapper.insert(user);
|
||||||
}
|
}
|
||||||
userMapper.insert(user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +56,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户信息(角色、状态、密码)
|
* 更新用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户对象
|
* @param user 用户对象
|
||||||
*/
|
*/
|
||||||
|
|
@ -68,14 +70,45 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户修改密码
|
* 管理员重置用户密码(管理端)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
*/
|
||||||
|
public void resetPassword(Long userId) {
|
||||||
|
User user = userMapper.selectById(userId);
|
||||||
|
if (user == null) {
|
||||||
|
throw new UserNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设定默认密码 123456
|
||||||
|
user.setPassword(PasswordUtil.encode("123456"));
|
||||||
|
userMapper.updateById(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封禁用户(管理端)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
*/
|
||||||
|
public void banUser(Long userId) {
|
||||||
|
User user = userMapper.selectById(userId);
|
||||||
|
if (user == null) {
|
||||||
|
throw new UserNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新状态为 banned
|
||||||
|
user.setStatus("banned");
|
||||||
|
userMapper.updateById(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户修改密码(用户端)
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param oldPassword 旧密码
|
* @param oldPassword 旧密码
|
||||||
* @param newPassword 新密码
|
* @param newPassword 新密码
|
||||||
*/
|
*/
|
||||||
public void changePassword(Long userId, String oldPassword, String newPassword) {
|
public void changePassword(Long userId, String oldPassword, String newPassword) {
|
||||||
// 获取用户
|
|
||||||
User user = userMapper.selectById(userId);
|
User user = userMapper.selectById(userId);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new UserNotFoundException();
|
throw new UserNotFoundException();
|
||||||
|
|
@ -86,15 +119,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||||
throw new PasswordIncorrectException();
|
throw new PasswordIncorrectException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新新密码(加密存储)
|
// 加密新密码
|
||||||
user.setPassword(PasswordUtil.encode(newPassword));
|
user.setPassword(PasswordUtil.encode(newPassword));
|
||||||
userMapper.updateById(user);
|
userMapper.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户修改个人信息(昵称、邮箱、头像)
|
* 用户修改个人信息(用户端)
|
||||||
*
|
*
|
||||||
* @param userId 用户ID(从 JWT 获取)
|
* @param userId 用户ID
|
||||||
* @param updatedUser 用户提交的新信息(昵称、邮箱、头像)
|
* @param updatedUser 用户提交的新信息(昵称、邮箱、头像)
|
||||||
*/
|
*/
|
||||||
public void updateProfile(Long userId, User updatedUser) {
|
public void updateProfile(Long userId, User updatedUser) {
|
||||||
|
|
@ -111,6 +144,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||||
userMapper.updateById(user);
|
userMapper.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户详情(用户端)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户信息
|
||||||
|
*/
|
||||||
|
public User getUserProfile(Long userId) {
|
||||||
|
User user = userMapper.selectById(userId);
|
||||||
|
if (user == null) {
|
||||||
|
throw new UserNotFoundException();
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除用户
|
* 删除用户
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bruce.sams.mapper.ClubMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sms.Club">
|
||||||
|
<id property="clubId" column="club_id" />
|
||||||
|
<result property="clubName" column="club_name" />
|
||||||
|
<result property="description" column="description" />
|
||||||
|
<result property="category" column="category" />
|
||||||
|
<result property="collegeId" column="college_id" />
|
||||||
|
<result property="leaderId" column="leader_id" />
|
||||||
|
<result property="createdAt" column="created_at" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
club_id,club_name,description,category,college_id,leader_id,
|
||||||
|
created_at
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bruce.sams.mapper.ClubUserMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sms.ClubUser">
|
||||||
|
<id property="sucId" column="suc_id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="clubId" column="club_id" />
|
||||||
|
<result property="roleId" column="role_id" />
|
||||||
|
<result property="isActive" column="is_active" />
|
||||||
|
<result property="joinDate" column="join_date" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
suc_id,user_id,club_id,role_id,is_active,join_date
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bruce.sams.mapper.CollegeLeaderMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sms.CollegeLeader">
|
||||||
|
<id property="collegeId" column="college_id" />
|
||||||
|
<id property="userId" column="user_id" />
|
||||||
|
<result property="assignedAt" column="assigned_at" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
college_id,user_id,assigned_at
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bruce.sams.mapper.CollegeMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sms.College">
|
||||||
|
<id property="collegeId" column="college_id" />
|
||||||
|
<result property="collegeName" column="college_name" />
|
||||||
|
<result property="parentId" column="parent_id" />
|
||||||
|
<result property="email" column="email" />
|
||||||
|
<result property="createdAt" column="created_at" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
college_id,college_name,parent_id,email,created_at
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.bruce.sams;
|
package com.bruce.sams;
|
||||||
|
|
||||||
import com.bruce.sams.utils.PasswordUtil;
|
import com.bruce.sams.common.utils.PasswordUtil;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue