派生自 projectDept/qhighschool

yn147
2023-11-24 26780c533f2c2af6b9216306f649c1bcede94e4a
src/main/java/com/qxueyou/scc/controller/SubjectController.java
@@ -1,10 +1,15 @@
package com.qxueyou.scc.controller;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.qxueyou.scc.base.util.DateUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -39,6 +44,8 @@
@RestController
@RequestMapping(value = "/teach/subject")
public class SubjectController {
   private final Logger log = LogManager.getLogger(SubjectController.class);
   @Autowired
   ISubjectService subjectService;
@@ -93,7 +100,9 @@
   @GetMapping(value = "/list")
   public Result list(String keyword,String status,Integer type, Integer limit, Integer pageNum) {
      String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId();
//      String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId();
      //判断是否是教师
      String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId());
      List<Subject> lst = subjectService.list(keyword, teacherId, status, type, limit, pageNum);
@@ -101,7 +110,7 @@
      return new Result(true, "success", CollectionUtils.newObjectMap("subjectLst",
            QBeanUtils.listBean2ListMap(lst,
                  CollectionUtils.newStringMap("name", "subjectName", "subjectId", "subjectId","type","type", "status",
                  CollectionUtils.newStringMap("name", "subjectName", "subjectId", "subjectId","type","type","startTime","startTime","endTime","endTime", "status",
                        "status", "updateTime", "updateTime", "lectureCount", "lectureCount")),
            "subjectCount", count));
@@ -175,8 +184,8 @@
    *            课程介绍
    */
   @PostMapping(value = "/copy")
   public Result copy(String subjectId, String subjectName, String imgPath, String content,int type) {
      return add(subjectName, imgPath, content,type);
   public Result copy(String subjectId, String subjectName, String imgPath, String content,int type,String startTime,String endTime) {
      return add(subjectName, imgPath, content,type,startTime,endTime);
   }
   /**
@@ -191,7 +200,7 @@
    * @return
    */
   @PostMapping(value = "/add")
   public Result add(String subjectName, String imgPath, String content,int type) {
   public Result add(String subjectName, String imgPath, String content, int type, String startTime, String endTime) {
      String contentFileId = null;
      
      if(StringUtils.isNotEmpty(content)){
@@ -204,8 +213,12 @@
      if (StringUtils.isNotBlank(imgPath)) {
         coverPageFileId = fileService.readIdByPath(imgPath);
      }
      return subjectService.add(subjectName, coverPageFileId,contentFileId,type);
      try {
         return subjectService.add(subjectName, coverPageFileId,contentFileId,type, DateUtils.convertStringToDate(startTime),DateUtils.convertStringToDate(endTime));
      }catch (ParseException e) {
         log.error(e, e);
         return new Result(false, "日期参数错误");
      }
   }
   /**