This commit is contained in:
LingandRX 2025-03-31 22:02:17 +08:00
parent a550815308
commit fa18e1c708
14 changed files with 599 additions and 17 deletions

8
gradlew vendored
View File

@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
# #
@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -86,7 +84,7 @@ done
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -205,7 +203,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command: # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped. # and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line. # treated as '${Hostname}' itself on the command line.

22
gradlew.bat vendored
View File

@ -13,8 +13,6 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2 echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. 1>&2 echo.
echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. 1>&2 echo location of your Java installation.
goto fail goto fail
@ -59,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. 1>&2 echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. 1>&2 echo.
echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. 1>&2 echo location of your Java installation.
goto fail goto fail

View File

@ -0,0 +1,28 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CategoryMapper {
int insert(Category category);
int insertBatch(@Param("entities") List<Category> entities);
List<Category> categoryList(@Param("entities") List<Category> entities);
Category findById(@Param("id") Integer id);
Category findByIdBatch(@Param("ids") List<Integer> ids);
Category findByIdOrParentId(@Param("id") Integer id, @Param("parentId") Integer parentId);
int deleteById(@Param("id") Integer id);
int deleteByIdBatch(@Param("ids") List<Integer> ids);
int update(@Param("entities") Category category);
}

View File

@ -0,0 +1,71 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.Collection;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CollectionMapper {
/**
* 根据ID查询收藏夹
*
* @param collectionId 收藏夹的ID
* @return 返回查询到的收藏夹对象
*/
Collection findById(@Param("collectionId") Integer collectionId);
/**
* 根据创建者 ID 查询收藏夹
*
* @param creatorId 创建者 ID
* @return 返回查询到的收藏夹列表
*/
List<Collection> findByCreatorId(@Param("creatorId") Long creatorId);
/**
* 根据收藏夹 ID 和创建者 ID 查询收藏夹
*
* @param collectionId 收藏夹 ID
* @param creatorId 创建者 ID
* @return 返回查询到的收藏夹对象
*/
Collection findByIdAndCreatorId(@Param("collectionId") Integer collectionId, @Param("creatorId") Long creatorId);
/**
* 根据收藏夹 ID创建者 ID 和笔记 ID 查询收藏夹
*
* @param collectionId 收藏夹 ID
* @param creatorId 创建者 ID
* @param noteId 笔记 ID
* @return 返回查询到的收藏夹对象
*/
int countByCreatorIdAndNoteId(
@Param("creatorId") Long creatorId,
@Param("noteId") Integer noteId);
/**
* 创建收藏夹
*
* @param collection 要创建的收藏夹对象
* @return 返回插入操作的影响行数
*/
int insert(Collection collection);
/**
* 更新收藏夹
*
* @param collection 要更新的收藏夹对象
* @return 返回更新操作的影响行数
*/
int update(Collection collection);
/**
* 删除收藏夹
*
* @param collectionId 要删除的收藏夹的ID
* @return 返回删除操作的影响行数
*/
int deleteById(@Param("collectionId") Integer collectionId);
}

View File

@ -0,0 +1,61 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.CollectionNote;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
@Mapper
public interface CollectionNoteMapper {
/**
* 查询用户收藏的笔记 ID 列表
*
* @param userId 用户 ID
* @param noteIds 笔记 ID 列表
* @return 用户收藏的笔记 ID 列表
*/
List<Integer> findUserCollectedNoteIds(
@Param("userId") Long userId,
@Param("noteIds") List<Integer> noteIds
);
/**
* 筛选出所给的收藏夹 ID 列表中收藏了 noteId 对应的 note 的记录
*
* @param noteId 笔记 ID
* @param collectionIds 收藏夹 ID 列表
* @return 筛选结果
*/
Set<Integer> filterCollectionIdsByNoteId(
@Param("noteId") Integer noteId,
@Param("collectionIds") List<Integer> collectionIds);
/**
* 插入记录
*
* @param collectionNote 收藏笔记记录
* @return 插入记录数
*/
int insert(CollectionNote collectionNote);
/**
* 根据 collectionId 删除记录
*
* @param collectionId 收藏夹 ID
* @return 删除记录数
*/
int deleteByCollectionId(@Param("collectionId") Integer collectionId);
/**
* 根据 collectionId noteId 删除记录
*
* @param collectionId 收藏夹 ID
* @param noteId 笔记 ID
* @return 删除记录数
*/
int deleteByCollectionIdAndNoteId(
@Param("collectionId") Integer collectionId,
@Param("noteId") Integer noteId);
}

View File

@ -0,0 +1,44 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.CommentLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Set;
/**
* 评论点赞Mapper接口
*/
@Mapper
public interface CommentLikeMapper {
/**
* 插入评论点赞
*
* @param commentLike 评论点赞实体
*/
void insert(CommentLike commentLike);
/**
* 删除评论点赞
*
* @param commentId 评论ID
* @param userId 用户ID
*/
void delete(@Param("commentId") Integer commentId, @Param("userId") Long userId);
/**
* 查询用户点赞的评论ID列表
*
* @param userId 用户ID
* @param commentIds 评论ID列表
* @return 用户点赞的评论ID集合
*/
Set<Integer> findUserLikedCommentIds(@Param("userId") Long userId,
@Param("commentIds") List<Integer> commentIds);
@Select("SELECT COUNT(*) > 0 FROM comment_like " +
"WHERE user_id = #{userId} AND comment_id = #{commentId}")
Boolean checkIsLiked(@Param("userId") Long userId, @Param("commentId") Integer commentId);
}

View File

@ -0,0 +1,91 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.dto.comment.CommentQueryParams;
import com.example.copykamanotes.model.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 评论Mapper接口
*/
@Mapper
public interface CommentMapper {
/**
* 插入评论
*
* @param comment 评论实体
*/
void insert(Comment comment);
/**
* 更新评论
*
* @param comment 评论实体
*/
void update(Comment comment);
/**
* 删除评论
*
* @param commentId 评论ID
*/
void deleteById(Integer commentId);
/**
* 根据ID查询评论
*
* @param commentId 评论ID
* @return 评论实体
*/
Comment findById(Integer commentId);
/**
* 查询评论列表
*
* @param params 查询参数
* @param pageSize 每页大小
* @param offset 偏移量
* @return 评论列表
*/
List<Comment> findByQueryParam(@Param("params") CommentQueryParams params,
@Param("pageSize") Integer pageSize,
@Param("offset") Integer offset);
/**
* 统计评论数量
*
* @param params 查询参数
* @return 评论数量
*/
int countByQueryParam(@Param("params") CommentQueryParams params);
/**
* 增加评论点赞数
*
* @param commentId 评论ID
*/
void incrementLikeCount(Integer commentId);
/**
* 减少评论点赞数
*
* @param commentId 评论ID
*/
void decrementLikeCount(Integer commentId);
/**
* 增加评论回复数
*
* @param commentId 评论ID
*/
void incrementReplyCount(Integer commentId);
/**
* 减少评论回复数
*
* @param commentId 评论ID
*/
void decrementReplyCount(Integer commentId);
}

View File

@ -0,0 +1,47 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.NoteCollect;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 笔记收藏Mapper接口
*/
@Mapper
public interface NoteCollectMapper {
/**
* 插入收藏记录
*
* @param noteCollect 收藏记录
* @return 影响的行数
*/
int insert(NoteCollect noteCollect);
/**
* 删除收藏记录
*
* @param noteId 笔记ID
* @param userId 用户ID
* @return 影响的行数
*/
int delete(@Param("noteId") Integer noteId, @Param("userId") Long userId);
/**
* 查找收藏记录
*
* @param noteId 笔记ID
* @param userId 用户ID
* @return 收藏记录
*/
NoteCollect findByNoteIdAndUserId(@Param("noteId") Integer noteId, @Param("userId") Long userId);
/**
* 获取用户收藏的笔记ID列表
*
* @param userId 用户ID
* @return 笔记ID列表
*/
List<Integer> findNoteIdsByUserId(@Param("userId") Long userId);
}

View File

@ -0,0 +1,31 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.NoteComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface NoteCommentMapper {
/**
* 插入评论
*/
void insert(NoteComment comment);
/**
* 更新评论
*/
void update(NoteComment comment);
/**
* 根据ID查询评论
*/
NoteComment findById(@Param("id") Integer id);
/**
* 查询笔记的评论列表
*/
List<NoteComment> findByNoteId(@Param("noteId") Integer noteId);
}

View File

@ -0,0 +1,79 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.QuestionListItem;
import com.example.copykamanotes.model.vo.questionListItem.QuestionListItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface QuestionListItemMapper {
/**
* 插入一个题单项
*
* @param questionListItem 题单项对象包含需要插入的题单项的信息
* @return 影响的行数表示插入操作是否成功
*/
int insert(QuestionListItem questionListItem);
/**
* 根据题单ID查找题单项
*
* @param questionListId 题单的唯一标识符
* @return 返回一个包含题单项的列表如果找不到对应的项则返回空列表
*/
List<QuestionListItemVO> findByQuestionListId(@Param("questionListId") Integer questionListId);
/**
* 根据题单ID查找题单项的数量
*
* @param questionListId 题单的ID用于标识要查找的题单项数量
* @return 返回题单项的数量
*/
int countByQuestionListId(@Param("questionListId") Integer questionListId);
/**
* 根据题单ID查找题单项分页
*
* @param questionListId 题单的ID用于标识要查找的题单项
* @param limit 每页显示的记录数
* @param offset 从第几条记录开始查询
*/
List<QuestionListItemVO> findByQuestionListIdPage(@Param("questionListId") Integer questionListId,
@Param("limit") Integer limit,
@Param("offset") Integer offset);
/**
* 根据题单ID删除题单项
*
* @param questionListId 题单的ID用于标识要删除的题单项
* @return 影响的行数表示删除操作是否成功
*/
int deleteByQuestionListId(Integer questionListId);
/**
* 根据题单ID和题目ID删除题单项
*
* @param questionListId 题单的ID用于标识要删除的题单项
* @param questionId 题目的ID用于标识要删除的题单项
* @return 影响的行数表示删除操作是否成功
*/
int deleteByQuestionListIdAndQuestionId(@Param("questionListId") Integer questionListId, @Param("questionId") Integer questionId);
/**
* 根据题单ID获取下一个序号
*
* @param questionListId 题单的ID
* @return 返回下一个序号
*/
int nextRank(Integer questionListId);
/**
* 更新题单项的序号
*
* @param questionListItem 新顺序的题单项
* @return 影响的行数表示更新操作是否成功
*/
int updateQuestionRank(QuestionListItem questionListItem);
}

View File

@ -0,0 +1,31 @@
package com.example.copykamanotes.mapper;
import com.example.copykamanotes.model.entity.Statistic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface StatisticMapper {
/**
* 添加统计数据
* @param statistic 统计数据
* @return 添加的记录数
*/
int insert(Statistic statistic);
/**
* 获取统计数据的 total
* @return total
*/
int countStatistic();
/**
* 查询统计数据
* @param limit 限制
* @param offset 偏移
* @return 统计数据
*/
List<Statistic> findByPage(@Param("limit") Integer limit, @Param("offset") Integer offset);
}

View File

@ -0,0 +1,42 @@
package com.example.copykamanotes.model.dto.comment;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* 评论查询参数
*/
@Data
public class CommentQueryParams {
/**
* 笔记ID
*/
@NotNull(message = "笔记ID不能为空")
private Integer noteId;
/**
* 父评论ID
*/
private Integer parentId;
/**
* 作者ID
*/
private Long authorId;
/**
* 页码
*/
@NotNull(message = "页码不能为空")
@Min(value = 1, message = "页码必须大于0")
private Integer page;
/**
* 每页大小
*/
@NotNull(message = "每页大小不能为空")
@Min(value = 1, message = "每页大小必须大于0")
private Integer pageSize;
}

View File

@ -0,0 +1,38 @@
package com.example.copykamanotes.model.vo.question;
import lombok.Data;
@Data
public class BaseQuestionVO {
/*
* 问题ID主键
*/
private Integer questionId;
/*
* 问题所属分类ID
*/
private Integer categoryId;
/*
* 问题标题
*/
private String title;
/*
* 问题难度
* 1=简单2=中等3=困难
*/
private Integer difficulty;
/*
* 题目考点
*/
private String examPoint;
/*
* 浏览量
*/
private Integer viewCount;
}

View File

@ -0,0 +1,23 @@
package com.example.copykamanotes.model.vo.questionListItem;
import com.example.copykamanotes.model.vo.question.BaseQuestionVO;
import lombok.Data;
@Data
public class QuestionListItemVO {
/*
* 题单ID联合主键
*/
private Integer questionListId;
/*
* 题目ID联合主键
*/
private BaseQuestionVO question;
/*
* 题单内题目的顺序从1开始
*/
private Integer rank;
}