From b2fce0dc7dc4ea5dec9792a2bc3ceb9d33d6e07b Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期一, 04 九月 2023 13:59:52 +0800
Subject: [PATCH] 修改后台社区动态加载不出来

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java |  125 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 110 insertions(+), 15 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
index 1f9b4c0..f40788b 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
@@ -4,9 +4,18 @@
 
 import javax.annotation.Resource;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.codec.Base64;
+import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
+import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.common.utlis.Snowflake;
+import com.panzhihua.service_community.dao.ComEventMapper;
+import com.panzhihua.service_community.entity.ComEvent;
+import com.panzhihua.service_community.util.MyAESUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -37,6 +46,12 @@
     @Resource
     private ComStreetDAO comStreetDAO;
 
+    @Resource
+    private UserService userService;
+
+    @Resource
+    private ComEventMapper comEventMapper;
+
     /**
      * 新增社区
      *
@@ -45,10 +60,8 @@
      * @return 新增结果
      */
     @Override
-    public R addStreet(ComStreetVO comStreetVO) {
-        String password = comStreetVO.getPassword();
-        String encode = new BCryptPasswordEncoder().encode(password);
-        comStreetVO.setPassword(encode);
+    @Transactional
+    public R<ComStreetVO> addStreet(ComStreetVO comStreetVO) {
         ComStreetDO comStreetDO = new ComStreetDO();
         LambdaQueryWrapper<ComStreetDO> param = new QueryWrapper<ComStreetDO>().lambda();
         param.eq(ComStreetDO::getName, comStreetVO.getName());
@@ -59,14 +72,31 @@
         if (integer > 0) {
             return R.fail(500, "街道已经存在");
         }
-        BeanUtils.copyProperties(comStreetVO, comStreetDO);
-        int insert = comStreetDAO.insert(comStreetDO);
-        if (insert > 0) {
-            ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param);
-            BeanUtils.copyProperties(comStreetDO1, comStreetVO);
-            return R.ok(comStreetVO);
+        AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO();
+        administratorsUserVO.setType(3);
+        administratorsUserVO.setAccount(comStreetVO.getAccount());
+        administratorsUserVO.setPassword(comStreetVO.getPassword());
+        administratorsUserVO.setSocialType(1);
+        administratorsUserVO.setRoleId(777777777L);
+        administratorsUserVO.setStreetId(0L);
+        administratorsUserVO.setName(comStreetVO.getName());
+        administratorsUserVO.setUserId(Snowflake.getId());
+        R r=userService.addUserBackstageProperty(administratorsUserVO);
+        if(R.isOk(r)){
+            BeanUtils.copyProperties(comStreetVO, comStreetDO);
+            int insert = comStreetDAO.insert(comStreetDO);
+            if (insert > 0) {
+                AdministratorsUserVO administratorsUserVO1=new AdministratorsUserVO();
+                administratorsUserVO1.setUserId(Long.parseLong(r.getData().toString()));
+                administratorsUserVO1.setStreetId(comStreetDO.getStreetId());
+                userService.updateStreet(administratorsUserVO1);
+                ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param);
+                BeanUtils.copyProperties(comStreetDO1, comStreetVO);
+                return R.ok(comStreetVO);
+            }
+            return R.fail(500, "");
         }
-        return R.fail(500, "");
+        return R.fail("账号已存在");
     }
 
     /**
@@ -111,10 +141,10 @@
         if (ObjectUtils.isEmpty(comStreetDO)) {
             return R.fail();
         }
-        ComActVO comActVO = new ComActVO();
-        BeanUtils.copyProperties(comStreetDO, comActVO);
-        comActVO.setAreaName(comActDAO.selectAreaName(comActVO.getAreaCode()));
-        return R.ok(comActVO);
+        ComStreetVO comStreetVO = new ComStreetVO();
+        BeanUtils.copyProperties(comStreetDO, comStreetVO);
+        comStreetVO.setAdministrativeRegions(comStreetDAO.retrieveRegions(comStreetVO.getAreaCode().toString()));
+        return R.ok(comStreetVO);
     }
 
     /**
@@ -140,6 +170,9 @@
         LambdaQueryWrapper<ComStreetDO> userLambdaQueryWrapper = Wrappers.lambdaQuery();
         if (pageComStreetDTO.getName() != null) {
             userLambdaQueryWrapper.like(ComStreetDO::getName, pageComStreetDTO.getName());
+        }
+        if (pageComStreetDTO.getAreaCode() != null) {
+            userLambdaQueryWrapper.like(ComStreetDO::getAreaCode, pageComStreetDTO.getAreaCode());
         }
         Page userPage = new Page(pageNum, pageSize);
         IPage<ComStreetDO> doPager =
@@ -170,4 +203,66 @@
         return R.fail();
     }
 
+
+    /**
+     * 修改街道信息
+     * @param comStreetVO 街道信息
+     * */
+    @Override
+    public R update(ComStreetVO comStreetVO) {
+        ComStreetDO comStreetDO=new ComStreetDO();
+        BeanUtils.copyProperties(comStreetVO,comStreetDO );
+        return R.ok(comStreetDAO.updateById(comStreetDO));
+    }
+
+    /**
+     * 删除街道
+     * */
+    @Override
+    public R remove(Long id) {
+        //是否有未结事件
+        List<Long> longs = comActDAO.selectCommunityByStreetId(id);
+        List<ComEvent> comEvents = comEventMapper.selectList(new QueryWrapper<ComEvent>().lambda().in(ComEvent::getEventProcessStatus, (4), (6), (7), (8)).in(ComEvent::getRequestUserCommunity, longs));
+        if (comEvents.size()!=0){
+            return R.fail("有未结事件不可删除");
+        }
+        comStreetDAO.deleteById(id);
+        return R.ok();
+    }
+
+    @Override
+    public R removeCommunity(Long id) {
+        //是否有未结案件
+        List<ComEvent> comEvents = comEventMapper.selectList(new QueryWrapper<ComEvent>().lambda().in(ComEvent::getEventProcessStatus, (4), (6), (7), (8)).eq(ComEvent::getRequestUserCommunity, id));
+        if (comEvents.size()!=0){
+            return R.fail("有未结事件不可删除");
+        }
+        comActDAO.deleteById(id);
+        return R.ok();
+    }
+
+    @Override
+    public R repassCommunity(ComActVO comActVO) {
+        ComActDO comActDO=new ComActDO();
+        try {
+            comActDO.setPassword(MyAESUtil.Encrypt(comActVO.getPassword(),"Ryo7M3n8loC5Abcd" ));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        comActDO.setCommunityId(comActVO.getCommunityId());
+        return R.ok(comActDAO.updateById(comActDO));
+    }
+
+    @Override
+    public R repssStreet(ComStreetVO comActVO) {
+        ComStreetDO comStreetDO=new ComStreetDO();
+        try {
+            comStreetDO.setPassword(MyAESUtil.Encrypt(comActVO.getPassword(),"Ryo7M3n8loC5Abcd" ));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        comStreetDO.setStreetId(comActVO.getStreetId());
+        return R.ok(comStreetDAO.updateById(comStreetDO));
+    }
+
 }

--
Gitblit v1.7.1