Compare commits
No commits in common. 'master' and 'main' have entirely different histories.
@ -1,16 +0,0 @@
|
||||
package com.wbq;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
// 项目启动类
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@Slf4j
|
||||
public class RollCallApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RollCallApplication.class, args);
|
||||
log.info("server started");
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/*package com.wbq.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.csrf().disable() // 禁用 CSRF 保护(如果不需要的话)
|
||||
.authorizeRequests()
|
||||
.antMatchers("/doc.html", "/swagger-ui/**", "/v2/api-docs/**", "/webjars/**").permitAll() // 允许访问 Swagger 文档
|
||||
.anyRequest().authenticated() // 其他请求需要认证
|
||||
.and()
|
||||
.formLogin().disable(); // 禁用默认的登录页面
|
||||
}
|
||||
}*/
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
package com.wbq.config;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.OAS_30) // 使用 OpenAPI 3
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.wbq.controller")) // 替换为你的包路径
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("API 文档标题")
|
||||
.description("API 文档描述")
|
||||
.version("1.0")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -1,94 +0,0 @@
|
||||
package com.wbq.config;
|
||||
|
||||
|
||||
import com.wbq.interceptor.JwtTokenAdminInterceptor;
|
||||
import com.wbq.interceptor.JwtTokenStudentInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
// MVC配置
|
||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
@Autowired
|
||||
private JwtTokenAdminInterceptor jwtTokenAdminInterceptor;
|
||||
@Autowired
|
||||
private JwtTokenStudentInterceptor jwtTokenStudentInterceptor;
|
||||
|
||||
/**
|
||||
* 注册自定义拦截器
|
||||
* @param registry
|
||||
*/
|
||||
protected void addInterceptors(InterceptorRegistry registry) {
|
||||
log.info("开始注册自定义拦截器...");
|
||||
registry.addInterceptor(jwtTokenStudentInterceptor)
|
||||
.addPathPatterns("/student/**")
|
||||
.excludePathPatterns("/student/login");
|
||||
registry.addInterceptor(jwtTokenAdminInterceptor)
|
||||
.addPathPatterns("/admin/**")
|
||||
.excludePathPatterns("/admin/login")
|
||||
.excludePathPatterns("/admin/registry");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket docketAdmin() {
|
||||
log.info("准备生成接口文档...");
|
||||
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||
.title("课堂随机点名项目接口文档")
|
||||
|
||||
.version("1.0")
|
||||
.description("课堂随机点名项目接口文档")
|
||||
.contact(new Contact("王碧强", "https://www.bilibili.com/", "2108095381@qq.com"))
|
||||
.build();
|
||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("管理端接口")
|
||||
.apiInfo(apiInfo)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.wbq.controller.admin"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
return docket;
|
||||
}
|
||||
@Bean
|
||||
public Docket docketStudent() {
|
||||
log.info("准备生成接口文档...");
|
||||
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||
.title("课堂随机点名项目接口文档")
|
||||
|
||||
.version("1.0")
|
||||
.description("课堂随机点名项目接口文档")
|
||||
.contact(new Contact("王碧强", "https://www.bilibili.com/", "2108095381@qq.com"))
|
||||
.build();
|
||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("学生端接口")
|
||||
.apiInfo(apiInfo)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.wbq.controller.student"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
return docket;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置静态资源映射
|
||||
* @param registry
|
||||
*/
|
||||
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
log.info("开始设置静态资源映射...");
|
||||
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
package com.wbq.constant;
|
||||
|
||||
// 常量配置
|
||||
public class EmailConstant {
|
||||
public static final String SMTP_HOST = "smtp.qq.com";
|
||||
public static final String SMTP_PORT = "465";
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package com.wbq.constant;
|
||||
|
||||
public class JwtClaimsConstant {
|
||||
public static final String ADMIN_ID = "adminId";
|
||||
public static final String STUDENT_ID = "studentId";
|
||||
public static final String PHONE = "phone";
|
||||
public static final String USERNAME = "username";
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package com.wbq.constant;
|
||||
|
||||
/**
|
||||
* 密码常量
|
||||
*/
|
||||
public class PasswordConstant {
|
||||
public static final String DEFAULT_PASSWORD = "1234";
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
// 管理前端传递的参数
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AdminDTO {
|
||||
// 姓名
|
||||
String name;
|
||||
// 账号
|
||||
int adminId;
|
||||
// 密码
|
||||
String password;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(description = "管理员登录时传递的数据模型")
|
||||
public class AdminLoginDTO {
|
||||
@ApiModelProperty("账号")
|
||||
private int adminId;
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AdminRegistryDTO {
|
||||
// 管理员账号
|
||||
private int adminId;
|
||||
// 姓名
|
||||
private String name;
|
||||
// 密码
|
||||
private String password;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CourseDTO {
|
||||
int courseId;
|
||||
String description;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StudentDTO {
|
||||
// 学号暨账号
|
||||
int studentId;
|
||||
// 姓名
|
||||
String name;
|
||||
// 密码
|
||||
String password;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(description = "学生登录时传递的数据模型")
|
||||
public class StudentLoginDTO {
|
||||
@ApiModelProperty("账号")
|
||||
private int studentId;
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StudentPageQueryDTO {
|
||||
int page;
|
||||
int pageSize;
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package com.wbq.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StudentRegistryDTO {
|
||||
// 学号
|
||||
private int studentId;
|
||||
// 真实姓名
|
||||
private String name;
|
||||
// qq邮箱
|
||||
private String userName;
|
||||
// 密码
|
||||
private String password;
|
||||
// 验证码
|
||||
private String verificationCode;
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package com.wbq.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
// 整个项目所用到的实体参数数据
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Admin implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
|
||||
//账号名暨管理员id
|
||||
private int adminId;
|
||||
//密码
|
||||
private String password;
|
||||
// 姓名
|
||||
private String name;
|
||||
// 管理的课程
|
||||
private List<Course> courseList;
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.wbq.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CallRecord implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// id
|
||||
private int id;
|
||||
// 时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime callTime;
|
||||
// 课程
|
||||
private String courseDescription;
|
||||
// 管理员
|
||||
private String adminName;
|
||||
// 加分
|
||||
private double score;
|
||||
// 学号
|
||||
private int studentId;
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.wbq.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Course implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
// 课程id
|
||||
private int courseId;
|
||||
// 课程描述
|
||||
private String description;
|
||||
// 课程学生
|
||||
private List<Student> studentList;
|
||||
// 课程管理员
|
||||
private List<Admin> adminList;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package com.wbq.entity;
|
||||
|
||||
import com.wbq.dto.CourseDTO;
|
||||
import com.wbq.dto.StudentDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EnrollRequest {
|
||||
private StudentDTO student;
|
||||
private CourseDTO course;
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
package com.wbq.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Student implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
|
||||
// 学号暨学生登录账号
|
||||
private int studentId;
|
||||
// 姓名
|
||||
private String name;
|
||||
// 密码
|
||||
private String password;
|
||||
// 参与的课程
|
||||
private List<Course> courseList;
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.wbq.exception;
|
||||
// 管理项目中出现的异常
|
||||
public class AccountNotFoundException extends BaseException{
|
||||
public AccountNotFoundException() {
|
||||
|
||||
}
|
||||
public AccountNotFoundException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package com.wbq.exception;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
public class BaseException extends RuntimeException{
|
||||
public BaseException(){}
|
||||
public BaseException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.wbq.exception;
|
||||
|
||||
public class LoginFailedException extends BaseException{
|
||||
public LoginFailedException() {
|
||||
|
||||
}
|
||||
public LoginFailedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.wbq.exception;
|
||||
|
||||
public class PasswordEditFailedException extends BaseException{
|
||||
public PasswordEditFailedException() {
|
||||
|
||||
}
|
||||
public PasswordEditFailedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.wbq.exception;
|
||||
|
||||
public class PasswordErrorException extends BaseException{
|
||||
public PasswordErrorException() {
|
||||
|
||||
}
|
||||
public PasswordErrorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.wbq.exception;
|
||||
|
||||
public class StudentNotLoginException extends BaseException{
|
||||
public StudentNotLoginException() {
|
||||
|
||||
}
|
||||
public StudentNotLoginException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.wbq.interceptor;
|
||||
|
||||
import com.wbq.constant.JwtClaimsConstant;
|
||||
import com.wbq.context.BaseContext;
|
||||
import com.wbq.properties.JwtProperties;
|
||||
import com.wbq.utils.JwtUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
// token拦截器
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JwtTokenAdminInterceptor implements HandlerInterceptor {
|
||||
@Autowired
|
||||
private JwtProperties jwtProperties;
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
/**
|
||||
* 校验jwt
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param handler
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 判断是否需要拦截,如果请求静态资源就不需要拦截
|
||||
if (!(handler instanceof HandlerMethod))
|
||||
return true;
|
||||
|
||||
// 从请求头获取令牌
|
||||
String token = request.getHeader(jwtProperties.getAdminTokenName());
|
||||
|
||||
// 校验令牌
|
||||
try{
|
||||
Claims claims = jwtUtils.parseJWT(token);
|
||||
|
||||
Integer adminId = Integer.valueOf(claims.get(JwtClaimsConstant.ADMIN_ID).toString());
|
||||
log.info("当前管理员id: {}", adminId);
|
||||
BaseContext.setCurrentId(adminId);
|
||||
|
||||
// 放行
|
||||
return true;
|
||||
|
||||
} catch (Exception ex) {
|
||||
response.setStatus(401);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.wbq.interceptor;
|
||||
|
||||
import com.wbq.constant.JwtClaimsConstant;
|
||||
import com.wbq.context.BaseContext;
|
||||
import com.wbq.properties.JwtProperties;
|
||||
import com.wbq.utils.JwtUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JwtTokenStudentInterceptor implements HandlerInterceptor {
|
||||
@Autowired
|
||||
private JwtProperties jwtProperties;
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
/**
|
||||
* 校验jwt
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param handler
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 判断是否需要拦截,如果请求静态资源就不需要拦截
|
||||
if (!(handler instanceof HandlerMethod))
|
||||
return true;
|
||||
|
||||
// 从请求头获取令牌
|
||||
String token = request.getHeader(jwtProperties.getStudentTokenName());
|
||||
|
||||
// 校验令牌
|
||||
try{
|
||||
Claims claims = jwtUtils.parseJWT(token);
|
||||
|
||||
Integer studentId = Integer.valueOf(claims.get(JwtClaimsConstant.STUDENT_ID).toString());
|
||||
log.info("当前学生id: {}", studentId);
|
||||
BaseContext.setCurrentId(studentId);
|
||||
|
||||
// 放行
|
||||
return true;
|
||||
|
||||
} catch (Exception ex) {
|
||||
response.setStatus(401);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package com.wbq.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
// mapper层操作数据库
|
||||
@Mapper
|
||||
public interface AdminCourseMapper {
|
||||
@Insert("insert into rollcall.admincourse (admin_id, course_id) " +
|
||||
"values (#{adminId}, #{courseId})")
|
||||
void insert(int adminId, int courseId);
|
||||
|
||||
@Delete("delete from rollcall.admincourse " +
|
||||
"where admin_id = #{adminId} and course_id = #{courseId}")
|
||||
void delete(int adminId, int courseId);
|
||||
|
||||
@Select("select course_id from rollcall.admincourse " +
|
||||
"where admin_id = #{adminId}")
|
||||
List<Integer> getByAdminId(int adminId);
|
||||
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.wbq.mapper;
|
||||
|
||||
import com.wbq.dto.AdminDTO;
|
||||
import com.wbq.dto.AdminLoginDTO;
|
||||
import com.wbq.entity.Admin;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface AdminMapper {
|
||||
/**
|
||||
* 修改管理员信息
|
||||
* @param adminDTO
|
||||
*/
|
||||
void update(AdminDTO adminDTO);
|
||||
|
||||
/**
|
||||
* 根据昵称和密码查询管理员
|
||||
* @param adminLoginDTO
|
||||
* @return
|
||||
*/
|
||||
Admin getByAdminLoginDTO(AdminLoginDTO adminLoginDTO);
|
||||
|
||||
/**
|
||||
* 根据id查询管理员
|
||||
* @param id
|
||||
*/
|
||||
@Select("select * from rollcall.admin " +
|
||||
"where id = #{id}")
|
||||
Admin getById(int id);
|
||||
|
||||
/**
|
||||
* 添加管理员
|
||||
* @param adminDTO
|
||||
*/
|
||||
@Insert("insert into rollcall.admin " +
|
||||
"(admin_id, name, password) " +
|
||||
"values " +
|
||||
"(#{adminId}, #{name}, #{password})")
|
||||
void insert(AdminDTO adminDTO);
|
||||
|
||||
/**
|
||||
* 根据管理员账号获得密码
|
||||
* @param adminId
|
||||
* @return
|
||||
*/
|
||||
String getPasswordByAdminId(int adminId);
|
||||
|
||||
/**
|
||||
* 根据管理员账号查询
|
||||
* @param adminId
|
||||
* @return
|
||||
*/
|
||||
Admin getByAdminId(int adminId);
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.wbq.mapper;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.wbq.dto.StudentPageQueryDTO;
|
||||
import com.wbq.entity.CallRecord;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CallRecordMapper {
|
||||
@Select("select * from rollcall.callrecord " +
|
||||
"where student_id = #{studentId} and " +
|
||||
"callrecord.course_description = #{courseDescription} " +
|
||||
"order by call_time desc")
|
||||
Page<CallRecord> pageQuery(StudentPageQueryDTO studentPageQueryDTO, int studentId, String courseDescription);
|
||||
|
||||
@Insert("insert into rollcall.callrecord " +
|
||||
"(call_time, course_description, admin_name, score, student_id) " +
|
||||
"values " +
|
||||
"(#{callTime}, #{courseDescription}, #{adminName}, #{score}, #{studentId})")
|
||||
void insert(CallRecord CallRecord);
|
||||
|
||||
void update(CallRecord callRecord);
|
||||
|
||||
@Select("select * from rollcall.callrecord " +
|
||||
"where student_id = #{studentId} " +
|
||||
"order by call_time desc")
|
||||
List<CallRecord> getByStudentId(int studentId);
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
package com.wbq.mapper;
|
||||
|
||||
import com.wbq.dto.CourseDTO;
|
||||
import com.wbq.entity.Course;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CourseMapper {
|
||||
@Select("select * from rollcall.course")
|
||||
List<Course> getCourses();
|
||||
|
||||
List<Course> getByCourseIdList(List<Integer> courseIdList);
|
||||
|
||||
@Insert("insert into rollcall.course " +
|
||||
"(course_id, description) " +
|
||||
"values (#{courseId}, #{description})")
|
||||
void insert(CourseDTO courseDTO);
|
||||
|
||||
@Select("select * from rollcall.course " +
|
||||
"where course_id = #{courseId}")
|
||||
Course getByCourseId(int courseId);
|
||||
|
||||
Boolean existsByCourseId(int courseId);
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
package com.wbq.mapper;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.wbq.dto.StudentDTO;
|
||||
import com.wbq.vo.StudentCourseInfoVO;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface StudentCourseMapper {
|
||||
@Insert("insert into studentcourse (student_id, course_id) " +
|
||||
"values (#{studentId}, #{courseId})")
|
||||
void insert(int studentId, int courseId);
|
||||
|
||||
@Select("select course_id from rollcall.studentcourse " +
|
||||
"where student_id = #{studentId}")
|
||||
List<Integer> getByStudentId(int studentId);
|
||||
|
||||
@Select("select student_id from rollcall.studentcourse " +
|
||||
"where course_id = #{courseId} " +
|
||||
"order by score desc")
|
||||
List<Integer> getByCourseId(int courseId);
|
||||
|
||||
|
||||
@Select("select s.student_id, s.name, sc.call_count, sc.score " +
|
||||
"from rollcall.students s " +
|
||||
"join rollcall.studentcourse sc on s.student_id = sc.student_id " +
|
||||
"where sc.student_id = #{studentId} and sc.course_id = #{courseId}")
|
||||
StudentCourseInfoVO getCourseInfo(int studentId, int courseId);
|
||||
|
||||
@Select("select s.student_id, s.name, sc.call_count, sc.score " +
|
||||
"from rollcall.students s " +
|
||||
"join rollcall.studentcourse sc on s.student_id = sc.student_id " +
|
||||
"where sc.course_id = #{courseId} " +
|
||||
"order by sc.score desc")
|
||||
Page<StudentCourseInfoVO> pageQuery4CourseInfo(int courseId);
|
||||
|
||||
|
||||
|
||||
@Delete("delete from rollcall.studentcourse " +
|
||||
"where student_id = #{studentId} and course_id = #{courseId}")
|
||||
void delete(int studentId, int courseId);
|
||||
|
||||
@Update("update rollcall.studentcourse " +
|
||||
"set call_count = #{callCount} " +
|
||||
"where student_id = #{studentId} and course_id = #{courseId}")
|
||||
void updateCallCountByStudentIdAndCourseId(int callCount, int studentId, int courseId);
|
||||
|
||||
@Update("update rollcall.studentcourse " +
|
||||
"set score = #{score} " +
|
||||
"where student_id = #{studentId} and course_id = #{courseId}")
|
||||
void updateScoreByStudentIdAndCourseId(double score, int studentId, int courseId);
|
||||
|
||||
/**
|
||||
* 批量增加点名系统的学生
|
||||
* @param courseId
|
||||
* @param studentDTOs
|
||||
*/
|
||||
void batchInsert(@Param("list") List<StudentDTO> studentDTOs, int courseId);
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.wbq.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
// 配置参数
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "wbq.jwt")
|
||||
@Component
|
||||
public class JwtProperties {
|
||||
// 管理员端
|
||||
private String adminSecretKey;
|
||||
private String adminTokenName;
|
||||
private long adminTtl;
|
||||
|
||||
// 学生端
|
||||
private String studentSecretKey;
|
||||
private String studentTokenName;
|
||||
private long studentTtl;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package com.wbq.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "wbq.qq")
|
||||
@Component
|
||||
public class MailProperties {
|
||||
private String emailCount;
|
||||
private String emailAuthorizationCode;
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.wbq.result;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
// 管理返回前端的数据
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageResult implements Serializable {
|
||||
private long total; //总记录数
|
||||
private List records; //当前页数据集合
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
package com.wbq.service;
|
||||
|
||||
import com.wbq.dto.*;
|
||||
import com.wbq.entity.Admin;
|
||||
import com.wbq.vo.CourseVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AdminService {
|
||||
/**
|
||||
* 修改管理员个人信息
|
||||
* @param adminDTO
|
||||
*/
|
||||
void update(AdminDTO adminDTO);
|
||||
|
||||
/**
|
||||
* 根据昵称和密码查询管理员
|
||||
* @param adminLoginDTO
|
||||
* @return
|
||||
*/
|
||||
Admin login(AdminLoginDTO adminLoginDTO);
|
||||
|
||||
/**
|
||||
* 根据id查询管理员
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Admin getById(int id);
|
||||
|
||||
/**
|
||||
* 添加管理课程
|
||||
* @param adminDTO
|
||||
* @param courseDTO
|
||||
*/
|
||||
void addCourse(AdminDTO adminDTO, CourseDTO courseDTO);
|
||||
|
||||
/**
|
||||
* 退出管理课程
|
||||
* @param adminDTO
|
||||
* @param courseDTO
|
||||
*/
|
||||
void dropCourse(AdminDTO adminDTO, CourseDTO courseDTO);
|
||||
|
||||
/**
|
||||
* 查询自己加入管理的课程
|
||||
* @return
|
||||
*/
|
||||
List<CourseVO> courseList();
|
||||
|
||||
/**
|
||||
* 添加管理员
|
||||
* @param adminDTO
|
||||
*/
|
||||
void addAdmin(AdminDTO adminDTO);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param adminDTO
|
||||
*/
|
||||
void changePassword(AdminDTO adminDTO);
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
package com.wbq.service;
|
||||
|
||||
import com.wbq.dto.CourseDTO;
|
||||
import com.wbq.vo.CourseVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CourseService {
|
||||
|
||||
/**
|
||||
* 查询所有的班级
|
||||
* @return
|
||||
*/
|
||||
List<CourseVO> courseList();
|
||||
|
||||
|
||||
/**
|
||||
* 增加新课程
|
||||
* @param courseDescription
|
||||
*/
|
||||
int addCourse(String courseDescription);
|
||||
}
|
||||
@ -1,134 +0,0 @@
|
||||
package com.wbq.service.impl;
|
||||
|
||||
import com.wbq.context.BaseContext;
|
||||
import com.wbq.dto.AdminDTO;
|
||||
import com.wbq.dto.AdminLoginDTO;
|
||||
import com.wbq.dto.CourseDTO;
|
||||
import com.wbq.dto.StudentDTO;
|
||||
import com.wbq.entity.Admin;
|
||||
import com.wbq.entity.Course;
|
||||
import com.wbq.entity.Student;
|
||||
import com.wbq.mapper.AdminCourseMapper;
|
||||
import com.wbq.mapper.AdminMapper;
|
||||
import com.wbq.mapper.CourseMapper;
|
||||
import com.wbq.service.AdminService;
|
||||
import com.wbq.vo.CourseVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// service服务层业务代码
|
||||
@Service
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
@Autowired
|
||||
private AdminMapper adminMapper;
|
||||
@Autowired
|
||||
private AdminCourseMapper adminCourseMapper;
|
||||
@Autowired
|
||||
private CourseMapper courseMapper;
|
||||
|
||||
/**
|
||||
* 更新管理员个人信息
|
||||
* @param adminDTO
|
||||
*/
|
||||
@Override
|
||||
public void update(AdminDTO adminDTO) {
|
||||
adminMapper.update(adminDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员登录
|
||||
* @param adminLoginDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Admin login(AdminLoginDTO adminLoginDTO) {
|
||||
Admin admin = null;
|
||||
String hashedPassword = adminMapper.getPasswordByAdminId(adminLoginDTO.getAdminId());
|
||||
// 使用BCrypt的checkpw方法来验证密码
|
||||
boolean isPasswordCorrect = BCrypt.checkpw(adminLoginDTO.getPassword(), hashedPassword);
|
||||
|
||||
// 验证成功
|
||||
if (isPasswordCorrect)
|
||||
admin = adminMapper.getByAdminId(adminLoginDTO.getAdminId());
|
||||
return admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询管理员
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Admin getById(int id) {
|
||||
return adminMapper.getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加管理课程
|
||||
* @param adminDTO
|
||||
* @param courseDTO
|
||||
*/
|
||||
@Override
|
||||
public void addCourse(AdminDTO adminDTO, CourseDTO courseDTO) {
|
||||
adminCourseMapper.insert(adminDTO.getAdminId(), courseDTO.getCourseId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出管理课程
|
||||
* @param adminDTO
|
||||
* @param courseDTO
|
||||
*/
|
||||
@Override
|
||||
public void dropCourse(AdminDTO adminDTO, CourseDTO courseDTO) {
|
||||
adminCourseMapper.delete(adminDTO.getAdminId(), courseDTO.getCourseId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自己加入管理的课程
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CourseVO> courseList() {
|
||||
Admin admin = adminMapper.getById(BaseContext.getCurrentId());
|
||||
int adminId = admin.getAdminId();
|
||||
List<Integer> courseIds = adminCourseMapper.getByAdminId(adminId);
|
||||
List<Course> courseList = courseMapper.getByCourseIdList(courseIds);
|
||||
List<CourseVO> courseVOList = new ArrayList<>();
|
||||
|
||||
for (Course course : courseList) {
|
||||
CourseVO courseVO = new CourseVO();
|
||||
BeanUtils.copyProperties(course, courseVO);
|
||||
courseVOList.add(courseVO);
|
||||
}
|
||||
|
||||
return courseVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加管理员
|
||||
* @param adminDTO
|
||||
*/
|
||||
@Override
|
||||
public void addAdmin(AdminDTO adminDTO) {
|
||||
String hashPassword = BCrypt.hashpw(adminDTO.getPassword(), BCrypt.gensalt());
|
||||
adminDTO.setPassword(hashPassword);
|
||||
adminMapper.insert(adminDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param adminDTO
|
||||
*/
|
||||
@Override
|
||||
public void changePassword(AdminDTO adminDTO) {
|
||||
String password = adminDTO.getPassword();
|
||||
String hashedPassword = BCrypt.hashpw(password, BCrypt.gensalt());
|
||||
adminDTO.setPassword(hashedPassword);
|
||||
adminMapper.update(adminDTO);
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.wbq.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.BeanUtil;
|
||||
import com.wbq.dto.CourseDTO;
|
||||
import com.wbq.entity.Course;
|
||||
import com.wbq.mapper.CourseMapper;
|
||||
import com.wbq.service.CourseService;
|
||||
import com.wbq.vo.CourseVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
public class CourseServiceImpl implements CourseService {
|
||||
@Autowired
|
||||
private CourseMapper courseMapper;
|
||||
|
||||
/**
|
||||
* 查询所有的班级
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CourseVO> courseList() {
|
||||
List<Course> courseList = courseMapper.getCourses();
|
||||
List<CourseVO> courseVOList = new ArrayList<>();
|
||||
|
||||
for (Course course : courseList) {
|
||||
CourseVO courseVO = new CourseVO();
|
||||
BeanUtils.copyProperties(course, courseVO);
|
||||
courseVOList.add(courseVO);
|
||||
}
|
||||
|
||||
return courseVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加新课程
|
||||
* @param courseDescription
|
||||
*/
|
||||
@Override
|
||||
public int addCourse(String courseDescription) {
|
||||
Random random = new Random();
|
||||
int courseId = 10000 + random.nextInt(90000);
|
||||
while (courseMapper.existsByCourseId(courseId)) {
|
||||
courseId = 10000 + random.nextInt(90000);
|
||||
}
|
||||
CourseDTO courseDTO = CourseDTO.builder()
|
||||
.courseId(courseId)
|
||||
.description(courseDescription)
|
||||
.build();
|
||||
courseMapper.insert(courseDTO);
|
||||
return courseId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
package com.wbq.utils;
|
||||
|
||||
import com.wbq.properties.JwtProperties;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
// 实用工具集合
|
||||
@Component
|
||||
public class JwtUtils {
|
||||
@Autowired
|
||||
private JwtProperties jwtProperties;
|
||||
|
||||
/**
|
||||
* 生成jwt
|
||||
* 使用Hs256算法, 私匙使用固定秘钥
|
||||
*
|
||||
* @param claims
|
||||
* @return
|
||||
*/
|
||||
public String createJWT(Map<String, Object> claims) {
|
||||
// 设置签名算法
|
||||
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
|
||||
// 设置截止时间
|
||||
long expMillis = System.currentTimeMillis() + jwtProperties.getAdminTtl();
|
||||
Date exp = new Date(expMillis);
|
||||
|
||||
// debug
|
||||
// System.out.println(claims);
|
||||
// System.out.println(jwtProperties.getAdminSecretKey());
|
||||
|
||||
// 生成JWT
|
||||
String JWT = Jwts.builder()
|
||||
.setClaims(claims)
|
||||
.signWith(signatureAlgorithm, jwtProperties.getAdminSecretKey().getBytes(StandardCharsets.UTF_8))
|
||||
.setExpiration(exp)
|
||||
.compact();
|
||||
|
||||
// debug
|
||||
// System.out.println(claims);
|
||||
|
||||
return JWT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Token解密
|
||||
*
|
||||
* @param token 加密后的token
|
||||
* @return
|
||||
*/
|
||||
public Claims parseJWT(String token) {
|
||||
// 得到DefaultJwtParser
|
||||
Claims claims = Jwts.parser()
|
||||
.setSigningKey(jwtProperties.getAdminSecretKey().getBytes(StandardCharsets.UTF_8))
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
return claims;
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.wbq.utils;
|
||||
|
||||
|
||||
import com.wbq.constant.EmailConstant;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Transport;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Properties;
|
||||
|
||||
@Component
|
||||
public class MailUtils {
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param fromEmail
|
||||
* @param toEmail
|
||||
* @param emailAuthorizationCode
|
||||
* @param subject
|
||||
* @param text
|
||||
*/
|
||||
public static void sendEmail(String fromEmail, String toEmail,
|
||||
String emailAuthorizationCode,
|
||||
String subject, String text) {
|
||||
// 配置SMTP服务器的属性
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", EmailConstant.SMTP_HOST);
|
||||
props.put("mail.smtp.port", EmailConstant.SMTP_HOST);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.ssl.enable", "true");
|
||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||
|
||||
Session session = Session.getInstance(props, new jakarta.mail.Authenticator() {
|
||||
protected jakarta.mail.PasswordAuthentication getPasswordAuthentication() {
|
||||
return new jakarta.mail.PasswordAuthentication(fromEmail, emailAuthorizationCode);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(fromEmail));
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail));
|
||||
message.setSubject(subject);
|
||||
message.setText(text);
|
||||
|
||||
Transport.send(message);
|
||||
System.out.println("邮件已发送成功!");
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
// 返回前端的可视化数据
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(description = "管理员登录返回的数据格式")
|
||||
public class AdminLoginVO {
|
||||
@ApiModelProperty("账号")
|
||||
private int adminId;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("jwt令牌")
|
||||
private String token;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AdminRegistryVO {
|
||||
private String registrationStatus;
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CourseCallVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime callTime;
|
||||
// 课程
|
||||
private String courseDescription;
|
||||
// 管理员
|
||||
private String adminName;
|
||||
// 加分
|
||||
private double score;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CourseVO {
|
||||
private int courseId;
|
||||
private String description;
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StudentCourseInfoVO {
|
||||
// 学号
|
||||
private int studentId;
|
||||
// 姓名
|
||||
private String name;
|
||||
// 被叫次数
|
||||
private int callCount;
|
||||
// 课程积分
|
||||
private double score;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(description = "学生登录返回的数据格式")
|
||||
public class StudentLoginVO {
|
||||
@ApiModelProperty("账号")
|
||||
private int studentId;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("jwt令牌")
|
||||
private String token;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.wbq.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StudentRegistryVO {
|
||||
private String registrationStatus;
|
||||
}
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/rollcall?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: 1234
|
||||
@ -1,48 +0,0 @@
|
||||
server:
|
||||
port: 8888
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: RollCallSystem
|
||||
profiles:
|
||||
active: dev
|
||||
main:
|
||||
allow-circular-references: true
|
||||
autoconfigure:
|
||||
exclude: org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
|
||||
|
||||
mybatis:
|
||||
#mapper配置文件
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
wbq:
|
||||
mapper: debug
|
||||
service: info
|
||||
controller: info
|
||||
wbq:
|
||||
jwt:
|
||||
admin-secret-key: bugaoshuni
|
||||
admin-token-name: admin_token
|
||||
admin-ttl: 7200000
|
||||
|
||||
student-secret-key: yebugaoshuni
|
||||
student-token-name: student_token
|
||||
student-ttl: 7200000
|
||||
|
||||
qq:
|
||||
email-count: 2108095381@qq.com
|
||||
email-authorization-code: alwlqedbpbpfdgfc
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
base-path: /doc
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.wbq.mapper.AdminCourseMapper">
|
||||
</mapper>
|
||||
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.wbq.mapper.AdminMapper">
|
||||
<update id="update" parameterType="com.wbq.dto.AdminDTO">
|
||||
update admin
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="password != null">
|
||||
password = #{password}
|
||||
</if>
|
||||
</set>
|
||||
where admin_id = #{adminId}
|
||||
</update>
|
||||
|
||||
<select id="getByAdminLoginDTO" parameterType="com.wbq.dto.AdminLoginDTO" resultType="com.wbq.entity.Admin">
|
||||
select * from admin
|
||||
where admin_id = #{adminId} and password = #{password}
|
||||
</select>
|
||||
|
||||
<select id="getPasswordByAdminId" resultType="java.lang.String" parameterType="java.lang.Integer">
|
||||
select password from admin
|
||||
where admin_id = #{adminId}
|
||||
</select>
|
||||
|
||||
<select id="getByAdminId" resultType="com.wbq.entity.Admin" parameterType="java.lang.Integer">
|
||||
select * from admin
|
||||
where admin_id = #{adminId}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.wbq.mapper.CallRecordMapper">
|
||||
<update id="update" parameterType="com.wbq.entity.CallRecord">
|
||||
update callrecord
|
||||
<set>
|
||||
<if test="callTime != null">
|
||||
call_time = #{callTime},
|
||||
</if>
|
||||
<if test="courseDescription != null">
|
||||
course_description = #{courseDescription},
|
||||
</if>
|
||||
<if test="adminName != null">
|
||||
admin_name = #{adminName},
|
||||
</if>
|
||||
<if test="score != null">
|
||||
score = #{score}
|
||||
</if>
|
||||
where id = #{id}
|
||||
</set>
|
||||
</update>
|
||||
</mapper>
|
||||
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.wbq.mapper.CourseMapper">
|
||||
<select id="getByCourseIdList" resultType="com.wbq.entity.Course">
|
||||
select * from course
|
||||
where course_id in
|
||||
<foreach collection="courseIdList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="existsByCourseId" resultType="boolean">
|
||||
select exists (select 1 from course where course_id = #{courseId})
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.wbq.mapper.StudentCourseMapper">
|
||||
<insert id="batchInsert">
|
||||
insert into rollcall.studentcourse (student_id, course_id) values
|
||||
<foreach collection="list" item="studentDTO" separator=",">
|
||||
(#{studentDTO.studentId}, #{courseId})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.wbq.mapper.StudentMapper">
|
||||
<select id="pageQuery" parameterType="com.wbq.dto.StudentPageQueryDTO"
|
||||
resultType="com.wbq.entity.Student">
|
||||
select * from students
|
||||
where student_id in
|
||||
<foreach collection="studentIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
order by FIELD(student_id,
|
||||
<foreach collection="studentIds" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
|
||||
<!--<select id="getByCallCount" resultType="com.wbq.entity.Student">
|
||||
select * from students
|
||||
<where>
|
||||
<if test="minCount != null">
|
||||
and call_count >= #{minCount}
|
||||
</if>
|
||||
<if test="maxCount != null">
|
||||
and call_count <= #{maxCount}
|
||||
</if>
|
||||
</where>
|
||||
order by score desc
|
||||
</select>-->
|
||||
|
||||
<!--<update id="update" parameterType="com.wbq.dto.StudentDTO">
|
||||
update students
|
||||
<set>
|
||||
<if test="score != null">
|
||||
score = #{score},
|
||||
</if>
|
||||
<if test="callCount != null">
|
||||
call_count = #{callCount},
|
||||
</if>
|
||||
</set>
|
||||
where student_id = #{studentId}
|
||||
</update>-->
|
||||
|
||||
<select id="getByStudentLoginDTO" parameterType="com.wbq.dto.StudentLoginDTO" resultType="com.wbq.entity.Student">
|
||||
select * from students
|
||||
where student_id = #{studentId} and password = #{password}
|
||||
</select>
|
||||
|
||||
<select id="getByStudentIds" resultType="com.wbq.entity.Student">
|
||||
select * from students
|
||||
where student_id in
|
||||
<foreach collection="studentIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getPasswordByStudentId" resultType="java.lang.String">
|
||||
select password from students
|
||||
where student_id = #{studentId}
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="com.wbq.dto.StudentDTO">
|
||||
update students
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="password != null">
|
||||
password = #{password}
|
||||
</if>
|
||||
</set>
|
||||
where student_id = #{studentId}
|
||||
</update>
|
||||
|
||||
<insert id="batchInsert">
|
||||
insert into rollcall.students (student_id, name, password) values
|
||||
<foreach collection="list" item="studentDTO" separator=",">
|
||||
(#{studentDTO.studentId}, #{studentDTO.name}, #{studentDTO.password})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Binary file not shown.
Binary file not shown.
@ -1,6 +0,0 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/rollcall?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: 1234
|
||||
@ -1,48 +0,0 @@
|
||||
server:
|
||||
port: 8888
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: RollCallSystem
|
||||
profiles:
|
||||
active: dev
|
||||
main:
|
||||
allow-circular-references: true
|
||||
autoconfigure:
|
||||
exclude: org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
|
||||
|
||||
mybatis:
|
||||
#mapper配置文件
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
wbq:
|
||||
mapper: debug
|
||||
service: info
|
||||
controller: info
|
||||
wbq:
|
||||
jwt:
|
||||
admin-secret-key: bugaoshuni
|
||||
admin-token-name: admin_token
|
||||
admin-ttl: 7200000
|
||||
|
||||
student-secret-key: yebugaoshuni
|
||||
student-token-name: student_token
|
||||
student-ttl: 7200000
|
||||
|
||||
qq:
|
||||
email-count: 2108095381@qq.com
|
||||
email-authorization-code: alwlqedbpbpfdgfc
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
base-path: /doc
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue