|
@@ -0,0 +1,62 @@
|
|
|
+package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.ExposureReportDao;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.ExposureReport;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.ExposureReportService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.VideoLessonGroupService;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.ExposureReportWrapper;
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ExposureReportServiceImpl extends ServiceImpl<ExposureReportDao, ExposureReport> implements ExposureReportService {
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(ExposureReportServiceImpl.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CourseGroupService courseGroupService;
|
|
|
+ @Resource
|
|
|
+ private MusicSheetService musicSheetService;
|
|
|
+ @Resource
|
|
|
+ private VideoLessonGroupService videoLessonGroupService;
|
|
|
+
|
|
|
+ public ExposureReportDao getDao() {
|
|
|
+ return baseMapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void report(List<ExposureReportWrapper.SaveExposureReportDto> exposureReportDto) {
|
|
|
+ Date now = new Date();
|
|
|
+ String exposureTime = DateUtil.format(now, DateUtil.DEFAULT_PATTERN);
|
|
|
+ exposureReportDto.forEach(e->e.setExposureTime(exposureTime));
|
|
|
+ baseMapper.saveExposureReport(exposureReportDto);
|
|
|
+ //按类型分组
|
|
|
+ Map<String, List<ExposureReportWrapper.SaveExposureReportDto>> typeMap = exposureReportDto.stream().collect(Collectors.groupingBy(ExposureReportWrapper.SaveExposureReportDto::getObjectType));
|
|
|
+ typeMap.forEach((k,v)->{
|
|
|
+ List<ExposureReportWrapper.SaveExposureReportDto> saveExposureReportDtos = typeMap.get(k);
|
|
|
+ //按对象id分组,并获取集合数量
|
|
|
+ Map<Long, Integer> exposureNumMap = saveExposureReportDtos.stream().collect(Collectors.groupingBy(ExposureReportWrapper.SaveExposureReportDto::getObjectId, Collectors.summingInt(e -> 1)));
|
|
|
+ exposureNumMap.forEach((objectId,exposureNum)-> {
|
|
|
+ if ("LIVE".equals(k)) {
|
|
|
+ courseGroupService.getDao().updateExposureNum(objectId, exposureNum);
|
|
|
+ } else if ("VIDEO".equals(k)) {
|
|
|
+ videoLessonGroupService.getDao().updateExposureNum(objectId, exposureNum);
|
|
|
+ }else if ("MUSIC".equals(k)) {
|
|
|
+ musicSheetService.getDao().updateExposureNum(objectId, exposureNum);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|