From 00a59b93c16b24e7be77c6f1ce4866c75a2e0431 Mon Sep 17 00:00:00 2001
From: 101captain <237651143@qq.com>
Date: 星期二, 19 四月 2022 16:32:21 +0800
Subject: [PATCH] 花城E+防疫修改

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActSocialOrgServiceImpl.java |   57 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActSocialOrgServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActSocialOrgServiceImpl.java
index cd66bcf..ebee445 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActSocialOrgServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActSocialOrgServiceImpl.java
@@ -8,6 +8,7 @@
 import com.panzhihua.common.model.vos.community.ComActSocialOrgVO;
 import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
 import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.service_community.entity.ComActCommittee;
 import com.panzhihua.service_community.entity.ComActSocialOrg;
 import com.panzhihua.service_community.dao.ComActSocialOrgDao;
 import com.panzhihua.service_community.service.ComActSocialOrgService;
@@ -38,7 +39,7 @@
 
     @Override
     public R selectById(Long id) {
-        return null;
+        return R.ok(comActSocialOrgDao.detail(id));
     }
 
     @Override
@@ -51,7 +52,23 @@
             administratorsUserVO.setType(3);
             administratorsUserVO.setAccount(comActSocialOrgVO.getAccount());
             administratorsUserVO.setPassword(comActSocialOrgVO.getPassword());
-            administratorsUserVO.setRoleId(comActSocialOrgVO.getRoleId());
+            //根据roleId判断是普通社会组织还是定制三社
+            if(comActSocialOrgVO.getRoleId()==null){
+                administratorsUserVO.setSocialType(2);
+                administratorsUserVO.setRoleId(777777777L);
+                comActSocialOrg.setIsSociety(1);
+            }
+            else {
+                administratorsUserVO.setRoleId(comActSocialOrgVO.getRoleId());
+            }
+            if(comActSocialOrg.getCommunityId()!=null){
+                administratorsUserVO.setCommunityId(comActSocialOrg.getCommunityId());
+            }
+            if(comActSocialOrg.getStreetId()!=null){
+                administratorsUserVO.setStreetId(comActSocialOrg.getStreetId());
+            }
+            administratorsUserVO.setName(comActSocialOrgVO.getContactName());
+            administratorsUserVO.setPhone(comActSocialOrgVO.getContactPhone());
             R r=userService.addUserBackstageProperty(administratorsUserVO);
             if(R.isOk(r)){
                 comActSocialOrg.setUserId(Long.parseLong(r.getData().toString()));
@@ -59,34 +76,26 @@
                 this.comActSocialOrgDao.insert(comActSocialOrg);
                 return R.ok();
             }
+            return R.fail("账号或手机号已存在");
         }
         return R.fail();
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public R update(ComActSocialOrgVO comActSocialOrgVO) {
         if(comActSocialOrgVO!=null){
-           if(!comActSocialOrgVO.getAccount().isEmpty()||!comActSocialOrgVO.getPassword().isEmpty()){
-               AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO();
-               administratorsUserVO.setUserId(comActSocialOrgVO.getUserId());
-               administratorsUserVO.setAccount(comActSocialOrgVO.getAccount());
-               administratorsUserVO.setPassword(comActSocialOrgVO.getPassword());
-               R r=userService.putUserBackstage(administratorsUserVO);
-               if(R.isOk(r)){
-                   ComActSocialOrg comActSocialOrg=new ComActSocialOrg();
-                   BeanUtils.copyProperties(comActSocialOrgVO,comActSocialOrg);
-                   this.comActSocialOrgDao.updateById(comActSocialOrg);
-                   return R.ok();
-               }
-               return R.fail("账号密码修改失败");
-           }
-           else {
                ComActSocialOrg comActSocialOrg=new ComActSocialOrg();
                BeanUtils.copyProperties(comActSocialOrgVO,comActSocialOrg);
+                if(comActSocialOrgVO.getRoleId()!=null){
+                    ComActSocialOrg comPropertyBase=this.comActSocialOrgDao.selectById(comActSocialOrgVO.getId());
+                    AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO();
+                    administratorsUserVO.setUserId(comPropertyBase.getUserId());
+                    administratorsUserVO.setRoleId(comActSocialOrgVO.getRoleId());
+                    administratorsUserVO.setLastLoginTime(DateUtil.date());
+                    this.userService.putUserBackstage(administratorsUserVO);
+                }
                this.comActSocialOrgDao.updateById(comActSocialOrg);
                return R.ok();
-           }
         }
         return R.fail();
     }
@@ -99,12 +108,10 @@
             if(comActSocialOrg.getUserId()!=null){
                 AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO();
                 administratorsUserVO.setUserId(comActSocialOrg.getUserId());
-                R r=userService.deleteUserBackstage(administratorsUserVO);
-                if(R.isOk(r)){
-                    this.comActSocialOrgDao.deleteById(id);
-                    return R.ok();
-                }
-                return R.fail("账号删除失败");
+                administratorsUserVO.setCommunityId(comActSocialOrg.getCommunityId());
+                userService.deleteUserBackstage(administratorsUserVO);
+                this.comActSocialOrgDao.deleteById(id);
+                return R.ok();
             }
         }
         return R.fail("用户账号错误");

--
Gitblit v1.7.1