feat(plan): 添加生成学案功能及界面支持
- 新增 AddLessonPlanReqVO 数据模型用于生成学案请求参数封装 - 新增 LessonPlanController 提供生成学案的后端接口,支持异步任务执行 - 新增 LessonPlanDialog 组件,实现前端学案生成弹窗及交互逻辑 - 在班级页面添加生成学案按钮,支持单个学生选择后调用弹窗 - 添加 plan.js 接口调用封装,调用后端生成学案接口 - 完成前后端联动,实现生成学案操作的完整流程和提示信息
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.yinlihupo.enlish.service.controller;
|
||||
|
||||
import com.yinlihupo.enlish.service.model.vo.plan.AddLessonPlanReqVO;
|
||||
import com.yinlihupo.enlish.service.service.LessonPlansService;
|
||||
import com.yinlihupo.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||
import com.yinlihupo.framework.common.response.Response;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@RequestMapping("/plan/")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class LessonPlanController {
|
||||
|
||||
@Resource
|
||||
private LessonPlansService lessonPlanService;
|
||||
|
||||
@Resource(name = "taskExecutor")
|
||||
private Executor taskExecutor;
|
||||
|
||||
@PostMapping("generate")
|
||||
@ApiOperationLog(description = "生成学案")
|
||||
public Response<String> generateLessonPlan(@RequestBody AddLessonPlanReqVO addLessonPlanReqVO) {
|
||||
Integer studentId = addLessonPlanReqVO.getStudentId();
|
||||
Integer unitId = addLessonPlanReqVO.getUnitId();
|
||||
try {
|
||||
taskExecutor.execute(() -> lessonPlanService.generateLessonPlans(studentId, unitId));
|
||||
return Response.success("生成学案成功,请等待 10 分钟");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Response.fail("生成学案失败" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yinlihupo.enlish.service.model.vo.plan;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
public class AddLessonPlanReqVO {
|
||||
|
||||
private Integer studentId;
|
||||
private Integer unitId;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -43,6 +44,7 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void generateLessonPlans(Integer studentId, Integer unitId) {
|
||||
List<VocabularyBankDO> vocabularyBankDOS = vocabularyBankDOMapper.selectVocabularyBankDOAllByUnitId(unitId);
|
||||
UnitDO unitDO = unitDOMapper.selectByPrimaryKey(unitId);
|
||||
|
||||
Reference in New Issue
Block a user