From 2527e081d921782cf12549112abf7dacd52a4900 Mon Sep 17 00:00:00 2001 From: 670788339 <670788339@qq.com> Date: Thu, 30 Oct 2025 14:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=A0=87=E7=AD=BE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/course/api/CourseManageApi.java | 4 +- .../service/impl/CourseTagServiceImpl.java | 43 +++++++++++++++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java index feec1e50..b5416afb 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java @@ -283,9 +283,9 @@ public class CourseManageApi extends ApiBaseController{ //填充必要的信息 try { - log.info("-------- 标签相关开始 -------"); + log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId()); CurrentUser userInfo = getCurrent(); - Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? courseService.get(dto.getCourse().getId()) : null; + Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId()); tagService.updateTags(oldCourse,dto.getCourse(),userInfo); log.info("-------- 标签相关结束 -------"); diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CourseTagServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CourseTagServiceImpl.java index bb38a374..4f06c33e 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CourseTagServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CourseTagServiceImpl.java @@ -375,14 +375,15 @@ public class CourseTagServiceImpl implements ICourseTagService { @Override public void updateTags(Course oldCourse, Course newCourse, CurrentUser userInfo) { - log.info(" --- 标签修改 --- 在线课参数 oldCourse = " + oldCourse); - log.info(" --- 标签修改 --- 在线课参数 newCourse = " + newCourse); - log.info(" --- 标签修改 --- 用户信息 userInfo = " + userInfo); + log.info(" --- 标签修改 --- 在线课参数 oldCourse = {} " , oldCourse); + log.info(" --- 标签修改 --- 在线课参数 newCourse = {} " , newCourse); + log.info(" --- 标签修改 --- 用户信息 userInfo = {} " , userInfo); // 获取新旧课程的标签ID列表 List oldTagIds = getTagIdsFromCourse(oldCourse); List newTagIds = getTagIdsFromCourse(newCourse); - + log.info(" --- 旧标签 oldTagIds = {} " , oldTagIds); + log.info(" --- 新修改 newTagIds = {} " , newTagIds); if (oldCourse == null) { // 新增课程 - 处理所有新标签 handleNewCourseTags(newCourse, newTagIds, userInfo); @@ -390,6 +391,7 @@ public class CourseTagServiceImpl implements ICourseTagService { // 编辑课程 - 比较差异并处理 handleEditCourseTags(oldCourse, newCourse, oldTagIds, newTagIds, userInfo); } + log.info("完成课程标签更新: courseId={}", newCourse != null ? newCourse.getId() : "null"); } /** @@ -417,6 +419,7 @@ public class CourseTagServiceImpl implements ICourseTagService { * 处理新增课程的标签逻辑 */ private void handleNewCourseTags(Course newCourse, List newTagIds, CurrentUser userInfo) { + log.info("处理新增课程的标签逻辑: courseId={}, tagCount={}", newCourse != null ? newCourse.getId() : "null", newTagIds.size()); String courseId = newCourse.getId(); for (String tagId : newTagIds) { @@ -440,6 +443,7 @@ public class CourseTagServiceImpl implements ICourseTagService { // 更新标签使用计数并检查是否设置为公共标签 updateTagUseCountAndPublicStatus(tag, userInfo); } + log.info("完成新增课程标签处理: courseId={}", newCourse != null ? newCourse.getId() : "null"); } /** @@ -447,6 +451,12 @@ public class CourseTagServiceImpl implements ICourseTagService { */ private void handleEditCourseTags(Course oldCourse, Course newCourse, List oldTagIds, List newTagIds, CurrentUser userInfo) { + log.info("处理编辑课程的标签逻辑: courseId={}, oldTagCount={}, newTagCount={}, toRemove={}, toAdd={}", + newCourse != null ? newCourse.getId() : "null", + oldTagIds.size(), newTagIds.size(), + oldTagIds.stream().filter(tagId -> !newTagIds.contains(tagId)).count(), + newTagIds.stream().filter(tagId -> !oldTagIds.contains(tagId)).count()); + String courseId = newCourse.getId(); // 找出需要删除的标签(存在于旧课程但不在新课程中) @@ -486,12 +496,16 @@ public class CourseTagServiceImpl implements ICourseTagService { if (hasCourseTypeChanged(oldCourse, newCourse)) { updateCourseTypeTagRelations(oldCourse, newCourse, newTagIds, userInfo); } + log.info("完成编辑课程标签处理: courseId={}", newCourse != null ? newCourse.getId() : "null"); } /** * 创建课程-标签关联关系 */ private void createCourseTagRelation(String courseId, CourseTag tag, CurrentUser userInfo) { + log.debug("创建课程-标签关联关系: courseId={}, tagId={}, tagName={}", + courseId, tag != null ? tag.getId() : "null", tag != null ? tag.getTagName() : "null"); + // 检查是否已存在关联关系 QueryBuilder query = QueryBuilder.from(CourseTagRelation.class); List filters = new ArrayList<>(); @@ -532,12 +546,21 @@ public class CourseTagServiceImpl implements ICourseTagService { courseTagRelationDao.saveOrUpdate(relation); } } + log.debug("完成课程-标签关联关系创建: courseId={}, tagId={}", courseId, tag != null ? tag.getId() : "null"); + } /** * 创建分类-标签关联关系 */ private void createCourseTypeTagRelations(Course course, CourseTag tag, CurrentUser userInfo) { + log.debug("创建分类-标签关联关系: courseId={}, tagId={}, sysType1={}, sysType2={}, sysType3={}", + course != null ? course.getId() : "null", + tag != null ? tag.getId() : "null", + course != null ? course.getSysType1() : "null", + course != null ? course.getSysType2() : "null", + course != null ? course.getSysType3() : "null"); + String sysType1 = course.getSysType1(); String sysType2 = course.getSysType2(); String sysType3 = course.getSysType3(); @@ -607,6 +630,7 @@ public class CourseTagServiceImpl implements ICourseTagService { * 移除课程-标签关联关系 */ private void removeCourseTagRelation(String courseId, String tagId, CurrentUser userInfo) { + log.debug("移除课程-标签关联关系: courseId={}, tagId={}", courseId, tagId); // 查找关联关系 QueryBuilder query = QueryBuilder.from(CourseTagRelation.class); List filters = new ArrayList<>(); @@ -641,6 +665,7 @@ public class CourseTagServiceImpl implements ICourseTagService { // 检查是否需要删除分类-标签关联关系 checkAndRemoveCourseTypeTagRelation(tagId, userInfo); } + log.debug("完成课程-标签关联关系移除: courseId={}, tagId={}", courseId, tagId); } /** @@ -681,6 +706,11 @@ public class CourseTagServiceImpl implements ICourseTagService { * 更新标签使用计数并检查公共标签状态 */ private void updateTagUseCountAndPublicStatus(CourseTag tag, CurrentUser userInfo) { + log.debug("更新标签使用计数和公共状态: tagId={}, tagName={}, beforeUseCount={}", + tag != null ? tag.getId() : "null", + tag != null ? tag.getTagName() : "null", + tag != null ? tag.getUseCount() : "null"); + // 统计当前活跃的关联关系数量 QueryBuilder query = QueryBuilder.from(CourseTagRelation.class); List filters = new ArrayList<>(); @@ -707,6 +737,11 @@ public class CourseTagServiceImpl implements ICourseTagService { tag.setSysUpdateTime(now); courseTagDao.update(tag); + log.debug("完成标签使用计数和公共状态更新: tagId={}, tagName={}, afterUseCount={}, isPublic={}", + tag != null ? tag.getId() : "null", + tag != null ? tag.getTagName() : "null", + tag != null ? tag.getUseCount() : "null", + tag != null ? tag.getIsPublic() : "null"); } /**