From 26780c533f2c2af6b9216306f649c1bcede94e4a Mon Sep 17 00:00:00 2001 From: yn147 <2270338776@qq.com> Date: 星期五, 24 十一月 2023 16:43:37 +0800 Subject: [PATCH] 学生、课程 --- src/main/java/com/qxueyou/scc/controller/SubjectController.java | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/controller/SubjectController.java b/src/main/java/com/qxueyou/scc/controller/SubjectController.java index 55a6fbe..63a1f46 100644 --- a/src/main/java/com/qxueyou/scc/controller/SubjectController.java +++ b/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; @@ -103,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)); @@ -193,7 +200,7 @@ * @return */ @PostMapping(value = "/add") - public Result add(String subjectName, String imgPath, String content,int type,String startTime,String endTime) { + public Result add(String subjectName, String imgPath, String content, int type, String startTime, String endTime) { String contentFileId = null; if(StringUtils.isNotEmpty(content)){ @@ -206,8 +213,12 @@ if (StringUtils.isNotBlank(imgPath)) { coverPageFileId = fileService.readIdByPath(imgPath); } - - return subjectService.add(subjectName, coverPageFileId,contentFileId,type,startTime,endTime); + 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, "鏃ユ湡鍙傛暟閿欒"); + } } /** -- Gitblit v1.8.0