فهرست منبع

add 需提交报告列表接口

周箭河 5 سال پیش
والد
کامیت
29af719b0f

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleEvaluateService.java

@@ -1,8 +1,10 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.dal.entity.TeacherCourseStatistics;
 import com.ym.mec.biz.dal.page.TeacherCourseStatisticsQueryInfo;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 import org.apache.ibatis.annotations.Param;
@@ -48,4 +50,11 @@ public interface CourseScheduleEvaluateService extends BaseService<Long, CourseS
      */
     List<CourseScheduleEvaluate> createEvaluate(Date NowDate,Date afterDate);
 
+    /**
+     * 更新学习报告
+     * @param courseScheduleEvaluate
+     * @return
+     */
+    boolean updateStudyReport(CourseScheduleEvaluate courseScheduleEvaluate);
+
 }

+ 17 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleEvaluateServiceImpl.java

@@ -46,7 +46,6 @@ public class CourseScheduleEvaluateServiceImpl extends BaseServiceImpl<Long, Cou
 
 
     @Override
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
     public boolean addStudyReport(CourseScheduleEvaluate courseScheduleEvaluate) {
         ClassGroup classGroup = classGroupDao.get(courseScheduleEvaluate.getClassGroupId());
         if (classGroup == null) {
@@ -64,6 +63,7 @@ public class CourseScheduleEvaluateServiceImpl extends BaseServiceImpl<Long, Cou
             courseScheduleEvaluate.setMusicGroupId(classGroup.getMusicGroupId());
             courseScheduleEvaluate.setCreateTime(new Date());
             courseScheduleEvaluate.setStatus(1);
+            courseScheduleEvaluate.setVersion(1);
             long num = courseScheduleEvaluateDao.insert(courseScheduleEvaluate);
             if (num <= 0) {
                 throw new BizException("报告添加失败,请重试");
@@ -121,4 +121,20 @@ public class CourseScheduleEvaluateServiceImpl extends BaseServiceImpl<Long, Cou
         }
         return needPostReportPracticeGroups;
     }
+
+    @Override
+    public boolean updateStudyReport(CourseScheduleEvaluate courseScheduleEvaluate) {
+        ClassGroup classGroup = classGroupDao.get(courseScheduleEvaluate.getClassGroupId());
+        if (classGroup == null) {
+            throw new BizException("课程不存在!");
+        }
+        courseScheduleEvaluate.setMusicGroupId(classGroup.getMusicGroupId());
+        courseScheduleEvaluate.setStatus(1);
+        courseScheduleEvaluate.setVersion(2);
+        long num = courseScheduleEvaluateDao.update(courseScheduleEvaluate);
+        if (num <= 0) {
+            throw new BizException("报告添加失败,请重试");
+        }
+        return true;
+    }
 }

+ 45 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleEvaluateMapper.xml

@@ -36,8 +36,51 @@
 
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">
         update course_schedule_evaluate
-        set is_pushed_=#{isPushed}
-        where id_ = #{id}
+        <set>
+            <if test="musicGroupId != null">
+                music_group_id_ = #{musicGroupId},
+            </if>
+            <if test="classGroupId != null">
+                class_group_id_ = #{classGroupId},
+            </if>
+            <if test="courseScheduleId != null">
+                course_schedule_id_ = #{courseScheduleId},
+            </if>
+            <if test="musicTheory != null">
+                music_theory_ = #{musicTheory},
+            </if>
+            <if test="song != null">
+                song_ = #{song},
+            </if>
+            <if test="teachingMaterial != null">
+                teaching_material_ = #{teachingMaterial},
+            </if>
+            <if test="item != null">
+                item_ = #{item},
+            </if>
+            <if test="comment != null">
+                comment_ = #{comment},
+            </if>
+            <if test="classGroupId != null">
+                class_group_id_ = #{classGroupId},
+            </if>
+            <if test="studentIdList != null">
+                student_id_list_ = #{studentIdList},
+            </if>
+            <if test="teacherId != null">
+                teacher_id_ = #{teacherId},
+            </if>
+            <if test="version != null != null">
+                version_ = #{version},
+            </if>
+            <if test="status != null">
+                status_ = #{status},
+            </if>
+            <if test="isPushed != null">
+                is_pushed_ = #{isPushed}
+            </if>
+        </set>
+        WHERE id_ = #{id}
     </update>
 
     <select id="findByClassGroupId" resultMap="CourseScheduleEvaluate">

+ 22 - 3
mec-teacher/src/main/java/com/ym/mec/teacher/controller/StudyReportController.java

@@ -5,14 +5,13 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.service.CourseScheduleEvaluateService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.util.date.DateUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
 import java.util.List;
@@ -86,4 +85,24 @@ public class StudyReportController extends BaseController {
         Date afterDate = DateUtil.addDays1(nowDate, 5);
         return succeed(courseScheduleEvaluateService.createEvaluate(nowDate, afterDate));
     }
+
+    @ApiOperation(value = "提交陪练报告")
+    @PostMapping(value = "/addStudyReport")
+    public HttpResponseResult addStudyReport(@RequestBody CourseScheduleEvaluate courseScheduleEvaluate) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(Objects.isNull(sysUser)){
+            return failed(HttpStatus.FORBIDDEN,"请登录");
+        }
+        if(courseScheduleEvaluate.getId()==null || courseScheduleEvaluate.getId()<0){
+            return failed(HttpStatus.BAD_REQUEST,"报告id不能为空");
+        }
+        if(courseScheduleEvaluate.getClassGroupId()==null || courseScheduleEvaluate.getClassGroupId()<0){
+            return failed(HttpStatus.BAD_REQUEST,"班级id必须大于0");
+        }
+        if(courseScheduleEvaluate.getItem()==null || courseScheduleEvaluate.getItem().isEmpty()){
+            return failed(HttpStatus.BAD_REQUEST,"课程评价选项不能为空");
+        }
+        courseScheduleEvaluate.setTeacherId(sysUser.getId());
+        return succeed(courseScheduleEvaluateService.updateStudyReport(courseScheduleEvaluate));
+    }
 }