public async Task UpdateAsync(SysDto model) { if (!model.IsJobNoUnique && model.IsJobNoPwdLoginEnabled) { throw new IamException(HttpStatusCode.BadRequest, "只有工号唯一才允许启用工号登录"); // 必须确保当前数据库中的工号是唯一的 } if (!model.IsUserPhoneUnique && model.IsPhonePwdLoginEnabled) { throw new IamException(HttpStatusCode.BadRequest, "只有手机号唯一才允许启用手机号登录"); // 必须确保当前数据库中的工号是唯一的 } if (model.IsJobNoUnique && !await _userService.IsJobNoUniqueAsync()) { throw new IamException(HttpStatusCode.BadRequest, "当前系统中多个用户工号相同,无法设置成工号唯一"); } if (model.IsUserPhoneUnique && !await _userService.IsPhoneUniqueAsync()) { throw new IamException(HttpStatusCode.BadRequest, "当前系统中多个用户手机号相同,无法设置成手机号唯一"); } var existed = await _sysRepo.GetAsync(false); if (existed != null) { existed.Update(model.IsJobNoUnique, model.IsUserPhoneUnique, model.IsPhonePwdLoginEnabled, model.IsJobNoPwdLoginEnabled, model.IsRegisterUserEnabled, model.EnabledQrExternalLogins); } else { _sysRepo.Add(new SystemInfo(model.IsJobNoUnique, model.IsUserPhoneUnique, model.IsPhonePwdLoginEnabled, model.IsJobNoPwdLoginEnabled, model.IsRegisterUserEnabled, model.EnabledQrExternalLogins)); } }