public async Task <IActionResult> ModifyPassword([FromBody] HospitalModifyPasswordRequestDto requestDto) { if (string.IsNullOrEmpty(UserID)) { return(Failed(ErrorCode.Empty, "账号不存在或已禁用")); } var hospitalBiz = new HospitalBiz(); var model = await hospitalBiz.GetAsync(UserID); if (model is null) { return(Failed(ErrorCode.Empty, "账号不存在或已禁用")); } var addSaltPwd = CryptoHelper.AddSalt(model.HospitalGuid, requestDto.Password); if (!model.Password.Equals(addSaltPwd, StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.Empty, "账号或密码错误")); } model.LastUpdatedBy = model.HospitalGuid; model.LastUpdatedDate = DateTime.Now; model.Password = CryptoHelper.AddSalt(model.HospitalGuid, requestDto.NewPassword); var result = await hospitalBiz.UpdateAsync(model); return(result ? Success() : Failed(ErrorCode.Empty, "密码更新失败!")); }
public async Task <IActionResult> DisableEnableHospitalAsync([FromBody] DisableEnableHospitalRequestDto request) { var hospitalBiz = new HospitalBiz(); var entity = await hospitalBiz.GetAsync(request.Guid); if (entity == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; entity.Enable = request.Enable; var result = await hospitalBiz.UpdateAsync(entity); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
public async Task <IActionResult> ResetPasswordAsync([FromBody] ResetPasswordResponseDto request) { HospitalBiz hospitalBiz = new HospitalBiz(); var entity = await hospitalBiz.GetAsync(request.Guid); if (entity == null) { return(Failed(ErrorCode.DataBaseError)); } if (string.IsNullOrWhiteSpace(entity.Account)) { return(Failed(ErrorCode.DataBaseError, "请先设置账号")); } var password = "******";//默认密码 entity.Password = CryptoHelper.AddSalt(entity.HospitalGuid, GD.Common.Helper.CryptoHelper.Md5(password)); entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; await hospitalBiz.UpdateAsync(entity); return(Success()); }
public async Task <IActionResult> UpdateHospitalAsync([FromBody] UpdateHospitalRequestDto request) { var hospitalBiz = new HospitalBiz(); var hospitalModel = await hospitalBiz.GetAsync(request.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } if (request.Account != hospitalModel.Account && await hospitalBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } var contentBiz = new RichtextBiz(); request.Content = string.IsNullOrWhiteSpace(request.Content) ? "暂无详细" : request.Content; request.HosTag = string.IsNullOrWhiteSpace(request.HosTag) ? "暂无标签" : request.HosTag; var richtextModel = await contentBiz.GetAsync(hospitalModel.HosDetailGuid); var richtextIsAdd = false; if (richtextModel != null) { richtextModel.Content = request.Content; richtextModel.LastUpdatedBy = UserID; richtextModel.LastUpdatedDate = DateTime.Now; richtextModel.OrgGuid = string.Empty; richtextModel.OwnerGuid = request.HospitalGuid; } else { var textGuid = Guid.NewGuid().ToString("N"); richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = hospitalModel.HospitalGuid, TextGuid = textGuid, }; hospitalModel.HosDetailGuid = textGuid; richtextIsAdd = true; } hospitalModel.HosAbstract = request.HosAbstract; hospitalModel.HosLevel = request.HosLevel; hospitalModel.HosName = request.HosName; hospitalModel.HosTag = request.HosTag; hospitalModel.Location = request.Location; hospitalModel.LogoGuid = request.LogoGuid; hospitalModel.RegisteredDate = request.RegisteredDate; hospitalModel.Visibility = request.Visibility; hospitalModel.LastUpdatedBy = UserID; hospitalModel.LastUpdatedDate = DateTime.Now; hospitalModel.Enable = request.Enable; hospitalModel.ContactNumber = request.ContactNumber; hospitalModel.Sort = request.Sort; hospitalModel.GuidanceUrl = request.GuidanceUrl ?? string.Empty; hospitalModel.ExternalLink = request.ExternalLink ?? string.Empty; hospitalModel.Account = request.Account; hospitalModel.IsHospital = request.IsHospital; hospitalModel.Longitude = request.Longitude; hospitalModel.Latitude = request.Latitude; if (null != request.Password) { hospitalModel.Password = CryptoHelper.AddSalt(hospitalModel.HospitalGuid, request.Password); } var response = await hospitalBiz.UpdateAsync(hospitalModel, richtextModel, richtextIsAdd); if (!response) { return(Failed(ErrorCode.DataBaseError, "修改失败")); } return(Success(response)); }