智慧保安后台管理-外网项目备份
用户新增时判断角色是否为保安员,如果是需要判断是否已存在身份证号相同的保安员,如果存在则提示
2 files modified
55 ■■■■ changed files
src/main/java/org/springblade/modules/system/controller/UserController.java 51 ●●●● patch | view | raw | blame | history
src/main/resources/application-test.yml 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -236,6 +236,18 @@
            if (userCount > 0) {
                throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
            }
            // 校验保安员,如果角色为保安员,则需要判断身份证号是否已注册
            List<String> roleIds = Arrays.asList(user.getRoleId().split(","));
            String roleId = "1412226235153731586";
            if (roleIds.contains(roleId)){
                // 判断是否已存在,通过身份证号码查询用户信息
                QueryWrapper<User> wrapper = new QueryWrapper<>();
                wrapper.eq("is_deleted",0).eq("status",1).eq("cardid",user.getCardid()).like("role_id","%"+roleId+"%");
                List<User> list = userService.list(wrapper);
                if (list.size()>0){
                    throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前保安员身份证号码 [{}] 已存在!", user.getCardid()));
                }
            }
            user.setTenantId("000000");
            user.setStatus(1);
            user.setIsDeleted(0);
@@ -254,51 +266,12 @@
            }
            //新增
            boolean stats = userService.save(user);
            if (stats) {
                //内网同步
                String s = "insert into blade_user(" +
                    "id,tenant_id,code,account,password,real_name,phone,sex,role_id,dept_id," +
                    "create_time,update_time,cardid,status,is_deleted,jurisdiction) " +
                    "values(" + "'" + user.getId() + "'" + "," +
                    "'" + user.getTenantId() + "'" + "," +
                    "'" + user.getCode() + "'" + "," +
                    "'" + user.getAccount() + "'" + "," +
                    "'" + user.getPassword() + "'" + "," +
                    "'" + user.getRealName() + "'" + "," +
                    "'" + user.getPhone() + "'" + "," +
                    "'" + user.getSex() + "'" + "," +
                    "'" + user.getRoleId() + "'" +
                    "," + "'" + user.getDeptId() + "'" +
                    "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getCreateTime()) + "'" +
                    "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" +
                    "," + "'" + user.getCardid() + "'" +
                    "," + "'" + user.getStatus() + "'" +
                    "," + "'" + user.getIsDeleted() + "'" +
                    "," + "'" + user.getJurisdiction() + "'"
                    + ")";
                myAsyncService.dataSync(s);
            }
        } else {
            //修改
            User user1 = userService.getById(user.getId());
            user.setPassword(user1.getPassword());
            user.setUpdateTime(new Date());
            boolean b = userService.updateById(user);
            if (b) {
                String s1 =
                    "update blade_user set account = " + "'" + user.getAccount() + "'"
                        + ",code = " + "'" + user.getCode() + "'"
                        + ",real_name = " + "'" + user.getRealName() + "'"
                        + ",phone = " + "'" + user.getPhone() + "'"
                        + ",sex = " + "'" + user.getSex() + "'"
                        + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'"
                        + ",role_id = " + "'" + user.getRoleId() + "'"
                        + ",dept_id = " + "'" + user.getDeptId() + "'"
                        + ",cardid = " + "'" + user.getCardid() + "'"
                        + ",guncode = " + "'" + user.getGuncode() + "'"
                        + " " + "where id = " + "'" + user.getId() + "'";
                myAsyncService.dataSync(s1);
            }
        }
        //返回
src/main/resources/application-test.yml
@@ -13,9 +13,9 @@
    #  commandTimeout: 5000
  datasource:
    # MySql
    url: jdbc:mysql://106.225.193.35:3306/zhbaw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
    url: jdbc:mysql://60.220.177.113:3308/zhbaw?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
    username: root
    password: HCyj@2022
    password: Zhba@jc@2023
    # rabbitmq 设置
#  rabbitmq:
#    host: 192.168.0.191