Parcourir la source

Merge remote-tracking branch 'origin/master'

周箭河 il y a 5 ans
Parent
commit
29973ab0bf

+ 4 - 3
mec-common/common-core/src/main/java/com/ym/mec/common/service/BaseService.java

@@ -7,13 +7,14 @@ package com.ym.mec.common.service;
  * @author pengdc
  * @create 2015年7月13日
  */
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
+
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
-import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.QueryInfo;
-
 public interface BaseService<PK extends Serializable, T> {
 	/**
 	 * 通过主键id获取对象

+ 6 - 6
mec-common/common-core/src/main/java/com/ym/mec/common/service/impl/BaseServiceImpl.java

@@ -7,18 +7,18 @@ package com.ym.mec.common.service.impl;
  * @author pengdc
  * @create 2015年7月13日
  */
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.util.collection.MapUtil;
 
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * SERVICE操作基类
  * @param <PK>

+ 33 - 0
mec-web/src/main/java/com/ym/mec/web/controller/CourseHomeworkController.java

@@ -0,0 +1,33 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.web.dal.page.CourseHomeworkQueryInfo;
+import com.ym.mec.web.service.CourseHomeworkService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author Joburgess
+ * @Date 2019/9/18
+ */
+@RequestMapping("courseHomework")
+@Api(tags = "课后作业")
+@RestController
+public class CourseHomeworkController extends BaseController {
+
+    @Autowired
+    private CourseHomeworkService courseHomeworkService;
+
+    @ApiOperation(value = "分页查询作业列表")
+    @PostMapping(value = "/queryPage",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public Object queryPage(@RequestBody CourseHomeworkQueryInfo queryInfo){
+        return succeed(courseHomeworkService.queryPage(queryInfo));
+    }
+
+}

+ 46 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentCourseHomeworkController.java

@@ -0,0 +1,46 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.web.dal.entity.StudentCourseHomework;
+import com.ym.mec.web.service.StudentCourseHomeworkService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+
+/**
+ * @Author Joburgess
+ * @Date 2019/9/18
+ */
+@RequestMapping("studentCourseHomework")
+@Api(tags = "学生作业")
+@RestController
+public class StudentCourseHomeworkController extends BaseController {
+
+    @Autowired
+    private StudentCourseHomeworkService studentCourseHomeworkService;
+
+    @ApiOperation(value = "提交作业")
+    @PostMapping(value = "/add",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public Object add(@RequestBody StudentCourseHomework studentCourseHomework){
+        studentCourseHomeworkService.insert(studentCourseHomework);
+        return succeed();
+    }
+
+    @ApiOperation(value = "重新提交")
+    @PutMapping(value = "/update",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public Object update(@RequestBody StudentCourseHomework studentCourseHomework){
+        studentCourseHomeworkService.update(studentCourseHomework);
+        return succeed();
+    }
+
+    @ApiOperation(value = "获取学生作业界面详细信息")
+    @GetMapping(value = "/findCourseHomeworkStudentDetail/{courseScheduleID}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public Object findCourseHomeworkStudentDetail(@PathVariable("courseScheduleID") Long courseScheduleID) throws IOException {
+        return succeed(studentCourseHomeworkService.findCourseHomeworkStudentDetail(courseScheduleID));
+    }
+
+}

+ 10 - 0
mec-web/src/main/java/com/ym/mec/web/dal/dao/StudentAttendanceDao.java

@@ -5,6 +5,7 @@ import com.ym.mec.web.dal.dto.StudentPersonalAttendanceDto;
 import com.ym.mec.web.dal.dto.StudentStatusCountUtilEntity;
 import com.ym.mec.web.dal.entity.StudentAttendance;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 import java.util.Map;
@@ -45,4 +46,13 @@ public interface StudentAttendanceDao extends BaseDAO<Long, StudentAttendance> {
      * 获取学生个人上课签到记录统计
      */
     int queryStudentPersonalAttendancesCount(Map<String,Object> params);
+
+
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/18
+     * 统计正常签到的学生数量
+     */
+    @Select("SELECT COUNT(*) FROM student_attendance WHERE class_group_id_=#{classGroupID} AND status_=\"NORMAL\"")
+    int countNormalAttendanceStudentNums(Long classGroupID);
 }

+ 18 - 0
mec-web/src/main/java/com/ym/mec/web/dal/dao/StudentCourseHomeworkDao.java

@@ -1,9 +1,27 @@
 package com.ym.mec.web.dal.dao;
 
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.web.dal.dto.CourseHomeworkStudentDetailDto;
 import com.ym.mec.web.dal.entity.StudentCourseHomework;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 public interface StudentCourseHomeworkDao extends BaseDAO<Long, StudentCourseHomework> {
 
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/18
+     * 统计已提交作业的人数
+     */
+    @Select("SELECT COUNT(*) FROM student_course_homework WHERE course_homework_id_=#{courseHomeworkID} FOR UPDATE")
+    int countCompletedStudentNum(Long courseHomeworkID);
+
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/18
+     * 获取学生作业界面详细信息
+     */
+    CourseHomeworkStudentDetailDto findCourseHomeworkStudentDetail(@Param("courseScheduleID") Long courseScheduleID,
+                                                                   @Param("userID") Long userID);
 	
 }

+ 111 - 0
mec-web/src/main/java/com/ym/mec/web/dal/dto/CourseHomeworkStudentDetailDto.java

@@ -0,0 +1,111 @@
+package com.ym.mec.web.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2019/9/18
+ */
+public class CourseHomeworkStudentDetailDto {
+
+    @ApiModelProperty(value = "乐团名称",required = false)
+    private String musicGroupName;
+
+    @ApiModelProperty(value = "班级名称",required = false)
+    private String classGroupName;
+
+    @ApiModelProperty(value = "作业ID",required = false)
+    private Long courseHomeworkId;
+
+    @ApiModelProperty(value = "作业内容",required = false)
+    private String content;
+
+    @ApiModelProperty(value = "截至日期",required = false)
+    private Date expiryDate;
+
+    @ApiModelProperty(value = "已完成人数",required = false)
+    private Integer completedNum;
+
+    @ApiModelProperty(value = "预计完成人数",required = false)
+    private Integer expectNum;
+
+    @ApiModelProperty(value = "学生作业文件链接",required = false)
+    private String attachments;
+
+    @ApiModelProperty(value = "学生作业评分",required = false)
+    private Long score;
+
+    public String getMusicGroupName() {
+        return musicGroupName;
+    }
+
+    public void setMusicGroupName(String musicGroupName) {
+        this.musicGroupName = musicGroupName;
+    }
+
+    public String getClassGroupName() {
+        return classGroupName;
+    }
+
+    public void setClassGroupName(String classGroupName) {
+        this.classGroupName = classGroupName;
+    }
+
+    public Long getCourseHomeworkId() {
+        return courseHomeworkId;
+    }
+
+    public void setCourseHomeworkId(Long courseHomeworkId) {
+        this.courseHomeworkId = courseHomeworkId;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Date getExpiryDate() {
+        return expiryDate;
+    }
+
+    public void setExpiryDate(Date expiryDate) {
+        this.expiryDate = expiryDate;
+    }
+
+    public Integer getCompletedNum() {
+        return completedNum;
+    }
+
+    public void setCompletedNum(Integer completedNum) {
+        this.completedNum = completedNum;
+    }
+
+    public Integer getExpectNum() {
+        return expectNum;
+    }
+
+    public void setExpectNum(Integer expectNum) {
+        this.expectNum = expectNum;
+    }
+
+    public String getAttachments() {
+        return attachments;
+    }
+
+    public void setAttachments(String attachments) {
+        this.attachments = attachments;
+    }
+
+    public Long getScore() {
+        return score;
+    }
+
+    public void setScore(Long score) {
+        this.score = score;
+    }
+}

+ 24 - 1
mec-web/src/main/java/com/ym/mec/web/dal/entity/CourseHomework.java

@@ -1,5 +1,6 @@
 package com.ym.mec.web.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -30,7 +31,29 @@ public class CourseHomework {
 	
 	/**  */
 	private Integer classGroupId;
-	
+
+	@ApiModelProperty(value = "作业完成人数",required = false)
+	private Integer completedNum;
+
+	@ApiModelProperty(value = "预计完成人数",required = false)
+	private Integer expectNum;
+
+	public Integer getCompletedNum() {
+		return completedNum;
+	}
+
+	public void setCompletedNum(Integer completedNum) {
+		this.completedNum = completedNum;
+	}
+
+	public Integer getExpectNum() {
+		return expectNum;
+	}
+
+	public void setExpectNum(Integer expectNum) {
+		this.expectNum = expectNum;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 13 - 1
mec-web/src/main/java/com/ym/mec/web/dal/entity/StudentCourseHomework.java

@@ -1,5 +1,6 @@
 package com.ym.mec.web.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -9,6 +10,9 @@ public class StudentCourseHomework {
 
 	/**  */
 	private Long id;
+
+	@ApiModelProperty(value = "学生ID",required = false)
+	private Long userId;
 	
 	/**  */
 	private Long courseHomeworkId;
@@ -32,7 +36,15 @@ public class StudentCourseHomework {
 	public Long getId(){
 		return this.id;
 	}
-			
+
+	public Long getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Long userId) {
+		this.userId = userId;
+	}
+
 	public void setCourseHomeworkId(Long courseHomeworkId){
 		this.courseHomeworkId = courseHomeworkId;
 	}

+ 24 - 0
mec-web/src/main/java/com/ym/mec/web/dal/page/CourseHomeworkQueryInfo.java

@@ -0,0 +1,24 @@
+package com.ym.mec.web.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2019/9/18
+ */
+public class CourseHomeworkQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "作业发布时间",required = false)
+    private java.util.Date createTime;
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 10 - 0
mec-web/src/main/java/com/ym/mec/web/service/StudentCourseHomeworkService.java

@@ -1,8 +1,18 @@
 package com.ym.mec.web.service;
 
 import com.ym.mec.common.service.BaseService;
+import com.ym.mec.web.dal.dto.CourseHomeworkStudentDetailDto;
 import com.ym.mec.web.dal.entity.StudentCourseHomework;
 
+import java.io.IOException;
+
 public interface StudentCourseHomeworkService extends BaseService<Long, StudentCourseHomework> {
 
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/18
+     * 获取学生作业界面详细信息
+     */
+    CourseHomeworkStudentDetailDto findCourseHomeworkStudentDetail(Long courseScheduleID) throws IOException;
+
 }

+ 65 - 4
mec-web/src/main/java/com/ym/mec/web/service/impl/StudentCourseHomeworkServiceImpl.java

@@ -1,23 +1,84 @@
 package com.ym.mec.web.service.impl;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.security.SecurityUtils;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.web.dal.dao.StudentCourseHomeworkDao;
+import com.ym.mec.web.dal.dto.CourseHomeworkStudentDetailDto;
+import com.ym.mec.web.dal.entity.CourseHomework;
 import com.ym.mec.web.dal.entity.StudentCourseHomework;
+import com.ym.mec.web.service.CourseHomeworkService;
 import com.ym.mec.web.service.StudentCourseHomeworkService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.IOException;
+import java.util.Map;
 
 @Service
 public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, StudentCourseHomework>  implements StudentCourseHomeworkService {
 	
 	@Autowired
 	private StudentCourseHomeworkDao studentCourseHomeworkDao;
+	@Autowired
+	private CourseHomeworkService courseHomeworkService;
+
+	@Autowired
+	private RestTemplate restTemplate;
+
+	@Autowired
+	private ObjectMapper objectMapper;
+
+	private String url = "http://auth-server/queryUserInfo";
 
 	@Override
 	public BaseDAO<Long, StudentCourseHomework> getDAO() {
 		return studentCourseHomeworkDao;
 	}
-	
+
+	@Transactional(rollbackFor = Exception.class)
+	@Override
+	public long insert(StudentCourseHomework bean) {
+		HttpHeaders headers = new HttpHeaders();
+		headers.add("Authorization", "bearer " + SecurityUtils.getToken());
+		headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+
+		HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<MultiValueMap<String, String>>(null, headers);
+
+		ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+
+		Map map = null;
+		try {
+			map = objectMapper.readValue(resp.getBody(), Map.class);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		bean.setUserId(Long.valueOf(map.get("id").toString()));
+		long insert = super.insert(bean);
+
+		CourseHomework courseHomework=new CourseHomework();
+		courseHomework.setId(bean.getCourseHomeworkId());
+		courseHomework.setCompletedNum(studentCourseHomeworkDao.countCompletedStudentNum(bean.getCourseHomeworkId()));
+		courseHomeworkService.update(courseHomework);
+		return insert;
+	}
+
+	@Override
+	public CourseHomeworkStudentDetailDto findCourseHomeworkStudentDetail(Long courseScheduleID) throws IOException {
+		HttpHeaders headers = new HttpHeaders();
+		headers.add("Authorization", "bearer " + SecurityUtils.getToken());
+		headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+
+		HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<MultiValueMap<String, String>>(null, headers);
+
+		ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+
+		Map map =  objectMapper.readValue(resp.getBody(), Map.class);
+		return studentCourseHomeworkDao.findCourseHomeworkStudentDetail(courseScheduleID,Long.valueOf(map.get("id").toString()));
+	}
 }

+ 4 - 0
mec-web/src/main/java/com/ym/mec/web/service/impl/TeacherAttendanceServiceImpl.java

@@ -5,6 +5,7 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.web.dal.dao.CourseScheduleDao;
+import com.ym.mec.web.dal.dao.StudentAttendanceDao;
 import com.ym.mec.web.dal.dao.TeacherAttendanceDao;
 import com.ym.mec.web.dal.dto.TeacherAttendanceDto;
 import com.ym.mec.web.dal.dto.TeacherPersonalAttendanceDto;
@@ -35,6 +36,8 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 	private CourseScheduleDao courseScheduleDao;
 	@Autowired
 	private CourseHomeworkService courseHomeworkService;
+	@Autowired
+	private StudentAttendanceDao studentAttendanceDao;
 
 	@Override
 	public BaseDAO<Long, TeacherAttendance> getDAO() {
@@ -81,6 +84,7 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 			courseHomework.setCourseScheduleId(teacherAttendance.getCourseScheduleId());
 			courseHomework.setMusicGroupId(currentCourseDetail.getMusicGroupId().intValue());
 			courseHomework.setClassGroupId(currentCourseDetail.getClassId().intValue());
+			courseHomework.setExpectNum(studentAttendanceDao.countNormalAttendanceStudentNums(teacherAttendance.getCourseScheduleId()));
 			courseHomeworkService.insert(courseHomework);
 		}
 	}

+ 47 - 27
mec-web/src/main/resources/config/mybatis/CourseHomeworkMapper.xml

@@ -15,6 +15,8 @@
 		<result column="update_time_" property="updateTime" />
 		<result column="music_group_id_" property="musicGroupId" />
 		<result column="class_group_id_" property="classGroupId" />
+		<result column="completed_num_" property="completedNum" />
+		<result column="expect_num_" property="expectNum" />
 	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -34,47 +36,65 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO course_homework (id_,course_schedule_id_,attachments_,content_,create_time_,update_time_,music_group_id_,class_group_id_) VALUES(#{id},#{courseScheduleId},#{attachments},#{content},now(),now(),#{musicGroupId},#{classGroupId})
+		INSERT INTO course_homework (id_,course_schedule_id_,attachments_,content_,create_time_,update_time_,music_group_id_,class_group_id_,completed_num_,expect_num_) VALUES(#{id},#{courseScheduleId},#{attachments},#{content},now(),now(),#{musicGroupId},#{classGroupId},#{completedNum},#{expectNum})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.web.dal.entity.CourseHomework">
 		UPDATE course_homework <set>
-<if test="attachments != null">
-	attachments_ = #{attachments},
-</if>
-<if test="id != null">
-id_ = #{id},
-</if>
-<if test="classGroupId != null">
-class_group_id_ = #{classGroupId},
-</if>
-<if test="courseScheduleId != null">
-course_schedule_id_ = #{courseScheduleId},
-</if>
-<if test="updateTime != null">
-update_time_ = #{updateTime},
-</if>
-<if test="content != null">
-content_ = #{content},
-</if>
-<if test="musicGroupId != null">
-music_group_id_ = #{musicGroupId},
-</if>
-<if test="createTime != null">
-create_time_ = #{createTime},
-</if>
-</set> WHERE id_ = #{id} 
+		<if test="attachments != null">
+			attachments_ = #{attachments},
+		</if>
+		<if test="id != null">
+		id_ = #{id},
+		</if>
+		<if test="classGroupId != null">
+		class_group_id_ = #{classGroupId},
+		</if>
+		<if test="courseScheduleId != null">
+		course_schedule_id_ = #{courseScheduleId},
+		</if>
+		<if test="completedNum != null">
+			completed_num_ = #{completedNum},
+		</if>
+
+		<if test="expectNum != null">
+			expect_num_ = #{expectNum},
+		</if>
+		<if test="updateTime != null">
+		update_time_ = #{updateTime},
+		</if>
+		<if test="content != null">
+		content_ = #{content},
+		</if>
+		<if test="musicGroupId != null">
+		music_group_id_ = #{musicGroupId},
+		</if>
+		<if test="createTime != null">
+		create_time_ = #{createTime},
+		</if>
+		</set> WHERE id_ = #{id}
 	</update>
 	
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM course_homework WHERE id_ = #{id} 
 	</delete>
+
+	<sql id="queryCondition">
+		<where>
+			<if test="createTime != null">
+				DATE_FORMAT(create_time_,"%Y%m%d") = DATE_FORMAT(#{createTime},"%Y%m%d")
+			</if>
+		</where>
+	</sql>
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="CourseHomework" parameterType="map">
-		SELECT * FROM course_homework ORDER BY id_ <include refid="global.limit"/>
+		SELECT * FROM course_homework
+		<include refid="queryCondition"/>
+		ORDER BY id_
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->

+ 51 - 20
mec-web/src/main/resources/config/mybatis/StudentCourseHomeworkMapper.xml

@@ -8,12 +8,25 @@
 	
 	<resultMap type="com.ym.mec.web.dal.entity.StudentCourseHomework" id="StudentCourseHomework">
 		<result column="id_" property="id" />
+		<result column="user_id_" property="userId"/>
 		<result column="course_homework_id_" property="courseHomeworkId" />
 		<result column="attachments_" property="attachments" />
 		<result column="score_" property="score" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
+
+	<resultMap type="com.ym.mec.web.dal.dto.CourseHomeworkStudentDetailDto" id="CourseHomeworkStudentDetailDto">
+		<result column="musicGroupName" property="musicGroupName" />
+		<result column="classGroupName" property="classGroupName"/>
+		<result column="id_" property="courseHomeworkId" />
+		<result column="content_" property="content" />
+		<result column="expiry_date_" property="expiryDate" />
+		<result column="completed_num_" property="completedNum" />
+		<result column="expect_num_" property="expectNum" />
+		<result column="attachments_" property="attachments" />
+		<result column="score_" property="score" />
+	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="StudentCourseHomework" >
@@ -32,31 +45,31 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO student_course_homework (id_,course_homework_id_,attachments_,score_,create_time_,update_time_) VALUES(#{id},#{courseHomeworkId},#{attachments},#{score},#{createTime},#{updateTime})
+		INSERT INTO student_course_homework (id_,user_id_,course_homework_id_,attachments_,score_,create_time_,update_time_) VALUES(#{id},#{userId},#{courseHomeworkId},#{attachments},#{score},now(),now())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.web.dal.entity.StudentCourseHomework">
 		UPDATE student_course_homework <set>
-<if test="id != null">
-id_ = #{id},
-</if>
-<if test="courseHomeworkId != null">
-course_homework_id_ = #{courseHomeworkId},
-</if>
-<if test="updateTime != null">
-update_time_ = #{updateTime},
-</if>
-<if test="score != null">
-score_ = #{score},
-</if>
-<if test="attachments != null">
-attachments_ = #{attachments},
-</if>
-<if test="createTime != null">
-create_time_ = #{createTime},
-</if>
-</set> WHERE id_ = #{id} 
+			<if test="id != null">
+			id_ = #{id},
+			</if>
+			<if test="courseHomeworkId != null">
+			course_homework_id_ = #{courseHomeworkId},
+			</if>
+			<if test="updateTime != null">
+			update_time_ = #{updateTime},
+			</if>
+			<if test="score != null">
+			score_ = #{score},
+			</if>
+			<if test="attachments != null">
+			attachments_ = #{attachments},
+			</if>
+			<if test="createTime != null">
+			create_time_ = #{createTime},
+			</if>
+		</set> WHERE id_ = #{id}
 	</update>
 	
 	<!-- 根据主键删除一条记录 -->
@@ -73,4 +86,22 @@ create_time_ = #{createTime},
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM student_course_homework
 	</select>
+	<select id="findCourseHomeworkStudentDetail" resultMap="CourseHomeworkStudentDetailDto">
+		SELECT
+			mg.name_ musicGroupName,
+			cg.name_ classGroupName,
+			ch.id_ courseHomeworkId,
+			ch.content_,
+			ch.expiry_date_,
+			ch.completed_num_,
+			ch.expect_num_,
+			sch.attachments_,
+			sch.score_
+		FROM
+			course_homework ch
+		LEFT JOIN student_course_homework sch ON ch.id_=sch.course_homework_id_
+		LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
+		LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
+		WHERE ch.course_schedule_id_=#{courseScheduleID} AND sch.user_id_=#{userID}
+	</select>
 </mapper>