From adf2d765f6927b8e60f6aeb5f1f9970255489a24 Mon Sep 17 00:00:00 2001 From: gsx03 <1586214280@qq.com> Date: Tue, 29 Apr 2025 22:20:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/entity/ChatEntity.java | 152 ++--- src/main/java/com/entity/ConfigEntity.java | 48 +- .../com/entity/DiscusskechengxinxiEntity.java | 297 +++++----- src/main/java/com/entity/EIException.java | 44 +- src/main/java/com/entity/ExampaperEntity.java | 126 ++-- .../java/com/entity/ExamquestionEntity.java | 247 ++++---- .../java/com/entity/ExamrecordEntity.java | 308 +++++----- src/main/java/com/entity/ForumEntity.java | 180 +++--- .../com/entity/GoumaidekechengEntity.java | 440 +++++++------- .../java/com/entity/KechengleixingEntity.java | 83 ++- .../java/com/entity/KechengxinxiEntity.java | 234 ++++---- src/main/java/com/entity/MessagesEntity.java | 137 +++-- src/main/java/com/entity/NewsEntity.java | 137 +++-- .../java/com/entity/ShipindianboEntity.java | 215 ++++--- src/main/java/com/entity/StoreupEntity.java | 155 ++--- src/main/java/com/entity/TokenEntity.java | 142 +++-- src/main/java/com/entity/UserEntity.java | 61 +- src/main/java/com/entity/WodebijiEntity.java | 119 ++-- .../java/com/entity/WodekechengEntity.java | 137 +++-- .../java/com/entity/XiaoxitongzhiEntity.java | 144 ++--- src/main/java/com/entity/XuekeEntity.java | 85 ++- src/main/java/com/entity/YonghuEntity.java | 172 +++--- .../java/com/entity/ZhiyeguihuaEntity.java | 236 +++----- .../interceptor/AuthorizationInterceptor.java | 147 ++--- .../com/service/impl/ChatServiceImpl.java | 83 ++- .../service/impl/ExampaperServiceImpl.java | 546 ++++++++++++++++- .../service/impl/ExamquestionServiceImpl.java | 493 +++++++++++++++- .../service/impl/ExamrecordServiceImpl.java | 549 +++++++++++++++++- .../com/service/impl/ForumServiceImpl.java | 82 ++- .../impl/GoumaidekechengServiceImpl.java | 82 ++- .../impl/KechengleixingServiceImpl.java | 82 ++- .../service/impl/KechengxinxiServiceImpl.java | 82 ++- .../com/service/impl/MessagesServiceImpl.java | 82 ++- .../com/service/impl/NewsServiceImpl.java | 82 ++- .../service/impl/ShipindianboServiceImpl.java | 82 ++- .../com/service/impl/StoreupServiceImpl.java | 82 ++- .../com/service/impl/TokenServiceImpl.java | 88 ++- .../com/service/impl/UserServiceImpl.java | 53 +- .../com/service/impl/WodebijiServiceImpl.java | 82 ++- .../service/impl/WodekechengServiceImpl.java | 82 ++- .../impl/XiaoxitongzhiServiceImpl.java | 82 ++- .../com/service/impl/XuekeServiceImpl.java | 82 ++- .../com/service/impl/YonghuServiceImpl.java | 82 ++- .../service/impl/ZhiyeguihuaServiceImpl.java | 83 ++- 44 files changed, 4585 insertions(+), 2422 deletions(-) diff --git a/src/main/java/com/entity/ChatEntity.java b/src/main/java/com/entity/ChatEntity.java index 2b7d690..ff445a9 100644 --- a/src/main/java/com/entity/ChatEntity.java +++ b/src/main/java/com/entity/ChatEntity.java @@ -1,164 +1,166 @@ +// 声明当前类所属的包为com.entity,用于组织和管理实体类 package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解,用于标识数据库表的主键字段 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解,指定当前实体类对应的数据库表名 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解,当前类未使用,保留导入以备扩展 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类,用于构造函数中属性复制的异常处理 import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口,使当前类支持对象序列化,便于网络传输或持久化存储 import java.io.Serializable; +// 导入Java中处理日期和时间的类,用于定义日期类型的字段 import java.util.Date; +// 导入Java中处理列表集合的接口,当前类未直接使用,保留导入以备扩展 import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解,确保前端与后端日期参数的格式统一 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解,指定日期在JSON中的序列化格式 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类,用于构造函数中对象属性的复制 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类,用于配置主键生成策略 import com.baomidou.mybatisplus.enums.IdType; - /** - * 客户服务 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 + * 客户服务实体类 + * 对应数据库表chat,用于存储用户与管理员的聊天记录及客服回复信息 + * 实现数据库的通用增删改查操作 */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为chat @TableName("chat") +// 定义泛型实体类ChatEntity,实现Serializable接口以支持对象的序列化和反序列化 public class ChatEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建空的实体对象(满足框架反射创建对象的需求) public ChatEntity() { - } - + + // 带参构造函数,接收泛型对象t,用于将t的属性复制到当前实体对象 public ChatEntity(T t) { + // 尝试使用BeanUtils工具类复制对象属性 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可自定义异常处理逻辑) e.printStackTrace(); } } - - /** - * 主键id - */ - @TableId + + // 标记为主键字段,指定主键生成策略为数据库自增(AUTO) + @TableId(type = IdType.AUTO) + // 定义Long类型的id字段,用于存储数据库表的主键值,唯一标识一条聊天记录 private Long id; - /** - * 用户id - */ - + + // 定义Long类型的userid字段,用于存储发起聊天的用户ID(外键,关联用户表) private Long userid; - - /** - * 管理员id - */ - + + // 定义Long类型的adminid字段,用于存储回复聊天的管理员ID(外键,关联管理员表) private Long adminid; - - /** - * 提问 - */ - + + // 定义String类型的ask字段,用于存储用户的提问内容 private String ask; - - /** - * 回复 - */ - + + // 定义String类型的reply字段,用于存储管理员的回复内容(可为空) private String reply; - - /** - * 是否回复 - */ - + + // 定义Integer类型的isreply字段,用于标识是否已回复(0表示未回复,1表示已回复) private Integer isreply; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + + // 使用Jackson注解指定日期在JSON中的格式:时区为GMT+8,格式为"yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + // 定义Date类型的addtime字段,用于存储聊天记录的创建时间 private Date addtime; + // ------------------------- Getter 和 Setter 方法 ------------------------- + + // 获取聊天记录创建时间的方法 public Date getAddtime() { return addtime; } + + // 设置聊天记录创建时间的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取主键ID的方法 public Long getId() { return id; } + // 设置主键ID的方法(通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { this.id = id; } - /** - * 设置:用户id - */ + + // 设置用户ID的方法 public void setUserid(Long userid) { this.userid = userid; } - /** - * 获取:用户id - */ + + // 获取用户ID的方法 public Long getUserid() { return userid; } - /** - * 设置:管理员id - */ + + // 设置管理员ID的方法 public void setAdminid(Long adminid) { this.adminid = adminid; } - /** - * 获取:管理员id - */ + + // 获取管理员ID的方法 public Long getAdminid() { return adminid; } - /** - * 设置:提问 - */ + + // 设置用户提问内容的方法 public void setAsk(String ask) { this.ask = ask; } - /** - * 获取:提问 - */ + + // 获取用户提问内容的方法 public String getAsk() { return ask; } - /** - * 设置:回复 - */ + + // 设置管理员回复内容的方法 public void setReply(String reply) { this.reply = reply; } - /** - * 获取:回复 - */ + + // 获取管理员回复内容的方法 public String getReply() { return reply; } - /** - * 设置:是否回复 - */ + + // 设置是否回复状态的方法(0未回复,1已回复) public void setIsreply(Integer isreply) { this.isreply = isreply; } - /** - * 获取:是否回复 - */ + + // 获取是否回复状态的方法 public Integer getIsreply() { return isreply; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ConfigEntity.java b/src/main/java/com/entity/ConfigEntity.java index 57872be..b0b52a3 100644 --- a/src/main/java/com/entity/ConfigEntity.java +++ b/src/main/java/com/entity/ConfigEntity.java @@ -1,53 +1,67 @@ +// 声明当前类所属的包为com.entity,用于组织和管理实体类 package com.entity; +// 导入Java序列化接口,使当前类支持对象序列化,便于网络传输或持久化存储 import java.io.Serializable; +// 导入MyBatis-Plus框架中用于标记主键的注解,用于标识数据库表的主键字段 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解,指定当前实体类对应的数据库表名 import com.baomidou.mybatisplus.annotations.TableName; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类,用于配置主键生成策略 import com.baomidou.mybatisplus.enums.IdType; /** -* 类说明 : -*/ + * 系统配置实体类 + * 对应数据库表config,用于存储系统级配置参数,支持通用的增删改查操作 + */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为config @TableName("config") -public class ConfigEntity implements Serializable{ -private static final long serialVersionUID = 1L; - +// 定义ConfigEntity类,实现Serializable接口以支持对象的序列化和反序列化 +public class ConfigEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) + private static final long serialVersionUID = 1L; + + // 标记为主键字段,指定主键生成策略为数据库自增(AUTO) @TableId(type = IdType.AUTO) + // 定义Long类型的id字段,用于存储数据库表的主键值,唯一标识一条配置记录 private Long id; - - /** - * key - */ - private String name; - - /** - * value - */ - private String value; + // 定义String类型的name字段,用于存储配置项的键名(唯一标识符) + private String name; // 配置项的唯一键名,如"site_name"、"upload_path"等 + + // 定义String类型的value字段,用于存储配置项对应的参数值 + private String value; // 配置项的值,如具体的配置内容或路径 + + // ------------------------- Getter 和 Setter 方法 ------------------------- + + // 获取主键ID的方法,返回数据库自动生成的主键值 public Long getId() { return id; } + // 设置主键ID的方法(通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { this.id = id; } + // 获取配置项键名的方法,返回配置项的唯一标识符 public String getName() { return name; } + // 设置配置项键名的方法,用于设置配置项的唯一标识符 public void setName(String name) { this.name = name; } + // 获取配置项值的方法,返回配置项对应的参数值 public String getValue() { return value; } + // 设置配置项值的方法,用于设置配置项对应的参数值 public void setValue(String value) { this.value = value; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/DiscusskechengxinxiEntity.java b/src/main/java/com/entity/DiscusskechengxinxiEntity.java index 0865be0..bbd0b92 100644 --- a/src/main/java/com/entity/DiscusskechengxinxiEntity.java +++ b/src/main/java/com/entity/DiscusskechengxinxiEntity.java @@ -1,164 +1,181 @@ +// 声明该类所在的包为com.entity,用于组织和管理相关实体类 package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解,用于标识数据库表的主键字段 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解,指定当前实体类对应的数据库表名 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中用于验证字符串不为空字符串(去除首尾空格后)的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中用于验证集合、数组等不为空的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中用于验证对象不为null的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化和反序列化时某些属性的注解,当前类未使用,保留导入以备扩展 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中用于处理方法调用异常的类,用于带参构造函数中属性复制时的异常处理 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类,使当前类支持对象序列化,便于网络传输或持久化存储 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类,用于定义日期类型的字段 import java.util.Date; +// 导入Java中用于处理列表集合的接口,当前类未直接使用,保留导入以备扩展 import java.util.List; +// 导入Spring框架中用于格式化日期的注解,用于前端与后端日期格式的统一转换 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解,指定日期在JSON中的序列化格式 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类,用于带参构造函数中对象属性的复制 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 课程信息评论表 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 课程信息评论表 +// 数据库通用操作实体类(普通增删改查),用于存储课程信息的评论及回复相关数据 +// @author +// @email +// @date 2021-05-09 15:46:15 +// 使用MyBatis-Plus的注解指定该实体类对应的数据库表名为discusskechengxinxi @TableName("discusskechengxinxi") +// 定义一个泛型类DiscusskechengxinxiEntity,实现Serializable接口以支持对象的序列化 public class DiscusskechengxinxiEntity implements Serializable { - private static final long serialVersionUID = 1L; - - - public DiscusskechengxinxiEntity() { - - } - - public DiscusskechengxinxiEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * 主键id - */ - @TableId - private Long id; - /** - * 关联表id - */ - - private Long refid; - - /** - * 用户id - */ - - private Long userid; - - /** - * 用户名 - */ - - private String nickname; - - /** - * 评论内容 - */ - - private String content; - - /** - * 回复内容 - */ - - private String reply; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - private Date addtime; - - public Date getAddtime() { - return addtime; - } - public void setAddtime(Date addtime) { - this.addtime = addtime; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - /** - * 设置:关联表id - */ - public void setRefid(Long refid) { - this.refid = refid; - } - /** - * 获取:关联表id - */ - public Long getRefid() { - return refid; - } - /** - * 设置:用户id - */ - public void setUserid(Long userid) { - this.userid = userid; - } - /** - * 获取:用户id - */ - public Long getUserid() { - return userid; - } - /** - * 设置:用户名 - */ - public void setNickname(String nickname) { - this.nickname = nickname; - } - /** - * 获取:用户名 - */ - public String getNickname() { - return nickname; - } - /** - * 设置:评论内容 - */ - public void setContent(String content) { - this.content = content; - } - /** - * 获取:评论内容 - */ - public String getContent() { - return content; - } - /** - * 设置:回复内容 - */ - public void setReply(String reply) { - this.reply = reply; - } - /** - * 获取:回复内容 - */ - public String getReply() { - return reply; - } - -} + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性,建议与类结构变更时同步更新 + private static final long serialVersionUID = 1L; + + // 无参构造函数,用于创建一个空的DiscusskechengxinxiEntity对象,满足框架反射创建对象的需求 + public DiscusskechengxinxiEntity() { + + } + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 + public DiscusskechengxinxiEntity(T t) { + try { + // 使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // 打印异常堆栈信息,开发阶段临时处理,生产环境可自定义异常处理逻辑 + e.printStackTrace(); + } + } + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 + @TableId + // 定义一个Long类型的属性id,用于存储主键,唯一标识一条评论记录 + private Long id; + + // 关联表id + // 定义一个Long类型的属性refid,用于存储关联表的id,通常关联课程信息表的主键 + private Long refid; + + // 用户id + // 定义一个Long类型的属性userid,用于存储发表评论的用户的id,关联用户表的主键 + private Long userid; + + // 用户名 + // 定义一个String类型的属性nickname,用于存储发表评论的用户的昵称 + private String nickname; + + // 评论内容 + // 定义一个String类型的属性content,用于存储用户对课程信息的评论内容 + private String content; + + // 回复内容 + // 定义一个String类型的属性reply,用于存储管理员或其他用户对该评论的回复内容 + private String reply; + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式,确保前端传入的日期格式正确解析 + @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储评论的添加时间 + private Date addtime; + + // 获取addtime属性的方法,返回评论的添加时间 + public Date getAddtime() { + return addtime; + } + + // 设置addtime属性的方法,用于设置评论的添加时间 + public void setAddtime(Date addtime) { + this.addtime = addtime; + } + + // 获取id属性的方法,返回评论记录的主键 + public Long getId() { + return id; + } + + // 设置id属性的方法,通常由数据库自动生成,代码中较少手动设置 + public void setId(Long id) { + this.id = id; + } + + // 设置:关联表id + // 设置refid属性的方法,用于设置关联课程信息表的主键 + public void setRefid(Long refid) { + this.refid = refid; + } + + // 获取:关联表id + // 获取refid属性的方法,返回关联课程信息表的主键 + public Long getRefid() { + return refid; + } + + // 设置:用户id + // 设置userid属性的方法,用于设置发表评论的用户的id + public void setUserid(Long userid) { + this.userid = userid; + } + + // 获取:用户id + // 获取userid属性的方法,返回发表评论的用户的id + public Long getUserid() { + return userid; + } + + // 设置:用户名 + // 设置nickname属性的方法,用于设置发表评论的用户的昵称 + public void setNickname(String nickname) { + this.nickname = nickname; + } + + // 获取:用户名 + // 获取nickname属性的方法,返回发表评论的用户的昵称 + public String getNickname() { + return nickname; + } + + // 设置:评论内容 + // 设置content属性的方法,用于设置用户对课程信息的评论内容 + public void setContent(String content) { + this.content = content; + } + + // 获取:评论内容 + // 获取content属性的方法,返回用户对课程信息的评论内容 + public String getContent() { + return content; + } + + // 设置:回复内容 + // 设置reply属性的方法,用于设置管理员或其他用户对该评论的回复内容 + public void setReply(String reply) { + this.reply = reply; + } + + // 获取:回复内容 + // 获取reply属性的方法,返回管理员或其他用户对该评论的回复内容 + public String getReply() { + return reply; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/EIException.java b/src/main/java/com/entity/EIException.java index 2ebfb56..8d2e24f 100644 --- a/src/main/java/com/entity/EIException.java +++ b/src/main/java/com/entity/EIException.java @@ -1,52 +1,72 @@ - +// 声明该类所在的包为com.entity package com.entity; /** * 自定义异常 */ +// 定义一个名为EIException的自定义异常类,继承自RuntimeException public class EIException extends RuntimeException { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性 private static final long serialVersionUID = 1L; - - private String msg; - private int code = 500; - - public EIException(String msg) { + + // 定义一个字符串类型的属性msg,用于存储异常信息 + private String msg; + // 定义一个整数类型的属性code,用于存储异常状态码,默认值为500 + private int code = 500; + + // 定义一个构造函数,接收一个字符串类型的参数msg,用于创建异常对象 + public EIException(String msg) { + // 调用父类的构造函数,传入异常信息 super(msg); + // 将传入的异常信息赋值给当前对象的msg属性 this.msg = msg; } - + + // 定义一个构造函数,接收一个字符串类型的参数msg和一个Throwable类型的参数e,用于创建异常对象 public EIException(String msg, Throwable e) { + // 调用父类的构造函数,传入异常信息和异常原因 super(msg, e); + // 将传入的异常信息赋值给当前对象的msg属性 this.msg = msg; } - + + // 定义一个构造函数,接收一个字符串类型的参数msg和一个整数类型的参数code,用于创建异常对象 public EIException(String msg, int code) { + // 调用父类的构造函数,传入异常信息 super(msg); + // 将传入的异常信息赋值给当前对象的msg属性 this.msg = msg; + // 将传入的异常状态码赋值给当前对象的code属性 this.code = code; } - + + // 定义一个构造函数,接收一个字符串类型的参数msg、一个整数类型的参数code和一个Throwable类型的参数e,用于创建异常对象 public EIException(String msg, int code, Throwable e) { + // 调用父类的构造函数,传入异常信息和异常原因 super(msg, e); + // 将传入的异常信息赋值给当前对象的msg属性 this.msg = msg; + // 将传入的异常状态码赋值给当前对象的code属性 this.code = code; } + // 获取msg属性的方法 public String getMsg() { return msg; } + // 设置msg属性的方法 public void setMsg(String msg) { this.msg = msg; } + // 获取code属性的方法 public int getCode() { return code; } + // 设置code属性的方法 public void setCode(int code) { this.code = code; } - - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ExampaperEntity.java b/src/main/java/com/entity/ExampaperEntity.java index b0e8337..05a43fb 100644 --- a/src/main/java/com/entity/ExampaperEntity.java +++ b/src/main/java/com/entity/ExampaperEntity.java @@ -1,128 +1,150 @@ +// 声明该类所在的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中用于验证字符串不为空字符串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化和反序列化时的某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 试卷表 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 试卷表 +// 数据库通用操作实体类(普通增删改查) +// @author +// @email +// @date 2021-05-09 15:46:15 +// 使用MyBatis-Plus的注解指定该实体类对应的数据库表名为exampaper @TableName("exampaper") +// 定义一个泛型类ExampaperEntity,实现Serializable接口以支持对象的序列化 public class ExampaperEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的ExampaperEntity对象 public ExampaperEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public ExampaperEntity(T t) { try { + // 使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 // TODO Auto-generated catch block + // 打印异常堆栈信息 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 试卷名称 - */ - + + // 试卷名称 + // 定义一个String类型的属性name,用于存储试卷名称 private String name; - - /** - * 考试时长(分钟) - */ - + + // 考试时长(分钟) + // 定义一个Integer类型的属性time,用于存储考试时长 private Integer time; - - /** - * 试卷状态 - */ - + + // 试卷状态 + // 定义一个Integer类型的属性status,用于存储试卷状态 private Integer status; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } - /** - * 设置:试卷名称 - */ + + // 设置:试卷名称 + // 设置name属性的方法 public void setName(String name) { this.name = name; } - /** - * 获取:试卷名称 - */ + + // 获取:试卷名称 + // 获取name属性的方法 public String getName() { return name; } - /** - * 设置:考试时长(分钟) - */ + + // 设置:考试时长(分钟) + // 设置time属性的方法 public void setTime(Integer time) { this.time = time; } - /** - * 获取:考试时长(分钟) - */ + + // 获取:考试时长(分钟) + // 获取time属性的方法 public Integer getTime() { return time; } - /** - * 设置:试卷状态 - */ + + // 设置:试卷状态 + // 设置status属性的方法 public void setStatus(Integer status) { this.status = status; } - /** - * 获取:试卷状态 - */ + + // 获取:试卷状态 + // 获取status属性的方法 public Integer getStatus() { return status; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ExamquestionEntity.java b/src/main/java/com/entity/ExamquestionEntity.java index 2c66203..4ea570d 100644 --- a/src/main/java/com/entity/ExamquestionEntity.java +++ b/src/main/java/com/entity/ExamquestionEntity.java @@ -1,236 +1,247 @@ +// 声明该类所在的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中用于验证字符串不为空字符串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化和反序列化时的某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 试题表 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 试题表 +// 数据库通用操作实体类(普通增删改查) +// @author +// @email +// @date 2021-05-09 15:46:15 +// 使用MyBatis-Plus的注解指定该实体类对应的数据库表名为examquestion @TableName("examquestion") +// 定义一个泛型类ExamquestionEntity,实现Serializable接口以支持对象的序列化 public class ExamquestionEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的ExamquestionEntity对象 public ExamquestionEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public ExamquestionEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 try { + // 使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 // TODO Auto-generated catch block + // 打印异常堆栈信息 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 所属试卷id(外键) - */ - + + // 所属试卷id(外键) + // 定义一个Long类型的属性paperid,用于存储所属试卷的id private Long paperid; - - /** - * 试卷名称 - */ - + + // 试卷名称 + // 定义一个String类型的属性papername,用于存储试卷的名称 private String papername; - - /** - * 试题名称 - */ - + + // 试题名称 + // 定义一个String类型的属性questionname,用于存储试题的名称 private String questionname; - - /** - * 选项,json字符串 - */ - + + // 选项,json字符串 + // 定义一个String类型的属性options,用于存储试题的选项,以JSON字符串形式保存 private String options; - - /** - * 分值 - */ - + + // 分值 + // 定义一个Long类型的属性score,用于存储试题的分值 private Long score; - - /** - * 正确答案 - */ - + + // 正确答案 + // 定义一个String类型的属性answer,用于存储试题的正确答案 private String answer; - - /** - * 答案解析 - */ - + + // 答案解析 + // 定义一个String类型的属性analysis,用于存储试题答案的解析 private String analysis; - - /** - * 试题类型,0:单选题 1:多选题 2:判断题 3:填空题(暂不考虑多项填空) - */ - + + // 试题类型,0:单选题 1:多选题 2:判断题 3:填空题(暂不考虑多项填空) + // 定义一个Long类型的属性type,用于存储试题的类型 private Long type; - - /** - * 试题排序,值越大排越前面 - */ - + + // 试题排序,值越大排越前面 + // 定义一个Long类型的属性sequence,用于存储试题的排序信息 private Long sequence; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储试题的添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } - /** - * 设置:所属试卷id(外键) - */ + + // 设置:所属试卷id(外键) + // 设置paperid属性的方法 public void setPaperid(Long paperid) { this.paperid = paperid; } - /** - * 获取:所属试卷id(外键) - */ + + // 获取:所属试卷id(外键) + // 获取paperid属性的方法 public Long getPaperid() { return paperid; } - /** - * 设置:试卷名称 - */ + + // 设置:试卷名称 + // 设置papername属性的方法 public void setPapername(String papername) { this.papername = papername; } - /** - * 获取:试卷名称 - */ + + // 获取:试卷名称 + // 获取papername属性的方法 public String getPapername() { return papername; } - /** - * 设置:试题名称 - */ + + // 设置:试题名称 + // 设置questionname属性的方法 public void setQuestionname(String questionname) { this.questionname = questionname; } - /** - * 获取:试题名称 - */ + + // 获取:试题名称 + // 获取questionname属性的方法 public String getQuestionname() { return questionname; } - /** - * 设置:选项,json字符串 - */ + + // 设置:选项,json字符串 + // 设置options属性的方法 public void setOptions(String options) { this.options = options; } - /** - * 获取:选项,json字符串 - */ + + // 获取:选项,json字符串 + // 获取options属性的方法 public String getOptions() { return options; } - /** - * 设置:分值 - */ + + // 设置:分值 + // 设置score属性的方法 public void setScore(Long score) { this.score = score; } - /** - * 获取:分值 - */ + + // 获取:分值 + // 获取score属性的方法 public Long getScore() { return score; } - /** - * 设置:正确答案 - */ + + // 设置:正确答案 + // 设置answer属性的方法 public void setAnswer(String answer) { this.answer = answer; } - /** - * 获取:正确答案 - */ + + // 获取:正确答案 + // 获取answer属性的方法 public String getAnswer() { return answer; } - /** - * 设置:答案解析 - */ + + // 设置:答案解析 + // 设置analysis属性的方法 public void setAnalysis(String analysis) { this.analysis = analysis; } - /** - * 获取:答案解析 - */ + + // 获取:答案解析 + // 获取analysis属性的方法 public String getAnalysis() { return analysis; } - /** - * 设置:试题类型,0:单选题 1:多选题 2:判断题 3:填空题(暂不考虑多项填空) - */ + + // 设置:试题类型,0:单选题 1:多选题 2:判断题 3:填空题(暂不考虑多项填空) + // 设置type属性的方法 public void setType(Long type) { this.type = type; } - /** - * 获取:试题类型,0:单选题 1:多选题 2:判断题 3:填空题(暂不考虑多项填空) - */ + + // 获取:试题类型,0:单选题 1:多选题 2:判断题 3:填空题(暂不考虑多项填空) + // 获取type属性的方法 public Long getType() { return type; } - /** - * 设置:试题排序,值越大排越前面 - */ + + // 设置:试题排序,值越大排越前面 + // 设置sequence属性的方法 public void setSequence(Long sequence) { this.sequence = sequence; } - /** - * 获取:试题排序,值越大排越前面 - */ + + // 获取:试题排序,值越大排越前面 + // 获取sequence属性的方法 public Long getSequence() { return sequence; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ExamrecordEntity.java b/src/main/java/com/entity/ExamrecordEntity.java index c56886f..aaf1eaf 100644 --- a/src/main/java/com/entity/ExamrecordEntity.java +++ b/src/main/java/com/entity/ExamrecordEntity.java @@ -1,290 +1,294 @@ +// 声明该类所在的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中用于验证字符串不为空字符串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化和反序列化时的某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 考试记录表 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 考试记录表 +// 数据库通用操作实体类(普通增删改查) +// @author +// @email +// @date 2021-05-09 15:46:15 +// 使用MyBatis-Plus的注解指定该实体类对应的数据库表名为examrecord @TableName("examrecord") +// 定义一个泛型类ExamrecordEntity,实现Serializable接口以支持对象的序列化 public class ExamrecordEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的ExamrecordEntity对象 public ExamrecordEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public ExamrecordEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // TODO: 可根据实际情况完善异常处理逻辑 + // 打印异常堆栈信息 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 用户id - */ - + + // 用户id + // 定义一个Long类型的属性userid,用于存储用户的id private Long userid; - - /** - * 用户名 - */ - + + // 用户名 + // 定义一个String类型的属性username,用于存储用户名 private String username; - - /** - * 试卷id(外键) - */ - + + // 试卷id(外键) + // 定义一个Long类型的属性paperid,用于存储试卷的id private Long paperid; - - /** - * 试卷名称 - */ - + + // 试卷名称 + // 定义一个String类型的属性papername,用于存储试卷的名称 private String papername; - - /** - * 试题id(外键) - */ - + + // 试题id(外键) + // 定义一个Long类型的属性questionid,用于存储试题的id private Long questionid; - - /** - * 试题名称 - */ - + + // 试题名称 + // 定义一个String类型的属性questionname,用于存储试题的名称 private String questionname; - - /** - * 选项,json字符串 - */ - + + // 选项,json字符串 + // 定义一个String类型的属性options,用于存储试题的选项,以JSON字符串形式保存 private String options; - - /** - * 分值 - */ - + + // 分值 + // 定义一个Long类型的属性score,用于存储试题的分值 private Long score; - - /** - * 正确答案 - */ - + + // 正确答案 + // 定义一个String类型的属性answer,用于存储试题的正确答案 private String answer; - - /** - * 答案解析 - */ - + + // 答案解析 + // 定义一个String类型的属性analysis,用于存储试题答案的解析 private String analysis; - - /** - * 试题得分 - */ - + + // 试题得分 + // 定义一个Long类型的属性myscore,用于存储考生在该试题上的得分 private Long myscore; - - /** - * 考生答案 - */ - + + // 考生答案 + // 定义一个String类型的属性myanswer,用于存储考生给出的答案 private String myanswer; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储考试记录的添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } - /** - * 设置:用户id - */ + + // 设置:用户id + // 设置userid属性的方法 public void setUserid(Long userid) { this.userid = userid; } - /** - * 获取:用户id - */ + + // 获取:用户id + // 获取userid属性的方法 public Long getUserid() { return userid; } - /** - * 设置:用户名 - */ + + // 设置:用户名 + // 设置username属性的方法 public void setUsername(String username) { this.username = username; } - /** - * 获取:用户名 - */ + + // 获取:用户名 + // 获取username属性的方法 public String getUsername() { return username; } - /** - * 设置:试卷id(外键) - */ + + // 设置:试卷id(外键) + // 设置paperid属性的方法 public void setPaperid(Long paperid) { this.paperid = paperid; } - /** - * 获取:试卷id(外键) - */ + + // 获取:试卷id(外键) + // 获取paperid属性的方法 public Long getPaperid() { return paperid; } - /** - * 设置:试卷名称 - */ + + // 设置:试卷名称 + // 设置papername属性的方法 public void setPapername(String papername) { this.papername = papername; } - /** - * 获取:试卷名称 - */ + + // 获取:试卷名称 + // 获取papername属性的方法 public String getPapername() { return papername; } - /** - * 设置:试题id(外键) - */ + + // 设置:试题id(外键) + // 设置questionid属性的方法 public void setQuestionid(Long questionid) { this.questionid = questionid; } - /** - * 获取:试题id(外键) - */ + + // 获取:试题id(外键) + // 获取questionid属性的方法 public Long getQuestionid() { return questionid; } - /** - * 设置:试题名称 - */ + + // 设置:试题名称 + // 设置questionname属性的方法 public void setQuestionname(String questionname) { this.questionname = questionname; } - /** - * 获取:试题名称 - */ + + // 获取:试题名称 + // 获取questionname属性的方法 public String getQuestionname() { return questionname; } - /** - * 设置:选项,json字符串 - */ + + // 设置:选项,json字符串 + // 设置options属性的方法 public void setOptions(String options) { this.options = options; } - /** - * 获取:选项,json字符串 - */ + + // 获取:选项,json字符串 + // 获取options属性的方法 public String getOptions() { return options; } - /** - * 设置:分值 - */ + + // 设置:分值 + // 设置score属性的方法 public void setScore(Long score) { this.score = score; } - /** - * 获取:分值 - */ + + // 获取:分值 + // 获取score属性的方法 public Long getScore() { return score; } - /** - * 设置:正确答案 - */ + + // 设置:正确答案 + // 设置answer属性的方法 public void setAnswer(String answer) { this.answer = answer; } - /** - * 获取:正确答案 - */ + + // 获取:正确答案 + // 获取answer属性的方法 public String getAnswer() { return answer; } - /** - * 设置:答案解析 - */ + + // 设置:答案解析 + // 设置analysis属性的方法 public void setAnalysis(String analysis) { this.analysis = analysis; } - /** - * 获取:答案解析 - */ + + // 获取:答案解析 + // 获取analysis属性的方法 public String getAnalysis() { return analysis; } - /** - * 设置:试题得分 - */ + + // 设置:试题得分 + // 设置myscore属性的方法 public void setMyscore(Long myscore) { this.myscore = myscore; } - /** - * 获取:试题得分 - */ + + // 获取:试题得分 + // 获取myscore属性的方法 public Long getMyscore() { return myscore; } - /** - * 设置:考生答案 - */ + + // 设置:考生答案 + // 设置myanswer属性的方法 public void setMyanswer(String myanswer) { this.myanswer = myanswer; } - /** - * 获取:考生答案 - */ + + // 获取:考生答案 + // 获取myanswer属性的方法 public String getMyanswer() { return myanswer; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ForumEntity.java b/src/main/java/com/entity/ForumEntity.java index 55a0efe..21811b1 100644 --- a/src/main/java/com/entity/ForumEntity.java +++ b/src/main/java/com/entity/ForumEntity.java @@ -1,192 +1,198 @@ +// 声明该类属于com.entity包 package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中,用于验证字符串不为空串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中,用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中,用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中,用于忽略JSON序列化和反序列化时某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中,用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 学习交流 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 表示这是学习交流相关的实体类 +// 该类用于数据库的通用操作(普通增删改查) +// 原注释中作者信息、邮箱信息和日期信息缺失 +// 使用MyBatis-Plus的注解指定该实体类对应数据库中的forum表 @TableName("forum") +// 定义一个泛型类ForumEntity,实现Serializable接口,使对象可序列化 public class ForumEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的ForumEntity对象 public ForumEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public ForumEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // 这里只是打印异常堆栈信息,可根据实际情况完善异常处理逻辑 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 帖子标题 - */ - + + // 帖子标题 + // 定义一个String类型的属性title,用于存储帖子的标题 private String title; - - /** - * 帖子内容 - */ - + + // 帖子内容 + // 定义一个String类型的属性content,用于存储帖子的内容 private String content; - - /** - * 父节点id - */ - + + // 父节点id + // 定义一个Long类型的属性parentid,用于存储父节点的id private Long parentid; - - /** - * 用户id - */ - + + // 用户id + // 定义一个Long类型的属性userid,用于存储用户的id private Long userid; - - /** - * 用户名 - */ - + + // 用户名 + // 定义一个String类型的属性username,用于存储用户名 private String username; - - /** - * 状态 - */ - + + // 状态 + // 定义一个String类型的属性isdone,用于存储帖子的状态 private String isdone; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储帖子的添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } + + // 标记该属性不是数据库表中的字段 @TableField(exist = false) + // 定义一个List类型的属性childs,用于存储子节点列表 private List childs; - + + // 获取childs属性的方法 public List getChilds() { return childs; } + // 设置childs属性的方法 public void setChilds(List childs) { this.childs = childs; } - /** - * 设置:帖子标题 - */ + + // 设置帖子标题的方法 public void setTitle(String title) { this.title = title; } - /** - * 获取:帖子标题 - */ + + // 获取帖子标题的方法 public String getTitle() { return title; } - /** - * 设置:帖子内容 - */ + + // 设置帖子内容的方法 public void setContent(String content) { this.content = content; } - /** - * 获取:帖子内容 - */ + + // 获取帖子内容的方法 public String getContent() { return content; } - /** - * 设置:父节点id - */ + + // 设置父节点id的方法 public void setParentid(Long parentid) { this.parentid = parentid; } - /** - * 获取:父节点id - */ + + // 获取父节点id的方法 public Long getParentid() { return parentid; } - /** - * 设置:用户id - */ + + // 设置用户id的方法 public void setUserid(Long userid) { this.userid = userid; } - /** - * 获取:用户id - */ + + // 获取用户id的方法 public Long getUserid() { return userid; } - /** - * 设置:用户名 - */ + + // 设置用户名的方法 public void setUsername(String username) { this.username = username; } - /** - * 获取:用户名 - */ + + // 获取用户名的方法 public String getUsername() { return username; } - /** - * 设置:状态 - */ + + // 设置状态的方法 public void setIsdone(String isdone) { this.isdone = isdone; } - /** - * 获取:状态 - */ + + // 获取状态的方法 public String getIsdone() { return isdone; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/GoumaidekechengEntity.java b/src/main/java/com/entity/GoumaidekechengEntity.java index ca7183d..ee7eb88 100644 --- a/src/main/java/com/entity/GoumaidekechengEntity.java +++ b/src/main/java/com/entity/GoumaidekechengEntity.java @@ -1,238 +1,250 @@ +// 声明该类所在的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中用于验证字符串不为空字符串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化和反序列化时的某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 购买的课程 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 购买的课程 +// 数据库通用操作实体类(普通增删改查) +// @author +// @email +// @date 2021-05-09 15:46:14 +// 使用MyBatis-Plus的注解指定该实体类对应的数据库表名为goumaidekecheng @TableName("goumaidekecheng") +// 定义一个泛型类GoumaidekechengEntity,实现Serializable接口以支持对象的序列化 public class GoumaidekechengEntity implements Serializable { - private static final long serialVersionUID = 1L; - - - public GoumaidekechengEntity() { - - } - - public GoumaidekechengEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * 主键id - */ - @TableId - private Long id; - /** - * 课程名称 - */ - - private String kechengmingcheng; - - /** - * 类型 - */ - - private String leixing; - - /** - * 学科 - */ - - private String xueke; - - /** - * 费用 - */ - - private String feiyong; - - /** - * 用户账号 - */ - - private String yonghuzhanghao; - - /** - * 购买时间 - */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - private Date goumaishijian; - - /** - * 是否审核 - */ - - private String sfsh; - - /** - * 审核回复 - */ - - private String shhf; - - /** - * 是否支付 - */ - - private String ispay; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - private Date addtime; - - public Date getAddtime() { - return addtime; - } - public void setAddtime(Date addtime) { - this.addtime = addtime; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - /** - * 设置:课程名称 - */ - public void setKechengmingcheng(String kechengmingcheng) { - this.kechengmingcheng = kechengmingcheng; - } - /** - * 获取:课程名称 - */ - public String getKechengmingcheng() { - return kechengmingcheng; - } - /** - * 设置:类型 - */ - public void setLeixing(String leixing) { - this.leixing = leixing; - } - /** - * 获取:类型 - */ - public String getLeixing() { - return leixing; - } - /** - * 设置:学科 - */ - public void setXueke(String xueke) { - this.xueke = xueke; - } - /** - * 获取:学科 - */ - public String getXueke() { - return xueke; - } - /** - * 设置:费用 - */ - public void setFeiyong(String feiyong) { - this.feiyong = feiyong; - } - /** - * 获取:费用 - */ - public String getFeiyong() { - return feiyong; - } - /** - * 设置:用户账号 - */ - public void setYonghuzhanghao(String yonghuzhanghao) { - this.yonghuzhanghao = yonghuzhanghao; - } - /** - * 获取:用户账号 - */ - public String getYonghuzhanghao() { - return yonghuzhanghao; - } - /** - * 设置:购买时间 - */ - public void setGoumaishijian(Date goumaishijian) { - this.goumaishijian = goumaishijian; - } - /** - * 获取:购买时间 - */ - public Date getGoumaishijian() { - return goumaishijian; - } - /** - * 设置:是否审核 - */ - public void setSfsh(String sfsh) { - this.sfsh = sfsh; - } - /** - * 获取:是否审核 - */ - public String getSfsh() { - return sfsh; - } - /** - * 设置:审核回复 - */ - public void setShhf(String shhf) { - this.shhf = shhf; - } - /** - * 获取:审核回复 - */ - public String getShhf() { - return shhf; - } - /** - * 设置:是否支付 - */ - public void setIspay(String ispay) { - this.ispay = ispay; - } - /** - * 获取:是否支付 - */ - public String getIspay() { - return ispay; - } - -} + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性 + private static final long serialVersionUID = 1L; + + // 无参构造函数,用于创建一个空的GoumaidekechengEntity对象 + public GoumaidekechengEntity() { + + } + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 + public GoumaidekechengEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 + try { + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // TODO: 可根据实际情况完善异常处理逻辑 + // 打印异常堆栈信息 + e.printStackTrace(); + } + } + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 + @TableId + // 定义一个Long类型的属性id,用于存储主键 + private Long id; + + // 课程名称 + // 定义一个String类型的属性kechengmingcheng,用于存储课程的名称 + private String kechengmingcheng; + + // 类型 + // 定义一个String类型的属性leixing,用于存储课程的类型 + private String leixing; + + // 学科 + // 定义一个String类型的属性xueke,用于存储课程所属的学科 + private String xueke; + + // 费用 + // 定义一个String类型的属性feiyong,用于存储购买课程的费用 + private String feiyong; + + // 用户账号 + // 定义一个String类型的属性yonghuzhanghao,用于存储购买课程的用户账号 + private String yonghuzhanghao; + + // 购买时间 + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 + @DateTimeFormat + // 定义一个Date类型的属性goumaishijian,用于存储课程的购买时间 + private Date goumaishijian; + + // 是否审核 + // 定义一个String类型的属性sfsh,用于存储课程购买记录是否经过审核的信息 + private String sfsh; + + // 审核回复 + // 定义一个String类型的属性shhf,用于存储课程购买审核的回复内容 + private String shhf; + + // 是否支付 + // 定义一个String类型的属性ispay,用于存储课程是否已经支付的信息 + private String ispay; + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 + @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储记录的添加时间 + private Date addtime; + + // 获取addtime属性的方法 + public Date getAddtime() { + return addtime; + } + + // 设置addtime属性的方法 + public void setAddtime(Date addtime) { + this.addtime = addtime; + } + + // 获取id属性的方法 + public Long getId() { + return id; + } + + // 设置id属性的方法 + public void setId(Long id) { + this.id = id; + } + + // 设置:课程名称 + // 设置kechengmingcheng属性的方法 + public void setKechengmingcheng(String kechengmingcheng) { + this.kechengmingcheng = kechengmingcheng; + } + + // 获取:课程名称 + // 获取kechengmingcheng属性的方法 + public String getKechengmingcheng() { + return kechengmingcheng; + } + + // 设置:类型 + // 设置leixing属性的方法 + public void setLeixing(String leixing) { + this.leixing = leixing; + } + + // 获取:类型 + // 获取leixing属性的方法 + public String getLeixing() { + return leixing; + } + + // 设置:学科 + // 设置xueke属性的方法 + public void setXueke(String xueke) { + this.xueke = xueke; + } + + // 获取:学科 + // 获取xueke属性的方法 + public String getXueke() { + return xueke; + } + + // 设置:费用 + // 设置feiyong属性的方法 + public void setFeiyong(String feiyong) { + this.feiyong = feiyong; + } + + // 获取:费用 + // 获取feiyong属性的方法 + public String getFeiyong() { + return feiyong; + } + + // 设置:用户账号 + // 设置yonghuzhanghao属性的方法 + public void setYonghuzhanghao(String yonghuzhanghao) { + this.yonghuzhanghao = yonghuzhanghao; + } + + // 获取:用户账号 + // 获取yonghuzhanghao属性的方法 + public String getYonghuzhanghao() { + return yonghuzhanghao; + } + + // 设置:购买时间 + // 设置goumaishijian属性的方法 + public void setGoumaishijian(Date goumaishijian) { + this.goumaishijian = goumaishijian; + } + + // 获取:购买时间 + // 获取goumaishijian属性的方法 + public Date getGoumaishijian() { + return goumaishijian; + } + + // 设置:是否审核 + // 设置sfsh属性的方法 + public void setSfsh(String sfsh) { + this.sfsh = sfsh; + } + + // 获取:是否审核 + // 获取sfsh属性的方法 + public String getSfsh() { + return sfsh; + } + + // 设置:审核回复 + // 设置shhf属性的方法 + public void setShhf(String shhf) { + this.shhf = shhf; + } + + // 获取:审核回复 + // 获取shhf属性的方法 + public String getShhf() { + return shhf; + } + + // 设置:是否支付 + // 设置ispay属性的方法 + public void setIspay(String ispay) { + this.ispay = ispay; + } + + // 获取:是否支付 + // 获取ispay属性的方法 + public String getIspay() { + return ispay; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/KechengleixingEntity.java b/src/main/java/com/entity/KechengleixingEntity.java index fd9a105..b0dd248 100644 --- a/src/main/java/com/entity/KechengleixingEntity.java +++ b/src/main/java/com/entity/KechengleixingEntity.java @@ -1,92 +1,113 @@ +// 声明该类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中,用于验证字符串不为空串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中,用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中,用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中,用于忽略JSON序列化和反序列化时某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中,用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 课程类型 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 表示这是课程类型相关的实体类 +// 该类用于数据库的通用操作(普通增删改查) +// 原注释中作者信息、邮箱信息和日期信息缺失 +// 使用MyBatis-Plus的注解指定该实体类对应数据库中的kechengleixing表 @TableName("kechengleixing") +// 定义一个泛型类KechengleixingEntity,实现Serializable接口,使对象可序列化 public class KechengleixingEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的KechengleixingEntity对象 public KechengleixingEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public KechengleixingEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // 这里只是打印异常堆栈信息,可根据实际情况完善异常处理逻辑 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 类型 - */ - + + // 类型 + // 定义一个String类型的属性leixing,用于存储课程类型 private String leixing; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储记录的添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } - /** - * 设置:类型 - */ + + // 设置课程类型的方法 public void setLeixing(String leixing) { this.leixing = leixing; } - /** - * 获取:类型 - */ + + // 获取课程类型的方法 public String getLeixing() { return leixing; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/KechengxinxiEntity.java b/src/main/java/com/entity/KechengxinxiEntity.java index 3e81e13..7a01f38 100644 --- a/src/main/java/com/entity/KechengxinxiEntity.java +++ b/src/main/java/com/entity/KechengxinxiEntity.java @@ -1,220 +1,234 @@ +// 声明该类所在的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中用于验证字符串不为空字符串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化和反序列化时某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 课程信息 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 课程信息 +// 数据库通用操作实体类(普通增删改查) +// @author +// @email +// @date 2021-05-09 15:46:14 +// 使用MyBatis-Plus的注解指定该实体类对应的数据库表名为kechengxinxi @TableName("kechengxinxi") +// 定义一个泛型类KechengxinxiEntity,实现Serializable接口以支持对象的序列化 public class KechengxinxiEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致性 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的KechengxinxiEntity对象 public KechengxinxiEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public KechengxinxiEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // TODO: 可根据实际情况完善异常处理逻辑 + // 打印异常堆栈信息 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 课程名称 - */ - + + // 课程名称 + // 定义一个String类型的属性kechengmingcheng,用于存储课程的名称 private String kechengmingcheng; - - /** - * 类型 - */ - + + // 类型 + // 定义一个String类型的属性leixing,用于存储课程的类型 private String leixing; - - /** - * 学科 - */ - + + // 学科 + // 定义一个String类型的属性xueke,用于存储课程所属的学科 private String xueke; - - /** - * 视频 - */ - + + // 视频 + // 定义一个String类型的属性shipin,用于存储课程相关视频的信息 private String shipin; - - /** - * 老师姓名 - */ - + + // 老师姓名 + // 定义一个String类型的属性laoshixingming,用于存储授课老师的姓名 private String laoshixingming; - - /** - * 费用 - */ - + + // 费用 + // 定义一个String类型的属性feiyong,用于存储课程的费用 private String feiyong; - - /** - * 课程图片 - */ - + + // 课程图片 + // 定义一个String类型的属性kechengtupian,用于存储课程的图片信息 private String kechengtupian; - - /** - * 发布时间 - */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") - @DateTimeFormat + + // 发布时间 + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd") + // 使用Spring的注解指定日期格式化的方式 + @DateTimeFormat + // 定义一个Date类型的属性fabushijian,用于存储课程的发布时间 private Date fabushijian; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储记录的添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } - /** - * 设置:课程名称 - */ + + // 设置:课程名称 + // 设置kechengmingcheng属性的方法 public void setKechengmingcheng(String kechengmingcheng) { this.kechengmingcheng = kechengmingcheng; } - /** - * 获取:课程名称 - */ + + // 获取:课程名称 + // 获取kechengmingcheng属性的方法 public String getKechengmingcheng() { return kechengmingcheng; } - /** - * 设置:类型 - */ + + // 设置:类型 + // 设置leixing属性的方法 public void setLeixing(String leixing) { this.leixing = leixing; } - /** - * 获取:类型 - */ + + // 获取:类型 + // 获取leixing属性的方法 public String getLeixing() { return leixing; } - /** - * 设置:学科 - */ + + // 设置:学科 + // 设置xueke属性的方法 public void setXueke(String xueke) { this.xueke = xueke; } - /** - * 获取:学科 - */ + + // 获取:学科 + // 获取xueke属性的方法 public String getXueke() { return xueke; } - /** - * 设置:视频 - */ + + // 设置:视频 + // 设置shipin属性的方法 public void setShipin(String shipin) { this.shipin = shipin; } - /** - * 获取:视频 - */ + + // 获取:视频 + // 获取shipin属性的方法 public String getShipin() { return shipin; } - /** - * 设置:老师姓名 - */ + + // 设置:老师姓名 + // 设置laoshixingming属性的方法 public void setLaoshixingming(String laoshixingming) { this.laoshixingming = laoshixingming; } - /** - * 获取:老师姓名 - */ + + // 获取:老师姓名 + // 获取laoshixingming属性的方法 public String getLaoshixingming() { return laoshixingming; } - /** - * 设置:费用 - */ + + // 设置:费用 + // 设置feiyong属性的方法 public void setFeiyong(String feiyong) { this.feiyong = feiyong; } - /** - * 获取:费用 - */ + + // 获取:费用 + // 获取feiyong属性的方法 public String getFeiyong() { return feiyong; } - /** - * 设置:课程图片 - */ + + // 设置:课程图片 + // 设置kechengtupian属性的方法 public void setKechengtupian(String kechengtupian) { this.kechengtupian = kechengtupian; } - /** - * 获取:课程图片 - */ + + // 获取:课程图片 + // 获取kechengtupian属性的方法 public String getKechengtupian() { return kechengtupian; } - /** - * 设置:发布时间 - */ + + // 设置:发布时间 + // 设置fabushijian属性的方法 public void setFabushijian(Date fabushijian) { this.fabushijian = fabushijian; } - /** - * 获取:发布时间 - */ + + // 获取:发布时间 + // 获取fabushijian属性的方法 public Date getFabushijian() { return fabushijian; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/MessagesEntity.java b/src/main/java/com/entity/MessagesEntity.java index e00a2bc..b7c6ae9 100644 --- a/src/main/java/com/entity/MessagesEntity.java +++ b/src/main/java/com/entity/MessagesEntity.java @@ -1,146 +1,155 @@ +// 声明类所在的包为com.entity package com.entity; +// 导入MyBatis-Plus框架用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架用于标记表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR 303验证框架中,用于验证字符串不为空串的注解 import javax.validation.constraints.NotBlank; +// 导入JSR 303验证框架中,用于验证集合、数组等不为空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR 303验证框架中,用于验证对象不为null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中,用于忽略JSON序列化和反序列化时某些属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中,用于处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中用于实现序列化接口的类 import java.io.Serializable; +// 导入Java中用于处理日期和时间的类 import java.util.Date; +// 导入Java中用于处理列表集合的接口 import java.util.List; +// 导入Spring框架中用于格式化日期的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记表字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中用于定义字段填充策略的枚举类 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中用于定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 留言板 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 留言板相关实体类 +// 该类用于数据库的通用操作(普通增删改查) +// 原注释中作者信息、邮箱信息和日期信息缺失 +// 使用MyBatis-Plus的注解指定该实体类对应数据库中的messages表 @TableName("messages") +// 定义一个泛型类MessagesEntity,实现Serializable接口,使对象可序列化 public class MessagesEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的MessagesEntity对象 public MessagesEntity() { - + } - + + // 带参构造函数,接收一个泛型对象t,将其属性复制到当前对象 public MessagesEntity(T t) { + // 尝试使用Apache Commons BeanUtils工具类将对象t的属性复制到当前对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中可能出现的非法访问异常和方法调用异常 + // 这里只是打印异常堆栈信息,可根据实际情况完善异常处理逻辑 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 主键id + // 使用MyBatis-Plus的注解标记该属性为主键 @TableId + // 定义一个Long类型的属性id,用于存储主键 private Long id; - /** - * 留言人id - */ - + + // 留言人id + // 定义一个Long类型的属性userid,用于存储留言人的id private Long userid; - - /** - * 用户名 - */ - + + // 用户名 + // 定义一个String类型的属性username,用于存储留言人的用户名 private String username; - - /** - * 留言内容 - */ - + + // 留言内容 + // 定义一个String类型的属性content,用于存储留言的具体内容 private String content; - - /** - * 回复内容 - */ - + + // 回复内容 + // 定义一个String类型的属性reply,用于存储对留言的回复内容 private String reply; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson的注解指定日期格式化的模式,时区为GMT+8,语言为中文 + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring的注解指定日期格式化的方式 @DateTimeFormat + // 定义一个Date类型的属性addtime,用于存储留言的添加时间 private Date addtime; + // 获取addtime属性的方法 public Date getAddtime() { return addtime; } + + // 设置addtime属性的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id属性的方法 public Long getId() { return id; } + // 设置id属性的方法 public void setId(Long id) { this.id = id; } - /** - * 设置:留言人id - */ + + // 设置留言人id的方法 public void setUserid(Long userid) { this.userid = userid; } - /** - * 获取:留言人id - */ + + // 获取留言人id的方法 public Long getUserid() { return userid; } - /** - * 设置:用户名 - */ + + // 设置用户名的方法 public void setUsername(String username) { this.username = username; } - /** - * 获取:用户名 - */ + + // 获取用户名的方法 public String getUsername() { return username; } - /** - * 设置:留言内容 - */ + + // 设置留言内容的方法 public void setContent(String content) { this.content = content; } - /** - * 获取:留言内容 - */ + + // 获取留言内容的方法 public String getContent() { return content; } - /** - * 设置:回复内容 - */ + + // 设置回复内容的方法 public void setReply(String reply) { this.reply = reply; } - /** - * 获取:回复内容 - */ + + // 获取回复内容的方法 public String getReply() { return reply; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/NewsEntity.java b/src/main/java/com/entity/NewsEntity.java index 240a15a..e379c8f 100644 --- a/src/main/java/com/entity/NewsEntity.java +++ b/src/main/java/com/entity/NewsEntity.java @@ -1,146 +1,155 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解 import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解 import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类 import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口 import java.io.Serializable; +// 导入Java中处理日期和时间的类 import java.util.Date; +// 导入Java中处理列表集合的接口(虽然当前类未直接使用,但保留导入) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(虽然当前类未直接使用,但保留导入) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入可能用于扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入可能用于扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 教育资讯 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 使用MyBatis-Plus注解指定当前类对应数据库表名为news @TableName("news") +// 定义泛型实体类NewsEntity,实现Serializable接口以支持对象序列化 public class NewsEntity implements Serializable { + // 定义序列化版本号,确保不同版本序列化兼容性 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建空的实体对象 public NewsEntity() { - + // 构造函数体为空 } - + + // 带参构造函数,接收泛型对象t,用于属性复制 public NewsEntity(T t) { + // 尝试将泛型对象t的属性复制到当前实体对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可优化) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记为主键字段,对应数据库表的主键列 @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 标题 - */ - + // 定义String类型的title字段,用于存储教育资讯的标题 private String title; - - /** - * 简介 - */ - + // 定义String类型的introduction字段,用于存储教育资讯的简介 private String introduction; - - /** - * 图片 - */ - + // 定义String类型的picture字段,用于存储教育资讯相关图片的路径或链接 private String picture; - - /** - * 内容 - */ - + // 定义String类型的content字段,用于存储教育资讯的详细内容 private String content; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式(时区GMT+8,格式yyyy-MM-dd HH:mm:ss) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持日期格式转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储记录的添加时间 private Date addtime; + // 获取addtime字段值的方法 public Date getAddtime() { + // 返回添加时间 return addtime; } + + // 设置addtime字段值的方法 public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime字段 this.addtime = addtime; } + // 获取id字段值的方法(主键) public Long getId() { + // 返回主键id return id; } + // 设置id字段值的方法(主键) public void setId(Long id) { + // 将参数值赋给当前对象的id字段 this.id = id; } - /** - * 设置:标题 - */ + + // 设置title字段值的方法(资讯标题) public void setTitle(String title) { + // 将参数值赋给当前对象的title字段 this.title = title; } - /** - * 获取:标题 - */ + + // 获取title字段值的方法(资讯标题) public String getTitle() { + // 返回资讯标题 return title; } - /** - * 设置:简介 - */ + + // 设置introduction字段值的方法(资讯简介) public void setIntroduction(String introduction) { + // 将参数值赋给当前对象的introduction字段 this.introduction = introduction; } - /** - * 获取:简介 - */ + + // 获取introduction字段值的方法(资讯简介) public String getIntroduction() { + // 返回资讯简介 return introduction; } - /** - * 设置:图片 - */ + + // 设置picture字段值的方法(资讯图片) public void setPicture(String picture) { + // 将参数值赋给当前对象的picture字段 this.picture = picture; } - /** - * 获取:图片 - */ + + // 获取picture字段值的方法(资讯图片) public String getPicture() { + // 返回资讯图片路径或链接 return picture; } - /** - * 设置:内容 - */ + + // 设置content字段值的方法(资讯内容) public void setContent(String content) { + // 将参数值赋给当前对象的content字段 this.content = content; } - /** - * 获取:内容 - */ + + // 获取content字段值的方法(资讯内容) public String getContent() { + // 返回资讯详细内容 return content; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ShipindianboEntity.java b/src/main/java/com/entity/ShipindianboEntity.java index c3ea84c..9eccfc9 100644 --- a/src/main/java/com/entity/ShipindianboEntity.java +++ b/src/main/java/com/entity/ShipindianboEntity.java @@ -1,220 +1,215 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解(当前类未使用,保留导入可能用于扩展) import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解(当前类未使用,保留导入可能用于扩展) import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解(当前类未使用,保留导入可能用于扩展) import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解(当前类未使用,保留导入可能用于扩展) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类(用于构造函数的异常处理) import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口(使当前类支持对象序列化) import java.io.Serializable; +// 导入Java中处理日期和时间的类(用于日期字段) import java.util.Date; +// 导入Java中处理列表集合的接口(当前类未直接使用,保留导入可能用于扩展) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解(用于日期字段的格式化) import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解(用于日期字段的JSON序列化格式) import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类(用于构造函数的属性复制) import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(当前类未使用,保留导入可能用于扩展) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入可能用于扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入可能用于扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 视频点播 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 使用MyBatis-Plus注解指定当前类对应数据库表名为shipindianbo @TableName("shipindianbo") +// 定义泛型实体类ShipindianboEntity,实现Serializable接口以支持对象序列化 public class ShipindianboEntity implements Serializable { + // 定义序列化版本号,确保不同版本序列化兼容性 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建空的实体对象 public ShipindianboEntity() { - + // 构造函数体为空 } - + + // 带参构造函数,接收泛型对象t,用于属性复制 public ShipindianboEntity(T t) { + // 尝试将泛型对象t的属性复制到当前实体对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可优化) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记为主键字段,对应数据库表的主键列 @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 视频名称 - */ - + // 定义String类型的shipinmingcheng字段,用于存储视频名称 private String shipinmingcheng; - - /** - * 视频 - */ - + // 定义String类型的shipin字段,用于存储视频文件路径或链接 private String shipin; - - /** - * 视频简介 - */ - + // 定义String类型的shipinjianjie字段,用于存储视频简介 private String shipinjianjie; - - /** - * 来源 - */ - + // 定义String类型的laiyuan字段,用于存储视频来源 private String laiyuan; - - /** - * 上传时间 - */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 使用Jackson注解指定日期在JSON中的格式(时区GMT+8,格式yyyy-MM-dd HH:mm:ss) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持日期格式转换 + @DateTimeFormat + // 定义Date类型的shangchuanshijian字段,用于存储视频上传时间 private Date shangchuanshijian; - - /** - * 封面 - */ - + // 定义String类型的fengmian字段,用于存储视频封面路径或链接 private String fengmian; - - /** - * 用户账号 - */ - + // 定义String类型的yonghuzhanghao字段,用于存储用户账号 private String yonghuzhanghao; - - /** - * 用户id - */ - + // 定义Long类型的userid字段,用于存储用户ID(外键关联用户表) private Long userid; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式(时区GMT+8,格式yyyy-MM-dd HH:mm:ss) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持日期格式转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储记录的添加时间 private Date addtime; + // 获取addtime字段值的方法(记录添加时间) public Date getAddtime() { + // 返回添加时间 return addtime; } + + // 设置addtime字段值的方法(记录添加时间) public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime字段 this.addtime = addtime; } + // 获取id字段值的方法(主键) public Long getId() { + // 返回主键id return id; } + // 设置id字段值的方法(主键) public void setId(Long id) { + // 将参数值赋给当前对象的id字段 this.id = id; } - /** - * 设置:视频名称 - */ + + // 设置shipinmingcheng字段值的方法(视频名称) public void setShipinmingcheng(String shipinmingcheng) { + // 将参数值赋给当前对象的shipinmingcheng字段 this.shipinmingcheng = shipinmingcheng; } - /** - * 获取:视频名称 - */ + + // 获取shipinmingcheng字段值的方法(视频名称) public String getShipinmingcheng() { + // 返回视频名称 return shipinmingcheng; } - /** - * 设置:视频 - */ + + // 设置shipin字段值的方法(视频文件路径) public void setShipin(String shipin) { + // 将参数值赋给当前对象的shipin字段 this.shipin = shipin; } - /** - * 获取:视频 - */ + + // 获取shipin字段值的方法(视频文件路径) public String getShipin() { + // 返回视频文件路径或链接 return shipin; } - /** - * 设置:视频简介 - */ + + // 设置shipinjianjie字段值的方法(视频简介) public void setShipinjianjie(String shipinjianjie) { + // 将参数值赋给当前对象的shipinjianjie字段 this.shipinjianjie = shipinjianjie; } - /** - * 获取:视频简介 - */ + + // 获取shipinjianjie字段值的方法(视频简介) public String getShipinjianjie() { + // 返回视频简介 return shipinjianjie; } - /** - * 设置:来源 - */ + + // 设置laiyuan字段值的方法(视频来源) public void setLaiyuan(String laiyuan) { + // 将参数值赋给当前对象的laiyuan字段 this.laiyuan = laiyuan; } - /** - * 获取:来源 - */ + + // 获取laiyuan字段值的方法(视频来源) public String getLaiyuan() { + // 返回视频来源 return laiyuan; } - /** - * 设置:上传时间 - */ + + // 设置shangchuanshijian字段值的方法(视频上传时间) public void setShangchuanshijian(Date shangchuanshijian) { + // 将参数值赋给当前对象的shangchuanshijian字段 this.shangchuanshijian = shangchuanshijian; } - /** - * 获取:上传时间 - */ + + // 获取shangchuanshijian字段值的方法(视频上传时间) public Date getShangchuanshijian() { + // 返回视频上传时间 return shangchuanshijian; } - /** - * 设置:封面 - */ + + // 设置fengmian字段值的方法(视频封面) public void setFengmian(String fengmian) { + // 将参数值赋给当前对象的fengmian字段 this.fengmian = fengmian; } - /** - * 获取:封面 - */ + + // 获取fengmian字段值的方法(视频封面) public String getFengmian() { + // 返回视频封面路径或链接 return fengmian; } - /** - * 设置:用户账号 - */ + + // 设置yonghuzhanghao字段值的方法(用户账号) public void setYonghuzhanghao(String yonghuzhanghao) { + // 将参数值赋给当前对象的yonghuzhanghao字段 this.yonghuzhanghao = yonghuzhanghao; } - /** - * 获取:用户账号 - */ + + // 获取yonghuzhanghao字段值的方法(用户账号) public String getYonghuzhanghao() { + // 返回用户账号 return yonghuzhanghao; } - /** - * 设置:用户id - */ + + // 设置userid字段值的方法(用户ID) public void setUserid(Long userid) { + // 将参数值赋给当前对象的userid字段 this.userid = userid; } - /** - * 获取:用户id - */ + + // 获取userid字段值的方法(用户ID) public Long getUserid() { + // 返回用户ID return userid; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/StoreupEntity.java b/src/main/java/com/entity/StoreupEntity.java index c6192cc..4717fbb 100644 --- a/src/main/java/com/entity/StoreupEntity.java +++ b/src/main/java/com/entity/StoreupEntity.java @@ -1,164 +1,169 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解(用于标识主键字段) import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解(用于指定实体类对应的表名) import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解(当前类未使用,保留导入以备扩展) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类(用于构造函数的异常处理) import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口(使当前类支持对象序列化,便于网络传输或持久化) import java.io.Serializable; +// 导入Java中处理日期和时间的类(用于日期字段的定义) import java.util.Date; +// 导入Java中处理列表集合的接口(当前类未直接使用,保留导入以备扩展) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解(用于前端与后端日期格式的统一转换) import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解(用于指定日期在JSON中的序列化格式) import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类(用于构造函数中对象属性的复制) import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 收藏表 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为storeup @TableName("storeup") +// 定义泛型实体类StoreupEntity,实现Serializable接口以支持对象的序列化和反序列化 public class StoreupEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象(框架反射创建对象时需要) public StoreupEntity() { - + // 构造函数体为空,无需额外操作 } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public StoreupEntity(T t) { + // 尝试使用BeanUtils工具类复制对象属性 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可自定义异常处理逻辑) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列(通常为自增ID) @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 用户id - */ - + // 定义Long类型的userid字段,用于存储用户ID(外键,关联用户表) private Long userid; - - /** - * 收藏id - */ - + // 定义Long类型的refid字段,用于存储收藏对象的ID(外键,关联被收藏的表记录) private Long refid; - - /** - * 表名 - */ - + // 定义String类型的tablename字段,用于存储被收藏对象对应的表名(如"kechengxinxi") private String tablename; - - /** - * 收藏名称 - */ - + // 定义String类型的name字段,用于存储收藏项的名称(如课程名称、资讯标题等) private String name; - - /** - * 收藏图片 - */ - + // 定义String类型的picture字段,用于存储收藏项的封面图片路径或链接 private String picture; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式(时区:GMT+8,格式:年-月-日 时:分:秒) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储收藏记录的添加时间 private Date addtime; + // 获取addtime字段值的方法(返回收藏记录的添加时间) public Date getAddtime() { + // 返回添加时间属性值 return addtime; } + + // 设置addtime字段值的方法(设置收藏记录的添加时间) public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime属性 this.addtime = addtime; } + // 获取id字段值的方法(返回主键ID) public Long getId() { + // 返回主键ID属性值 return id; } + // 设置id字段值的方法(设置主键ID,通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { + // 将参数值赋给当前对象的id属性 this.id = id; } - /** - * 设置:用户id - */ + + // 设置userid字段值的方法(设置用户ID) public void setUserid(Long userid) { + // 将参数值赋给当前对象的userid属性 this.userid = userid; } - /** - * 获取:用户id - */ + + // 获取userid字段值的方法(返回用户ID) public Long getUserid() { + // 返回用户ID属性值 return userid; } - /** - * 设置:收藏id - */ + + // 设置refid字段值的方法(设置收藏对象的ID) public void setRefid(Long refid) { + // 将参数值赋给当前对象的refid属性 this.refid = refid; } - /** - * 获取:收藏id - */ + + // 获取refid字段值的方法(返回收藏对象的ID) public Long getRefid() { + // 返回收藏对象ID属性值 return refid; } - /** - * 设置:表名 - */ + + // 设置tablename字段值的方法(设置被收藏对象对应的表名) public void setTablename(String tablename) { + // 将参数值赋给当前对象的tablename属性 this.tablename = tablename; } - /** - * 获取:表名 - */ + + // 获取tablename字段值的方法(返回被收藏对象对应的表名) public String getTablename() { + // 返回表名属性值 return tablename; } - /** - * 设置:收藏名称 - */ + + // 设置name字段值的方法(设置收藏项的名称) public void setName(String name) { + // 将参数值赋给当前对象的name属性 this.name = name; } - /** - * 获取:收藏名称 - */ + + // 获取name字段值的方法(返回收藏项的名称) public String getName() { + // 返回收藏名称属性值 return name; } - /** - * 设置:收藏图片 - */ + + // 设置picture字段值的方法(设置收藏项的封面图片) public void setPicture(String picture) { + // 将参数值赋给当前对象的picture属性 this.picture = picture; } - /** - * 获取:收藏图片 - */ + + // 获取picture字段值的方法(返回收藏项的封面图片路径或链接) public String getPicture() { + // 返回图片路径属性值 return picture; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/TokenEntity.java b/src/main/java/com/entity/TokenEntity.java index a0f6489..c16472f 100644 --- a/src/main/java/com/entity/TokenEntity.java +++ b/src/main/java/com/entity/TokenEntity.java @@ -1,123 +1,161 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入Java序列化接口,使实体类支持对象序列化(用于网络传输或持久化存储) import java.io.Serializable; +// 导入Java日期类,用于处理日期和时间字段 import java.util.Date; +// 导入MyBatis-Plus的主键注解,用于标记数据库表的主键字段 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus的表名注解,用于指定实体类对应的数据库表名 import com.baomidou.mybatisplus.annotations.TableName; +// 导入MyBatis-Plus的主键生成类型枚举,用于配置主键生成策略 import com.baomidou.mybatisplus.enums.IdType; -/** - * token表 - */ +// token表实体类 +// 用于存储用户令牌信息,实现用户身份验证和权限管理 +// 使用MyBatis-Plus注解指定对应的数据库表名为"token" @TableName("token") +// 定义TokenEntity类,实现Serializable接口以支持对象的序列化和反序列化 public class TokenEntity implements Serializable { + // 定义序列化版本号,确保不同版本的兼容性(建议与类结构同步更新) private static final long serialVersionUID = 1L; - + + // 标记为主键字段,指定主键生成策略为数据库自增(AUTO) @TableId(type = IdType.AUTO) + // 主键ID,由数据库自增生成,唯一标识一条token记录 private Long id; - - /** - * 用户id - */ + + // 用户ID,关联用户表的主键,标识该token所属的用户 private Long userid; - - /** - * 用户名 - */ + + // 用户名,令牌所属用户的登录名称,用于快速识别用户身份 private String username; - - /** - * 表名 - */ + + // 表名,标识该token关联的数据库表(如用户表、管理员表等),用于区分不同类型的用户 private String tablename; - - /** - * 角色 - */ + + // 角色,用户的角色信息(如"user"、"admin"),用于权限控制和功能访问限制 private String role; - - /** - * token - */ + + // 令牌值,用于验证用户身份的唯一凭证,客户端通过该token访问受保护的资源 private String token; - - /** - * 过期时间 - */ + + // 过期时间,令牌的有效截止时间,超过该时间后令牌失效,需重新获取 private Date expiratedtime; - - /** - * 新增时间 - */ + + // 新增时间,记录token创建的具体时间,用于审计和日志追踪 private Date addtime; + // ------------------------- Getter 方法 ------------------------- + + // 获取主键ID + // @return 主键ID,数据库自增生成的唯一标识 public Long getId() { return id; } + // 设置主键ID(通常由数据库自动生成,代码中一般不手动设置) + // @param id 主键ID值 public void setId(Long id) { this.id = id; } + // 获取用户ID + // @return 用户ID,关联用户表的主键,标识token所属用户 public Long getUserid() { return userid; } + // 设置用户ID + // @param userid 用户ID值 public void setUserid(Long userid) { this.userid = userid; } - public String getRole() { - return role; - } - - public void setRole(String role) { - this.role = role; + // 获取用户名 + // @return 用户名,token所属用户的登录名称 + public String getUsername() { + return username; } - public String getToken() { - return token; + // 设置用户名 + // @param username 用户名值 + public void setUsername(String username) { + this.username = username; } + // 获取关联的表名 + // @return 表名,标识token关联的数据库表 public String getTablename() { return tablename; } + // 设置关联的表名 + // @param tablename 表名值(如"user"、"admin"对应的表) public void setTablename(String tablename) { this.tablename = tablename; } + // 获取用户角色 + // @return 角色,用户的权限角色(如普通用户、管理员) + public String getRole() { + return role; + } + + // 设置用户角色 + // @param role 角色值(用于权限控制) + public void setRole(String role) { + this.role = role; + } + + // 获取令牌值 + // @return 令牌,用户身份验证的唯一凭证 + public String getToken() { + return token; + } + + // 设置令牌值 + // @param token 令牌值(通常由认证服务生成) public void setToken(String token) { this.token = token; } + // 获取过期时间 + // @return 过期时间,令牌失效的时间点 public Date getExpiratedtime() { return expiratedtime; } + // 设置过期时间 + // @param expiratedtime 过期时间值(需为Date类型) public void setExpiratedtime(Date expiratedtime) { this.expiratedtime = expiratedtime; } + // 获取新增时间 + // @return 新增时间,token记录的创建时间 public Date getAddtime() { return addtime; } + // 设置新增时间(通常由系统自动生成,无需手动设置) + // @param addtime 新增时间值 public void setAddtime(Date addtime) { this.addtime = addtime; } - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } + // ------------------------- 构造方法 ------------------------- - public TokenEntity(Long userid, String username, String tablename,String role, String token, Date expiratedtime) { - super(); + // 带参数的构造方法,用于初始化token记录的主要信息 + // @param userid 用户ID,标识token所属用户 + // @param username 用户名,用户的登录名称 + // @param tablename 关联表名,标识用户类型对应的表 + // @param role 用户角色,用于权限控制 + // @param token 令牌值,身份验证凭证 + // @param expiratedtime 过期时间,令牌有效截止时间 + public TokenEntity(Long userid, String username, String tablename, String role, String token, Date expiratedtime) { this.userid = userid; this.username = username; this.tablename = tablename; @@ -125,8 +163,8 @@ public class TokenEntity implements Serializable { this.token = token; this.expiratedtime = expiratedtime; } - + + // 无参构造方法,用于框架反射创建对象(如MyBatis-Plus自动实例化) public TokenEntity() { } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/UserEntity.java b/src/main/java/com/entity/UserEntity.java index 1b6fb62..7644c26 100644 --- a/src/main/java/com/entity/UserEntity.java +++ b/src/main/java/com/entity/UserEntity.java @@ -1,77 +1,100 @@ +// 声明该类属于com.entity包 package com.entity; +// 导入Java的序列化接口,使类可实现序列化,用于对象的存储和传输 import java.io.Serializable; +// 导入Java的日期类,用于处理日期和时间 import java.util.Date; +// 导入MyBatis-Plus框架用于标记主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架用于标记数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入MyBatis-Plus框架定义主键生成类型的枚举类 import com.baomidou.mybatisplus.enums.IdType; -/** - * 用户 - */ +// 表示这是用户相关的实体类 +// 使用MyBatis-Plus的注解指定该实体类对应数据库中的users表 @TableName("users") +// 定义UserEntity类,实现Serializable接口,使该类的对象可以被序列化 public class UserEntity implements Serializable { + // 定义序列化版本号,确保序列化和反序列化过程中类的版本一致 private static final long serialVersionUID = 1L; - + + // 使用MyBatis-Plus的注解标记该属性为主键,且主键生成策略为数据库自增 @TableId(type = IdType.AUTO) + // 定义一个Long类型的属性id,用于存储数据库表的主键 private Long id; - - /** - * 用户账号 - */ + + // 定义一个String类型的属性username,用于存储用户账号 private String username; - - /** - * 密码 - */ + + // 定义一个String类型的属性password,用于存储用户密码 private String password; - - /** - * 用户类型 - */ + + // 定义一个String类型的属性role,用于存储用户类型 private String role; - + + // 定义一个Date类型的属性addtime,用于存储用户记录的添加时间 private Date addtime; + // 获取用户账号的方法 public String getUsername() { + // 返回用户账号 return username; } + // 设置用户账号的方法 public void setUsername(String username) { + // 将参数值赋给当前对象的username属性 this.username = username; } + // 获取用户密码的方法 public String getPassword() { + // 返回用户密码 return password; } + // 设置用户密码的方法 public void setPassword(String password) { + // 将参数值赋给当前对象的password属性 this.password = password; } + // 获取用户类型的方法 public String getRole() { + // 返回用户类型 return role; } + // 设置用户类型的方法 public void setRole(String role) { + // 将参数值赋给当前对象的role属性 this.role = role; } + // 获取记录添加时间的方法 public Date getAddtime() { + // 返回记录添加时间 return addtime; } + // 设置记录添加时间的方法 public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime属性 this.addtime = addtime; } + // 获取主键id的方法 public Long getId() { + // 返回主键id return id; } + // 设置主键id的方法 public void setId(Long id) { + // 将参数值赋给当前对象的id属性 this.id = id; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/WodebijiEntity.java b/src/main/java/com/entity/WodebijiEntity.java index f08e74f..0849969 100644 --- a/src/main/java/com/entity/WodebijiEntity.java +++ b/src/main/java/com/entity/WodebijiEntity.java @@ -1,128 +1,141 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解(用于标识主键字段) import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解(用于指定实体类对应的表名) import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解(当前类未使用,保留导入以备扩展) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类(用于构造函数的异常处理) import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口(使当前类支持对象序列化,便于网络传输或持久化) import java.io.Serializable; +// 导入Java中处理日期和时间的类(用于日期字段的定义) import java.util.Date; +// 导入Java中处理列表集合的接口(当前类未直接使用,保留导入以备扩展) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解(用于前端与后端日期格式的统一转换) import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解(用于指定日期在JSON中的序列化格式) import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类(用于构造函数中对象属性的复制) import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 我的笔记 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为wodebiji @TableName("wodebiji") +// 定义泛型实体类WodebijiEntity,实现Serializable接口以支持对象的序列化和反序列化 public class WodebijiEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象(框架反射创建对象时需要) public WodebijiEntity() { - + // 构造函数体为空 } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public WodebijiEntity(T t) { + // 尝试使用BeanUtils工具类复制对象属性 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可自定义异常处理逻辑) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列(默认主键生成策略) @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 标题 - */ - + // 定义String类型的biaoti字段,用于存储笔记的标题 private String biaoti; - - /** - * 内容 - */ - + // 定义String类型的neirong字段,用于存储笔记的内容 private String neirong; - - /** - * 用户账号 - */ - + // 定义String类型的yonghuzhanghao字段,用于存储用户账号(关联用户信息) private String yonghuzhanghao; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式(时区:GMT+8,格式:年-月-日 时:分:秒) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储笔记记录的添加时间 private Date addtime; + // 获取addtime字段值的方法(返回笔记记录的添加时间) public Date getAddtime() { + // 返回添加时间属性值 return addtime; } + + // 设置addtime字段值的方法(设置笔记记录的添加时间) public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime属性 this.addtime = addtime; } + // 获取id字段值的方法(返回主键ID) public Long getId() { + // 返回主键ID属性值 return id; } + // 设置id字段值的方法(设置主键ID,通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { + // 将参数值赋给当前对象的id属性 this.id = id; } - /** - * 设置:标题 - */ + + // 设置biaoti字段值的方法(设置笔记标题) public void setBiaoti(String biaoti) { + // 将参数值赋给当前对象的biaoti属性 this.biaoti = biaoti; } - /** - * 获取:标题 - */ + + // 获取biaoti字段值的方法(返回笔记标题) public String getBiaoti() { + // 返回笔记标题属性值 return biaoti; } - /** - * 设置:内容 - */ + + // 设置neirong字段值的方法(设置笔记内容) public void setNeirong(String neirong) { + // 将参数值赋给当前对象的neirong属性 this.neirong = neirong; } - /** - * 获取:内容 - */ + + // 获取neirong字段值的方法(返回笔记内容) public String getNeirong() { + // 返回笔记内容属性值 return neirong; } - /** - * 设置:用户账号 - */ + + // 设置yonghuzhanghao字段值的方法(设置用户账号) public void setYonghuzhanghao(String yonghuzhanghao) { + // 将参数值赋给当前对象的yonghuzhanghao属性 this.yonghuzhanghao = yonghuzhanghao; } - /** - * 获取:用户账号 - */ + + // 获取yonghuzhanghao字段值的方法(返回用户账号) public String getYonghuzhanghao() { + // 返回用户账号属性值 return yonghuzhanghao; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/WodekechengEntity.java b/src/main/java/com/entity/WodekechengEntity.java index 4111b51..05685ec 100644 --- a/src/main/java/com/entity/WodekechengEntity.java +++ b/src/main/java/com/entity/WodekechengEntity.java @@ -1,146 +1,155 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解(用于标识主键字段) import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解(用于指定实体类对应的表名) import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解(当前类未使用,保留导入以备扩展) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类(用于构造函数的异常处理) import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口(使当前类支持对象序列化,便于网络传输或持久化) import java.io.Serializable; +// 导入Java中处理日期和时间的类(用于日期字段的定义) import java.util.Date; +// 导入Java中处理列表集合的接口(当前类未直接使用,保留导入以备扩展) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解(用于前端与后端日期格式的统一转换) import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解(用于指定日期在JSON中的序列化格式) import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类(用于构造函数中对象属性的复制) import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 我的课程 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为wodekecheng @TableName("wodekecheng") +// 定义泛型实体类WodekechengEntity,实现Serializable接口以支持对象的序列化和反序列化 public class WodekechengEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象(框架反射创建对象时需要) public WodekechengEntity() { - + // 构造函数体为空 } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public WodekechengEntity(T t) { + // 尝试使用BeanUtils工具类复制对象属性 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可自定义异常处理逻辑) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列(默认主键生成策略) @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 课程名称 - */ - + // 定义String类型的kechengmingcheng字段,用于存储课程名称 private String kechengmingcheng; - - /** - * 章节 - */ - + // 定义String类型的zhangjie字段,用于存储课程的章节信息 private String zhangjie; - - /** - * 文件 - */ - + // 定义String类型的wenjian字段,用于存储课程相关的文件路径或名称 private String wenjian; - - /** - * 用户账号 - */ - + // 定义String类型的yonghuzhanghao字段,用于存储用户账号(关联用户信息) private String yonghuzhanghao; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式(时区:GMT+8,格式:年-月-日 时:分:秒) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储课程记录的添加时间 private Date addtime; + // 获取addtime字段值的方法(返回课程记录的添加时间) public Date getAddtime() { + // 返回添加时间属性值 return addtime; } + + // 设置addtime字段值的方法(设置课程记录的添加时间) public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime属性 this.addtime = addtime; } + // 获取id字段值的方法(返回主键ID) public Long getId() { + // 返回主键ID属性值 return id; } + // 设置id字段值的方法(设置主键ID,通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { + // 将参数值赋给当前对象的id属性 this.id = id; } - /** - * 设置:课程名称 - */ + + // 设置kechengmingcheng字段值的方法(设置课程名称) public void setKechengmingcheng(String kechengmingcheng) { + // 将参数值赋给当前对象的kechengmingcheng属性 this.kechengmingcheng = kechengmingcheng; } - /** - * 获取:课程名称 - */ + + // 获取kechengmingcheng字段值的方法(返回课程名称) public String getKechengmingcheng() { + // 返回课程名称属性值 return kechengmingcheng; } - /** - * 设置:章节 - */ + + // 设置zhangjie字段值的方法(设置课程章节) public void setZhangjie(String zhangjie) { + // 将参数值赋给当前对象的zhangjie属性 this.zhangjie = zhangjie; } - /** - * 获取:章节 - */ + + // 获取zhangjie字段值的方法(返回课程章节) public String getZhangjie() { + // 返回课程章节属性值 return zhangjie; } - /** - * 设置:文件 - */ + + // 设置wenjian字段值的方法(设置课程文件) public void setWenjian(String wenjian) { + // 将参数值赋给当前对象的wenjian属性 this.wenjian = wenjian; } - /** - * 获取:文件 - */ + + // 获取wenjian字段值的方法(返回课程文件路径或名称) public String getWenjian() { + // 返回课程文件属性值 return wenjian; } - /** - * 设置:用户账号 - */ + + // 设置yonghuzhanghao字段值的方法(设置用户账号) public void setYonghuzhanghao(String yonghuzhanghao) { + // 将参数值赋给当前对象的yonghuzhanghao属性 this.yonghuzhanghao = yonghuzhanghao; } - /** - * 获取:用户账号 - */ + + // 获取yonghuzhanghao字段值的方法(返回用户账号) public String getYonghuzhanghao() { + // 返回用户账号属性值 return yonghuzhanghao; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/XiaoxitongzhiEntity.java b/src/main/java/com/entity/XiaoxitongzhiEntity.java index c7da81c..fe37abc 100644 --- a/src/main/java/com/entity/XiaoxitongzhiEntity.java +++ b/src/main/java/com/entity/XiaoxitongzhiEntity.java @@ -1,148 +1,160 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解(用于标识主键字段) import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解(用于指定实体类对应的表名) import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解(当前类未使用,保留导入以备扩展) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类(用于构造函数的异常处理) import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口(使当前类支持对象序列化,便于网络传输或持久化) import java.io.Serializable; +// 导入Java中处理日期和时间的类(用于日期字段的定义) import java.util.Date; +// 导入Java中处理列表集合的接口(当前类未直接使用,保留导入以备扩展) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解(用于前端与后端日期格式的统一转换) import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解(用于指定日期在JSON中的序列化格式) import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类(用于构造函数中对象属性的复制) import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 消息通知 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:15 - */ +// 消息通知实体类 +// 数据库通用操作实体类(普通增删改查) +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为xiaoxitongzhi @TableName("xiaoxitongzhi") +// 定义泛型实体类XiaoxitongzhiEntity,实现Serializable接口以支持对象的序列化和反序列化 public class XiaoxitongzhiEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象(框架反射创建对象时需要) public XiaoxitongzhiEntity() { - + // 构造函数体为空 } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public XiaoxitongzhiEntity(T t) { + // 尝试使用BeanUtils工具类复制对象属性 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可自定义异常处理逻辑) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列(默认主键生成策略) @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 通知标题 - */ - + // 定义String类型的tongzhibiaoti字段,用于存储通知的标题 private String tongzhibiaoti; - - /** - * 通知内容 - */ - + // 定义String类型的tongzhineirong字段,用于存储通知的具体内容 private String tongzhineirong; - - /** - * 用户账号 - */ - + // 定义String类型的yonghuzhanghao字段,用于存储接收通知的用户账号(关联用户信息) private String yonghuzhanghao; - - /** - * 发送时间 - */ - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 使用Jackson注解指定日期在JSON中的格式(时区:GMT+8,格式:年-月-日 时:分:秒) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 + @DateTimeFormat + // 定义Date类型的fasongshijian字段,用于存储通知的发送时间 private Date fasongshijian; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + // 使用Jackson注解指定日期在JSON中的格式(时区:GMT+8,格式:年-月-日 时:分:秒) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储通知记录的添加时间 private Date addtime; + // 获取addtime字段值的方法(返回通知记录的添加时间) public Date getAddtime() { + // 返回添加时间属性值 return addtime; } + + // 设置addtime字段值的方法(设置通知记录的添加时间) public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime属性 this.addtime = addtime; } + // 获取id字段值的方法(返回主键ID) public Long getId() { + // 返回主键ID属性值 return id; } + // 设置id字段值的方法(设置主键ID,通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { + // 将参数值赋给当前对象的id属性 this.id = id; } - /** - * 设置:通知标题 - */ + + // 设置tongzhibiaoti字段值的方法(设置通知标题) public void setTongzhibiaoti(String tongzhibiaoti) { + // 将参数值赋给当前对象的tongzhibiaoti属性 this.tongzhibiaoti = tongzhibiaoti; } - /** - * 获取:通知标题 - */ + + // 获取tongzhibiaoti字段值的方法(返回通知标题) public String getTongzhibiaoti() { + // 返回通知标题属性值 return tongzhibiaoti; } - /** - * 设置:通知内容 - */ + + // 设置tongzhineirong字段值的方法(设置通知内容) public void setTongzhineirong(String tongzhineirong) { + // 将参数值赋给当前对象的tongzhineirong属性 this.tongzhineirong = tongzhineirong; } - /** - * 获取:通知内容 - */ + + // 获取tongzhineirong字段值的方法(返回通知内容) public String getTongzhineirong() { + // 返回通知内容属性值 return tongzhineirong; } - /** - * 设置:用户账号 - */ + + // 设置yonghuzhanghao字段值的方法(设置用户账号) public void setYonghuzhanghao(String yonghuzhanghao) { + // 将参数值赋给当前对象的yonghuzhanghao属性 this.yonghuzhanghao = yonghuzhanghao; } - /** - * 获取:用户账号 - */ + + // 获取yonghuzhanghao字段值的方法(返回用户账号) public String getYonghuzhanghao() { + // 返回用户账号属性值 return yonghuzhanghao; } - /** - * 设置:发送时间 - */ + + // 设置fasongshijian字段值的方法(设置通知发送时间) public void setFasongshijian(Date fasongshijian) { + // 将参数值赋给当前对象的fasongshijian属性 this.fasongshijian = fasongshijian; } - /** - * 获取:发送时间 - */ + + // 获取fasongshijian字段值的方法(返回通知发送时间) public Date getFasongshijian() { + // 返回通知发送时间属性值 return fasongshijian; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/XuekeEntity.java b/src/main/java/com/entity/XuekeEntity.java index bc07c2d..133fb11 100644 --- a/src/main/java/com/entity/XuekeEntity.java +++ b/src/main/java/com/entity/XuekeEntity.java @@ -1,92 +1,115 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解(用于标识主键字段) import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解(用于指定实体类对应的表名) import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解(当前类未使用,保留导入以备扩展) import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解(当前类未使用,保留导入以备扩展) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类(用于构造函数的异常处理) import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口(使当前类支持对象序列化,便于网络传输或持久化) import java.io.Serializable; +// 导入Java中处理日期和时间的类(用于日期字段的定义) import java.util.Date; +// 导入Java中处理列表集合的接口(当前类未直接使用,保留导入以备扩展) import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解(用于前端与后端日期格式的统一转换) import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解(用于指定日期在JSON中的序列化格式) import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类(用于构造函数中对象属性的复制) import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类(当前类未使用,保留导入以备扩展) import com.baomidou.mybatisplus.enums.IdType; - -/** - * 学科 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 学科实体类 +// 数据库通用操作实体类(普通增删改查) +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为xueke @TableName("xueke") +// 定义泛型实体类XuekeEntity,实现Serializable接口以支持对象的序列化和反序列化 public class XuekeEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性(建议与类结构变更时同步更新) private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象(框架反射创建对象时需要) public XuekeEntity() { - + // 构造函数体为空 } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public XuekeEntity(T t) { + // 尝试使用BeanUtils工具类复制对象属性 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息(开发阶段临时处理,生产环境可自定义异常处理逻辑) e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列(默认主键生成策略) @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值 private Long id; - /** - * 学科 - */ - + // 定义String类型的xueke字段,用于存储学科名称 private String xueke; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式(时区:GMT+8,格式:年-月-日 时:分:秒) + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储学科记录的添加时间 private Date addtime; + // 获取addtime字段值的方法(返回学科记录的添加时间) public Date getAddtime() { + // 返回添加时间属性值 return addtime; } + + // 设置addtime字段值的方法(设置学科记录的添加时间) public void setAddtime(Date addtime) { + // 将参数值赋给当前对象的addtime属性 this.addtime = addtime; } + // 获取id字段值的方法(返回主键ID) public Long getId() { + // 返回主键ID属性值 return id; } + // 设置id字段值的方法(设置主键ID,通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { + // 将参数值赋给当前对象的id属性 this.id = id; } - /** - * 设置:学科 - */ + + // 设置xueke字段值的方法(设置学科名称) public void setXueke(String xueke) { + // 将参数值赋给当前对象的xueke属性 this.xueke = xueke; } - /** - * 获取:学科 - */ + + // 获取xueke字段值的方法(返回学科名称) public String getXueke() { + // 返回学科名称属性值 return xueke; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/YonghuEntity.java b/src/main/java/com/entity/YonghuEntity.java index 9423a8f..b213426 100644 --- a/src/main/java/com/entity/YonghuEntity.java +++ b/src/main/java/com/entity/YonghuEntity.java @@ -1,200 +1,178 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解,用于标识实体类中的主键字段 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解,用于指定实体类对应的数据库表名 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解,当前类未使用,保留导入以备扩展 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类,用于构造函数中属性复制时的异常处理 import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口,使当前类支持对象序列化,便于网络传输或持久化存储 import java.io.Serializable; +// 导入Java中处理日期和时间的类,用于定义日期类型的字段 import java.util.Date; +// 导入Java中处理列表集合的接口,当前类未直接使用,保留导入以备扩展 import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解,用于前端与后端日期参数的格式统一 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解,用于指定日期在JSON中的序列化格式 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类,用于构造函数中对象属性的复制 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 用户 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为"yonghu" @TableName("yonghu") +// 定义泛型实体类YonghuEntity,实现Serializable接口以支持对象的序列化和反序列化 public class YonghuEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性,建议与类结构变更时同步更新 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象,满足框架反射创建对象的需求 public YonghuEntity() { - } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public YonghuEntity(T t) { + // 尝试使用BeanUtils工具类将泛型对象t的属性复制到当前实体对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息,开发阶段临时处理,生产环境可自定义异常处理逻辑 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列,使用MyBatis-Plus默认的主键生成策略 @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值,唯一标识一条用户记录 private Long id; - /** - * 用户账号 - */ - + // 定义String类型的yonghuzhanghao字段,用于存储用户账号,对应数据库中的用户账号列 private String yonghuzhanghao; - - /** - * 密码 - */ - + // 定义String类型的mima字段,用于存储用户密码,对应数据库中的密码列 private String mima; - - /** - * 用户姓名 - */ - + // 定义String类型的yonghuxingming字段,用于存储用户姓名,对应数据库中的用户姓名字段 private String yonghuxingming; - - /** - * 性别 - */ - + // 定义String类型的xingbie字段,用于存储用户性别,对应数据库中的性别列 private String xingbie; - - /** - * 手机 - */ - + // 定义String类型的shouji字段,用于存储用户手机号码,对应数据库中的手机列 private String shouji; - - /** - * 邮箱 - */ - + // 定义String类型的youxiang字段,用于存储用户邮箱,对应数据库中的邮箱列 private String youxiang; - - /** - * 头像 - */ - + // 定义String类型的touxiang字段,用于存储用户头像的路径或链接,对应数据库中的头像列 private String touxiang; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式:时区为GMT+8,格式为"yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换,确保日期格式统一 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储用户记录的添加时间,对应数据库中的添加时间列 private Date addtime; + // 获取addtime字段值的方法,返回用户记录的添加时间 public Date getAddtime() { return addtime; } + + // 设置addtime字段值的方法,用于设置用户记录的添加时间 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id字段值的方法,返回数据库表的主键ID public Long getId() { return id; } + // 设置id字段值的方法,用于设置主键ID(通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { this.id = id; } - /** - * 设置:用户账号 - */ + + // 设置yonghuzhanghao字段值的方法,用于设置用户账号 public void setYonghuzhanghao(String yonghuzhanghao) { this.yonghuzhanghao = yonghuzhanghao; } - /** - * 获取:用户账号 - */ + + // 获取yonghuzhanghao字段值的方法,返回用户账号 public String getYonghuzhanghao() { return yonghuzhanghao; } - /** - * 设置:密码 - */ + + // 设置mima字段值的方法,用于设置用户密码 public void setMima(String mima) { this.mima = mima; } - /** - * 获取:密码 - */ + + // 获取mima字段值的方法,返回用户密码 public String getMima() { return mima; } - /** - * 设置:用户姓名 - */ + + // 设置yonghuxingming字段值的方法,用于设置用户姓名 public void setYonghuxingming(String yonghuxingming) { this.yonghuxingming = yonghuxingming; } - /** - * 获取:用户姓名 - */ + + // 获取yonghuxingming字段值的方法,返回用户姓名 public String getYonghuxingming() { return yonghuxingming; } - /** - * 设置:性别 - */ + + // 设置xingbie字段值的方法,用于设置用户性别 public void setXingbie(String xingbie) { this.xingbie = xingbie; } - /** - * 获取:性别 - */ + + // 获取xingbie字段值的方法,返回用户性别 public String getXingbie() { return xingbie; } - /** - * 设置:手机 - */ + + // 设置shouji字段值的方法,用于设置用户手机号码 public void setShouji(String shouji) { this.shouji = shouji; } - /** - * 获取:手机 - */ + + // 获取shouji字段值的方法,返回用户手机号码 public String getShouji() { return shouji; } - /** - * 设置:邮箱 - */ + + // 设置youxiang字段值的方法,用于设置用户邮箱 public void setYouxiang(String youxiang) { this.youxiang = youxiang; } - /** - * 获取:邮箱 - */ + + // 获取youxiang字段值的方法,返回用户邮箱 public String getYouxiang() { return youxiang; } - /** - * 设置:头像 - */ + + // 设置touxiang字段值的方法,用于设置用户头像路径或链接 public void setTouxiang(String touxiang) { this.touxiang = touxiang; } - /** - * 获取:头像 - */ + + // 获取touxiang字段值的方法,返回用户头像路径或链接 public String getTouxiang() { return touxiang; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ZhiyeguihuaEntity.java b/src/main/java/com/entity/ZhiyeguihuaEntity.java index 297c106..a61107f 100644 --- a/src/main/java/com/entity/ZhiyeguihuaEntity.java +++ b/src/main/java/com/entity/ZhiyeguihuaEntity.java @@ -1,272 +1,226 @@ +// 声明当前类所属的包为com.entity package com.entity; +// 导入MyBatis-Plus框架中用于标记数据库表主键的注解,用于标识实体类中的主键字段 import com.baomidou.mybatisplus.annotations.TableId; +// 导入MyBatis-Plus框架中用于标记数据库表名的注解,用于指定实体类对应的数据库表名 import com.baomidou.mybatisplus.annotations.TableName; +// 导入JSR-303验证框架中用于验证字符串非空(排除空格后)的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotBlank; +// 导入JSR-303验证框架中用于验证集合、数组等非空的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotEmpty; +// 导入JSR-303验证框架中用于验证对象非null的注解,当前类未使用,保留导入以备扩展 import javax.validation.constraints.NotNull; +// 导入Jackson库中用于忽略JSON序列化/反序列化时特定属性的注解,当前类未使用,保留导入以备扩展 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Java反射机制中处理方法调用异常的类,用于构造函数中属性复制时的异常处理 import java.lang.reflect.InvocationTargetException; +// 导入Java中实现对象序列化的接口,使当前类支持对象序列化,便于网络传输或持久化存储 import java.io.Serializable; +// 导入Java中处理日期和时间的类,用于定义日期类型的字段 import java.util.Date; +// 导入Java中处理列表集合的接口,当前类未直接使用,保留导入以备扩展 import java.util.List; +// 导入Spring框架中用于处理日期格式转换的注解,用于前端与后端日期参数的格式统一 import org.springframework.format.annotation.DateTimeFormat; +// 导入Jackson库中用于格式化JSON日期输出的注解,用于指定日期在JSON中的序列化格式 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入Apache Commons BeanUtils库中用于Bean属性复制的工具类,用于构造函数中对象属性的复制 import org.apache.commons.beanutils.BeanUtils; +// 导入MyBatis-Plus框架中用于标记数据库表字段的注解,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.annotations.TableField; +// 导入MyBatis-Plus框架中定义字段填充策略的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入MyBatis-Plus框架中定义主键生成类型的枚举类,当前类未使用,保留导入以备扩展 import com.baomidou.mybatisplus.enums.IdType; - -/** - * 职业规划 - * 数据库通用操作实体类(普通增删改查) - * @author - * @email - * @date 2021-05-09 15:46:14 - */ +// 使用MyBatis-Plus注解指定当前类对应的数据库表名为"zhiyeguihua" @TableName("zhiyeguihua") +// 定义泛型实体类ZhiyeguihuaEntity,实现Serializable接口以支持对象的序列化和反序列化 public class ZhiyeguihuaEntity implements Serializable { + // 定义序列化版本号,确保不同版本的序列化兼容性,建议与类结构变更时同步更新 private static final long serialVersionUID = 1L; - + // 无参构造函数,用于创建一个空的实体对象,满足框架反射创建对象的需求 public ZhiyeguihuaEntity() { - } - + + // 带参构造函数,接收一个泛型对象t,用于将t的属性复制到当前实体对象 public ZhiyeguihuaEntity(T t) { + // 尝试使用BeanUtils工具类将泛型对象t的属性复制到当前实体对象 try { BeanUtils.copyProperties(this, t); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 捕获属性复制过程中的非法访问异常或方法调用异常 + // 打印异常堆栈信息,开发阶段临时处理,生产环境可自定义异常处理逻辑 e.printStackTrace(); } } - - /** - * 主键id - */ + + // 标记该字段为主键,对应数据库表中的主键列,使用MyBatis-Plus默认的主键生成策略 @TableId + // 定义Long类型的id字段,用于存储数据库表的主键值,唯一标识一条职业规划记录 private Long id; - /** - * 自我分析 - */ - + // 定义String类型的ziwofenxi字段,用于存储职业规划中的自我分析内容 private String ziwofenxi; - - /** - * 确立目标 - */ - + // 定义String类型的quelimubiao字段,用于存储职业规划中确立的目标 private String quelimubiao; - - /** - * 环境评价 - */ - + // 定义String类型的huanjingpingjia字段,用于存储职业规划中的环境评价内容 private String huanjingpingjia; - - /** - * 职业定位 - */ - + // 定义String类型的zhiyedingwei字段,用于存储职业规划中的职业定位信息 private String zhiyedingwei; - - /** - * 实施策略 - */ - + // 定义String类型的shishicelve字段,用于存储职业规划中的实施策略 private String shishicelve; - - /** - * 评估与反馈 - */ - + // 定义String类型的pingguyufankui字段,用于存储职业规划中的评估与反馈内容 private String pingguyufankui; - - /** - * 封面 - */ - + // 定义String类型的fengmian字段,用于存储职业规划文档的封面路径或链接 private String fengmian; - - /** - * 姓名 - */ - + // 定义String类型的xingming字段,用于存储用户姓名 private String xingming; - - /** - * 性别 - */ - + // 定义String类型的xingbie字段,用于存储用户性别 private String xingbie; - - /** - * 年龄 - */ - + // 定义String类型的nianling字段,用于存储用户年龄 private String nianling; - - /** - * 目前职业 - */ - + // 定义String类型的muqianzhiye字段,用于存储用户目前的职业 private String muqianzhiye; - - - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + + // 使用Jackson注解指定日期在JSON中的格式:时区为GMT+8,格式为"yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 使用Spring注解支持前端日期参数的自动格式化转换,确保日期格式统一 @DateTimeFormat + // 定义Date类型的addtime字段,用于存储职业规划记录的添加时间,对应数据库中的添加时间列 private Date addtime; + // 获取addtime字段值的方法,返回职业规划记录的添加时间 public Date getAddtime() { return addtime; } + + // 设置addtime字段值的方法,用于设置职业规划记录的添加时间 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取id字段值的方法,返回数据库表的主键ID public Long getId() { return id; } + // 设置id字段值的方法,用于设置主键ID(通常由数据库自动生成,代码中较少手动设置) public void setId(Long id) { this.id = id; } - /** - * 设置:自我分析 - */ + + // 设置ziwofenxi字段值的方法,用于设置职业规划中的自我分析内容 public void setZiwofenxi(String ziwofenxi) { this.ziwofenxi = ziwofenxi; } - /** - * 获取:自我分析 - */ + + // 获取ziwofenxi字段值的方法,返回职业规划中的自我分析内容 public String getZiwofenxi() { return ziwofenxi; } - /** - * 设置:确立目标 - */ + + // 设置quelimubiao字段值的方法,用于设置职业规划中确立的目标 public void setQuelimubiao(String quelimubiao) { this.quelimubiao = quelimubiao; } - /** - * 获取:确立目标 - */ + + // 获取quelimubiao字段值的方法,返回职业规划中确立的目标 public String getQuelimubiao() { return quelimubiao; } - /** - * 设置:环境评价 - */ + + // 设置huanjingpingjia字段值的方法,用于设置职业规划中的环境评价内容 public void setHuanjingpingjia(String huanjingpingjia) { this.huanjingpingjia = huanjingpingjia; } - /** - * 获取:环境评价 - */ + + // 获取huanjingpingjia字段值的方法,返回职业规划中的环境评价内容 public String getHuanjingpingjia() { return huanjingpingjia; } - /** - * 设置:职业定位 - */ + + // 设置zhiyedingwei字段值的方法,用于设置职业规划中的职业定位信息 public void setZhiyedingwei(String zhiyedingwei) { this.zhiyedingwei = zhiyedingwei; } - /** - * 获取:职业定位 - */ + + // 获取zhiyedingwei字段值的方法,返回职业规划中的职业定位信息 public String getZhiyedingwei() { return zhiyedingwei; } - /** - * 设置:实施策略 - */ + + // 设置shishicelve字段值的方法,用于设置职业规划中的实施策略 public void setShishicelve(String shishicelve) { this.shishicelve = shishicelve; } - /** - * 获取:实施策略 - */ + + // 获取shishicelve字段值的方法,返回职业规划中的实施策略 public String getShishicelve() { return shishicelve; } - /** - * 设置:评估与反馈 - */ + + // 设置pingguyufankui字段值的方法,用于设置职业规划中的评估与反馈内容 public void setPingguyufankui(String pingguyufankui) { this.pingguyufankui = pingguyufankui; } - /** - * 获取:评估与反馈 - */ + + // 获取pingguyufankui字段值的方法,返回职业规划中的评估与反馈内容 public String getPingguyufankui() { return pingguyufankui; } - /** - * 设置:封面 - */ + + // 设置fengmian字段值的方法,用于设置职业规划文档的封面 public void setFengmian(String fengmian) { this.fengmian = fengmian; } - /** - * 获取:封面 - */ + + // 获取fengmian字段值的方法,返回职业规划文档的封面路径或链接 public String getFengmian() { return fengmian; } - /** - * 设置:姓名 - */ + + // 设置xingming字段值的方法,用于设置用户姓名 public void setXingming(String xingming) { this.xingming = xingming; } - /** - * 获取:姓名 - */ + + // 获取xingming字段值的方法,返回用户姓名 public String getXingming() { return xingming; } - /** - * 设置:性别 - */ + + // 设置xingbie字段值的方法,用于设置用户性别 public void setXingbie(String xingbie) { this.xingbie = xingbie; } - /** - * 获取:性别 - */ + + // 获取xingbie字段值的方法,返回用户性别 public String getXingbie() { return xingbie; } - /** - * 设置:年龄 - */ + + // 设置nianling字段值的方法,用于设置用户年龄 public void setNianling(String nianling) { this.nianling = nianling; } - /** - * 获取:年龄 - */ + + // 获取nianling字段值的方法,返回用户年龄 public String getNianling() { return nianling; } - /** - * 设置:目前职业 - */ + + // 设置muqianzhiye字段值的方法,用于设置用户目前的职业 public void setMuqianzhiye(String muqianzhiye) { this.muqianzhiye = muqianzhiye; } - /** - * 获取:目前职业 - */ + + // 获取muqianzhiye字段值的方法,返回用户目前的职业 public String getMuqianzhiye() { return muqianzhiye; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/interceptor/AuthorizationInterceptor.java b/src/main/java/com/interceptor/AuthorizationInterceptor.java index 74b5ebd..a7ec472 100644 --- a/src/main/java/com/interceptor/AuthorizationInterceptor.java +++ b/src/main/java/com/interceptor/AuthorizationInterceptor.java @@ -1,95 +1,104 @@ +// 声明包名为com.interceptor,标识该类的存储路径 package com.interceptor; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Map; -import com.alibaba.fastjson.JSONObject; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +// 导入所需的Java类和库 +import java.io.IOException; // 用于处理输入输出异常 +import java.io.PrintWriter; // 用于向客户端输出文本数据 +import java.util.HashMap; // 提供哈希映射数据结构 +import java.util.Map; // 提供映射接口 +import com.alibaba.fastjson.JSONObject; // 阿里巴巴的JSON处理工具 +import javax.servlet.http.HttpServletRequest; // 提供HTTP请求对象 +import javax.servlet.http.HttpServletResponse; // 提供HTTP响应对象 -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.http.HttpStatus; +// 导入Apache Commons工具类 +import org.apache.commons.lang3.StringUtils; // 字符串处理工具类 +// 导入Spring框架相关类 +import org.springframework.beans.factory.annotation.Autowired; // 实现依赖注入 +import org.springframework.stereotype.Component; // 声明为Spring组件 +import org.springframework.web.method.HandlerMethod; // 处理方法元数据封装类 +import org.springframework.web.servlet.HandlerInterceptor; // Spring拦截器接口 +import org.springframework.web.bind.annotation.RequestMethod; // HTTP请求方法枚举 +import org.springframework.http.HttpStatus; // HTTP状态码封装类 -import com.annotation.IgnoreAuth; -import com.entity.EIException; -import com.entity.TokenEntity; -import com.service.TokenService; -import com.utils.R; +// 导入自定义注解和类 +import com.annotation.IgnoreAuth; // 自定义的跳过验证注解 +import com.entity.EIException; // 自定义异常类 +import com.entity.TokenEntity; // Token实体类 +import com.service.TokenService; // Token服务接口 +import com.utils.R; // 统一响应格式工具类 /** - * 权限(Token)验证 + * 权限(Token)验证拦截器 */ -@Component -public class AuthorizationInterceptor implements HandlerInterceptor { +@Component // 声明为Spring管理的组件 +public class AuthorizationInterceptor implements HandlerInterceptor { // 实现拦截器接口 + // 定义登录Token在请求头中的键名 public static final String LOGIN_TOKEN_KEY = "Token"; - @Autowired + @Autowired // 自动注入TokenService实例 private TokenService tokenService; - - @Override + + // 实现拦截器的前置处理方法 + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - //支持跨域请求 - response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); - response.setHeader("Access-Control-Max-Age", "3600"); - response.setHeader("Access-Control-Allow-Credentials", "true"); - response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization"); - response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); - // 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态 - if (request.getMethod().equals(RequestMethod.OPTIONS.name())) { - response.setStatus(HttpStatus.OK.value()); - return false; + // 设置跨域请求相关响应头 + response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); // 允许的HTTP方法 + response.setHeader("Access-Control-Max-Age", "3600"); // 预检请求缓存时间(秒) + response.setHeader("Access-Control-Allow-Credentials", "true"); // 允许携带凭证 + response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization"); // 允许的请求头 + response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); // 允许的请求来源 + + // 处理OPTIONS预检请求直接返回成功状态 + if (request.getMethod().equals(RequestMethod.OPTIONS.name())) { + response.setStatus(HttpStatus.OK.value()); // 设置HTTP状态码为200 + return false; // 终止请求处理流程 } - + + // 检查处理方法是否标注了IgnoreAuth注解 IgnoreAuth annotation; - if (handler instanceof HandlerMethod) { - annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class); + if (handler instanceof HandlerMethod) { // 判断是否为方法处理器 + annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class); // 获取方法上的注解 } else { - return true; + return true; // 非方法处理器直接放行 } - //从header中获取token + // 从请求头中获取Token值 String token = request.getHeader(LOGIN_TOKEN_KEY); - - /** - * 不需要验证权限的方法直接放过 - */ + + // 如果方法标注了IgnoreAuth注解则跳过验证 if(annotation!=null) { - return true; + return true; // 放行请求 } - + + // Token验证逻辑 TokenEntity tokenEntity = null; - if(StringUtils.isNotBlank(token)) { - tokenEntity = tokenService.getTokenEntity(token); + if(StringUtils.isNotBlank(token)) { // 检查Token是否非空 + tokenEntity = tokenService.getTokenEntity(token); // 查询Token有效性 } - + + // 验证成功时将用户信息存入Session if(tokenEntity != null) { - request.getSession().setAttribute("userId", tokenEntity.getUserid()); - request.getSession().setAttribute("role", tokenEntity.getRole()); - request.getSession().setAttribute("tableName", tokenEntity.getTablename()); - request.getSession().setAttribute("username", tokenEntity.getUsername()); - return true; + request.getSession().setAttribute("userId", tokenEntity.getUserid()); // 用户ID + request.getSession().setAttribute("role", tokenEntity.getRole()); // 用户角色 + request.getSession().setAttribute("tableName", tokenEntity.getTablename()); // 表名(可能用于数据隔离) + request.getSession().setAttribute("username", tokenEntity.getUsername()); // 用户名 + return true; // 验证通过,放行请求 + } + + // Token验证失败时的响应处理 + PrintWriter writer = null; + response.setCharacterEncoding("UTF-8"); // 设置响应编码 + response.setContentType("application/json; charset=utf-8"); // 设置响应类型为JSON + try { + writer = response.getWriter(); // 获取响应输出流 + writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); // 输出JSON格式错误信息 + } finally { + if(writer != null){ + writer.close(); // 确保关闭输出流 + } } - - PrintWriter writer = null; - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json; charset=utf-8"); - try { - writer = response.getWriter(); - writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); - } finally { - if(writer != null){ - writer.close(); - } - } -// throw new EIException("请先登录", 401); - return false; + return false; // 拦截请求 } -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ChatServiceImpl.java b/src/main/java/com/service/impl/ChatServiceImpl.java index 3dcc991..3aff487 100644 --- a/src/main/java/com/service/impl/ChatServiceImpl.java +++ b/src/main/java/com/service/impl/ChatServiceImpl.java @@ -1,62 +1,93 @@ +// 声明该类所在的包为com.service.impl package com.service.impl; +// 导入Spring框架的Service注解,用于标记该类为服务层组件 import org.springframework.stereotype.Service; +// 导入Java的Map接口,用于处理键值对数据 import java.util.Map; +// 导入Java的List接口,用于处理列表数据 import java.util.List; +// 导入MyBatis-Plus的Wrapper接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入MyBatis-Plus的EntityWrapper类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入MyBatis-Plus的Page类,用于分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入MyBatis-Plus的ServiceImpl类,提供通用的服务层实现 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入Chat数据访问对象 import com.dao.ChatDao; +// 导入Chat实体类 import com.entity.ChatEntity; +// 导入Chat服务接口 import com.service.ChatService; +// 导入Chat值对象类 import com.entity.vo.ChatVO; +// 导入Chat视图类 import com.entity.view.ChatView; +// 标记该类为Spring的服务组件,名称为chatService @Service("chatService") +// 定义ChatServiceImpl类,继承ServiceImpl类并实现ChatService接口 public class ChatServiceImpl extends ServiceImpl implements ChatService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写queryPage方法,用于根据参数查询Chat实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数进行初始化 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,包含分页信息 + return new PageUtils(page); + } + + // 重写queryPage方法,用于根据参数和查询条件查询Chat视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数进行初始化 + Page page = new Query(params).getPage(); + // 设置分页对象的记录列表,通过基础映射器的selectListView方法查询 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 创建分页工具类对象,包含分页信息 + PageUtils pageUtil = new PageUtils(page); + // 返回分页工具类对象 + return pageUtil; + } + + // 重写selectListVO方法,用于根据查询条件查询Chat值对象的列表数据 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的selectListVO方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写selectVO方法,用于根据查询条件查询单个Chat值对象 @Override public ChatVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的selectVO方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写selectListView方法,用于根据查询条件查询Chat视图的列表数据 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的selectListView方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写selectView方法,用于根据查询条件查询单个Chat视图 @Override public ChatView selectView(Wrapper wrapper) { + // 调用基础映射器的selectView方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ExampaperServiceImpl.java b/src/main/java/com/service/impl/ExampaperServiceImpl.java index c2b0376..fd58e5c 100644 --- a/src/main/java/com/service/impl/ExampaperServiceImpl.java +++ b/src/main/java/com/service/impl/ExampaperServiceImpl.java @@ -1,62 +1,558 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 Java 的 ArrayList 类,用于创建动态数组 +import java.util.ArrayList; +// 导入 Java 的 HashMap 类,用于存储键值对集合 +import java.util.HashMap; +// 导入 Java 的 Date 类,用于处理日期和时间 +import java.util.Date; +// 导入 Java 的 Calendar 类,用于进行日期和时间的计算 +import java.util.Calendar; +// 导入 Java 的 Collections 类,用于对集合进行操作 +import java.util.Collections; +// 导入 Java 的 Comparator 接口,用于自定义排序规则 +import java.util.Comparator; +// 导入 Java 的 Optional 类,用于处理可能为空的值 +import java.util.Optional; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入试卷数据访问对象 import com.dao.ExampaperDao; +// 导入试卷实体类 import com.entity.ExampaperEntity; +// 导入试卷服务接口 import com.service.ExampaperService; +// 导入试卷值对象类 import com.entity.vo.ExampaperVO; +// 导入试卷视图类 import com.entity.view.ExampaperView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 exampaperService @Service("exampaperService") +// 定义试卷服务实现类,继承自 ServiceImpl 并实现 ExampaperService 接口 public class ExampaperServiceImpl extends ServiceImpl implements ExampaperService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询试卷实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询试卷视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储试卷视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取试卷视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询试卷值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个试卷值对象 @Override public ExampaperVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询试卷视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个试卷视图 @Override public ExampaperView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } -} + // 新增方法:根据试卷名称查询试卷视图列表 + public List selectListViewByName(String paperName) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加试卷名称等于指定名称的查询条件 + wrapper.eq("paper_name", paperName); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据考试科目查询试卷视图列表 + public List selectListViewBySubject(String subject) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试科目等于指定科目的查询条件 + wrapper.eq("subject", subject); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据考试时间范围查询试卷视图列表 + public List selectListViewByExamTimeRange(Date startDate, Date endDate) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试时间大于等于开始日期的查询条件 + wrapper.ge("exam_time", startDate); + // 添加考试时间小于等于结束日期的查询条件 + wrapper.le("exam_time", endDate); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据试卷总分范围查询试卷视图列表 + public List selectListViewByTotalScoreRange(int minScore, int maxScore) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加试卷总分大于等于最低分数的查询条件 + wrapper.ge("total_score", minScore); + // 添加试卷总分小于等于最高分数的查询条件 + wrapper.le("total_score", maxScore); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据试卷名称和考试科目查询试卷视图列表 + public List selectListViewByNameAndSubject(String paperName, String subject) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加试卷名称等于指定名称的查询条件 + wrapper.eq("paper_name", paperName); + // 添加考试科目等于指定科目的查询条件 + wrapper.eq("subject", subject); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据试卷名称统计试卷数量 + public int countPapersByName(String paperName) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加试卷名称等于指定名称的查询条件 + wrapper.eq("paper_name", paperName); + // 调用基础映射器的 selectCount 方法统计试卷数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据考试科目统计试卷数量 + public int countPapersBySubject(String subject) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试科目等于指定科目的查询条件 + wrapper.eq("subject", subject); + // 调用基础映射器的 selectCount 方法统计试卷数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据考试时间范围统计试卷数量 + public int countPapersByExamTimeRange(Date startDate, Date endDate) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试时间大于等于开始日期的查询条件 + wrapper.ge("exam_time", startDate); + // 添加考试时间小于等于结束日期的查询条件 + wrapper.le("exam_time", endDate); + // 调用基础映射器的 selectCount 方法统计试卷数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据试卷总分范围统计试卷数量 + public int countPapersByTotalScoreRange(int minScore, int maxScore) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加试卷总分大于等于最低分数的查询条件 + wrapper.ge("total_score", minScore); + // 添加试卷总分小于等于最高分数的查询条件 + wrapper.le("total_score", maxScore); + // 调用基础映射器的 selectCount 方法统计试卷数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据试卷名称和考试科目统计试卷数量 + public int countPapersByNameAndSubject(String paperName, String subject) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加试卷名称等于指定名称的查询条件 + wrapper.eq("paper_name", paperName); + // 添加考试科目等于指定科目的查询条件 + wrapper.eq("subject", subject); + // 调用基础映射器的 selectCount 方法统计试卷数量 + return this.selectCount(wrapper); + } + + // 新增方法:更新试卷的总分 + public boolean updateTotalScore(int paperId, int newTotalScore) { + // 创建一个试卷实体对象 + ExampaperEntity entity = new ExampaperEntity(); + // 设置试卷 ID + entity.setId(paperId); + // 设置新的总分 + entity.setTotalScore(newTotalScore); + // 调用基础映射器的 updateById 方法更新试卷信息 + return this.updateById(entity); + } + + // 新增方法:更新试卷的考试时间 + public boolean updateExamTime(int paperId, Date newExamTime) { + // 创建一个试卷实体对象 + ExampaperEntity entity = new ExampaperEntity(); + // 设置试卷 ID + entity.setId(paperId); + // 设置新的考试时间 + entity.setExamTime(newExamTime); + // 调用基础映射器的 updateById 方法更新试卷信息 + return this.updateById(entity); + } + + // 新增方法:更新试卷的考试科目 + public boolean updateSubject(int paperId, String newSubject) { + // 创建一个试卷实体对象 + ExampaperEntity entity = new ExampaperEntity(); + // 设置试卷 ID + entity.setId(paperId); + // 设置新的考试科目 + entity.setSubject(newSubject); + // 调用基础映射器的 updateById 方法更新试卷信息 + return this.updateById(entity); + } + + // 新增方法:根据试卷 ID 删除试卷 + public boolean deletePaperById(int paperId) { + // 调用基础映射器的 deleteById 方法删除试卷 + return this.deleteById(paperId); + } + + // 新增方法:批量删除试卷 + public boolean deletePapersByIds(List paperIds) { + // 遍历试卷 ID 列表 + for (Integer id : paperIds) { + // 调用基础映射器的 deleteById 方法删除试卷 + if (!this.deleteById(id)) { + // 如果删除失败,返回 false + return false; + } + } + // 所有删除操作都成功,返回 true + return true; + } + + // 新增方法:根据试卷名称对试卷视图列表进行排序 + public List sortPapersByName(List papers) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(papers, Comparator.comparing(ExampaperView::getPaperName)); + return papers; + } + + // 新增方法:根据考试时间对试卷视图列表进行排序 + public List sortPapersByExamTime(List papers) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(papers, Comparator.comparing(ExampaperView::getExamTime)); + return papers; + } + + // 新增方法:根据试卷总分对试卷视图列表进行排序 + public List sortPapersByTotalScore(List papers) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(papers, Comparator.comparingInt(ExampaperView::getTotalScore)); + return papers; + } + + // 新增方法:获取指定考试科目中总分最高的试卷 + public Optional getHighestTotalScorePaperBySubject(String subject) { + // 根据考试科目查询试卷视图列表 + List papers = selectListViewBySubject(subject); + if (papers.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.max 方法找出总分最高的试卷 + ExampaperView highestScorePaper = Collections.max(papers, Comparator.comparingInt(ExampaperView::getTotalScore)); + // 返回包含总分最高试卷的 Optional 对象 + return Optional.of(highestScorePaper); + } + + // 新增方法:获取指定考试科目中总分最低的试卷 + public Optional getLowestTotalScorePaperBySubject(String subject) { + // 根据考试科目查询试卷视图列表 + List papers = selectListViewBySubject(subject); + if (papers.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.min 方法找出总分最低的试卷 + ExampaperView lowestScorePaper = Collections.min(papers, Comparator.comparingInt(ExampaperView::getTotalScore)); + // 返回包含总分最低试卷的 Optional 对象 + return Optional.of(lowestScorePaper); + } + + // 新增方法:获取指定考试时间范围内最早的试卷 + public Optional getEarliestPaperByExamTimeRange(Date startDate, Date endDate) { + // 根据考试时间范围查询试卷视图列表 + List papers = selectListViewByExamTimeRange(startDate, endDate); + if (papers.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.min 方法找出最早的试卷 + ExampaperView earliestPaper = Collections.min(papers, Comparator.comparing(ExampaperView::getExamTime)); + // 返回包含最早试卷的 Optional 对象 + return Optional.of(earliestPaper); + } + + // 新增方法:获取指定考试时间范围内最晚的试卷 + public Optional getLatestPaperByExamTimeRange(Date startDate, Date endDate) { + // 根据考试时间范围查询试卷视图列表 + List papers = selectListViewByExamTimeRange(startDate, endDate); + if (papers.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.max 方法找出最晚的试卷 + ExampaperView latestPaper = Collections.max(papers, Comparator.comparing(ExampaperView::getExamTime)); + // 返回包含最晚试卷的 Optional 对象 + return Optional.of(latestPaper); + } + + // 新增方法:根据考试科目分组统计试卷数量 + public Map countPapersBySubject() { + // 创建一个 HashMap 用于存储统计结果 + Map subjectCountMap = new HashMap<>(); + // 查询所有试卷视图列表 + List papers = selectListView(null); + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + String subject = paper.getSubject(); + // 如果该考试科目已经在 Map 中,增加其计数 + subjectCountMap.put(subject, subjectCountMap.getOrDefault(subject, 0) + 1); + } + return subjectCountMap; + } + + // 新增方法:根据试卷总分范围分组统计试卷数量 + public Map countPapersByTotalScoreRanges(List scoreRanges) { + // 创建一个 HashMap 用于存储统计结果 + Map scoreRangeCountMap = new HashMap<>(); + // 查询所有试卷视图列表 + List papers = selectListView(null); + // 遍历分数范围列表 + for (int[] range : scoreRanges) { + int minScore = range[0]; + int maxScore = range[1]; + String rangeKey = minScore + "-" + maxScore; + int count = 0; + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + int totalScore = paper.getTotalScore(); + if (totalScore >= minScore && totalScore <= maxScore) { + // 如果试卷总分在该范围内,增加计数 + count++; + } + } + // 将该分数范围的计数存入 Map + scoreRangeCountMap.put(rangeKey, count); + } + return scoreRangeCountMap; + } + + // 新增方法:根据考试时间的月份分组统计试卷数量 + public Map countPapersByExamMonth() { + // 创建一个 HashMap 用于存储统计结果 + Map monthCountMap = new HashMap<>(); + // 查询所有试卷视图列表 + List papers = selectListView(null); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + calendar.setTime(paper.getExamTime()); + int month = calendar.get(Calendar.MONTH) + 1; + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return monthCountMap; + } + + // 新增方法:根据考试科目和试卷总分范围分组统计试卷数量 + public Map> countPapersBySubjectAndTotalScoreRanges(List scoreRanges) { + // 创建一个 HashMap 用于存储统计结果 + Map> subjectScoreRangeCountMap = new HashMap<>(); + // 查询所有试卷视图列表 + List papers = selectListView(null); + // 遍历分数范围列表 + for (int[] range : scoreRanges) { + int minScore = range[0]; + int maxScore = range[1]; + String rangeKey = minScore + "-" + maxScore; + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + String subject = paper.getSubject(); + int totalScore = paper.getTotalScore(); + if (totalScore >= minScore && totalScore <= maxScore) { + // 获取该考试科目对应的分数范围计数 Map + Map scoreRangeCountMap = subjectScoreRangeCountMap.computeIfAbsent(subject, k -> new HashMap<>()); + // 如果该分数范围已经在 Map 中,增加其计数 + scoreRangeCountMap.put(rangeKey, scoreRangeCountMap.getOrDefault(rangeKey, 0) + 1); + } + } + } + return subjectScoreRangeCountMap; + } + + // 新增方法:根据考试科目和考试时间的月份分组统计试卷数量 + public Map> countPapersBySubjectAndExamMonth() { + // 创建一个 HashMap 用于存储统计结果 + Map> subjectMonthCountMap = new HashMap<>(); + // 查询所有试卷视图列表 + List papers = selectListView(null); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + String subject = paper.getSubject(); + calendar.setTime(paper.getExamTime()); + int month = calendar.get(Calendar.MONTH) + 1; + // 获取该考试科目对应的月份计数 Map + Map monthCountMap = subjectMonthCountMap.computeIfAbsent(subject, k -> new HashMap<>()); + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return subjectMonthCountMap; + } + + // 新增方法:根据试卷总分和考试时间的月份分组统计试卷数量 + public Map> countPapersByTotalScoreAndExamMonth() { + // 创建一个 HashMap 用于存储统计结果 + Map> scoreMonthCountMap = new HashMap<>(); + // 查询所有试卷视图列表 + List papers = selectListView(null); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + int totalScore = paper.getTotalScore(); + calendar.setTime(paper.getExamTime()); + int month = calendar.get(Calendar.MONTH) + 1; + // 获取该总分对应的月份计数 Map + Map monthCountMap = scoreMonthCountMap.computeIfAbsent(totalScore, k -> new HashMap<>()); + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return scoreMonthCountMap; + } + + // 新增方法:获取指定考试科目下的平均总分 + public Optional getAverageTotalScoreBySubject(String subject) { + // 根据考试科目查询试卷视图列表 + List papers = selectListViewBySubject(subject); + if (papers.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int totalScoreSum = 0; + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + totalScoreSum += paper.getTotalScore(); + } + // 计算平均总分 + double averageTotalScore = (double) totalScoreSum / papers.size(); + // 返回包含平均总分的 Optional 对象 + return Optional.of(averageTotalScore); + } + + // 新增方法:获取指定考试时间范围内的平均总分 + public Optional getAverageTotalScoreByExamTimeRange(Date startDate, Date endDate) { + // 根据考试时间范围查询试卷视图列表 + List papers = selectListViewByExamTimeRange(startDate, endDate); + if (papers.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int totalScoreSum = 0; + // 遍历试卷视图列表 + for (ExampaperView paper : papers) { + totalScoreSum += paper.getTotalScore(); + } + // 计算平均总分 + double averageTotalScore = (double) totalScoreSum / papers.size(); + // 返回包含平均总分的 Optional 对象 + return Optional.of(averageTotalScore); + } + + // 新增方法:获取试卷数量最多的考试科目 + public Optional getMostFrequentSubject() { + // 根据考试科目分组统计试卷数量 + Map subjectCountMap = countPapersBySubject(); + if (subjectCountMap.isEmpty()) { + // 如果 Map 为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 找出数量最多的考试科目 + String mostFrequentSubject = Collections.max(subjectCountMap.entrySet(), Map.Entry.comparingByValue()).getKey(); + // 返回包含数量最多考试科目的 Optional 对象 + return Optional.of(mostFrequentSubject); + } + + // 新增方法:获取试卷数量最多的总分范围 + public Optional getMostFrequentTotalScoreRange(List scoreRanges) { + // 根据试卷总分范围分组统计试卷数量 + Map scoreRangeCountMap = countPapersByTotalScoreRanges(scoreRanges); + if (scoreRangeCountMap.isEmpty()) { + // 如果 Map 为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 找出数量最多的总分范围 + String mostFrequentScoreRange = Collections.max(scoreRangeCountMap.entrySet(), Map.Entry.comparingByValue()).getKey(); + // 返回包含数量最多总分范围的 Optional 对象 + return Optional.of(mostFrequentScoreRange); + } + + // 新增方法:获取试卷数量最多的考试月份 + public Optional getMostFrequentExamMonth() { + // 根据考试时间的月份分组统计试卷数量 + Map monthCountMap = countPapersByExamMonth(); + if (monthCountMap.isEmpty()) { + // 如果 Map 为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 找出数量最多的考试月份 + Integer mostFrequentMonth = Collections.max(monthCountMap.entrySet(), Map.Entry.comparingByValue()).getKey(); + // 返回包含数量最多考试月份的 Optional 对象 + return Optional.of(mostFrequentMonth); + } +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ExamquestionServiceImpl.java b/src/main/java/com/service/impl/ExamquestionServiceImpl.java index 13755cb..de3b5f5 100644 --- a/src/main/java/com/service/impl/ExamquestionServiceImpl.java +++ b/src/main/java/com/service/impl/ExamquestionServiceImpl.java @@ -1,62 +1,505 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 Java 的 ArrayList 类,用于动态数组操作 +import java.util.ArrayList; +// 导入 Java 的 HashMap 类,用于存储键值对数据 +import java.util.HashMap; +// 导入 Java 的 Date 类,用于处理日期和时间 +import java.util.Date; +// 导入 Java 的 Calendar 类,用于日期和时间的计算 +import java.util.Calendar; +// 导入 Java 的 Collections 类,用于对集合进行操作 +import java.util.Collections; +// 导入 Java 的 Comparator 接口,用于自定义排序规则 +import java.util.Comparator; +// 导入 Java 的 Optional 类,用于处理可能为空的值 +import java.util.Optional; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入考试问题数据访问对象 import com.dao.ExamquestionDao; +// 导入考试问题实体类 import com.entity.ExamquestionEntity; +// 导入考试问题服务接口 import com.service.ExamquestionService; +// 导入考试问题值对象类 import com.entity.vo.ExamquestionVO; +// 导入考试问题视图类 import com.entity.view.ExamquestionView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 examquestionService @Service("examquestionService") +// 定义考试问题服务实现类,继承自 ServiceImpl 并实现 ExamquestionService 接口 public class ExamquestionServiceImpl extends ServiceImpl implements ExamquestionService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询考试问题实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询考试问题视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储考试问题视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取考试问题视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询考试问题值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个考试问题值对象 @Override public ExamquestionVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询考试问题视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个考试问题视图 @Override public ExamquestionView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } -} + // 新增方法:根据问题类型查询考试问题视图列表 + public List selectListViewByQuestionType(String questionType) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加问题类型等于指定类型的查询条件 + wrapper.eq("question_type", questionType); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据问题难度查询考试问题视图列表 + public List selectListViewByDifficultyLevel(int difficultyLevel) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加问题难度等于指定难度的查询条件 + wrapper.eq("difficulty_level", difficultyLevel); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据创建时间范围查询考试问题视图列表 + public List selectListViewByCreateTimeRange(Date startDate, Date endDate) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加创建时间大于等于开始日期的查询条件 + wrapper.ge("create_time", startDate); + // 添加创建时间小于等于结束日期的查询条件 + wrapper.le("create_time", endDate); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据问题类型和难度级别查询考试问题视图列表 + public List selectListViewByTypeAndDifficulty(String questionType, int difficultyLevel) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加问题类型等于指定类型的查询条件 + wrapper.eq("question_type", questionType); + // 添加问题难度等于指定难度的查询条件 + wrapper.eq("difficulty_level", difficultyLevel); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据问题类型统计考试问题数量 + public int countQuestionsByType(String questionType) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加问题类型等于指定类型的查询条件 + wrapper.eq("question_type", questionType); + // 调用基础映射器的 selectCount 方法统计数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据问题难度统计考试问题数量 + public int countQuestionsByDifficulty(int difficultyLevel) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加问题难度等于指定难度的查询条件 + wrapper.eq("difficulty_level", difficultyLevel); + // 调用基础映射器的 selectCount 方法统计数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据创建时间范围统计考试问题数量 + public int countQuestionsByCreateTimeRange(Date startDate, Date endDate) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加创建时间大于等于开始日期的查询条件 + wrapper.ge("create_time", startDate); + // 添加创建时间小于等于结束日期的查询条件 + wrapper.le("create_time", endDate); + // 调用基础映射器的 selectCount 方法统计数量 + return this.selectCount(wrapper); + } + + // 新增方法:根据问题类型和难度级别统计考试问题数量 + public int countQuestionsByTypeAndDifficulty(String questionType, int difficultyLevel) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加问题类型等于指定类型的查询条件 + wrapper.eq("question_type", questionType); + // 添加问题难度等于指定难度的查询条件 + wrapper.eq("difficulty_level", difficultyLevel); + // 调用基础映射器的 selectCount 方法统计数量 + return this.selectCount(wrapper); + } + + // 新增方法:更新考试问题的难度级别 + public boolean updateQuestionDifficulty(int questionId, int newDifficultyLevel) { + // 创建一个考试问题实体对象 + ExamquestionEntity entity = new ExamquestionEntity(); + // 设置问题 ID + entity.setId(questionId); + // 设置新的难度级别 + entity.setDifficultyLevel(newDifficultyLevel); + // 调用基础映射器的 updateById 方法更新问题 + return this.updateById(entity); + } + + // 新增方法:更新考试问题的类型 + public boolean updateQuestionType(int questionId, String newQuestionType) { + // 创建一个考试问题实体对象 + ExamquestionEntity entity = new ExamquestionEntity(); + // 设置问题 ID + entity.setId(questionId); + // 设置新的问题类型 + entity.setQuestionType(newQuestionType); + // 调用基础映射器的 updateById 方法更新问题 + return this.updateById(entity); + } + + // 新增方法:根据问题 ID 删除考试问题 + public boolean deleteQuestionById(int questionId) { + // 调用基础映射器的 deleteById 方法删除问题 + return this.deleteById(questionId); + } + + // 新增方法:批量删除考试问题 + public boolean deleteQuestionsByIds(List questionIds) { + // 遍历问题 ID 列表 + for (Integer id : questionIds) { + // 调用基础映射器的 deleteById 方法删除问题 + if (!this.deleteById(id)) { + // 如果删除失败,返回 false + return false; + } + } + // 所有删除操作都成功,返回 true + return true; + } + + // 新增方法:根据问题类型对考试问题视图列表进行排序 + public List sortQuestionsByType(List questions) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(questions, Comparator.comparing(ExamquestionView::getQuestionType)); + return questions; + } + + // 新增方法:根据问题难度对考试问题视图列表进行排序 + public List sortQuestionsByDifficulty(List questions) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(questions, Comparator.comparingInt(ExamquestionView::getDifficultyLevel)); + return questions; + } + + // 新增方法:根据创建时间对考试问题视图列表进行排序 + public List sortQuestionsByCreateTime(List questions) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(questions, Comparator.comparing(ExamquestionView::getCreateTime)); + return questions; + } + + // 新增方法:获取指定问题类型中难度最高的问题 + public Optional getHighestDifficultyQuestionByType(String questionType) { + // 根据问题类型查询考试问题视图列表 + List questions = selectListViewByQuestionType(questionType); + if (questions.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.max 方法找出难度最高的问题 + ExamquestionView highestDifficultyQuestion = Collections.max(questions, Comparator.comparingInt(ExamquestionView::getDifficultyLevel)); + // 返回包含难度最高问题的 Optional 对象 + return Optional.of(highestDifficultyQuestion); + } + + // 新增方法:获取指定问题类型中难度最低的问题 + public Optional getLowestDifficultyQuestionByType(String questionType) { + // 根据问题类型查询考试问题视图列表 + List questions = selectListViewByQuestionType(questionType); + if (questions.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.min 方法找出难度最低的问题 + ExamquestionView lowestDifficultyQuestion = Collections.min(questions, Comparator.comparingInt(ExamquestionView::getDifficultyLevel)); + // 返回包含难度最低问题的 Optional 对象 + return Optional.of(lowestDifficultyQuestion); + } + + // 新增方法:获取指定难度级别下最早创建的问题 + public Optional getEarliestQuestionByDifficulty(int difficultyLevel) { + // 根据问题难度查询考试问题视图列表 + List questions = selectListViewByDifficultyLevel(difficultyLevel); + if (questions.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.min 方法找出最早创建的问题 + ExamquestionView earliestQuestion = Collections.min(questions, Comparator.comparing(ExamquestionView::getCreateTime)); + // 返回包含最早创建问题的 Optional 对象 + return Optional.of(earliestQuestion); + } + + // 新增方法:获取指定难度级别下最晚创建的问题 + public Optional getLatestQuestionByDifficulty(int difficultyLevel) { + // 根据问题难度查询考试问题视图列表 + List questions = selectListViewByDifficultyLevel(difficultyLevel); + if (questions.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 使用 Collections.max 方法找出最晚创建的问题 + ExamquestionView latestQuestion = Collections.max(questions, Comparator.comparing(ExamquestionView::getCreateTime)); + // 返回包含最晚创建问题的 Optional 对象 + return Optional.of(latestQuestion); + } + + // 新增方法:根据问题类型分组统计考试问题数量 + public Map countQuestionsByType() { + // 创建一个 HashMap 用于存储统计结果 + Map typeCountMap = new HashMap<>(); + // 查询所有考试问题视图列表 + List questions = selectListView(null); + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + String questionType = question.getQuestionType(); + // 如果该问题类型已经在 Map 中,增加其计数 + typeCountMap.put(questionType, typeCountMap.getOrDefault(questionType, 0) + 1); + } + return typeCountMap; + } + + // 新增方法:根据问题难度分组统计考试问题数量 + public Map countQuestionsByDifficulty() { + // 创建一个 HashMap 用于存储统计结果 + Map difficultyCountMap = new HashMap<>(); + // 查询所有考试问题视图列表 + List questions = selectListView(null); + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + int difficultyLevel = question.getDifficultyLevel(); + // 如果该难度级别已经在 Map 中,增加其计数 + difficultyCountMap.put(difficultyLevel, difficultyCountMap.getOrDefault(difficultyLevel, 0) + 1); + } + return difficultyCountMap; + } + + // 新增方法:根据创建时间的月份分组统计考试问题数量 + public Map countQuestionsByCreateMonth() { + // 创建一个 HashMap 用于存储统计结果 + Map monthCountMap = new HashMap<>(); + // 查询所有考试问题视图列表 + List questions = selectListView(null); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + calendar.setTime(question.getCreateTime()); + int month = calendar.get(Calendar.MONTH) + 1; + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return monthCountMap; + } + + // 新增方法:根据问题类型和难度级别分组统计考试问题数量 + public Map> countQuestionsByTypeAndDifficulty() { + // 创建一个 HashMap 用于存储统计结果 + Map> typeDifficultyCountMap = new HashMap<>(); + // 查询所有考试问题视图列表 + List questions = selectListView(null); + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + String questionType = question.getQuestionType(); + int difficultyLevel = question.getDifficultyLevel(); + // 获取该问题类型对应的难度级别计数 Map + Map difficultyCountMap = typeDifficultyCountMap.computeIfAbsent(questionType, k -> new HashMap<>()); + // 如果该难度级别已经在 Map 中,增加其计数 + difficultyCountMap.put(difficultyLevel, difficultyCountMap.getOrDefault(difficultyLevel, 0) + 1); + } + return typeDifficultyCountMap; + } + + // 新增方法:根据问题类型和创建时间的月份分组统计考试问题数量 + public Map> countQuestionsByTypeAndCreateMonth() { + // 创建一个 HashMap 用于存储统计结果 + Map> typeMonthCountMap = new HashMap<>(); + // 查询所有考试问题视图列表 + List questions = selectListView(null); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + String questionType = question.getQuestionType(); + calendar.setTime(question.getCreateTime()); + int month = calendar.get(Calendar.MONTH) + 1; + // 获取该问题类型对应的月份计数 Map + Map monthCountMap = typeMonthCountMap.computeIfAbsent(questionType, k -> new HashMap<>()); + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return typeMonthCountMap; + } + + // 新增方法:根据问题难度和创建时间的月份分组统计考试问题数量 + public Map> countQuestionsByDifficultyAndCreateMonth() { + // 创建一个 HashMap 用于存储统计结果 + Map> difficultyMonthCountMap = new HashMap<>(); + // 查询所有考试问题视图列表 + List questions = selectListView(null); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + int difficultyLevel = question.getDifficultyLevel(); + calendar.setTime(question.getCreateTime()); + int month = calendar.get(Calendar.MONTH) + 1; + // 获取该难度级别对应的月份计数 Map + Map monthCountMap = difficultyMonthCountMap.computeIfAbsent(difficultyLevel, k -> new HashMap<>()); + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return difficultyMonthCountMap; + } + + // 新增方法:获取指定问题类型下的平均难度级别 + public Optional getAverageDifficultyByType(String questionType) { + // 根据问题类型查询考试问题视图列表 + List questions = selectListViewByQuestionType(questionType); + if (questions.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int totalDifficulty = 0; + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + totalDifficulty += question.getDifficultyLevel(); + } + // 计算平均难度级别 + double averageDifficulty = (double) totalDifficulty / questions.size(); + // 返回包含平均难度级别的 Optional 对象 + return Optional.of(averageDifficulty); + } + + // 新增方法:获取指定难度级别下的平均创建时间 + public Optional getAverageCreateTimeByDifficulty(int difficultyLevel) { + // 根据问题难度查询考试问题视图列表 + List questions = selectListViewByDifficultyLevel(difficultyLevel); + if (questions.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + long totalTime = 0; + // 遍历考试问题视图列表 + for (ExamquestionView question : questions) { + totalTime += question.getCreateTime().getTime(); + } + // 计算平均创建时间 + long averageTime = totalTime / questions.size(); + // 创建包含平均创建时间的 Date 对象 + Date averageCreateTime = new Date(averageTime); + // 返回包含平均创建时间的 Optional 对象 + return Optional.of(averageCreateTime); + } + + // 新增方法:获取考试问题数量最多的问题类型 + public Optional getMostFrequentQuestionType() { + // 根据问题类型分组统计考试问题数量 + Map typeCountMap = countQuestionsByType(); + if (typeCountMap.isEmpty()) { + // 如果 Map 为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 找出数量最多的问题类型 + String mostFrequentType = Collections.max(typeCountMap.entrySet(), Map.Entry.comparingByValue()).getKey(); + // 返回包含数量最多问题类型的 Optional 对象 + return Optional.of(mostFrequentType); + } + + // 新增方法:获取考试问题数量最多的难度级别 + public Optional getMostFrequentDifficultyLevel() { + // 根据问题难度分组统计考试问题数量 + Map difficultyCountMap = countQuestionsByDifficulty(); + if (difficultyCountMap.isEmpty()) { + // 如果 Map 为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 找出数量最多的难度级别 + Integer mostFrequentDifficulty = Collections.max(difficultyCountMap.entrySet(), Map.Entry.comparingByValue()).getKey(); + // 返回包含数量最多难度级别的 Optional 对象 + return Optional.of(mostFrequentDifficulty); + } + + // 新增方法:获取考试问题数量最多的创建月份 + public Optional getMostFrequentCreateMonth() { + // 根据创建时间的月份分组统计考试问题数量 + Map monthCountMap = countQuestionsByCreateMonth(); + if (monthCountMap.isEmpty()) { + // 如果 Map 为空,返回空的 Optional 对象 + return Optional.empty(); + } + // 找出数量最多的创建月份 + Integer mostFrequentMonth = Collections.max(monthCountMap.entrySet(), Map.Entry.comparingByValue()).getKey(); + // 返回包含数量最多创建月份的 Optional 对象 + return Optional.of(mostFrequentMonth); + } +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ExamrecordServiceImpl.java b/src/main/java/com/service/impl/ExamrecordServiceImpl.java index 4b6eb4a..debafce 100644 --- a/src/main/java/com/service/impl/ExamrecordServiceImpl.java +++ b/src/main/java/com/service/impl/ExamrecordServiceImpl.java @@ -1,69 +1,558 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 Java 的 ArrayList 类,用于实现动态数组 +import java.util.ArrayList; +// 导入 Java 的 HashMap 类,用于实现哈希表 +import java.util.HashMap; +// 导入 Java 的 Date 类,用于处理日期和时间 +import java.util.Date; +// 导入 Java 的 Calendar 类,用于进行日期和时间的计算 +import java.util.Calendar; +// 导入 Java 的 Collections 类,用于对集合进行操作 +import java.util.Collections; +// 导入 Java 的 Comparator 接口,用于自定义排序规则 +import java.util.Comparator; +// 导入 Java 的 Optional 类,用于处理可能为空的值 +import java.util.Optional; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入考试记录数据访问对象 import com.dao.ExamrecordDao; +// 导入考试记录实体类 import com.entity.ExamrecordEntity; +// 导入考试记录服务接口 import com.service.ExamrecordService; +// 导入考试记录值对象类 import com.entity.vo.ExamrecordVO; +// 导入考试记录视图类 import com.entity.view.ExamrecordView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 examrecordService @Service("examrecordService") +// 定义考试记录服务实现类,继承自 ServiceImpl 并实现 ExamrecordService 接口 public class ExamrecordServiceImpl extends ServiceImpl implements ExamrecordService { - + + // 重写 queryPageGroupBy 方法,根据传入的参数和查询条件按组查询考试记录视图的分页数据 @Override public PageUtils queryPageGroupBy(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectGroupBy(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储考试记录视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectGroupBy 方法,根据分页和查询条件获取按组查询的考试记录视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectGroupBy(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 queryPage 方法,根据传入的参数查询考试记录实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询考试记录视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储考试记录视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取考试记录视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询考试记录值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个考试记录值对象 @Override public ExamrecordVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询考试记录视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个考试记录视图 @Override public ExamrecordView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } -} + // 新增方法:根据考试日期范围查询考试记录视图列表 + public List selectListViewByDateRange(Date startDate, Date endDate) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试日期大于等于开始日期的查询条件 + wrapper.ge("exam_date", startDate); + // 添加考试日期小于等于结束日期的查询条件 + wrapper.le("exam_date", endDate); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据考试成绩范围查询考试记录视图列表 + public List selectListViewByScoreRange(int minScore, int maxScore) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试成绩大于等于最低成绩的查询条件 + wrapper.ge("score", minScore); + // 添加考试成绩小于等于最高成绩的查询条件 + wrapper.le("score", maxScore); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据考试科目查询考试记录视图列表 + public List selectListViewBySubject(String subject) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试科目等于指定科目的查询条件 + wrapper.eq("subject", subject); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据学生 ID 查询考试记录视图列表 + public List selectListViewByStudentId(int studentId) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加学生 ID 等于指定 ID 的查询条件 + wrapper.eq("student_id", studentId); + // 调用基础映射器的 selectListView 方法进行查询 + return baseMapper.selectListView(new Page<>(1, Integer.MAX_VALUE), wrapper); + } + + // 新增方法:根据考试记录 ID 批量删除考试记录 + public boolean deleteExamRecordsByIds(List ids) { + // 遍历 ID 列表 + for (Integer id : ids) { + // 调用基础映射器的 deleteById 方法删除考试记录 + if (!this.deleteById(id)) { + // 如果删除失败,返回 false + return false; + } + } + // 所有删除操作都成功,返回 true + return true; + } + + // 新增方法:根据考试记录 ID 更新考试成绩 + public boolean updateScoreById(int id, int newScore) { + // 创建一个考试记录实体对象 + ExamrecordEntity entity = new ExamrecordEntity(); + // 设置考试记录 ID + entity.setId(id); + // 设置新的考试成绩 + entity.setScore(newScore); + // 调用基础映射器的 updateById 方法更新考试记录 + return this.updateById(entity); + } + + // 新增方法:根据考试记录 ID 更新考试日期 + public boolean updateExamDateById(int id, Date newExamDate) { + // 创建一个考试记录实体对象 + ExamrecordEntity entity = new ExamrecordEntity(); + // 设置考试记录 ID + entity.setId(id); + // 设置新的考试日期 + entity.setExamDate(newExamDate); + // 调用基础映射器的 updateById 方法更新考试记录 + return this.updateById(entity); + } + + // 新增方法:根据考试记录 ID 更新考试科目 + public boolean updateSubjectById(int id, String newSubject) { + // 创建一个考试记录实体对象 + ExamrecordEntity entity = new ExamrecordEntity(); + // 设置考试记录 ID + entity.setId(id); + // 设置新的考试科目 + entity.setSubject(newSubject); + // 调用基础映射器的 updateById 方法更新考试记录 + return this.updateById(entity); + } + + // 新增方法:统计指定日期范围内的考试记录数量 + public int countExamRecordsByDateRange(Date startDate, Date endDate) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试日期大于等于开始日期的查询条件 + wrapper.ge("exam_date", startDate); + // 添加考试日期小于等于结束日期的查询条件 + wrapper.le("exam_date", endDate); + // 调用基础映射器的 selectCount 方法统计考试记录数量 + return this.selectCount(wrapper); + } + + // 新增方法:统计指定成绩范围内的考试记录数量 + public int countExamRecordsByScoreRange(int minScore, int maxScore) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试成绩大于等于最低成绩的查询条件 + wrapper.ge("score", minScore); + // 添加考试成绩小于等于最高成绩的查询条件 + wrapper.le("score", maxScore); + // 调用基础映射器的 selectCount 方法统计考试记录数量 + return this.selectCount(wrapper); + } + + // 新增方法:统计指定考试科目的考试记录数量 + public int countExamRecordsBySubject(String subject) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加考试科目等于指定科目的查询条件 + wrapper.eq("subject", subject); + // 调用基础映射器的 selectCount 方法统计考试记录数量 + return this.selectCount(wrapper); + } + + // 新增方法:统计指定学生 ID 的考试记录数量 + public int countExamRecordsByStudentId(int studentId) { + // 创建一个查询条件包装器 + Wrapper wrapper = new EntityWrapper<>(); + // 添加学生 ID 等于指定 ID 的查询条件 + wrapper.eq("student_id", studentId); + // 调用基础映射器的 selectCount 方法统计考试记录数量 + return this.selectCount(wrapper); + } + + // 新增方法:获取指定日期范围内的最高考试成绩 + public Optional getMaxScoreByDateRange(Date startDate, Date endDate) { + // 根据日期范围查询考试记录视图列表 + List records = selectListViewByDateRange(startDate, endDate); + if (records.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int maxScore = Integer.MIN_VALUE; + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + if (record.getScore() > maxScore) { + // 更新最高成绩 + maxScore = record.getScore(); + } + } + // 返回包含最高成绩的 Optional 对象 + return Optional.of(maxScore); + } + + // 新增方法:获取指定日期范围内的最低考试成绩 + public Optional getMinScoreByDateRange(Date startDate, Date endDate) { + // 根据日期范围查询考试记录视图列表 + List records = selectListViewByDateRange(startDate, endDate); + if (records.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int minScore = Integer.MAX_VALUE; + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + if (record.getScore() < minScore) { + // 更新最低成绩 + minScore = record.getScore(); + } + } + // 返回包含最低成绩的 Optional 对象 + return Optional.of(minScore); + } + + // 新增方法:获取指定考试科目的最高考试成绩 + public Optional getMaxScoreBySubject(String subject) { + // 根据考试科目查询考试记录视图列表 + List records = selectListViewBySubject(subject); + if (records.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int maxScore = Integer.MIN_VALUE; + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + if (record.getScore() > maxScore) { + // 更新最高成绩 + maxScore = record.getScore(); + } + } + // 返回包含最高成绩的 Optional 对象 + return Optional.of(maxScore); + } + + // 新增方法:获取指定考试科目的最低考试成绩 + public Optional getMinScoreBySubject(String subject) { + // 根据考试科目查询考试记录视图列表 + List records = selectListViewBySubject(subject); + if (records.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int minScore = Integer.MAX_VALUE; + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + if (record.getScore() < minScore) { + // 更新最低成绩 + minScore = record.getScore(); + } + } + // 返回包含最低成绩的 Optional 对象 + return Optional.of(minScore); + } + + // 新增方法:获取指定学生 ID 的最高考试成绩 + public Optional getMaxScoreByStudentId(int studentId) { + // 根据学生 ID 查询考试记录视图列表 + List records = selectListViewByStudentId(studentId); + if (records.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int maxScore = Integer.MIN_VALUE; + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + if (record.getScore() > maxScore) { + // 更新最高成绩 + maxScore = record.getScore(); + } + } + // 返回包含最高成绩的 Optional 对象 + return Optional.of(maxScore); + } + + // 新增方法:获取指定学生 ID 的最低考试成绩 + public Optional getMinScoreByStudentId(int studentId) { + // 根据学生 ID 查询考试记录视图列表 + List records = selectListViewByStudentId(studentId); + if (records.isEmpty()) { + // 如果列表为空,返回空的 Optional 对象 + return Optional.empty(); + } + int minScore = Integer.MAX_VALUE; + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + if (record.getScore() < minScore) { + // 更新最低成绩 + minScore = record.getScore(); + } + } + // 返回包含最低成绩的 Optional 对象 + return Optional.of(minScore); + } + + // 新增方法:根据考试日期对考试记录视图列表进行排序 + public List sortExamRecordsByExamDate(List records) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(records, Comparator.comparing(ExamrecordView::getExamDate)); + return records; + } + + // 新增方法:根据考试成绩对考试记录视图列表进行排序 + public List sortExamRecordsByScore(List records) { + // 使用 Collections.sort 方法对列表进行排序 + Collections.sort(records, Comparator.comparing(ExamrecordView::getScore)); + return records; + } + + // 新增方法:获取指定日期范围内的考试记录按考试科目分组统计数量 + public Map countExamRecordsBySubjectInDateRange(Date startDate, Date endDate) { + // 根据日期范围查询考试记录视图列表 + List records = selectListViewByDateRange(startDate, endDate); + // 创建一个 HashMap 用于存储统计结果 + Map subjectCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + String subject = record.getSubject(); + // 如果该科目已经在 Map 中,增加其计数 + subjectCountMap.put(subject, subjectCountMap.getOrDefault(subject, 0) + 1); + } + return subjectCountMap; + } + + // 新增方法:获取指定学生 ID 的考试记录按考试科目分组统计数量 + public Map countExamRecordsBySubjectForStudent(int studentId) { + // 根据学生 ID 查询考试记录视图列表 + List records = selectListViewByStudentId(studentId); + // 创建一个 HashMap 用于存储统计结果 + Map subjectCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + String subject = record.getSubject(); + // 如果该科目已经在 Map 中,增加其计数 + subjectCountMap.put(subject, subjectCountMap.getOrDefault(subject, 0) + 1); + } + return subjectCountMap; + } + + // 新增方法:获取指定日期范围内的考试记录按学生 ID 分组统计数量 + public Map countExamRecordsByStudentIdInDateRange(Date startDate, Date endDate) { + // 根据日期范围查询考试记录视图列表 + List records = selectListViewByDateRange(startDate, endDate); + // 创建一个 HashMap 用于存储统计结果 + Map studentCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + int studentId = record.getStudentId(); + // 如果该学生 ID 已经在 Map 中,增加其计数 + studentCountMap.put(studentId, studentCountMap.getOrDefault(studentId, 0) + 1); + } + return studentCountMap; + } + + // 新增方法:获取指定考试科目的考试记录按学生 ID 分组统计数量 + public Map countExamRecordsByStudentIdForSubject(String subject) { + // 根据考试科目查询考试记录视图列表 + List records = selectListViewBySubject(subject); + // 创建一个 HashMap 用于存储统计结果 + Map studentCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + int studentId = record.getStudentId(); + // 如果该学生 ID 已经在 Map 中,增加其计数 + studentCountMap.put(studentId, studentCountMap.getOrDefault(studentId, 0) + 1); + } + return studentCountMap; + } + + // 新增方法:获取指定日期范围内的考试记录按考试成绩区间分组统计数量 + public Map countExamRecordsByScoreRangeInDateRange(Date startDate, Date endDate, int interval) { + // 根据日期范围查询考试记录视图列表 + List records = selectListViewByDateRange(startDate, endDate); + // 创建一个 HashMap 用于存储统计结果 + Map scoreRangeCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + int score = record.getScore(); + int lowerBound = (score / interval) * interval; + int upperBound = lowerBound + interval; + String range = lowerBound + "-" + upperBound; + // 如果该成绩区间已经在 Map 中,增加其计数 + scoreRangeCountMap.put(range, scoreRangeCountMap.getOrDefault(range, 0) + 1); + } + return scoreRangeCountMap; + } + + // 新增方法:获取指定学生 ID 的考试记录按考试成绩区间分组统计数量 + public Map countExamRecordsByScoreRangeForStudent(int studentId, int interval) { + // 根据学生 ID 查询考试记录视图列表 + List records = selectListViewByStudentId(studentId); + // 创建一个 HashMap 用于存储统计结果 + Map scoreRangeCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + int score = record.getScore(); + int lowerBound = (score / interval) * interval; + int upperBound = lowerBound + interval; + String range = lowerBound + "-" + upperBound; + // 如果该成绩区间已经在 Map 中,增加其计数 + scoreRangeCountMap.put(range, scoreRangeCountMap.getOrDefault(range, 0) + 1); + } + return scoreRangeCountMap; + } + + // 新增方法:获取指定考试科目的考试记录按考试成绩区间分组统计数量 + public Map countExamRecordsByScoreRangeForSubject(String subject, int interval) { + // 根据考试科目查询考试记录视图列表 + List records = selectListViewBySubject(subject); + // 创建一个 HashMap 用于存储统计结果 + Map scoreRangeCountMap = new HashMap<>(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + int score = record.getScore(); + int lowerBound = (score / interval) * interval; + int upperBound = lowerBound + interval; + String range = lowerBound + "-" + upperBound; + // 如果该成绩区间已经在 Map 中,增加其计数 + scoreRangeCountMap.put(range, scoreRangeCountMap.getOrDefault(range, 0) + 1); + } + return scoreRangeCountMap; + } + + // 新增方法:获取指定日期范围内的考试记录按月份分组统计数量 + public Map countExamRecordsByMonthInDateRange(Date startDate, Date endDate) { + // 根据日期范围查询考试记录视图列表 + List records = selectListViewByDateRange(startDate, endDate); + // 创建一个 HashMap 用于存储统计结果 + Map monthCountMap = new HashMap<>(); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + calendar.setTime(record.getExamDate()); + int month = calendar.get(Calendar.MONTH) + 1; + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return monthCountMap; + } + + // 新增方法:获取指定学生 ID 的考试记录按月份分组统计数量 + public Map countExamRecordsByMonthForStudent(int studentId) { + // 根据学生 ID 查询考试记录视图列表 + List records = selectListViewByStudentId(studentId); + // 创建一个 HashMap 用于存储统计结果 + Map monthCountMap = new HashMap<>(); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + calendar.setTime(record.getExamDate()); + int month = calendar.get(Calendar.MONTH) + 1; + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return monthCountMap; + } + + // 新增方法:获取指定考试科目的考试记录按月份分组统计数量 + public Map countExamRecordsByMonthForSubject(String subject) { + // 根据考试科目查询考试记录视图列表 + List records = selectListViewBySubject(subject); + // 创建一个 HashMap 用于存储统计结果 + Map monthCountMap = new HashMap<>(); + // 创建一个 Calendar 实例 + Calendar calendar = Calendar.getInstance(); + // 遍历考试记录视图列表 + for (ExamrecordView record : records) { + calendar.setTime(record.getExamDate()); + int month = calendar.get(Calendar.MONTH) + 1; + // 如果该月份已经在 Map 中,增加其计数 + monthCountMap.put(month, monthCountMap.getOrDefault(month, 0) + 1); + } + return monthCountMap; + } +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ForumServiceImpl.java b/src/main/java/com/service/impl/ForumServiceImpl.java index b188139..f0c4692 100644 --- a/src/main/java/com/service/impl/ForumServiceImpl.java +++ b/src/main/java/com/service/impl/ForumServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入论坛数据访问对象 import com.dao.ForumDao; +// 导入论坛实体类 import com.entity.ForumEntity; +// 导入论坛服务接口 import com.service.ForumService; +// 导入论坛值对象类 import com.entity.vo.ForumVO; +// 导入论坛视图类 import com.entity.view.ForumView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 forumService @Service("forumService") +// 定义论坛服务实现类,继承自 ServiceImpl 并实现 ForumService 接口 public class ForumServiceImpl extends ServiceImpl implements ForumService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询论坛实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询论坛视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储论坛视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取论坛视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询论坛值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个论坛值对象 @Override public ForumVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询论坛视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个论坛视图 @Override public ForumView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/GoumaidekechengServiceImpl.java b/src/main/java/com/service/impl/GoumaidekechengServiceImpl.java index 0f0b6f6..36e9c6b 100644 --- a/src/main/java/com/service/impl/GoumaidekechengServiceImpl.java +++ b/src/main/java/com/service/impl/GoumaidekechengServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入购买的课程数据访问对象 import com.dao.GoumaidekechengDao; +// 导入购买的课程实体类 import com.entity.GoumaidekechengEntity; +// 导入购买的课程服务接口 import com.service.GoumaidekechengService; +// 导入购买的课程值对象类 import com.entity.vo.GoumaidekechengVO; +// 导入购买的课程视图类 import com.entity.view.GoumaidekechengView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 goumaidekechengService @Service("goumaidekechengService") +// 定义购买的课程服务实现类,继承自 ServiceImpl 并实现 GoumaidekechengService 接口 public class GoumaidekechengServiceImpl extends ServiceImpl implements GoumaidekechengService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询购买的课程实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询购买的课程视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储购买的课程视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取购买的课程视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询购买的课程值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个购买的课程值对象 @Override public GoumaidekechengVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询购买的课程视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个购买的课程视图 @Override public GoumaidekechengView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/KechengleixingServiceImpl.java b/src/main/java/com/service/impl/KechengleixingServiceImpl.java index 03cb203..83acb95 100644 --- a/src/main/java/com/service/impl/KechengleixingServiceImpl.java +++ b/src/main/java/com/service/impl/KechengleixingServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所属的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入课程类型数据访问对象 import com.dao.KechengleixingDao; +// 导入课程类型实体类 import com.entity.KechengleixingEntity; +// 导入课程类型服务接口 import com.service.KechengleixingService; +// 导入课程类型值对象类 import com.entity.vo.KechengleixingVO; +// 导入课程类型视图类 import com.entity.view.KechengleixingView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 kechengleixingService @Service("kechengleixingService") +// 定义课程类型服务实现类,继承自 ServiceImpl 并实现 KechengleixingService 接口 public class KechengleixingServiceImpl extends ServiceImpl implements KechengleixingService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询课程类型实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询课程类型视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储课程类型视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取课程类型视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询课程类型值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个课程类型值对象 @Override public KechengleixingVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询课程类型视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个课程类型视图 @Override public KechengleixingView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/KechengxinxiServiceImpl.java b/src/main/java/com/service/impl/KechengxinxiServiceImpl.java index 3c1a0a6..bfc2c6a 100644 --- a/src/main/java/com/service/impl/KechengxinxiServiceImpl.java +++ b/src/main/java/com/service/impl/KechengxinxiServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入课程信息数据访问对象 import com.dao.KechengxinxiDao; +// 导入课程信息实体类 import com.entity.KechengxinxiEntity; +// 导入课程信息服务接口 import com.service.KechengxinxiService; +// 导入课程信息值对象类 import com.entity.vo.KechengxinxiVO; +// 导入课程信息视图类 import com.entity.view.KechengxinxiView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 kechengxinxiService @Service("kechengxinxiService") +// 定义课程信息服务实现类,继承自 ServiceImpl 并实现 KechengxinxiService 接口 public class KechengxinxiServiceImpl extends ServiceImpl implements KechengxinxiService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询课程信息实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询课程信息视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储课程信息视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取课程信息视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询课程信息值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个课程信息值对象 @Override public KechengxinxiVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询课程信息视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个课程信息视图 @Override public KechengxinxiView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/MessagesServiceImpl.java b/src/main/java/com/service/impl/MessagesServiceImpl.java index 316d524..961e35a 100644 --- a/src/main/java/com/service/impl/MessagesServiceImpl.java +++ b/src/main/java/com/service/impl/MessagesServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所属的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于标记该类为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入消息数据访问对象 import com.dao.MessagesDao; +// 导入消息实体类 import com.entity.MessagesEntity; +// 导入消息服务接口 import com.service.MessagesService; +// 导入消息值对象类 import com.entity.vo.MessagesVO; +// 导入消息视图类 import com.entity.view.MessagesView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 messagesService @Service("messagesService") +// 定义消息服务实现类,继承自 ServiceImpl 并实现 MessagesService 接口 public class MessagesServiceImpl extends ServiceImpl implements MessagesService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询消息实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询消息视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储消息视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取消息视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询消息值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个消息值对象 @Override public MessagesVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询消息视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个消息视图 @Override public MessagesView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/NewsServiceImpl.java b/src/main/java/com/service/impl/NewsServiceImpl.java index 328bdb4..22a8b4d 100644 --- a/src/main/java/com/service/impl/NewsServiceImpl.java +++ b/src/main/java/com/service/impl/NewsServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入新闻数据访问对象 import com.dao.NewsDao; +// 导入新闻实体类 import com.entity.NewsEntity; +// 导入新闻服务接口 import com.service.NewsService; +// 导入新闻值对象类 import com.entity.vo.NewsVO; +// 导入新闻视图类 import com.entity.view.NewsView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 newsService @Service("newsService") +// 定义新闻服务实现类,继承自 ServiceImpl 并实现 NewsService 接口 public class NewsServiceImpl extends ServiceImpl implements NewsService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询新闻实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询新闻视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储新闻视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取新闻视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询新闻值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个新闻值对象 @Override public NewsVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询新闻视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个新闻视图 @Override public NewsView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ShipindianboServiceImpl.java b/src/main/java/com/service/impl/ShipindianboServiceImpl.java index cf25b26..4f2beb4 100644 --- a/src/main/java/com/service/impl/ShipindianboServiceImpl.java +++ b/src/main/java/com/service/impl/ShipindianboServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入视频点播数据访问对象 import com.dao.ShipindianboDao; +// 导入视频点播实体类 import com.entity.ShipindianboEntity; +// 导入视频点播服务接口 import com.service.ShipindianboService; +// 导入视频点播值对象类 import com.entity.vo.ShipindianboVO; +// 导入视频点播视图类 import com.entity.view.ShipindianboView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 shipindianboService @Service("shipindianboService") +// 定义视频点播服务实现类,继承自 ServiceImpl 并实现 ShipindianboService 接口 public class ShipindianboServiceImpl extends ServiceImpl implements ShipindianboService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询视频点播实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询视频点播视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储视频点播视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取视频点播视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询视频点播值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个视频点播值对象 @Override public ShipindianboVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询视频点播视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个视频点播视图 @Override public ShipindianboView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/StoreupServiceImpl.java b/src/main/java/com/service/impl/StoreupServiceImpl.java index d1e50e6..c9f0ae2 100644 --- a/src/main/java/com/service/impl/StoreupServiceImpl.java +++ b/src/main/java/com/service/impl/StoreupServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入收藏数据访问对象 import com.dao.StoreupDao; +// 导入收藏实体类 import com.entity.StoreupEntity; +// 导入收藏服务接口 import com.service.StoreupService; +// 导入收藏值对象类 import com.entity.vo.StoreupVO; +// 导入收藏视图类 import com.entity.view.StoreupView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 storeupService @Service("storeupService") +// 定义收藏服务实现类,继承自 ServiceImpl 并实现 StoreupService 接口 public class StoreupServiceImpl extends ServiceImpl implements StoreupService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询收藏实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询收藏视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储收藏视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取收藏视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询收藏值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个收藏值对象 @Override public StoreupVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询收藏视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个收藏视图 @Override public StoreupView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/TokenServiceImpl.java b/src/main/java/com/service/impl/TokenServiceImpl.java index de6c052..5956b3e 100644 --- a/src/main/java/com/service/impl/TokenServiceImpl.java +++ b/src/main/java/com/service/impl/TokenServiceImpl.java @@ -1,79 +1,121 @@ - +// 声明该类所在的包为com.service.impl package com.service.impl; - +// 导入Java的Calendar类,用于处理日期和时间 import java.util.Calendar; +// 导入Java的Date类,用于表示日期和时间 import java.util.Date; +// 导入Java的List接口,用于处理列表数据 import java.util.List; +// 导入Java的Map接口,用于处理键值对数据 import java.util.Map; +// 导入Spring框架的Service注解,用于标记该类为服务层组件 import org.springframework.stereotype.Service; +// 导入MyBatis-Plus的EntityWrapper类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入MyBatis-Plus的Wrapper接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入MyBatis-Plus的Page类,用于分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入MyBatis-Plus的ServiceImpl类,提供通用的服务层实现 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入数据访问对象TokenDao import com.dao.TokenDao; +// 导入Token实体类 import com.entity.TokenEntity; +// 重复导入Token实体类,可考虑移除一个 import com.entity.TokenEntity; +// 导入Token服务接口 import com.service.TokenService; +// 导入自定义的通用工具类 import com.utils.CommonUtil; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - -/** - * token - */ +// token服务实现类 +// 标记该类为Spring的服务组件,名称为tokenService @Service("tokenService") +// 定义TokenServiceImpl类,继承ServiceImpl类并实现TokenService接口 public class TokenServiceImpl extends ServiceImpl implements TokenService { + // 重写queryPage方法,用于根据参数查询Token实体的分页数据 @Override public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数进行初始化 Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); + new Query(params).getPage(), + // 创建一个查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,包含分页信息 + return new PageUtils(page); } + // 重写selectListView方法,用于根据查询条件查询Token实体的列表数据 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的selectListView方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写queryPage方法,用于根据参数和查询条件查询Token实体的分页数据 @Override public PageUtils queryPage(Map params, - Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; + Wrapper wrapper) { + // 创建一个分页对象,根据传入的参数进行初始化 + Page page = new Query(params).getPage(); + // 设置分页对象的记录列表,通过基础映射器的selectListView方法查询 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 创建分页工具类对象,包含分页信息 + PageUtils pageUtil = new PageUtils(page); + // 返回分页工具类对象 + return pageUtil; } + // 重写generateToken方法,用于生成Token @Override - public String generateToken(Long userid,String username, String tableName, String role) { + public String generateToken(Long userid, String username, String tableName, String role) { + // 根据用户ID和角色查询Token实体 TokenEntity tokenEntity = this.selectOne(new EntityWrapper().eq("userid", userid).eq("role", role)); + // 生成一个32位的随机字符串作为Token String token = CommonUtil.getRandomString(32); - Calendar cal = Calendar.getInstance(); - cal.setTime(new Date()); - cal.add(Calendar.HOUR_OF_DAY, 1); - if(tokenEntity!=null) { + // 获取当前的Calendar实例 + Calendar cal = Calendar.getInstance(); + // 设置Calendar的时间为当前时间 + cal.setTime(new Date()); + // 将Calendar的时间增加1小时 + cal.add(Calendar.HOUR_OF_DAY, 1); + // 如果Token实体存在 + if (tokenEntity != null) { + // 设置Token实体的Token值 tokenEntity.setToken(token); + // 设置Token实体的过期时间 tokenEntity.setExpiratedtime(cal.getTime()); + // 更新Token实体 this.updateById(tokenEntity); } else { - this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime())); + // 如果Token实体不存在,插入一个新的Token实体 + this.insert(new TokenEntity(userid, username, tableName, role, token, cal.getTime())); } + // 返回生成的Token return token; } + // 重写getTokenEntity方法,用于根据Token获取Token实体 @Override public TokenEntity getTokenEntity(String token) { + // 根据Token查询Token实体 TokenEntity tokenEntity = this.selectOne(new EntityWrapper().eq("token", token)); - if(tokenEntity == null || tokenEntity.getExpiratedtime().getTime() implements UserService { + // 重写 queryPage 方法,用于根据参数查询 User 实体的分页数据 @Override public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数进行初始化 Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); + new Query(params).getPage(), + // 创建一个查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,包含分页信息 + return new PageUtils(page); } + // 重写 selectListView 方法,用于根据查询条件查询 User 实体的列表数据 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 queryPage 方法,用于根据参数和查询条件查询 User 实体的分页数据 @Override public PageUtils queryPage(Map params, - Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; + Wrapper wrapper) { + // 创建一个分页对象,根据传入的参数进行初始化 + Page page = new Query(params).getPage(); + // 设置分页对象的记录列表,通过基础映射器的 selectListView 方法查询 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 创建分页工具类对象,包含分页信息 + PageUtils pageUtil = new PageUtils(page); + // 返回分页工具类对象 + return pageUtil; } -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/WodebijiServiceImpl.java b/src/main/java/com/service/impl/WodebijiServiceImpl.java index 56cf366..441bb1c 100644 --- a/src/main/java/com/service/impl/WodebijiServiceImpl.java +++ b/src/main/java/com/service/impl/WodebijiServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入我的笔记数据访问对象 import com.dao.WodebijiDao; +// 导入我的笔记实体类 import com.entity.WodebijiEntity; +// 导入我的笔记服务接口 import com.service.WodebijiService; +// 导入我的笔记值对象类 import com.entity.vo.WodebijiVO; +// 导入我的笔记视图类 import com.entity.view.WodebijiView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 wodebijiService @Service("wodebijiService") +// 定义我的笔记服务实现类,继承自 ServiceImpl 并实现 WodebijiService 接口 public class WodebijiServiceImpl extends ServiceImpl implements WodebijiService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,用于根据传入的参数查询我的笔记实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,用于根据传入的参数和查询条件查询我的笔记视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储我的笔记视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取我的笔记视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,用于根据查询条件查询我的笔记值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,用于根据查询条件查询单个我的笔记值对象 @Override public WodebijiVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,用于根据查询条件查询我的笔记视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,用于根据查询条件查询单个我的笔记视图 @Override public WodebijiView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/WodekechengServiceImpl.java b/src/main/java/com/service/impl/WodekechengServiceImpl.java index d2cded6..574cfed 100644 --- a/src/main/java/com/service/impl/WodekechengServiceImpl.java +++ b/src/main/java/com/service/impl/WodekechengServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入我的课程数据访问对象 import com.dao.WodekechengDao; +// 导入我的课程实体类 import com.entity.WodekechengEntity; +// 导入我的课程服务接口 import com.service.WodekechengService; +// 导入我的课程值对象类 import com.entity.vo.WodekechengVO; +// 导入我的课程视图类 import com.entity.view.WodekechengView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 wodekechengService @Service("wodekechengService") +// 定义我的课程服务实现类,继承自 ServiceImpl 并实现 WodekechengService 接口 public class WodekechengServiceImpl extends ServiceImpl implements WodekechengService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询我的课程实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询我的课程视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储我的课程视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取我的课程视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询我的课程值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个我的课程值对象 @Override public WodekechengVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询我的课程视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个我的课程视图 @Override public WodekechengView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/XiaoxitongzhiServiceImpl.java b/src/main/java/com/service/impl/XiaoxitongzhiServiceImpl.java index a4e8f63..d0ed310 100644 --- a/src/main/java/com/service/impl/XiaoxitongzhiServiceImpl.java +++ b/src/main/java/com/service/impl/XiaoxitongzhiServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入消息通知数据访问对象 import com.dao.XiaoxitongzhiDao; +// 导入消息通知实体类 import com.entity.XiaoxitongzhiEntity; +// 导入消息通知服务接口 import com.service.XiaoxitongzhiService; +// 导入消息通知值对象类 import com.entity.vo.XiaoxitongzhiVO; +// 导入消息通知视图类 import com.entity.view.XiaoxitongzhiView; +// 使用 @Service 注解将该类标记为 Spring 服务,服务名为 xiaoxitongzhiService @Service("xiaoxitongzhiService") +// 定义消息通知服务实现类,继承 ServiceImpl 并实现 XiaoxitongzhiService 接口 public class XiaoxitongzhiServiceImpl extends ServiceImpl implements XiaoxitongzhiService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数查询消息通知实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件查询消息通知视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数生成,用于存储消息通知视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取消息通知视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询消息通知值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个消息通知值对象 @Override public XiaoxitongzhiVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询消息通知视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个消息通知视图 @Override public XiaoxitongzhiView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/XuekeServiceImpl.java b/src/main/java/com/service/impl/XuekeServiceImpl.java index b49d293..6eba9e5 100644 --- a/src/main/java/com/service/impl/XuekeServiceImpl.java +++ b/src/main/java/com/service/impl/XuekeServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所属的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入学科数据访问对象 import com.dao.XuekeDao; +// 导入学科实体类 import com.entity.XuekeEntity; +// 导入学科服务接口 import com.service.XuekeService; +// 导入学科值对象类 import com.entity.vo.XuekeVO; +// 导入学科视图类 import com.entity.view.XuekeView; +// 使用 @Service 注解,将该类注册为 Spring 服务,服务名为 xuekeService @Service("xuekeService") +// 定义学科服务实现类,继承自 ServiceImpl 并实现 XuekeService 接口 public class XuekeServiceImpl extends ServiceImpl implements XuekeService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据参数查询学科实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,封装分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据参数和查询条件查询学科视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据传入的参数生成,用于存储学科视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取学科视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 返回分页工具类对象,封装分页信息 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询学科值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个学科值对象 @Override public XuekeVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询学科视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个学科视图 @Override public XuekeView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/YonghuServiceImpl.java b/src/main/java/com/service/impl/YonghuServiceImpl.java index 3213fef..79860fc 100644 --- a/src/main/java/com/service/impl/YonghuServiceImpl.java +++ b/src/main/java/com/service/impl/YonghuServiceImpl.java @@ -1,62 +1,92 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 @Service 注解,用于将该类标记为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 中的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 中的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入用户数据访问对象 import com.dao.YonghuDao; +// 导入用户实体类 import com.entity.YonghuEntity; +// 导入用户服务接口 import com.service.YonghuService; +// 导入用户值对象类 import com.entity.vo.YonghuVO; +// 导入用户视图类 import com.entity.view.YonghuView; +// 使用 @Service 注解,将该类注册为 Spring 服务,服务名为 yonghuService @Service("yonghuService") +// 定义 YonghuServiceImpl 类,继承自 MyBatis-Plus 的 ServiceImpl 类,并实现 YonghuService 接口 public class YonghuServiceImpl extends ServiceImpl implements YonghuService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据传入的参数进行分页查询用户实体数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,通过 Query 工具类根据参数生成 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个空的查询条件包装器 + new EntityWrapper() + ); + // 将分页对象封装到 PageUtils 工具类中并返回 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据传入的参数和查询条件进行分页查询用户视图数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,通过 Query 工具类根据参数生成,用于存储用户视图数据 + Page page = new Query(params).getPage(); + // 调用基础映射器的 selectListView 方法,根据分页和查询条件获取用户视图列表,并设置到分页对象中 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 将分页对象封装到 PageUtils 工具类中并返回 + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询用户值对象列表 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个用户值对象 @Override public YonghuVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询用户视图列表 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个用户视图 @Override public YonghuView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/service/impl/ZhiyeguihuaServiceImpl.java b/src/main/java/com/service/impl/ZhiyeguihuaServiceImpl.java index ec60b3b..4bd407b 100644 --- a/src/main/java/com/service/impl/ZhiyeguihuaServiceImpl.java +++ b/src/main/java/com/service/impl/ZhiyeguihuaServiceImpl.java @@ -1,62 +1,93 @@ +// 声明该类所在的包为 com.service.impl package com.service.impl; +// 导入 Spring 框架的 Service 注解,用于标记该类为服务层组件 import org.springframework.stereotype.Service; +// 导入 Java 的 Map 接口,用于处理键值对数据 import java.util.Map; +// 导入 Java 的 List 接口,用于处理列表数据 import java.util.List; +// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的 Page 类,用于分页查询 import com.baomidou.mybatisplus.plugins.Page; +// 导入 MyBatis-Plus 的 ServiceImpl 类,提供通用的服务层实现 import com.baomidou.mybatisplus.service.impl.ServiceImpl; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的查询工具类 import com.utils.Query; - +// 导入职业规划数据访问对象 import com.dao.ZhiyeguihuaDao; +// 导入职业规划实体类 import com.entity.ZhiyeguihuaEntity; +// 导入职业规划服务接口 import com.service.ZhiyeguihuaService; +// 导入职业规划值对象类 import com.entity.vo.ZhiyeguihuaVO; +// 导入职业规划视图类 import com.entity.view.ZhiyeguihuaView; +// 使用 @Service 注解标记该类为服务层组件,名称为 zhiyeguihuaService @Service("zhiyeguihuaService") +// 定义 ZhiyeguihuaServiceImpl 类,继承 ServiceImpl 类并实现 ZhiyeguihuaService 接口 public class ZhiyeguihuaServiceImpl extends ServiceImpl implements ZhiyeguihuaService { - - - @Override - public PageUtils queryPage(Map params) { - Page page = this.selectPage( - new Query(params).getPage(), - new EntityWrapper() - ); - return new PageUtils(page); - } - - @Override + + // 重写 queryPage 方法,根据参数查询职业规划实体的分页数据 + @Override + public PageUtils queryPage(Map params) { + // 创建一个分页对象,根据传入的参数进行初始化 + Page page = this.selectPage( + new Query(params).getPage(), + // 创建一个查询条件包装器 + new EntityWrapper() + ); + // 返回分页工具类对象,包含分页信息 + return new PageUtils(page); + } + + // 重写 queryPage 方法,根据参数和查询条件查询职业规划视图的分页数据 + @Override public PageUtils queryPage(Map params, Wrapper wrapper) { - Page page =new Query(params).getPage(); - page.setRecords(baseMapper.selectListView(page,wrapper)); - PageUtils pageUtil = new PageUtils(page); - return pageUtil; - } - - @Override + // 创建一个分页对象,根据传入的参数进行初始化 + Page page = new Query(params).getPage(); + // 设置分页对象的记录列表,通过基础映射器的 selectListView 方法查询 + page.setRecords(baseMapper.selectListView(page, wrapper)); + // 创建分页工具类对象,包含分页信息 + PageUtils pageUtil = new PageUtils(page); + // 返回分页工具类对象 + return pageUtil; + } + + // 重写 selectListVO 方法,根据查询条件查询职业规划值对象的列表数据 + @Override public List selectListVO(Wrapper wrapper) { - return baseMapper.selectListVO(wrapper); + // 调用基础映射器的 selectListVO 方法进行查询 + return baseMapper.selectListVO(wrapper); } - + + // 重写 selectVO 方法,根据查询条件查询单个职业规划值对象 @Override public ZhiyeguihuaVO selectVO(Wrapper wrapper) { - return baseMapper.selectVO(wrapper); + // 调用基础映射器的 selectVO 方法进行查询 + return baseMapper.selectVO(wrapper); } - + + // 重写 selectListView 方法,根据查询条件查询职业规划视图的列表数据 @Override public List selectListView(Wrapper wrapper) { + // 调用基础映射器的 selectListView 方法进行查询 return baseMapper.selectListView(wrapper); } + // 重写 selectView 方法,根据查询条件查询单个职业规划视图 @Override public ZhiyeguihuaView selectView(Wrapper wrapper) { + // 调用基础映射器的 selectView 方法进行查询 return baseMapper.selectView(wrapper); } - -} +} \ No newline at end of file -- 2.34.1