Skip to content
Open

1 #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
80 changes: 80 additions & 0 deletions Server/ArtEducation0331/WebContent/jsp/tm-postCourse.jsp
Original file line number Diff line number Diff line change
@@ -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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>教师发布课程</title>
</head>
<body>
<div class="col-md-6">
<p class="bg-warning">以下内容全部必填</p>
<form action="/ArtEducation/teacher/publishCourse.action" method="post" enctype="multipart/form-data">
<input type="hidden" name="teacherId" value="1" />
<div class="form-group">
<label for="courseName">课程名称</label>
<input type="text" class="form-control" name="courseName" id="courseName" required>
</div>
<div class="form-group">
<label for="courseDesc">课程描述</label>
<textarea class="form-control" name="courseDesc" id="courseDesc" cols="30" rows="10" required></textarea>
</div>
<div class="row">
<div class="col-md-4">
<p style="font-weight: bold;font-size: 20px;margin-top: 50px;">选择时间</p>
</div>
<div class="col-md-8">
<div class="form-group">
<label for="courseStartTime">课程开始时间</label>
<input type="text" name="courseStartTime" id="courseStartTime" ui-date required/>
</div>
<div class="form-group">
<label for="courseEndTime">课程结束时间</label>
<input type="text" name="courseEndTime" id="courseEndTime" ui-date required/>
</div>
<div class="form-group">
<label for="classTime">每周上课时间</label>
<input type="text" name="classTime" id="classTime" required/>
</div>
</div>
</div>
<div class="form-group">
<label for="teachAddress">上课地点</label>
<input type="text" class="form-control" name="teachAddress" id="teachAddress" required>
</div>
<div class="form-group">
<label for="lessonNum">课时数</label>
<input type="text" class="form-control" name="lessonNum" id="lessonNum" required>
</div>
<div class="form-group">
<label for="teachMethod">授课方式</label>
<select name="teachMethod" id="teachMethod" class="form-control" required>
<option value="2001" selected>上门授课</option>
<option value="2002">机构教室</option>
</select>
</div>
<div class="form-group">
<label for="teachMethod">是否支持试听</label>
<select name="listenTest" id="listenTest" class="form-control" required>
<option value="3001" selected>不支持试听</option>
<option value="3002">支持试听</option>
</select>
</div>
<div class="form-group">
<label for="coursePrice">课程价格(元)</label>
<input type="text" class="form-control" name="coursePrice" id="coursePrice" required>
</div>
<div class="form-group">
<label for="mainImage">一张与课程相关的图片</label>
<img src="" alt="" style="display: block;margin: 5px;">
<input type="file" name="mainImageFile" id="mainImage" required>
</div>
<div class="form-group">
<label for="planStuNum">计划招生人数</label>
<input type="text" class="form-control" name="planStuNum" id="planStuNum" required>
</div>
<button class="btn btn-danger" type="submit">创建课程</button>
</form>
</div>
</body>
</html>
4 changes: 0 additions & 4 deletions Server/ArtEducation0331/build/classes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
/cn/
/db.properties
/log4j.properties
/mybatis/
/spring/
/tools/
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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})
</insert>


<insert id="insertCourse" parameterType="courseCustom">
<selectKey keyProperty="courseId" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
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})
</insert>

<select id="findHistoryCourseByTeacherId" parameterType="courseCustom" resultType="courseCustom">
select * from t_course where teacherId = #{teacherId} and courseStatus = #{courseStatus};
</select>

<update id="deleteCourseBycourseId" parameterType="java.lang.Integer">
update t_course set courseStatus = 1007 where courseId = #{courseId}
</update>

<select id="findCourseByTeacherId" parameterType="java.lang.Integer" resultType="courseCustom">
select * from t_course where teacherId = #{teacherId}
</select>

</mapper>

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<bean id="teacherService" class="cn.itcast.ssm.service.impl.TeacherServiceImpl"/>
<bean id="organizationService" class="cn.itcast.ssm.service.impl.OrganizationServiceImpl"/>
<bean id="courseService" class="cn.itcast.ssm.service.impl.CourseServiceImpl"/>
<bean id="fileService" class="cn.itcast.ssm.service.impl.FileServiceImpl"/>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<bean id="teacherService" class="cn.itcast.ssm.service.impl.TeacherServiceImpl"/>
<bean id="organizationService" class="cn.itcast.ssm.service.impl.OrganizationServiceImpl"/>
<bean id="courseService" class="cn.itcast.ssm.service.impl.CourseServiceImpl"/>
<bean id="fileService" class="cn.itcast.ssm.service.impl.FileServiceImpl"/>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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){
Expand All @@ -58,6 +63,7 @@ public String login(HttpServletRequest request,HttpSession session){
TeacherCustom tc=teacherService.findTeacherById(teacherId);
List<TeacherCoursesView> teacherCoursesViews=teacherService.findTeacherCourses(teacherId);
session.setAttribute("teacherCustom", tc);
session.setAttribute("teacherId", teacherId);
session.setAttribute("teacherCoursesViews", teacherCoursesViews);
return "redirect:/jsp/teacher/tm.jsp";
}
Expand Down Expand Up @@ -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<CourseCustom> 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<CourseCustom> 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;
}


}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 10 additions & 0 deletions Server/ArtEducation0331/src/cn/itcast/ssm/mapper/FileMapper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.itcast.ssm.mapper.FileMapper" >
<insert id="insertFile" parameterType="fileCustom">
<selectKey keyProperty="fileId" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into t_file(fileName,fileSize,fileType,filePath,date) value(#{fileName},#{fileSize},#{fileType},#{filePath},#{date})
</insert>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +29,16 @@ public interface TeacherMapper {

public Integer insertTeacher(Teacher teacher);

// 教师发布课程
public Integer insertCourse(CourseCustom cc) throws Exception;

// 根据教师id和课程状态查询历史课程
public List<CourseCustom> findHistoryCourseByTeacherId(CourseCustom cc) throws Exception;

// 根据课程id删除课程,只是逻辑删除,在数据库中修改课程状态为1007
public Integer deleteCourseBycourseId(Integer courseId) throws Exception;

// 根据课程id查询课程
public List<CourseCustom> findCourseByTeacherId(Integer courseId) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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})
</insert>


<insert id="insertCourse" parameterType="courseCustom">
<selectKey keyProperty="courseId" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
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})
</insert>

<select id="findHistoryCourseByTeacherId" parameterType="courseCustom" resultType="courseCustom">
select * from t_course where teacherId = #{teacherId} and courseStatus = #{courseStatus};
</select>

<update id="deleteCourseBycourseId" parameterType="java.lang.Integer">
update t_course set courseStatus = 1007 where courseId = #{courseId}
</update>

<select id="findCourseByTeacherId" parameterType="java.lang.Integer" resultType="courseCustom">
select * from t_course where teacherId = #{teacherId}
</select>

</mapper>

Expand Down
16 changes: 8 additions & 8 deletions Server/ArtEducation0331/src/cn/itcast/ssm/po/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Course {

private Integer realStuNum;

private String courseStatus;
private Integer courseStatus;

private String discountUseInfo;

Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions Server/ArtEducation0331/src/cn/itcast/ssm/po/FileCustom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cn.itcast.ssm.po;

public class FileCustom extends File{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cn.itcast.ssm.service;

import java.io.File;

public interface FileService {
public Integer insertFile(String fileName,File file);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CourseCustom> findHisCourseByTIdAndStatus(Integer teacherId,Integer courseStatus) throws Exception;

// 根据课程id删除课程,只是逻辑删除,在数据库中修改课程状态为1007
public Integer deleteCourseBycourseId(Integer courseId);

// 根据课程id查询课程
public List<CourseCustom> findCourseByTeacherId(Integer courseId);
}
Loading