From 3389e27613953cf3d7d06653139bf902e08736dc Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期五, 22 十月 2021 13:58:33 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test' into test --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 38 insertions(+), 8 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java index 9aff4c0..93d0ee7 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; import javax.annotation.Resource; @@ -21,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComActActEvaluateVO; +import com.panzhihua.common.model.vos.community.MyActivityEvaluateVO; import com.panzhihua.service_community.dao.ComActActEvaluateDAO; import com.panzhihua.service_community.dao.ComActActRegistDAO; import com.panzhihua.service_community.dao.ComActActSignDAO; @@ -75,7 +75,9 @@ //需要签到类型 int registCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() .lambda().eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getActivityId, activityId)); - if (registCount <= 0) { + int evaluateCount = this.baseMapper.selectCount(new QueryWrapper<ComActActEvaluateDO>().lambda() + .eq(ComActActEvaluateDO::getUserId, userId).eq(ComActActEvaluateDO::getActivityId, activityId)); + if (registCount <= evaluateCount) { //未签到,不能评价 return R.fail("未签到,不能评价"); } @@ -83,11 +85,6 @@ if (nowDate.before(beginAt)) { return R.fail("活动还未开始,暂不支持评价"); } - } - ComActActEvaluateDO currentUserEvaluateForThisActivity = this.baseMapper.selectOne(new QueryWrapper<ComActActEvaluateDO>() - .lambda().eq(ComActActEvaluateDO::getActivityId, activityId).eq(ComActActEvaluateDO::getUserId, userId)); - if (Objects.nonNull(currentUserEvaluateForThisActivity)) { - return R.fail("该用户已评论过了,请勿重复评论"); } ComActActEvaluateDO comActActEvaluateDO = new ComActActEvaluateDO(); BeanUtils.copyProperties(comActActEvaluateVO, comActActEvaluateDO); @@ -150,7 +147,7 @@ public R listEvaluate(Long userId) { List<ComActActEvaluateDO> comActActEvaluateDOList = this.baseMapper.selectList(new QueryWrapper<ComActActEvaluateDO>() .lambda().eq(ComActActEvaluateDO::getUserId, userId)); - ArrayList<ComActActEvaluateVO> comActActEvaluateVOS = new ArrayList<>(); + List<ComActActEvaluateVO> comActActEvaluateVOS = new ArrayList<>(); if (!ObjectUtils.isEmpty(comActActEvaluateDOList)) { comActActEvaluateDOList.forEach(comActActEvaluateDO -> { ComActActEvaluateVO comActActEvaluateVO = new ComActActEvaluateVO(); @@ -160,4 +157,37 @@ } return R.ok(comActActEvaluateVOS); } + + /** + * 我的评价 + * @param userId + * @param activityId + * @return + */ + @Override + public R listMyActivityEvaluate(Long userId, Long activityId) { + ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); + if (isNull(comActActivityDO)) { + return R.fail("活动不存在"); + } + List<ComActActEvaluateDO> comActActEvaluateDOList = this.baseMapper.selectList(new QueryWrapper<ComActActEvaluateDO>() + .lambda().eq(ComActActEvaluateDO::getUserId, userId).eq(ComActActEvaluateDO::getActivityId, activityId)); + List<ComActActEvaluateVO> comActActEvaluateVOS = new ArrayList<>(); + if (!ObjectUtils.isEmpty(comActActEvaluateDOList)) { + comActActEvaluateDOList.forEach(comActActEvaluateDO -> { + ComActActEvaluateVO comActActEvaluateVO = new ComActActEvaluateVO(); + BeanUtils.copyProperties(comActActEvaluateDO, comActActEvaluateVO); + comActActEvaluateVOS.add(comActActEvaluateVO); + }); + } + int registCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() + .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId)); + + MyActivityEvaluateVO evaluateVO = new MyActivityEvaluateVO(); + evaluateVO.setMyEvaluateList(comActActEvaluateVOS); + boolean needDisplay = registCount > comActActEvaluateVOS.size() && + new Date().before(DateUtils.addDays(comActActivityDO.getEndAt(), 3)); + evaluateVO.setIsDisplay(needDisplay ? 1 : 0); + return R.ok(evaluateVO); + } } -- Gitblit v1.7.1