diff --git a/.DS_Store b/.DS_Store index 8538cae..356b912 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Server/ArtEducation0331/WebContent/jsp/tm-postCourse.jsp b/Server/ArtEducation0331/WebContent/jsp/tm-postCourse.jsp new file mode 100644 index 0000000..b79a9ad --- /dev/null +++ b/Server/ArtEducation0331/WebContent/jsp/tm-postCourse.jsp @@ -0,0 +1,80 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + +教师发布课程 + + +
+

以下内容全部必填

+
+ +
+ + +
+
+ + +
+
+
+

选择时间

+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/Server/ArtEducation0331/build/classes/.gitignore b/Server/ArtEducation0331/build/classes/.gitignore index 1204122..0320912 100644 --- a/Server/ArtEducation0331/build/classes/.gitignore +++ b/Server/ArtEducation0331/build/classes/.gitignore @@ -1,6 +1,2 @@ /cn/ -/db.properties -/log4j.properties -/mybatis/ /spring/ -/tools/ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/controller/TeacherController.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/controller/TeacherController.class index f155afb..3b1f0d1 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/controller/TeacherController.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/controller/TeacherController.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.class index 8334535..bc1128e 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.xml b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.xml index 7c37679..22759aa 100644 --- a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.xml +++ b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/mapper/TeacherMapper.xml @@ -49,7 +49,27 @@ values(null,#{teacherCode},#{teacherName},#{password},#{email},#{headPortraits},#{realName},#{gender},#{teacherAge},#{preference},#{phone},#{seniority},#{organizationId},#{education},#{description},2001,#{idNumber},#{teacherType},#{idPic},#{diplomaPic},#{masterDiplomaPic}) - + + + SELECT LAST_INSERT_ID() + + insert into t_course(courseCode,courseTypeId,teacherId,courseName,courseDesc,teachTime,totalStarLevel,teachAddress, + lessonNum,teachMethod,listenTest,coursePrice,mainImage,planStuNum,realStuNum,courseStatus) value(#{courseCode},#{courseTypeId}, + #{teacherId},#{courseName},#{courseDesc},#{teachTime},#{totalStarLevel},#{teachAddress}, + #{lessonNum},#{teachMethod},#{listenTest},#{coursePrice},#{mainImage},#{planStuNum},#{realStuNum},#{courseStatus}) + + + + + + update t_course set courseStatus = 1007 where courseId = #{courseId} + + + diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/Course.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/Course.class index d29ba4f..00d3ac6 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/Course.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/Course.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/CourseCustom.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/CourseCustom.class index 6f4d707..23fc0dc 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/CourseCustom.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/po/CourseCustom.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/TeacherService.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/TeacherService.class index 604289c..b1331af 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/TeacherService.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/TeacherService.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/CourseServiceImpl.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/CourseServiceImpl.class index f0d30cd..db9b60b 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/CourseServiceImpl.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/CourseServiceImpl.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/TeacherServiceImpl.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/TeacherServiceImpl.class index 95ea9f9..b94bca6 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/TeacherServiceImpl.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/service/impl/TeacherServiceImpl.class differ diff --git a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/view/CourseDetailView.class b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/view/CourseDetailView.class index 7d26047..71abfba 100644 Binary files a/Server/ArtEducation0331/build/classes/cn/itcast/ssm/view/CourseDetailView.class and b/Server/ArtEducation0331/build/classes/cn/itcast/ssm/view/CourseDetailView.class differ diff --git a/Server/ArtEducation0331/build/classes/spring/applicationContext-service.xml b/Server/ArtEducation0331/build/classes/spring/applicationContext-service.xml index 606fae0..353620a 100644 --- a/Server/ArtEducation0331/build/classes/spring/applicationContext-service.xml +++ b/Server/ArtEducation0331/build/classes/spring/applicationContext-service.xml @@ -18,5 +18,6 @@ + \ No newline at end of file diff --git a/Server/ArtEducation0331/config/spring/applicationContext-service.xml b/Server/ArtEducation0331/config/spring/applicationContext-service.xml index 606fae0..353620a 100644 --- a/Server/ArtEducation0331/config/spring/applicationContext-service.xml +++ b/Server/ArtEducation0331/config/spring/applicationContext-service.xml @@ -18,5 +18,6 @@ + \ No newline at end of file diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/controller/TeacherController.java b/Server/ArtEducation0331/src/cn/itcast/ssm/controller/TeacherController.java index bd4f528..ca5a192 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/controller/TeacherController.java +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/controller/TeacherController.java @@ -21,7 +21,9 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import cn.itcast.ssm.po.TeacherCustom; +import cn.itcast.ssm.po.CourseCustom; import cn.itcast.ssm.po.Teacher; +import cn.itcast.ssm.service.FileService; import cn.itcast.ssm.service.TeacherService; import cn.itcast.ssm.view.TeacherCoursesView; import cn.itcast.ssm.view.TeacherDiplomaInfoView; @@ -33,6 +35,9 @@ public class TeacherController { @Autowired private TeacherService teacherService; + @Autowired + private FileService fileService; + // 教师登录 @RequestMapping(value="/login.action",method=RequestMethod.POST) public String login(HttpServletRequest request,HttpSession session){ @@ -58,6 +63,7 @@ public String login(HttpServletRequest request,HttpSession session){ TeacherCustom tc=teacherService.findTeacherById(teacherId); List teacherCoursesViews=teacherService.findTeacherCourses(teacherId); session.setAttribute("teacherCustom", tc); + session.setAttribute("teacherId", teacherId); session.setAttribute("teacherCoursesViews", teacherCoursesViews); return "redirect:/jsp/teacher/tm.jsp"; } @@ -225,7 +231,66 @@ private String savePic(MultipartFile file ,String rootPath ) } + //发布课程 + @RequestMapping(value="/publishCourse.action",method=RequestMethod.POST) + public String publishCourse(CourseCustom cc,String courseStartTime, + String courseEndTime,String classTime,Integer teacherId,MultipartFile mainImageFile, + Model model) throws IllegalStateException, IOException{ + System.out.println("------->"+cc.getCourseName()); + System.out.println("------->"+courseStartTime); +// 存储图片的物理路径 + String pic_path="/Users/hardor/Desktop/picture/"; + String teachTime = courseStartTime + "-" + courseEndTime + "-" + classTime; + cc.setTeachTime(teachTime); + cc.setTeacherId(teacherId); +// 图片的原始名称 + String mainImageName = mainImageFile.getOriginalFilename(); + if(mainImageFile != null && mainImageName != null){ +// 新的图片名称 + String newMainImageName = UUID.randomUUID() + mainImageName.substring(mainImageName.lastIndexOf('.')); +// 新图片 + File newFile = new File(pic_path + newMainImageName); +// 将内存中的数据写入磁盘 + mainImageFile.transferTo(newFile); + + fileService.insertFile(newMainImageName, newFile); + + cc.setMainImage(newMainImageName); + } + + Integer courseId = teacherService.insertCourse(cc); + + model.addAttribute("courseId", courseId); + + return ""; + } + + //查询历史课程 + @RequestMapping(value="/queryHistoryCourse.action",method=RequestMethod.GET) + public String queryHistoryCourse(Integer teacherId,Integer courseStatus,Model model) throws Exception{ + List ccList = teacherService.findHisCourseByTIdAndStatus(teacherId, courseStatus); + model.addAttribute("courseList", ccList); + return ""; + } + + //查询课程 + @RequestMapping(value="/queryCourse.action",method=RequestMethod.GET) + public String queryCourse(Integer teacherId,Model model){ + List ccList = teacherService.findCourseByTeacherId(teacherId); + model.addAttribute("courseList", ccList); + return ""; + } + //删除课程 + @RequestMapping(value="/deleteCourse.action",method=RequestMethod.GET) + public String deleteCourse(Integer courseId,HttpSession session){ + teacherService.deleteCourseBycourseId(courseId); + Integer teacherId = (Integer)session.getAttribute("teacherId"); + if(teacherId == null){ + teacherId = 1; + } + return "forward:queryCourse.action?teacherId="+teacherId; + } } diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.java b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.java new file mode 100644 index 0000000..6acae31 --- /dev/null +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.java @@ -0,0 +1,7 @@ +package cn.itcast.ssm.mapper; + +import cn.itcast.ssm.po.File; + +public interface FileMapper { + public Integer insertFile(File file) throws Exception; +} diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.xml b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.xml new file mode 100644 index 0000000..50824d9 --- /dev/null +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.xml @@ -0,0 +1,10 @@ + + + + + + SELECT LAST_INSERT_ID() + + insert into t_file(fileName,fileSize,fileType,filePath,date) value(#{fileName},#{fileSize},#{fileType},#{filePath},#{date}) + + \ No newline at end of file diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.java b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.java index e0b62ef..15b2a8f 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.java +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.java @@ -2,6 +2,7 @@ import java.util.List; +import cn.itcast.ssm.po.CourseCustom; import cn.itcast.ssm.po.Teacher; import cn.itcast.ssm.po.TeacherCourses; import cn.itcast.ssm.po.TeacherCustom; @@ -28,6 +29,16 @@ public interface TeacherMapper { public Integer insertTeacher(Teacher teacher); +// 教师发布课程 + public Integer insertCourse(CourseCustom cc) throws Exception; +// 根据教师id和课程状态查询历史课程 + public List findHistoryCourseByTeacherId(CourseCustom cc) throws Exception; + +// 根据课程id删除课程,只是逻辑删除,在数据库中修改课程状态为1007 + public Integer deleteCourseBycourseId(Integer courseId) throws Exception; + +// 根据课程id查询课程 + public List findCourseByTeacherId(Integer courseId) throws Exception; } diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.xml b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.xml index 7c37679..22759aa 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.xml +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/mapper/TeacherMapper.xml @@ -49,7 +49,27 @@ values(null,#{teacherCode},#{teacherName},#{password},#{email},#{headPortraits},#{realName},#{gender},#{teacherAge},#{preference},#{phone},#{seniority},#{organizationId},#{education},#{description},2001,#{idNumber},#{teacherType},#{idPic},#{diplomaPic},#{masterDiplomaPic}) - + + + SELECT LAST_INSERT_ID() + + insert into t_course(courseCode,courseTypeId,teacherId,courseName,courseDesc,teachTime,totalStarLevel,teachAddress, + lessonNum,teachMethod,listenTest,coursePrice,mainImage,planStuNum,realStuNum,courseStatus) value(#{courseCode},#{courseTypeId}, + #{teacherId},#{courseName},#{courseDesc},#{teachTime},#{totalStarLevel},#{teachAddress}, + #{lessonNum},#{teachMethod},#{listenTest},#{coursePrice},#{mainImage},#{planStuNum},#{realStuNum},#{courseStatus}) + + + + + + update t_course set courseStatus = 1007 where courseId = #{courseId} + + + diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/po/Course.java b/Server/ArtEducation0331/src/cn/itcast/ssm/po/Course.java index 684c922..8895853 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/po/Course.java +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/po/Course.java @@ -35,7 +35,7 @@ public class Course { private Integer realStuNum; - private String courseStatus; + private Integer courseStatus; private String discountUseInfo; @@ -167,15 +167,15 @@ public void setRealStuNum(Integer realStuNum) { this.realStuNum = realStuNum; } - public String getCourseStatus() { - return courseStatus; - } + public Integer getCourseStatus() { + return courseStatus; + } - public void setCourseStatus(String courseStatus) { - this.courseStatus = courseStatus; - } + public void setCourseStatus(Integer courseStatus) { + this.courseStatus = courseStatus; + } - public String getDiscountUseInfo() { + public String getDiscountUseInfo() { return discountUseInfo; } diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/po/FileCustom.java b/Server/ArtEducation0331/src/cn/itcast/ssm/po/FileCustom.java new file mode 100644 index 0000000..71397c9 --- /dev/null +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/po/FileCustom.java @@ -0,0 +1,5 @@ +package cn.itcast.ssm.po; + +public class FileCustom extends File{ + +} diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/service/FileService.java b/Server/ArtEducation0331/src/cn/itcast/ssm/service/FileService.java new file mode 100644 index 0000000..bac9565 --- /dev/null +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/service/FileService.java @@ -0,0 +1,7 @@ +package cn.itcast.ssm.service; + +import java.io.File; + +public interface FileService { + public Integer insertFile(String fileName,File file); +} diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/service/TeacherService.java b/Server/ArtEducation0331/src/cn/itcast/ssm/service/TeacherService.java index c6ebe42..2f7565b 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/service/TeacherService.java +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/service/TeacherService.java @@ -2,6 +2,7 @@ import java.util.List; +import cn.itcast.ssm.po.CourseCustom; import cn.itcast.ssm.po.Teacher; import cn.itcast.ssm.po.TeacherCourses; import cn.itcast.ssm.po.TeacherCustom; @@ -32,4 +33,16 @@ public interface TeacherService { public String editTeacherInfo(TeacherCustom teacherCustom); public String register(Teacher teacher); + +// 发布课程 + public Integer insertCourse(CourseCustom cc); + +// 根据教师id和课程状态查询历史课程 + public List findHisCourseByTIdAndStatus(Integer teacherId,Integer courseStatus) throws Exception; + +// 根据课程id删除课程,只是逻辑删除,在数据库中修改课程状态为1007 + public Integer deleteCourseBycourseId(Integer courseId); + +// 根据课程id查询课程 + public List findCourseByTeacherId(Integer courseId); } diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/FileServiceImpl.java b/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/FileServiceImpl.java new file mode 100644 index 0000000..3ac7d8a --- /dev/null +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/FileServiceImpl.java @@ -0,0 +1,36 @@ +package cn.itcast.ssm.service.impl; + +import java.util.Date; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; + +import cn.itcast.ssm.mapper.FileMapper; +import cn.itcast.ssm.po.File; +import cn.itcast.ssm.service.FileService; + +public class FileServiceImpl implements FileService{ + + @Autowired + private FileMapper fileMapper; + + @Override + public Integer insertFile(String fileName, java.io.File file) { + // TODO Auto-generated method stub + Integer fileId = 0; + File newFile = new File(); + newFile.setFileName(fileName); + newFile.setFileSize((int)file.length()); + newFile.setFileType(fileName.substring(fileName.lastIndexOf("."))); + newFile.setDate(new Date()); + newFile.setFilePath(""); + try { + fileId = fileMapper.insertFile(newFile); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return fileId; + } + +} diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/TeacherServiceImpl.java b/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/TeacherServiceImpl.java index b79f0f8..29ef621 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/TeacherServiceImpl.java +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/service/impl/TeacherServiceImpl.java @@ -1,11 +1,13 @@ package cn.itcast.ssm.service.impl; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import cn.itcast.ssm.mapper.TeacherMapper; +import cn.itcast.ssm.po.CourseCustom; import cn.itcast.ssm.po.Teacher; import cn.itcast.ssm.po.TeacherCourses; import cn.itcast.ssm.po.TeacherCustom; @@ -173,6 +175,62 @@ public String register(Teacher teacher) { } + + @Override + public Integer insertCourse(CourseCustom cc) { + // TODO Auto-generated method stub + Integer courseId = 0; + cc.setCourseCode(""); + cc.setCourseStatus(1001); + cc.setRealStuNum(0); + cc.setTotalStarLevel("0"); + cc.setCourseTypeId(1); + try { + courseId = teacherMapper.insertCourse(cc); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return courseId; + } + + @Override + public List findHisCourseByTIdAndStatus(Integer teacherId, Integer courseStatus) throws Exception { + // TODO Auto-generated method stub + CourseCustom cc = new CourseCustom(); + cc.setTeacherId(teacherId); + cc.setCourseStatus(courseStatus); + List ccList = new LinkedList<>(); + ccList = teacherMapper.findHistoryCourseByTeacherId(cc); + return ccList; + } + + @Override + public Integer deleteCourseBycourseId(Integer courseId) { + // TODO Auto-generated method stub + Integer newCourseId = 0; + try { + newCourseId = teacherMapper.deleteCourseBycourseId(courseId); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCourseId; + } + + @Override + public List findCourseByTeacherId(Integer courseId) { + // TODO Auto-generated method stub + List ccList = new LinkedList<>(); + try { + ccList = teacherMapper.findCourseByTeacherId(courseId); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ccList; + } + } diff --git a/Server/ArtEducation0331/src/cn/itcast/ssm/view/CourseDetailView.java b/Server/ArtEducation0331/src/cn/itcast/ssm/view/CourseDetailView.java index 901671c..e108414 100644 --- a/Server/ArtEducation0331/src/cn/itcast/ssm/view/CourseDetailView.java +++ b/Server/ArtEducation0331/src/cn/itcast/ssm/view/CourseDetailView.java @@ -8,7 +8,7 @@ public class CourseDetailView { private String teacherName; private String mainImage; private String courseDesc; - private String courseStatus; + private Integer courseStatus; private String education; private Integer seniority; private String description; @@ -46,11 +46,11 @@ public String getCourseDesc() { } public void setCourseDesc(String courseDesc) { this.courseDesc = courseDesc; - } - public String getCourseStatus() { + } + public Integer getCourseStatus() { return courseStatus; } - public void setCourseStatus(String courseStatus) { + public void setCourseStatus(Integer courseStatus) { this.courseStatus = courseStatus; } public String getEducation() {