diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseAuditApi.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseAuditApi.java index 058af336..d80843db 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseAuditApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseAuditApi.java @@ -513,58 +513,6 @@ public class CourseAuditApi extends ApiBaseController{ HttpUtils.sendMessage(message,url); } -// public static void main(String[] args) throws JsonProcessingException { -// // 创建 BoeaiVideoResourceDto 列表 -// List videoResources = new ArrayList<>(); -// BoeaiVideoResourceDto videoResource = BoeaiVideoResourceDto.builder() -// .id(1L) -// .videoId("VID123456") -// .courseId("CID123456") -// .title("Introduction to Java") -// .originalUrl("http://example.com/video.mp4") -// .duration(3600) -// .fileSize(102400L) -// .format("mp4") -// .status(2) -// .isReviewed(1) -// .reviewerId("REV001") -// .build(); -// videoResources.add(videoResource); -// -// // 创建 BoeaiCourseDto 列表 -// List courseDtos = new ArrayList<>(); -// BoeaiCourseDto courseDto = BoeaiCourseDto.builder() -// .id(1L) -// .courseId("CID123456") -// .videoId("VID123456") -// .title("Java Programming Course") -// .instructor("John Doe") -// .chapterCount(10) -// .videoCount(20) -// .totalDuration(72000) -// .description("A comprehensive Java programming course.") -// .languageCode("en-US") -// .aiSet(1) -// .aiAbstract(0) -// .aiDraft(0) -// .aiTranslate(1) -// .languageStatus(1) -// .boeaiVideoResourceReqList(videoResources) -// -// .build(); -// courseDtos.add(courseDto); -// -// // 创建 BoeaiCourseParamsReq 并设置 boeaiCourseReqList 属性 -// BoeaiCourseParamsReq paramReq = new BoeaiCourseParamsReq(); -// paramReq.setBoeaiCourseReqList(courseDtos); -// -// ObjectMapper objectMapper = new ObjectMapper(); -// String message = objectMapper.writeValueAsString(paramReq); -// -// System.out.println( message); -// } - - /*** * 审核 diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/dto/AiVideoResourceRsp.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/dto/AiVideoResourceRsp.java new file mode 100644 index 00000000..c923f55f --- /dev/null +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/dto/AiVideoResourceRsp.java @@ -0,0 +1,86 @@ +package com.xboe.module.course.dto; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author Huang Run + * @date 2025年11月04日 + */ +@Data +public class AiVideoResourceRsp { + //多语言字幕信息 + List boeaiSubtitleRspList; + + private Long id; + + /** + * 视频业务ID + */ + private String videoId; + /** + * 视频语言编码 如 zh-CN, en-US + */ + //private String languageCode; + /** + * 课程ID + */ + private String courseId; + + /** + * 视频标题 + */ + private String title; + + /** + * 原始视频URL + */ + private String originalUrl; + + /** + * 视频时长(秒) + */ + private Integer duration; + + /** + * 文件大小(字节) + */ + private Long fileSize; + + /** + * 视频格式 mp4/avi等 + */ + private String format; + + /** + * 状态 0-待处理 1-处理中 2-已完成 3-失败 + */ + private Integer status; + + /** + * 是否已审核 0-否 1-是 + */ + private Integer isReviewed; + + /** + * 审核人ID + */ + private String reviewerId; + + /** + * 审核时间 + */ + private Date reviewedAt; + + /** + * + */ + private Date createdAt; + + /** + * + */ + private Date updatedAt; +} diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/dto/BoeaiSubtitleRsp.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/dto/BoeaiSubtitleRsp.java new file mode 100644 index 00000000..a4d14393 --- /dev/null +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/dto/BoeaiSubtitleRsp.java @@ -0,0 +1,80 @@ +package com.xboe.module.course.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author + * 视频字幕表 + */ +@Data +public class BoeaiSubtitleRsp implements Serializable { + /** + * 主键ID + */ + private Long id; + + /** + * 关联视频ID + */ + private String videoId; + + /** + * 字幕语言(如 zh-CN, en-US) + */ + private String language; + + /** + * WebVTT字幕文件URL(OSS地址) + */ + private String subtitleUrl; + + /** + * 是否原始字幕 0-翻译 1-原始 + */ + private Byte isOriginal; + + /** + * 源语言/翻译来源(如 zh-CN) + */ + private String sourceLanguage; + + /** + * 翻译引擎(llm/google/deepl) + */ + private String translateEngine; + + /** + * 状态(0-待生成 1-生成中 2-已完成 3-失败) + */ + private Boolean status; + + /** + * 创建时间 + */ + private Date createdAt; + + /** + * 更新时间 + */ + private Date updatedAt; + + /** + * 字幕数据(JSON 数组格式,包含时间戳和翻译文本) + */ + private String subtitleData; + + /** + * WebVTT 格式字幕内容 + */ + private String vttContent; + + /** + * 错误信息 + */ + private String errorMsg; + private static final long serialVersionUID = 1L; + +} diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/entity/CourseContent.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/entity/CourseContent.java index 3e92ee3a..122a6bc1 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/entity/CourseContent.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/entity/CourseContent.java @@ -8,9 +8,12 @@ import javax.persistence.Transient; import com.xboe.core.SysConstant; import com.xboe.core.orm.BaseEntity; +import com.xboe.module.course.dto.BoeaiSubtitleRsp; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + /** * 课程内容表 * */ @@ -93,6 +96,9 @@ public class CourseContent extends BaseEntity { /**用于学习时的状态显示,非存储字段*/ @Transient private Integer status; + + @Transient + List boeaiSubtitleRspList; public CourseContent() { diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/utils/HttpUtils.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/utils/HttpUtils.java index 260a4a0d..dd1f422c 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/utils/HttpUtils.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/utils/HttpUtils.java @@ -1,11 +1,13 @@ package com.xboe.module.course.utils; import lombok.extern.slf4j.Slf4j; +import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; import java.nio.charset.StandardCharsets; @@ -15,7 +17,7 @@ import java.nio.charset.StandardCharsets; */ @Slf4j public class HttpUtils { - public static CloseableHttpResponse sendMessage(String message,String url) { + public static String sendMessage(String message,String url) { log.info("----------------发送消息开始 -------"); //log.info("----------------发送消息url -------{}",url); log.info("----------------发送消息参数 -------{}",message); @@ -28,8 +30,15 @@ public class HttpUtils { httpPost.setHeader("Content-Type", "application/json; charset=utf-8"); httpPost.setHeader("Accept", "application/json"); CloseableHttpResponse response = httpClient.execute(httpPost); - log.info("---------------发送消息响应 -------{}",response); - return response; + + HttpEntity responseEntity = response.getEntity(); + String responseBody = ""; + if (responseEntity != null) { + responseBody = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8); + System.out.println("Response Body: " + responseBody); + } + log.info("---------------发送消息响应 -------{}",responseBody); + return responseBody; // System.out.println("状态码: " + response.getCode()); // System.out.println("响应体: " + EntityUtils.toString(response.getEntity())); diff --git a/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java b/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java index 92adc0d2..f25138d4 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java @@ -9,11 +9,15 @@ import java.util.function.Function; import java.util.stream.Collectors; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter; import com.boe.feign.api.infrastructure.entity.CommonSearchVo; import com.boe.feign.api.infrastructure.entity.Dict; import com.xboe.api.ThirdApi; import com.xboe.constants.CacheName; +import com.xboe.module.course.dto.BoeaiSubtitleRsp; +import com.xboe.module.course.utils.HttpUtils; import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.usergroup.service.IUserGroupService; import com.xboe.school.study.dao.StudyCourseDao; @@ -230,6 +234,10 @@ public class StudyCourseApi extends ApiBaseController{ ct.setTeacherName("BOE教师"); } } + for (CourseContent cc : cclist) { + log.info("根据视频信息查询AI字幕数据:cc = " + cc.toString()); + this.getVtt( cid , cc); + } rs.put("isCrowd",pass); rs.put("contents",cclist); @@ -320,6 +328,33 @@ public class StudyCourseApi extends ApiBaseController{ return success(rs); } + public void getVtt(String couirseId, CourseContent cc){ + log.info("------KJB --------- getVtt couirseId = " + couirseId + " videoId = " + cc.getId()); + String url = "http://10.251.186.27:8088/aiVideo/getVideoVtt"; + JSONObject message = new JSONObject(); + message.put("courseId", couirseId); + message.put("videoId", cc.getId()); + String result = HttpUtils.sendMessage(message.toJSONString(), url); + if(StringUtils.isBlank(result)){ + log.error("未获取到AI字幕信息"); + return; + } + //将返回string 转为json对象 + JSONObject jsonObject = JSONObject.parseObject(result); + JSONArray rows = jsonObject.getJSONArray("rows"); + //将json数组转为list对象 + + List boeaiSubtitleRspList = new ArrayList<>(); + //循环json对象 + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + //将json对象转为实体对象 CourseContentVtt + BoeaiSubtitleRsp vtt = row.toJavaObject(BoeaiSubtitleRsp.class); + boeaiSubtitleRspList.add(vtt); + } + + } + /** * 在打开课程详细页面的时候,调用此接口,返回学习课程信息,上次学习的位置。
* 如果没有就返回空