From 37f55403e7573d8c15b6b0f957b7cb1baf6be4ea Mon Sep 17 00:00:00 2001
From: huanghongfa <18228131219@163.com>
Date: 星期二, 29 十二月 2020 14:47:15 +0800
Subject: [PATCH] 攀枝花项目服务层异常捕获统一返回给视图层服务

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
index ed13908..a37dbc6 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -19,8 +19,11 @@
 import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -84,10 +87,10 @@
         Page page = new Page<>();
         Long pageNum = comActActivityVO.getPageNum();
         Long pageSize = comActActivityVO.getPageSize();
-        if (ObjectUtils.isEmpty(pageNum)||0==pageNum) {
+        if (null==pageNum||0==pageNum) {
             pageNum = 1l;
         }
-        if (ObjectUtils.isEmpty(pageSize)||0==pageSize) {
+        if (null==pageSize||0==pageSize) {
             pageSize = 10l;
         }
         page.setSize(pageSize);
@@ -126,7 +129,7 @@
         ComActActivityDO comActActivityDO=new ComActActivityDO();
         comActActivityDO.setId(comActActivityVO.getId());
         comActActivityDO.setStatus(comActActivityVO.getStatus());
-        comActActivityDO.setCancelReason(comActActivityVO.getCancelRenson());
+        comActActivityDO.setCancelReason(comActActivityVO.getCancelReason());
         int update = comActActivityDAO.updateById(comActActivityDO);
         if (update>0) {
             return R.ok();
@@ -178,10 +181,10 @@
         Page page = new Page<>();
         Long pageNum = comActActivityVO.getPageNum();
         Long pageSize = comActActivityVO.getPageSize();
-        if (ObjectUtils.isEmpty(pageNum)||0==pageNum) {
+        if (null==pageNum||0==pageNum) {
             pageNum = 1l;
         }
-        if (ObjectUtils.isEmpty(pageSize)||0==pageSize) {
+        if (null==pageSize||0==pageSize) {
             pageSize = 10l;
         }
         page.setSize(pageSize);
@@ -218,5 +221,36 @@
         return R.fail();
     }
 
+    /**
+     * 用户参加的所有社区活动
+     *
+     * @param userId 用户id
+     * @return 活动列表
+     */
+    @Override
+    public R listActivity(Long userId) {
+        List<ComActActSignDO> comActActSignDOS = comActActSignDAO.selectList(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getUserId, userId));
+        if (ObjectUtils.isEmpty(comActActSignDOS)) {
+            return R.fail();
+        }
+        List<Long> longs = comActActSignDOS.stream().map(comActActSignDO -> comActActSignDO.getActivityId()).collect(Collectors.toList());
+        List<ComActActivityDO> comActActivityDOS = comActActivityDAO.selectBatchIds(longs);
+        List<ComActActivityVO>comActActivityVOS=new ArrayList<>();
+        comActActivityDOS.forEach(comActActivityDO -> {
+            ComActActivityVO comActActivityVO=new ComActActivityVO();
+            BeanUtils.copyProperties(comActActivityDO,comActActivityVO);
+            List<ComActActSignDO> collect = comActActSignDOS.stream().filter(comActActSignDO -> comActActSignDO.getActivityId().equals(comActActivityVO.getId())).limit(1).collect(Collectors.toList());
+            ComActActSignDO comActActSignDO = collect.get(0);
+            Integer isVolunteer = comActActSignDO.getIsVolunteer();
+            if (isVolunteer.intValue()==1) {
+                comActActivityVO.setType(1);
+            }else{
+                comActActivityVO.setType(2);
+            }
+            comActActivityVOS.add(comActActivityVO);
+        });
+        return R.ok(comActActivityVOS);
+    }
+
 
 }

--
Gitblit v1.7.1