v0.2.7 完成活动审批模块搭建 优化权限系统 完善文件获取模块

v0.2o
bruce 2025-02-20 17:32:22 +08:00
parent befecab00c
commit e7950bf615
44 changed files with 1485 additions and 57 deletions

View File

@ -1,34 +1,57 @@
package com.bruce.sams.common.config;
import com.bruce.sams.common.filter.JwtAuthFilter;
import com.bruce.sams.service.impl.CustomUserDetailsService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
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.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
/**
* Spring Security
*/
import java.util.Collections;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
private final JwtAuthFilter jwtAuthFilter;
public SecurityConfig(JwtAuthFilter jwtAuthFilter) {
this.jwtAuthFilter = jwtAuthFilter;
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
return http
.csrf(csrf -> csrf.disable())
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(auth -> auth
.requestMatchers("/api/auth/**").permitAll() // 允许访问认证相关接口
.requestMatchers("/api/auth/login").permitAll()
.requestMatchers("/api/admin/**").hasAuthority("ADMIN")
.requestMatchers("/api/user/**").hasAuthority("participant")
.anyRequest().authenticated()
)
.addFilterBefore(new JwtAuthFilter(), UsernamePasswordAuthenticationFilter.class);
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class) // JWT 过滤器
.build();
}
return http.build();
@Bean
public AuthenticationManager authenticationManager(UserDetailsService userDetailsService) {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(new BCryptPasswordEncoder());
return new ProviderManager(Collections.singletonList(authProvider));
}
@Bean
public UserDetailsService userDetailsService() {
return new CustomUserDetailsService();
}
}

View File

@ -0,0 +1,16 @@
package com.bruce.sams.common.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/uploads/**")
.addResourceLocations("file:uploads/");
}
}

View File

@ -1,44 +1,58 @@
package com.bruce.sams.common.filter;
import com.bruce.sams.service.impl.CustomUserDetailsService;
import com.bruce.sams.common.utils.TokenUtil;
import com.bruce.sams.domain.sys.User;
import com.bruce.sams.service.impl.CustomUserDetailsService;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtException;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import java.io.IOException;
/**
* JWT Token
*/
@Component
public class JwtAuthFilter extends OncePerRequestFilter {
private final UserDetailsService userDetailsService;
public JwtAuthFilter(CustomUserDetailsService userDetailsService) {
this.userDetailsService = userDetailsService;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
String token = request.getHeader("Authorization");
String token = getTokenFromRequest(request);
if (token != null && token.startsWith("Bearer ")) {
token = token.substring(7);
if (StringUtils.hasText(token)) {
try {
// 解析 Token
Long userId = TokenUtil.getUserIdFromToken(token);
String role = TokenUtil.getRoleFromToken(token);
// 将 userId 存入 request供 Controller 直接使用
request.setAttribute("userId", userId);
// **从数据库加载完整用户信息**
User userDetails = (User) userDetailsService.loadUserByUsername(String.valueOf(userId));
// **确保 Authentication 存入 User**
UsernamePasswordAuthenticationToken authentication =
new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
// **存入 SecurityContext**
SecurityContextHolder.getContext().setAuthentication(authentication);
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken(userId, null, null));
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid Token");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token 无效");
return;
}
}
@ -46,9 +60,15 @@ public class JwtAuthFilter extends OncePerRequestFilter {
filterChain.doFilter(request, response);
}
@Bean
public UserDetailsService userDetailsService() {
return new CustomUserDetailsService(); // 认证逻辑
}
/**
* Token
*/
private String getTokenFromRequest(HttpServletRequest request) {
String bearerToken = request.getHeader("Authorization");
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
return bearerToken.substring(7);
}
return null;
}
}

View File

@ -0,0 +1,27 @@
package com.bruce.sams.common.utils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.file.*;
public class FileUploadUtil {
private static final String UPLOAD_DIR = "uploads/";
public static String uploadFile(MultipartFile file, String subDir) {
if (file.isEmpty()) {
throw new RuntimeException("文件不能为空");
}
try {
String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
Path uploadPath = Paths.get(UPLOAD_DIR + subDir);
Files.createDirectories(uploadPath);
Path filePath = uploadPath.resolve(fileName);
Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
return "/uploads/" + subDir + fileName;
} catch (IOException e) {
throw new RuntimeException("文件上传失败", e);
}
}
}

View File

@ -1,10 +1,12 @@
package com.bruce.sams.controller;
import com.bruce.sams.common.utils.FileUploadUtil;
import com.bruce.sams.domain.entity.LoginRequest;
import com.bruce.sams.service.AuthService;
import com.bruce.sams.common.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
*
@ -28,4 +30,6 @@ public class AuthController {
String token = authService.authenticate(loginRequest);
return AjaxResult.success("登录成功", token);
}
}

View File

@ -0,0 +1,40 @@
package com.bruce.sams.controller.ams;
import com.bruce.sams.common.utils.AjaxResult;
import com.bruce.sams.domain.ams.Activity;
import com.bruce.sams.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
*
*/
@RestController
@RequestMapping("/api/admin/activity")
public class ActivityController {
@Autowired
private ActivityService activityService;
/**
*
*/
@PreAuthorize("hasRole('USER') or hasRole('CLUB_ADMIN')")
@PostMapping("/create")
public AjaxResult createActivity(@RequestBody Activity activity) {
activityService.createActivity(activity);
return AjaxResult.success("活动创建成功,等待审批");
}
/**
*
*/
@PreAuthorize("hasRole('CLUB_ADMIN')")
@PutMapping("/cancel")
public AjaxResult cancelActivity(@RequestParam Long actId) {
activityService.cancelActivity(actId);
return AjaxResult.success("活动已取消");
}
}

View File

@ -0,0 +1,41 @@
package com.bruce.sams.controller.ams;
import com.bruce.sams.common.utils.AjaxResult;
import com.bruce.sams.service.ApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
*
*/
@RestController
@RequestMapping("/api/admin/approval")
public class ApprovalController {
@Autowired
private ApprovalService approvalService;
/**
*
*/
@PreAuthorize("hasRole('CLUB_ADMIN') or hasRole('DEPARTMENT_ADMIN') or hasRole('COLLEGE_ADMIN')")
@PostMapping("/approve")
public AjaxResult approveActivity(@RequestParam Long apprId, @RequestParam Long approverId) {
approvalService.approveActivity(apprId, approverId);
return AjaxResult.success("审批已通过");
}
/**
*
*/
@PreAuthorize("hasRole('CLUB_ADMIN') or hasRole('DEPARTMENT_ADMIN') or hasRole('COLLEGE_ADMIN')")
@PostMapping("/reject")
public AjaxResult rejectActivity(@RequestParam Long apprId, @RequestParam String reason, @RequestParam Long approverId) {
approvalService.rejectActivity(apprId, reason, approverId);
return AjaxResult.success("审批已拒绝");
}
}

View File

@ -0,0 +1,15 @@
package com.bruce.sams.controller.sys;
import com.bruce.sams.common.utils.FileUploadUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/upload")
public class DocumentUploadController {
@PostMapping("/document")
public String uploadDocument(@RequestParam("file") MultipartFile file) {
return FileUploadUtil.uploadFile(file, "documents/");
}
}

View File

@ -1,10 +1,15 @@
package com.bruce.sams.controller.sys;
import com.bruce.sams.common.utils.FileUploadUtil;
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.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.security.core.Authentication;
/**
* -
@ -53,4 +58,32 @@ public class UserController {
public AjaxResult getUserProfile(@PathVariable Long userId) {
return AjaxResult.success(userService.getUserProfile(userId));
}
/**
*
* @param file
* @return AjaxResult
*/
@PostMapping("/avatar")
public String uploadAvatar(@RequestParam("file") MultipartFile file) {
// 获取当前认证信息
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !authentication.isAuthenticated()) {
throw new RuntimeException("未认证用户");
}
// 获取当前用户对象
User userDetails = (User) authentication.getPrincipal();
Long userId = userDetails.getUserId(); // 获取 userId
// 上传文件
String avatarUrl = FileUploadUtil.uploadFile(file, "avatars/");
// 更新用户头像
userService.updateUserAvatar(userId, avatarUrl);
return avatarUrl;
}
}

View File

@ -0,0 +1,188 @@
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 com.bruce.sams.domain.entity.ActivityStatus;
import com.bruce.sams.domain.entity.ActivityType;
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 ActivityStatus status;
/**
*
*/
private Date createdAt;
/**
*
*/
private Date updatedAt;
/**
* COLLEGE: , DEPARTMENT: , CLUB_INTERNAL: , CLUB_EXTERNAL: )
*/
private ActivityType activityType;
/**
* ID
*/
private Long currentApproverId;
@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()))
&& (this.getActivityType() == null ? other.getActivityType() == null : this.getActivityType().equals(other.getActivityType()))
&& (this.getCurrentApproverId() == null ? other.getCurrentApproverId() == null : this.getCurrentApproverId().equals(other.getCurrentApproverId()));
}
@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());
result = prime * result + ((getActivityType() == null) ? 0 : getActivityType().hashCode());
result = prime * result + ((getCurrentApproverId() == null) ? 0 : getCurrentApproverId().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(", activityType=").append(activityType);
sb.append(", currentApproverId=").append(currentApproverId);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,114 @@
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.util.Date;
import com.bruce.sams.domain.entity.ApprovalStatus;
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 ApprovalStatus 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() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", apprId=").append(apprId);
sb.append(", actId=").append(actId);
sb.append(", userId=").append(userId);
sb.append(", approverId=").append(approverId);
sb.append(", status=").append(status);
sb.append(", reason=").append(reason);
sb.append(", approvedAt=").append(approvedAt);
sb.append(", createdAt=").append(createdAt);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,96 @@
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.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() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", commentId=").append(commentId);
sb.append(", userId=").append(userId);
sb.append(", actId=").append(actId);
sb.append(", parentCommentId=").append(parentCommentId);
sb.append(", content=").append(content);
sb.append(", createdAt=").append(createdAt);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,88 @@
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.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() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", reactionId=").append(reactionId);
sb.append(", userId=").append(userId);
sb.append(", actId=").append(actId);
sb.append(", reactionType=").append(reactionType);
sb.append(", createdAt=").append(createdAt);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,104 @@
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.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() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", regId=").append(regId);
sb.append(", actId=").append(actId);
sb.append(", userId=").append(userId);
sb.append(", role=").append(role);
sb.append(", status=").append(status);
sb.append(", registerTime=").append(registerTime);
sb.append(", attendTime=").append(attendTime);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,16 @@
package com.bruce.sams.domain.entity;
/**
*
*
*/
public enum ActivityStatus {
DRAFT, // 草稿(未提交)
PENDING_CLUB, // 待社团管理员审批(适用于社团外部活动)
PENDING_DEPARTMENT,// 待院级管理员审批
PENDING_COLLEGE, // 待校级管理员审批
APPROVED, // 已批准
ONGOING, // 活动进行中
COMPLETED, // 活动已完成
CANCELLED // 活动已取消
}

View File

@ -0,0 +1,11 @@
package com.bruce.sams.domain.entity;
/**
*
*/
public enum ActivityType {
COLLEGE, // 校级活动
DEPARTMENT, // 院级活动
CLUB_INTERNAL, // 社团内部活动
CLUB_EXTERNAL // 社团外部活动
}

View File

@ -0,0 +1,10 @@
package com.bruce.sams.domain.entity;
/**
*
*/
public enum ApprovalStatus {
APPROVED, // 审批通过
REJECTED, // 审批拒绝
PENDING // 待审批
}

View File

@ -1,10 +1,13 @@
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;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.List;
/**
*
@ -12,7 +15,7 @@ import lombok.Data;
*/
@TableName(value ="sys_user")
@Data
public class User {
public class User implements UserDetails {
/**
* ID
*/
@ -27,7 +30,8 @@ public class User {
/**
*
*/
private String userName;
private String username;
/**
*
@ -59,6 +63,15 @@ public class User {
*/
private Object status;
// 不映射到数据库
private List<GrantedAuthority> authorities;
public User(String username, String password, List<GrantedAuthority> authorities) {
this.username = username;
this.password = password;
this.authorities = authorities;
}
@Override
public boolean equals(Object that) {
if (this == that) {
@ -73,7 +86,7 @@ public class User {
User other = (User) that;
return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getNickName() == null ? other.getNickName() == null : this.getNickName().equals(other.getNickName()))
&& (this.getUserName() == null ? other.getUserName() == null : this.getUserName().equals(other.getUserName()))
&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
&& (this.getSchoolId() == null ? other.getSchoolId() == null : this.getSchoolId().equals(other.getSchoolId()))
&& (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId()))
@ -88,7 +101,7 @@ public class User {
int result = 1;
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getNickName() == null) ? 0 : getNickName().hashCode());
result = prime * result + ((getUserName() == null) ? 0 : getUserName().hashCode());
result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
result = prime * result + ((getSchoolId() == null) ? 0 : getSchoolId().hashCode());
result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode());
@ -100,20 +113,20 @@ public class User {
@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(", 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();
return getClass().getSimpleName() +
" [" +
"Hash = " + hashCode() +
", userId=" + userId +
", nickName=" + nickName +
", userName=" + username +
", password=" + password +
", schoolId=" + schoolId +
", collegeId=" + collegeId +
", email=" + email +
", avatar=" + avatar +
", status=" + status +
"]";
}
}

View File

@ -0,0 +1,18 @@
package com.bruce.sams.mapper;
import com.bruce.sams.domain.ams.Activity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author bruce
* @description ams_activity()Mapper
* @createDate 2025-02-20 16:01:31
* @Entity com.bruce.sams.domain.ams.Activity
*/
public interface ActivityMapper extends BaseMapper<Activity> {
}

View File

@ -0,0 +1,20 @@
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-20 15:46:26
* @Entity com.bruce.sams.domain.ams.Approval
*/
@Mapper
public interface ApprovalMapper extends BaseMapper<Approval> {
}

View File

@ -0,0 +1,20 @@
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-20 15:08:30
* @Entity com.bruce.sams.domain.ams.Comment
*/
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
}

View File

@ -0,0 +1,20 @@
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-20 15:08:43
* @Entity com.bruce.sams.domain.ams.Reaction
*/
@Mapper
public interface ReactionMapper extends BaseMapper<Reaction> {
}

View File

@ -0,0 +1,20 @@
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-20 15:08:53
* @Entity com.bruce.sams.domain.ams.Registration
*/
@Mapper
public interface RegistrationMapper extends BaseMapper<Registration> {
}

View File

@ -40,6 +40,9 @@ public interface UserMapper extends BaseMapper<User> {
@Select("SELECT * FROM sys_user WHERE user_id = #{userId}")
User getUserById(@Param("userId") Long userId);
@Update("UPDATE sys_user SET avatar = #{avatarUrl} WHERE user_id = #{userId}")
void updateAvatar(Long userId, String avatarUrl);
}

View File

@ -0,0 +1,36 @@
package com.bruce.sams.service;
import com.bruce.sams.domain.ams.Activity;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author bruce
* @description ams_activity()Service
* @createDate 2025-02-20 15:46:18
*/
public interface ActivityService extends IService<Activity> {
/**
*
*/
void createActivity(Activity activity);
/**
*
* @param activity
*/
void updateActivity(Activity activity);
/**
*
* @param actId ID
*/
void cancelActivity(Long actId);
/**
*
* @param actId ID
* @return
*/
Activity getActivityById(Long actId);
}

View File

@ -0,0 +1,21 @@
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-20 15:46:26
*/
public interface ApprovalService extends IService<Approval> {
/**
*
*/
void approveActivity(Long apprId, Long approverId);
/**
*
*/
void rejectActivity(Long apprId, String reason, Long approverId);
}

View File

@ -0,0 +1,13 @@
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-20 15:08:30
*/
public interface CommentService extends IService<Comment> {
}

View File

@ -0,0 +1,13 @@
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-20 15:08:43
*/
public interface ReactionService extends IService<Reaction> {
}

View File

@ -0,0 +1,13 @@
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-20 15:08:53
*/
public interface RegistrationService extends IService<Registration> {
}

View File

@ -82,4 +82,11 @@ public interface UserService {
*/
List<Role> getRolesByUserId(Long userId);
/**
*
* @param userId ID
* @param avatarUrl
*/
public void updateUserAvatar(Long userId, String avatarUrl);
}

View File

@ -0,0 +1,70 @@
package com.bruce.sams.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bruce.sams.domain.ams.Activity;
import com.bruce.sams.domain.entity.ActivityStatus;
import com.bruce.sams.service.ActivityService;
import com.bruce.sams.mapper.ActivityMapper;
import org.springframework.stereotype.Service;
/**
*
*
*/
@Service
public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> implements ActivityService {
/**
*
* @param activity
*/
@Override
public void createActivity(Activity activity) {
// 初始化活动审批状态
switch (activity.getActivityType()) {
case CLUB_INTERNAL, CLUB_EXTERNAL:
activity.setStatus(ActivityStatus.PENDING_CLUB);
break;
case DEPARTMENT:
activity.setStatus(ActivityStatus.PENDING_DEPARTMENT);
break;
case COLLEGE:
activity.setStatus(ActivityStatus.PENDING_COLLEGE);
break;
default:
activity.setStatus(ActivityStatus.DRAFT);
break;
}
this.save(activity);
}
/**
*
* @param activity
*/
@Override
public void updateActivity(Activity activity) {
this.updateById(activity);
}
/**
*
* @param actId ID
*/
@Override
public void cancelActivity(Long actId) {
Activity activity = this.getById(actId);
activity.setStatus(ActivityStatus.CANCELLED);
this.updateById(activity);
}
/**
*
* @param actId ID
* @return
*/
@Override
public Activity getActivityById(Long actId) {
return this.getById(actId);
}
}

View File

@ -0,0 +1,102 @@
package com.bruce.sams.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bruce.sams.domain.ams.Activity;
import com.bruce.sams.domain.ams.Approval;
import com.bruce.sams.domain.entity.ActivityStatus;
import com.bruce.sams.domain.entity.ActivityType;
import com.bruce.sams.domain.entity.ApprovalStatus;
import com.bruce.sams.service.ActivityService;
import com.bruce.sams.service.ApprovalService;
import com.bruce.sams.mapper.ApprovalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
*
*/
@Service
public class ApprovalServiceImpl extends ServiceImpl<ApprovalMapper, Approval> implements ApprovalService {
@Autowired
private ActivityService activityService;
/**
*
* @param apprId ID
* @param approverId ID
*/
@Override
public void approveActivity(Long apprId, Long approverId) {
Approval approval = this.getById(apprId);
Activity activity = activityService.getActivityById(approval.getActId());
// 记录审批人
approval.setApproverId(approverId);
this.updateById(approval);
// 确定下一级审批流转
switch (activity.getStatus()) {
case PENDING_CLUB:
if (activity.getActivityType() == ActivityType.CLUB_INTERNAL) {
activity.setStatus(ActivityStatus.APPROVED);
activity.setCurrentApproverId(null);
} else {
activity.setStatus(ActivityStatus.PENDING_DEPARTMENT);
activity.setCurrentApproverId(getNextApprover("DEPARTMENT_ADMIN"));
}
break;
case PENDING_DEPARTMENT:
activity.setStatus(ActivityStatus.PENDING_COLLEGE);
activity.setCurrentApproverId(getNextApprover("COLLEGE_ADMIN"));
break;
case PENDING_COLLEGE:
activity.setStatus(ActivityStatus.APPROVED);
activity.setCurrentApproverId(null);
break;
default:
throw new RuntimeException("无效审批状态");
}
activityService.updateActivity(activity);
}
/**
*
* @param apprId ID
* @param reason
* @param approverId ID
*/
@Override
public void rejectActivity(Long apprId, String reason, Long approverId) {
Approval approval = this.getById(apprId);
Activity activity = activityService.getActivityById(approval.getActId());
activity.setStatus(ActivityStatus.CANCELLED);
activity.setCurrentApproverId(null);
approval.setApprovedAt(ApprovalStatus.REJECTED);
approval.setReason(reason);
approval.setApproverId(approverId);
this.updateById(approval);
activityService.updateActivity(activity);
}
/**
*
* @param role
* @return ID
*/
private Long getNextApprover(String role) {
// 这里可查询 `sys_user_role` 表以获取指定角色的审批人
if ("DEPARTMENT_ADMIN".equals(role)) {
return 1L;
} else if ("COLLEGE_ADMIN".equals(role)) {
return 2L;
}
return null;
}
}

View File

@ -19,7 +19,7 @@ import java.util.List;
public class ClubUserServiceImpl extends ServiceImpl<ClubUserMapper, ClubUser> implements ClubUserService {
/**
*
*
*
* @param clubId ID
* @param userId ID
@ -36,7 +36,7 @@ public class ClubUserServiceImpl extends ServiceImpl<ClubUserMapper, ClubUser> i
}
/**
* /
*
*
* @param clubId ID
* @param userId ID
@ -49,7 +49,7 @@ public class ClubUserServiceImpl extends ServiceImpl<ClubUserMapper, ClubUser> i
}
/**
*
*
*
* @param clubId ID
* @return

View File

@ -0,0 +1,22 @@
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-20 15:08:30
*/
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>
implements CommentService{
}

View File

@ -37,6 +37,6 @@ public class CustomUserDetailsService implements UserDetailsService {
.collect(Collectors.toList());
// 返回 LoginUser符合 Spring Security 的 UserDetails
return new LoginUser(user.getUserId(), user.getUserName(), user.getPassword(), authorities);
return new LoginUser(user.getUserId(), user.getUsername(), user.getPassword(), authorities);
}
}

View File

@ -0,0 +1,22 @@
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-20 15:08:43
*/
@Service
public class ReactionServiceImpl extends ServiceImpl<ReactionMapper, Reaction>
implements ReactionService{
}

View File

@ -0,0 +1,22 @@
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-20 15:08:53
*/
@Service
public class RegistrationServiceImpl extends ServiceImpl<RegistrationMapper, Registration>
implements RegistrationService{
}

View File

@ -1,13 +1,11 @@
package com.bruce.sams.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bruce.sams.domain.sys.Role;
import com.bruce.sams.domain.sys.User;
import com.bruce.sams.common.exception.PasswordIncorrectException;
import com.bruce.sams.common.exception.UserNotFoundException;
import com.bruce.sams.domain.sys.UserRole;
import com.bruce.sams.mapper.RoleMapper;
import com.bruce.sams.mapper.UserMapper;
import com.bruce.sams.mapper.UserRoleMapper;
@ -17,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
@ -60,7 +57,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
public List<User> listUsers(String keyword) {
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
if (keyword != null && !keyword.isEmpty()) {
queryWrapper.like(User::getUserName, keyword)
queryWrapper.like(User::getUsername, keyword)
.or().like(User::getSchoolId, keyword)
.or().like(User::getEmail, keyword);
}
@ -197,4 +194,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
// 3. 根据 role_id 查询 sys_role 表
return roleMapper.selectRolesByIds(roleIds);
}
/**
*
* @param userId ID
* @param avatarUrl
*/
public void updateUserAvatar(Long userId, String avatarUrl) {
userMapper.updateAvatar(userId, avatarUrl);
}
}

View File

@ -1,9 +1,16 @@
spring:
application:
name: SAMS
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/SAMS
username: root
password: admin123
password: admin123
servlet:
multipart:
enabled: true
max-file-size: 5MB # 限制上传文件大小
max-request-size: 10MB
file:
upload-dir: uploads/

View File

@ -0,0 +1,33 @@
<?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.ActivityMapper">
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.ams.Activity">
<id property="actId" column="act_id" />
<result property="title" column="title" />
<result property="description" column="description" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="location" column="location" />
<result property="budget" column="budget" />
<result property="maxParticipants" column="max_participants" />
<result property="creatorId" column="creator_id" />
<result property="collegeId" column="college_id" />
<result property="clubId" column="club_id" />
<result property="visibility" column="visibility" />
<result property="status" column="status" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="activityType" column="activity_type" />
<result property="currentApproverId" column="current_approver_id" />
</resultMap>
<sql id="Base_Column_List">
act_id,title,description,start_time,end_time,location,
budget,max_participants,creator_id,college_id,club_id,
visibility,status,created_at,updated_at,activity_type,
current_approver_id
</sql>
</mapper>

View File

@ -0,0 +1,22 @@
<?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.ApprovalMapper">
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.ams.Approval">
<id property="apprId" column="appr_id" />
<result property="actId" column="act_id" />
<result property="userId" column="user_id" />
<result property="approverId" column="approver_id" />
<result property="status" column="status" />
<result property="reason" column="reason" />
<result property="approvedAt" column="approved_at" />
<result property="createdAt" column="created_at" />
</resultMap>
<sql id="Base_Column_List">
appr_id,act_id,user_id,approver_id,status,reason,
approved_at,created_at
</sql>
</mapper>

View File

@ -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.CommentMapper">
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.ams.Comment">
<id property="commentId" column="comment_id" />
<result property="userId" column="user_id" />
<result property="actId" column="act_id" />
<result property="parentCommentId" column="parent_comment_id" />
<result property="content" column="content" />
<result property="createdAt" column="created_at" />
</resultMap>
<sql id="Base_Column_List">
comment_id,user_id,act_id,parent_comment_id,content,created_at
</sql>
</mapper>

View File

@ -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.ReactionMapper">
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.ams.Reaction">
<id property="reactionId" column="reaction_id" />
<result property="userId" column="user_id" />
<result property="actId" column="act_id" />
<result property="reactionType" column="reaction_type" />
<result property="createdAt" column="created_at" />
</resultMap>
<sql id="Base_Column_List">
reaction_id,user_id,act_id,reaction_type,created_at
</sql>
</mapper>

View File

@ -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.RegistrationMapper">
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.ams.Registration">
<id property="regId" column="reg_id" />
<result property="actId" column="act_id" />
<result property="userId" column="user_id" />
<result property="role" column="role" />
<result property="status" column="status" />
<result property="registerTime" column="register_time" />
<result property="attendTime" column="attend_time" />
</resultMap>
<sql id="Base_Column_List">
reg_id,act_id,user_id,role,status,register_time,
attend_time
</sql>
</mapper>