public override async Task <ActionResult <UserLoginDto> > Put([FromRoute] UserLoginKey id, [FromBody] UserLoginUpdateRequest updateRequest) { if (!id.Equals(updateRequest.Id)) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var dto = await _service.UpdateAsync(updateRequest); return(CreatedAtAction(nameof(Get), new { id = dto.Id }, dto)); } catch (ValidationException e) { // 应该是 422 UnprocessableEntityResult return(BadRequest(e)); } catch (DbUpdateConcurrencyException) { if (!_service.Exists(id)) { return(NotFound()); } else { return(BadRequest("数据已被更改!")); throw; } } }