|
@@ -1,16 +1,19 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.CourseScheduleRepliedDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.CourseScheduleStudentPaymentDao;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.CourseSchedule;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.CourseScheduleReplied;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.CourseScheduleStudentPayment;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.CourseRepliedService;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.MyRepliedVo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -56,24 +59,21 @@ public class CourseRepliedServiceImpl extends ServiceImpl<CourseScheduleRepliedD
|
|
|
throw new RuntimeException("课程未开始无法评论");
|
|
|
}
|
|
|
|
|
|
- //评论存在执行修改
|
|
|
- QueryWrapper<CourseScheduleReplied> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("student_id_", replied.getStudentId());
|
|
|
- queryWrapper.eq("course_schedule_id_", replied.getCourseScheduleId());
|
|
|
- queryWrapper.eq("course_group_id_", replied.getCourseGroupId());
|
|
|
- queryWrapper.eq("course_group_type_", CourseScheduleEnum.PRACTICE.getCode());
|
|
|
- CourseScheduleReplied scheduleReplied = repliedDao.selectOne(queryWrapper);
|
|
|
- if (scheduleReplied != null) {
|
|
|
- repliedDao.updateReplied(replied);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
//当前用户为老师
|
|
|
CourseSchedule courseSchedule = scheduleDao.selectById(scheduleId);
|
|
|
if (courseSchedule != null) {
|
|
|
Long teacherId = courseSchedule.getTeacherId();
|
|
|
if (userId == teacherId) {
|
|
|
- repliedDao.insert(replied);
|
|
|
+ if (studentId == null) {
|
|
|
+ throw new RuntimeException("学生id不能为空");
|
|
|
+ }
|
|
|
+ replied.setScore(null);
|
|
|
+ replied.setStudentReplied(null);
|
|
|
+ if (!repliedIsNull(replied)){//评论已存在
|
|
|
+ repliedDao.updateReplied(replied);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ repliedDao.insertReplied(replied);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -84,10 +84,31 @@ public class CourseRepliedServiceImpl extends ServiceImpl<CourseScheduleRepliedD
|
|
|
wrapper.eq("course_id_", scheduleId);
|
|
|
wrapper.eq("course_type_", CourseScheduleEnum.PRACTICE);
|
|
|
CourseScheduleStudentPayment payment = paymentDao.selectOne(wrapper);
|
|
|
- if (payment == null || userId != studentId) {
|
|
|
+ if (payment == null) {
|
|
|
throw new RuntimeException("未购买该课无法评论");
|
|
|
}
|
|
|
- repliedDao.insert(replied);
|
|
|
+ replied.setStudentId(userId);
|
|
|
+ replied.setTeacherReplied(null);
|
|
|
+ if (!repliedIsNull(replied)){//评论已存在
|
|
|
+ repliedDao.updateReplied(replied);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ repliedDao.insertReplied(replied);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 判断评论是否存在
|
|
|
+ * @Author: cy
|
|
|
+ * @Date: 2022/4/13
|
|
|
+ */
|
|
|
+ public boolean repliedIsNull(CourseScheduleReplied replied) {
|
|
|
+ QueryWrapper<CourseScheduleReplied> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("student_id_", replied.getStudentId());
|
|
|
+ queryWrapper.eq("course_schedule_id_", replied.getCourseScheduleId());
|
|
|
+ queryWrapper.eq("course_group_id_", replied.getCourseGroupId());
|
|
|
+ queryWrapper.eq("course_group_type_", CourseScheduleEnum.PRACTICE.getCode());
|
|
|
+ CourseScheduleReplied scheduleReplied = repliedDao.selectOne(queryWrapper);
|
|
|
+ return scheduleReplied == null ? true : false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -105,4 +126,14 @@ public class CourseRepliedServiceImpl extends ServiceImpl<CourseScheduleRepliedD
|
|
|
return repliedDao.selectOne(wrapper);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description: 首页-我收到的评价
|
|
|
+ * @Author: cy
|
|
|
+ * @Date: 2022/4/13
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<MyRepliedVo> myReplied(IPage<MyRepliedVo> page, MyCourseSearch search) {
|
|
|
+ return page.setRecords(repliedDao.myReplied(page, search));
|
|
|
+ }
|
|
|
+
|
|
|
}
|