From 65c8fd598ffc4b718aa4e43f56f754316dd0ba32 Mon Sep 17 00:00:00 2001 From: winter <2436197699@qq.com> Date: Tue, 2 Jan 2024 16:32:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86=E5=8C=85=20dao=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AdminAppraiseServiceImpl.java | 2 +- .../controller/frontend/HelloController.java | 2 +- .../model/entity/weekDuty/WeekDuty.java | 26 +++++++++++++++++++ .../AppraiseRecordRepository.java | 2 +- .../AppraiseRepository.java | 2 +- .../ChatSessionRepository.java | 2 +- .../{dao => repository}/ClassRepository.java | 2 +- .../{dao => repository}/SchoolRepository.java | 2 +- .../StudentRepository.java | 2 +- .../TeacherRepository.java | 2 +- .../service/impl/ChatMessageServiceImpl.java | 4 +-- .../service/impl/ChatSessionServiceImpl.java | 2 +- .../service/impl/EvaluationServiceImpl.java | 2 +- .../TeamModelExtensionApplicationTests.java | 2 +- 14 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 src/main/java/cn/teammodel/model/entity/weekDuty/WeekDuty.java rename src/main/java/cn/teammodel/{dao => repository}/AppraiseRecordRepository.java (99%) rename src/main/java/cn/teammodel/{dao => repository}/AppraiseRepository.java (98%) rename src/main/java/cn/teammodel/{dao => repository}/ChatSessionRepository.java (96%) rename src/main/java/cn/teammodel/{dao => repository}/ClassRepository.java (95%) rename src/main/java/cn/teammodel/{dao => repository}/SchoolRepository.java (97%) rename src/main/java/cn/teammodel/{dao => repository}/StudentRepository.java (96%) rename src/main/java/cn/teammodel/{dao => repository}/TeacherRepository.java (94%) diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java index 7e58c3d..7779d46 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java @@ -4,7 +4,7 @@ import cn.teammodel.common.ErrorCode; import cn.teammodel.common.PK; import cn.teammodel.config.exception.ServiceException; import cn.teammodel.controller.admin.service.AdminAppraiseService; -import cn.teammodel.dao.*; +import cn.teammodel.repository.*; import cn.teammodel.model.dto.admin.TimeRangeDto; import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto; import cn.teammodel.model.entity.User; diff --git a/src/main/java/cn/teammodel/controller/frontend/HelloController.java b/src/main/java/cn/teammodel/controller/frontend/HelloController.java index 7e12a1c..b839a16 100644 --- a/src/main/java/cn/teammodel/controller/frontend/HelloController.java +++ b/src/main/java/cn/teammodel/controller/frontend/HelloController.java @@ -1,7 +1,7 @@ package cn.teammodel.controller.frontend; import cn.teammodel.common.R; -import cn.teammodel.dao.AppraiseRepository; +import cn.teammodel.repository.AppraiseRepository; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/cn/teammodel/model/entity/weekDuty/WeekDuty.java b/src/main/java/cn/teammodel/model/entity/weekDuty/WeekDuty.java new file mode 100644 index 0000000..8570d3f --- /dev/null +++ b/src/main/java/cn/teammodel/model/entity/weekDuty/WeekDuty.java @@ -0,0 +1,26 @@ +package cn.teammodel.model.entity.weekDuty; + +import cn.teammodel.model.entity.BaseItem; +import com.azure.spring.data.cosmos.core.mapping.Container; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 值周对象是班级,对应一个评价的指标 + * @author winter + * @create 2023-12-29 15:53 + */ +@EqualsAndHashCode(callSuper = true) +@Container(containerName = "School") +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class WeekDuty extends BaseItem { + private String classId; + private String className; + /** + * 备注 + */ + private String note; + private Long createTime; +} diff --git a/src/main/java/cn/teammodel/dao/AppraiseRecordRepository.java b/src/main/java/cn/teammodel/repository/AppraiseRecordRepository.java similarity index 99% rename from src/main/java/cn/teammodel/dao/AppraiseRecordRepository.java rename to src/main/java/cn/teammodel/repository/AppraiseRecordRepository.java index 8c8be2c..ad45191 100644 --- a/src/main/java/cn/teammodel/dao/AppraiseRecordRepository.java +++ b/src/main/java/cn/teammodel/repository/AppraiseRecordRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.appraise.AppraiseRecord; import cn.teammodel.model.entity.appraise.AppraiseTreeNode; diff --git a/src/main/java/cn/teammodel/dao/AppraiseRepository.java b/src/main/java/cn/teammodel/repository/AppraiseRepository.java similarity index 98% rename from src/main/java/cn/teammodel/dao/AppraiseRepository.java rename to src/main/java/cn/teammodel/repository/AppraiseRepository.java index 9fe115a..4cfe6ef 100644 --- a/src/main/java/cn/teammodel/dao/AppraiseRepository.java +++ b/src/main/java/cn/teammodel/repository/AppraiseRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.appraise.Appraise; import cn.teammodel.model.entity.appraise.AppraiseTreeNode; diff --git a/src/main/java/cn/teammodel/dao/ChatSessionRepository.java b/src/main/java/cn/teammodel/repository/ChatSessionRepository.java similarity index 96% rename from src/main/java/cn/teammodel/dao/ChatSessionRepository.java rename to src/main/java/cn/teammodel/repository/ChatSessionRepository.java index 389b437..26c82b2 100644 --- a/src/main/java/cn/teammodel/dao/ChatSessionRepository.java +++ b/src/main/java/cn/teammodel/repository/ChatSessionRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.ai.ChatSession; import com.azure.spring.data.cosmos.repository.CosmosRepository; diff --git a/src/main/java/cn/teammodel/dao/ClassRepository.java b/src/main/java/cn/teammodel/repository/ClassRepository.java similarity index 95% rename from src/main/java/cn/teammodel/dao/ClassRepository.java rename to src/main/java/cn/teammodel/repository/ClassRepository.java index e7e8997..9da6a4b 100644 --- a/src/main/java/cn/teammodel/dao/ClassRepository.java +++ b/src/main/java/cn/teammodel/repository/ClassRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.school.ClassInfo; import com.azure.spring.data.cosmos.repository.CosmosRepository; diff --git a/src/main/java/cn/teammodel/dao/SchoolRepository.java b/src/main/java/cn/teammodel/repository/SchoolRepository.java similarity index 97% rename from src/main/java/cn/teammodel/dao/SchoolRepository.java rename to src/main/java/cn/teammodel/repository/SchoolRepository.java index 53b9357..108f044 100644 --- a/src/main/java/cn/teammodel/dao/SchoolRepository.java +++ b/src/main/java/cn/teammodel/repository/SchoolRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.school.School; import com.azure.spring.data.cosmos.repository.CosmosRepository; diff --git a/src/main/java/cn/teammodel/dao/StudentRepository.java b/src/main/java/cn/teammodel/repository/StudentRepository.java similarity index 96% rename from src/main/java/cn/teammodel/dao/StudentRepository.java rename to src/main/java/cn/teammodel/repository/StudentRepository.java index 3b3c549..bc4a566 100644 --- a/src/main/java/cn/teammodel/dao/StudentRepository.java +++ b/src/main/java/cn/teammodel/repository/StudentRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.school.Student; import com.azure.spring.data.cosmos.repository.CosmosRepository; diff --git a/src/main/java/cn/teammodel/dao/TeacherRepository.java b/src/main/java/cn/teammodel/repository/TeacherRepository.java similarity index 94% rename from src/main/java/cn/teammodel/dao/TeacherRepository.java rename to src/main/java/cn/teammodel/repository/TeacherRepository.java index c47f18a..6574f54 100644 --- a/src/main/java/cn/teammodel/dao/TeacherRepository.java +++ b/src/main/java/cn/teammodel/repository/TeacherRepository.java @@ -1,4 +1,4 @@ -package cn.teammodel.dao; +package cn.teammodel.repository; import cn.teammodel.model.entity.school.Teacher; import com.azure.spring.data.cosmos.repository.CosmosRepository; diff --git a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java index e46c07d..dcf6c18 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java @@ -8,7 +8,7 @@ import cn.teammodel.ai.listener.SparkGptStreamListener; import cn.teammodel.common.ErrorCode; import cn.teammodel.common.PK; import cn.teammodel.config.exception.ServiceException; -import cn.teammodel.dao.ChatSessionRepository; +import cn.teammodel.repository.ChatSessionRepository; import cn.teammodel.model.dto.ai.ChatCompletionReqDto; import cn.teammodel.model.entity.User; import cn.teammodel.model.entity.ai.ChatSession; @@ -49,7 +49,7 @@ public class ChatMessageServiceImpl implements ChatMessageService { ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(sessionId), "该会话不存在"); if (!session.getUserId().equals(userId)) { - throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "该会话不存在"); + throw new ServiceException(ErrorCode.NO_AUTH_ERROR.getCode(), "该会话不存在"); } SseEmitter sseEmitter = new SseEmitter(-1L); diff --git a/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java index 26583d1..5fe3a36 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.lang.UUID; import cn.teammodel.common.ErrorCode; import cn.teammodel.common.PK; import cn.teammodel.config.exception.ServiceException; -import cn.teammodel.dao.ChatSessionRepository; +import cn.teammodel.repository.ChatSessionRepository; import cn.teammodel.model.dto.ai.UpdateSessionDto; import cn.teammodel.model.entity.User; import cn.teammodel.model.entity.ai.ChatSession; diff --git a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java index 6ff7531..5e1694c 100644 --- a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java @@ -7,7 +7,7 @@ import cn.teammodel.common.FiveEducations; import cn.teammodel.common.IdRequest; import cn.teammodel.common.PK; import cn.teammodel.config.exception.ServiceException; -import cn.teammodel.dao.*; +import cn.teammodel.repository.*; import cn.teammodel.model.dto.Appraise.*; import cn.teammodel.model.entity.User; import cn.teammodel.model.entity.appraise.*; diff --git a/src/test/java/cn/teammodel/TeamModelExtensionApplicationTests.java b/src/test/java/cn/teammodel/TeamModelExtensionApplicationTests.java index 7b12b5c..f6ae1ed 100644 --- a/src/test/java/cn/teammodel/TeamModelExtensionApplicationTests.java +++ b/src/test/java/cn/teammodel/TeamModelExtensionApplicationTests.java @@ -2,7 +2,7 @@ package cn.teammodel; import cn.teammodel.common.PK; import cn.teammodel.controller.admin.service.AdminAppraiseService; -import cn.teammodel.dao.*; +import cn.teammodel.repository.*; import cn.teammodel.manager.DingAlertNotifier; import cn.teammodel.model.dto.admin.TimeRangeDto; import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto;