From e2970b6e0050a480c799cb0aae255a9da04740b1 Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期三, 05 七月 2023 09:42:44 +0800
Subject: [PATCH] 修改新增社区 不同区域同名字社区添加报错

---
 springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
index aa368ba..5b53465 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -1256,6 +1256,15 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R addUserBackstage(AdministratorsUserVO administratorsUserVO) {
+
+        List<SysUserDO> list=userDao.selectList(new QueryWrapper<SysUserDO>().lambda().
+                       eq(SysUserDO::getAppId,administratorsUserVO.getAppid()).
+                eq(SysUserDO::getAccount,administratorsUserVO.getAccount()));
+        if(list!=null && list.size()>0)
+        {
+            return R.fail("账户已存在!");
+        }
+
         ComActVO comActVO = userDao.selectCommunity(administratorsUserVO.getCommunityId());
         if (nonNull(comActVO)) {
             List<ComAreaTownCommunityVO> areaTownList = userDao.selectAreaTownCommunity(comActVO.getName());
@@ -1288,6 +1297,7 @@
             }
             sysRoleDO.setRoleSort(0);
             sysRoleDO.setCreateBy(administratorsUserVO.getUserId());
+            sysRoleDO.setRoleId(Snowflake.getId());
             int insert = roleDAO.insert(sysRoleDO);
             if (insert > 0) {
                 SysRoleDO sysRoleDO1 = roleDAO.selectOne(
@@ -1307,6 +1317,7 @@
             sysRoleDO.setRoleKey(Constants.STREET_ROLE_KEY + administratorsUserVO.getStreetId());
             sysRoleDO.setRoleSort(0);
             sysRoleDO.setCreateBy(administratorsUserVO.getUserId());
+            sysRoleDO.setRoleId(Snowflake.getId());
             int insert = roleDAO.insert(sysRoleDO);
             if (insert > 0) {
                 SysRoleDO sysRoleDO1 = roleDAO.selectOne(
@@ -1405,10 +1416,10 @@
             }
             sysRoleDO.setRoleSort(0);
             sysRoleDO.setCreateBy(administratorsUserVO.getUserId());
-            SysRoleDO sysRoleDO1 = roleDAO.selectOne(
+            List<SysRoleDO> sysRoleDO1 = roleDAO.selectList(
                     new QueryWrapper<SysRoleDO>().lambda().eq(SysRoleDO::getRoleKey, sysRoleDO.getRoleKey()));
-            if (sysRoleDO1 != null) {
-                sysRoleDO = sysRoleDO1;
+            if (sysRoleDO1 != null && sysRoleDO1.size()>0 ) {
+                sysRoleDO = sysRoleDO1.get(0);
                 roleId = sysRoleDO.getRoleId();
             } else {
                 roleDAO.insert(sysRoleDO);

--
Gitblit v1.7.1