|
@@ -0,0 +1,148 @@
|
|
|
+package com.ym.mec.biz.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
+import com.ym.mec.biz.dal.page.CourseReview4EduQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.CourseReviewQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.common.constant.CommonConstants;
|
|
|
+import com.ym.mec.common.controller.BaseController;
|
|
|
+import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
+import com.ym.mec.common.entity.ImGroupMember;
|
|
|
+import com.ym.mec.common.entity.ImGroupModel;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
+import com.ym.mec.common.service.IdGeneratorService;
|
|
|
+import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
+import com.ym.mec.im.ImFeignService;
|
|
|
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
+import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
+import com.ym.mec.util.http.HttpUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.*;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.WeekFields;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseScheduleReview> implements CourseReviewService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleReviewDao courseScheduleReviewDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleDao courseScheduleDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PracticeGroupDao practiceGroupDao;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseDAO<Integer, CourseScheduleReview> getDAO() {
|
|
|
+ return courseScheduleReviewDao;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<CourseReviewDto> findPracticeGroupReviews(CourseReviewQueryInfo queryInfo) {
|
|
|
+ PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<CourseReviewDto> dataList = null;
|
|
|
+ int count = courseScheduleReviewDao.countPracticeGroupReviews(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = courseScheduleReviewDao.getPracticeGroupReviewList(params);
|
|
|
+ if (dataList != null && dataList.size() > 0) {
|
|
|
+ List<Integer> subjectIds = dataList.stream().map(CourseReviewDto::getSubjectId).distinct().collect(Collectors.toList());
|
|
|
+ Set<Integer> organIds = dataList.stream().map(CourseReviewDto::getOrganId).collect(Collectors.toSet());
|
|
|
+ //声部名称列表
|
|
|
+ Map<Long, String> subjectNames = MapUtil.convertMybatisMap(subjectDao.findBySubjecIds(StringUtils.join(subjectIds, ",")));
|
|
|
+ Map<Integer, String> organNames = MapUtil.convertMybatisMap(organizationDao.findOrganNameMapList(organIds));
|
|
|
+ dataList.forEach(e -> {
|
|
|
+ e.setSubjectName(subjectNames.get(e.getSubjectId().intValue()));
|
|
|
+ e.setOrganName(organNames.get(e.getOrganId()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<CourseScheduleReview> findPracticeGroupReviews4Edu(CourseReview4EduQueryInfo queryInfo) {
|
|
|
+ PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<CourseScheduleReview> dataList = null;
|
|
|
+ int count = courseScheduleReviewDao.countPracticeGroupReviews4Edu(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = courseScheduleReviewDao.getPracticeGroupReview4EduList(params);
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CourseScheduleReview addPracticeGroupReview(CourseScheduleReview courseScheduleReview) {
|
|
|
+ Integer courseScheduleId = courseScheduleReview.getCourseScheduleId();
|
|
|
+ if (courseScheduleId == null || courseScheduleId <= 0) {
|
|
|
+ throw new BizException("课程id必须大于0");
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+ CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId.longValue());
|
|
|
+ PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(courseSchedule.getMusicGroupId()));
|
|
|
+
|
|
|
+ courseScheduleReview.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ courseScheduleReview.setEducationalTeacherId(practiceGroup.getEducationalTeacherId());
|
|
|
+ courseScheduleReview.setStudentId(practiceGroup.getStudentId());
|
|
|
+ courseScheduleReview.setCreateTime(date);
|
|
|
+ courseSchedule.setUpdateTime(date);
|
|
|
+ long num = courseScheduleReviewDao.insert(courseScheduleReview);
|
|
|
+ if (num <= 0) {
|
|
|
+ throw new BizException("评论提交失败,请重试");
|
|
|
+ }
|
|
|
+ return courseScheduleReview;
|
|
|
+ }
|
|
|
+}
|