| | |
| | | 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; |
| | |
| | | @RestController |
| | | @RequestMapping(value = "/teach/subject") |
| | | public class SubjectController { |
| | | |
| | | private final Logger log = LogManager.getLogger(SubjectController.class); |
| | | |
| | | @Autowired |
| | | ISubjectService subjectService; |
| | |
| | | @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); |
| | | |
| | |
| | | |
| | | 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)); |
| | |
| | | * 课程介绍 |
| | | */ |
| | | @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); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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)){ |
| | |
| | | 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, "日期参数错误"); |
| | | } |
| | | } |
| | | |
| | | /** |