|
@@ -1,83 +1,86 @@
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Optional;
|
|
|
|
-
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.activity.ActivityRankingRuleEnum;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
|
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.yonge.cooleshow.biz.dal.dao.ActivityEvaluationRecordDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.ActivityEvaluationRecordDao;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.ActivityEvaluationRecordSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.ActivityEvaluationRecordSearch;
|
|
import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluation;
|
|
import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluation;
|
|
import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluationRecord;
|
|
import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluationRecord;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
|
|
import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationRecordService;
|
|
import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationRecordService;
|
|
import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationService;
|
|
import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationService;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityEvaluationRecordVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityEvaluationRecordVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
|
|
import com.yonge.cooleshow.common.enums.ActivityResourceEnum;
|
|
import com.yonge.cooleshow.common.enums.ActivityResourceEnum;
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
-public class ActivityEvaluationRecordServiceImpl extends ServiceImpl<ActivityEvaluationRecordDao, ActivityEvaluationRecord> implements ActivityEvaluationRecordService {
|
|
|
|
- private final static Logger log = LoggerFactory.getLogger(ActivityEvaluationRecordServiceImpl.class);
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ActivityEvaluationService activityEvaluationService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ActivityPlanService activityPlanService;
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public ActivityEvaluationRecordVo detail(Long id) {
|
|
|
|
- return baseMapper.detail(id);
|
|
|
|
|
|
+public class ActivityEvaluationRecordServiceImpl
|
|
|
|
+ extends ServiceImpl<ActivityEvaluationRecordDao, ActivityEvaluationRecord>
|
|
|
|
+ implements ActivityEvaluationRecordService {
|
|
|
|
+ private final static Logger log =
|
|
|
|
+ LoggerFactory.getLogger(ActivityEvaluationRecordServiceImpl.class);
|
|
|
|
+
|
|
|
|
+ @Autowired private ActivityEvaluationService activityEvaluationService;
|
|
|
|
+
|
|
|
|
+ @Autowired private ActivityPlanService activityPlanService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ActivityEvaluationRecordVo detail(Long id) {
|
|
|
|
+ return baseMapper.detail(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<ActivityEvaluationRecordVo>
|
|
|
|
+ selectPage(IPage<ActivityEvaluationRecordVo> page,
|
|
|
|
+ ActivityEvaluationRecordSearch query) {
|
|
|
|
+ return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<Long> getJoinEvaluationIdList(Long activityId, Long userId) {
|
|
|
|
+ return baseMapper.getJoinEvaluationIdList(activityId, userId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void saveRecord(Long evaluationId, Long userId, BigDecimal score) {
|
|
|
|
+ if (evaluationId == null) {
|
|
|
|
+ throw new BizException("评测项目id不能为空");
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public IPage<ActivityEvaluationRecordVo> selectPage(IPage<ActivityEvaluationRecordVo> page, ActivityEvaluationRecordSearch query){
|
|
|
|
- return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<Long> getJoinEvaluationIdList(Long activityId, Long userId) {
|
|
|
|
- return baseMapper.getJoinEvaluationIdList(activityId,userId);
|
|
|
|
|
|
+ ActivityEvaluation activityEvaluation =
|
|
|
|
+ activityEvaluationService.getById(evaluationId);
|
|
|
|
+ if (activityEvaluation == null) {
|
|
|
|
+ throw new BizException("未找到评测项目");
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void saveRecord(Long evaluationId, Long userId, BigDecimal score) {
|
|
|
|
- if (evaluationId == null) {
|
|
|
|
- throw new BizException("评测项目id不能为空");
|
|
|
|
- }
|
|
|
|
- ActivityEvaluation activityEvaluation = activityEvaluationService.getById(evaluationId);
|
|
|
|
- if (activityEvaluation == null) {
|
|
|
|
- throw new BizException("未找到评测项目");
|
|
|
|
- }
|
|
|
|
- ActivityEvaluationRecord activityEvaluationRecord = new ActivityEvaluationRecord();
|
|
|
|
- activityEvaluationRecord.setActivityId(activityEvaluation.getActivityId());
|
|
|
|
- activityEvaluationRecord.setUserId(userId);
|
|
|
|
- activityEvaluationRecord.setEvaluationId(evaluationId);
|
|
|
|
- activityEvaluationRecord.setCreateTime(new Date());
|
|
|
|
- activityEvaluationRecord.setScore(score == null ? 0:score.doubleValue());
|
|
|
|
-
|
|
|
|
- ActivityEvaluationRecord lastestRecord = baseMapper.queryLastestRecord(activityEvaluation.getActivityId(), userId);
|
|
|
|
- if(lastestRecord == null){
|
|
|
|
- activityEvaluationRecord.setTimes(1);
|
|
|
|
- }else{
|
|
|
|
- activityEvaluationRecord.setTimes(lastestRecord.getTimes() + 1);
|
|
|
|
- }
|
|
|
|
- save(activityEvaluationRecord);
|
|
|
|
|
|
+ ActivityEvaluationRecord activityEvaluationRecord =
|
|
|
|
+ new ActivityEvaluationRecord();
|
|
|
|
+ activityEvaluationRecord.setActivityId(activityEvaluation.getActivityId());
|
|
|
|
+ activityEvaluationRecord.setUserId(userId);
|
|
|
|
+ activityEvaluationRecord.setEvaluationId(evaluationId);
|
|
|
|
+ activityEvaluationRecord.setCreateTime(new Date());
|
|
|
|
+ activityEvaluationRecord.setScore(score == null ? 0 : score.doubleValue());
|
|
|
|
+
|
|
|
|
+ ActivityEvaluationRecord lastestRecord = baseMapper.queryLastestRecord(
|
|
|
|
+ activityEvaluation.getActivityId(), userId);
|
|
|
|
+ if (lastestRecord == null) {
|
|
|
|
+ activityEvaluationRecord.setTimes(1);
|
|
|
|
+ } else {
|
|
|
|
+ activityEvaluationRecord.setTimes(lastestRecord.getTimes() + 1);
|
|
}
|
|
}
|
|
|
|
+ save(activityEvaluationRecord);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -99,46 +102,51 @@ public class ActivityEvaluationRecordServiceImpl extends ServiceImpl<ActivityEva
|
|
this.save(activityEvaluationRecord);
|
|
this.save(activityEvaluationRecord);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ActivityRankingVo> queryRankingList(Long activityPlanId, Long activityEvaluationId, int limit) {
|
|
|
|
- ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
|
|
|
|
- if (activityPlan == null) {
|
|
|
|
- throw new BizException("活动已结束");
|
|
|
|
- }
|
|
|
|
- return baseMapper.queryRankingList(activityPlanId, activityEvaluationId, limit,activityPlan.getRankingRule());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public ActivityRankingVo queryUserRanking(Long activityPlanId, Long activityEvaluationId, Long userId) {
|
|
|
|
- ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
|
|
|
|
- if (activityPlan == null) {
|
|
|
|
- throw new BizException("活动已结束");
|
|
|
|
- }
|
|
|
|
- return baseMapper.queryUserRanking(activityPlanId, activityEvaluationId, userId,activityPlan.getRankingRule());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 用户活动最高排名信息
|
|
|
|
- *
|
|
|
|
- * @param activityId 活动ID
|
|
|
|
- * @param userIds 用户ID
|
|
|
|
- * @return List<ActivityEvaluationRecord>
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public List<ActivityEvaluationRecord> queryActivityUserHighestRankingInfo(Long activityId, List<Long> userIds) {
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isEmpty(userIds)) {
|
|
|
|
- return Lists.newArrayList();
|
|
|
|
- }
|
|
|
|
- ActivityPlan activityPlan = activityPlanService.getById(activityId);
|
|
|
|
- if (activityPlan == null) {
|
|
|
|
- throw new BizException("活动已结束");
|
|
|
|
- }
|
|
|
|
- // 用户最高排名信息
|
|
|
|
- List<ActivityEvaluationRecord> records = getBaseMapper().selectUserHighestRankingInfo(activityId, userIds,activityPlan.getRankingRule());
|
|
|
|
-
|
|
|
|
- return Optional.ofNullable(records).orElse(Lists.newArrayList());
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<ActivityRankingVo> queryRankingList(Long activityPlanId, Long activityEvaluationId, int limit) {
|
|
|
|
+ ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
|
|
|
|
+ if (activityPlan == null) {
|
|
|
|
+ throw new BizException("活动已结束");
|
|
|
|
+ }
|
|
|
|
+ return baseMapper.queryRankingList(activityPlanId, activityEvaluationId,
|
|
|
|
+ limit, activityPlan.getRankingRule());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ActivityRankingVo queryUserRanking(Long activityPlanId,
|
|
|
|
+ Long activityEvaluationId,
|
|
|
|
+ Long userId) {
|
|
|
|
+ ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
|
|
|
|
+ if (activityPlan == null) {
|
|
|
|
+ throw new BizException("活动已结束");
|
|
|
|
+ }
|
|
|
|
+ return baseMapper.queryUserRanking(activityPlanId, activityEvaluationId,
|
|
|
|
+ userId, activityPlan.getRankingRule());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户活动最高排名信息
|
|
|
|
+ *
|
|
|
|
+ * @param activityId 活动ID
|
|
|
|
+ * @param userIds 用户ID
|
|
|
|
+ * @return List<ActivityEvaluationRecord>
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<ActivityEvaluationRecord>
|
|
|
|
+ queryActivityUserHighestRankingInfo(Long activityId, List<Long> userIds) {
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isEmpty(userIds)) {
|
|
|
|
+ return Lists.newArrayList();
|
|
|
|
+ }
|
|
|
|
+ ActivityPlan activityPlan = activityPlanService.getById(activityId);
|
|
|
|
+ if (activityPlan == null) {
|
|
|
|
+ throw new BizException("活动已结束");
|
|
}
|
|
}
|
|
|
|
+ // 用户最高排名信息
|
|
|
|
+ List<ActivityEvaluationRecord> records =
|
|
|
|
+ getBaseMapper().selectUserHighestRankingInfo(
|
|
|
|
+ activityId, userIds, activityPlan.getRankingRule());
|
|
|
|
|
|
|
|
+ return Optional.ofNullable(records).orElse(Lists.newArrayList());
|
|
|
|
+ }
|
|
}
|
|
}
|