public IActionResult GetArticleInfoAsync([FromBody] GetArticleInfoRequestDto request) { var articleBiz = new ArticleBiz(); var contentBiz = new RichtextBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); CollectionBiz collection = new CollectionBiz(); var articleModel = articleBiz.GetModel(request.ArticleGuid); if (articleModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } var richtextModel = contentBiz.GetModel(articleModel.ContentGuid); var accessory = accessoryBiz.GetAccessoryModelByGuid(articleModel.PictureGuid); var likeCount = new LikeBiz().GetLikeNumByTargetGuid(articleModel.ArticleGuid); var pageViewCount = new ArticleViewBiz().CountNumByTargetIDAsync(articleModel.ArticleGuid).Result; int collectionCount = collection.GetListCountByTarget(articleModel.ArticleGuid); return(Success(new GetArticleInfoResponseDto { ArticleTypeDic = articleModel.ArticleTypeDic, Abstract = articleModel.Abstract, Content = richtextModel?.Content, PictureGuid = articleModel.PictureGuid, Title = articleModel.Title, Visible = articleModel.Visible, PictureUrl = $"{accessory?.BasePath}{accessory?.RelativePath}", ArticleGuid = articleModel.ArticleGuid, ActcleReleaseStatus = articleModel.ActcleReleaseStatus.ToString(), CreationDate = articleModel.CreationDate, LikeCount = likeCount, VisitCount = pageViewCount, Collection = collectionCount })); }
public async Task <IActionResult> GetArticleInfoAsync([FromBody] GetArticleInfoRequestDto request) { var articleBiz = new ArticleBiz(); var contentBiz = new RichtextBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); var articleModel = await articleBiz.GetAsync(request.ArticleGuid); if (articleModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid); var accessory = await accessoryBiz.GetAsync(articleModel.PictureGuid); return(Success(new GetArticleInfoResponseDto { ArticleTypeDic = articleModel.ArticleTypeDic, Abstract = articleModel.Abstract, Content = richtextModel.Content, PictureGuid = articleModel.PictureGuid, Title = articleModel.Title, Visible = articleModel.Visible, PictureUrl = $"{accessory?.BasePath}{accessory?.RelativePath}", ArticleGuid = articleModel.ArticleGuid, Enable = articleModel.Enable, ActcleReleaseStatus = Enum.Parse <Dtos.Article.ReleaseStatus>(articleModel.ActcleReleaseStatus.ToString()), Keyword = JsonConvert.DeserializeObject <string[]>(string.IsNullOrWhiteSpace(articleModel.Keyword) ? "[]" : articleModel.Keyword), ExternalLink = articleModel.ExternalLink })); }
public async Task <IActionResult> GetCourseInfoAsync([FromBody] GetCourseInfoRequestDto request) { var courseBiz = new CourseBiz(); var contentBiz = new RichtextBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); var courseModel = await courseBiz.GetAsync(request.CourseGuid); if (courseModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } var richtextModel = await contentBiz.GetAsync(courseModel.ContentGuid); var accessory = await accessoryBiz.GetAsync(courseModel.LogoGuid); return(Success(new GetCourseInfoResponseDto { Abstract = courseModel.Summary, Content = richtextModel.Content, PictureGuid = courseModel.LogoGuid, Title = courseModel.Title, Visible = courseModel.Visible, Enable = courseModel.Enable, PictureUrl = $"{accessory?.BasePath}{accessory?.RelativePath}", CourseGuid = courseModel.CourseGuid })); }
public IActionResult GetAskedDoctorClassicQaDetails(string qaGuid) { var qaBiz = new QaBiz(); var doctorBiz = new DoctorBiz(); var accessoryBiz = new AccessoryBiz(); var userBiz = new UserBiz(); var likeBiz = new LikeBiz(); var dictionaryBiz = new DictionaryBiz(); var model = qaBiz.GetModel(qaGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var dto = model.ToDto <GetAskedDoctorClassicQaDetailsResponseDto>(); dto.DoctorName = userBiz.GetUser(model.AuthorGuid)?.UserName; var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); dto.DoctorPortrait = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}"; dto.HospitalGuid = doctorModel.HospitalGuid; dto.HospitalName = doctorModel.HospitalName; dto.JobTitle = dictionaryBiz.GetModelById(doctorModel.TitleGuid)?.ConfigName; } dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(qaGuid); dto.Liked = likeBiz.GetLikeState(UserID, qaGuid); return(Success(dto)); }
public async Task <IActionResult> GetCourseDetailAsync([FromBody] GetCourseDetailRequestDto request) { var info = await new ArticleBiz().GetAsync(request.CourseGuid); //await new CourseBiz().GetAsync(request.CourseGuid); var accessoryBiz = new AccessoryBiz(); var richtextEntity = await new RichtextBiz().GetAsync(info.ContentGuid); var logoAccessoryEntity = await accessoryBiz.GetAsync(info.PictureGuid); //var videoAccessoryEntity = await accessoryBiz.GetAsync(info.VideoGuid); var userEntity = new AccountBiz().GetUserById(info.AuthorGuid); //await new UserBiz().GetModelAsync(info.AuthorGuid); var response = info.ToDto <GetCourseDetailResponseDto>(); response.Content = richtextEntity?.Content; response.LogoUrl = $"{logoAccessoryEntity?.BasePath }{logoAccessoryEntity?.RelativePath }"; //response.VideoUrl = $"{videoAccessoryEntity?.BasePath }{videoAccessoryEntity?.RelativePath }"; response.AuthorName = userEntity?.UserName; var hotModel = await new HotExBiz().GetModelAsync(request.CourseGuid); response.LikeTotal = hotModel?.LikeCount ?? 0; //await new LikeBiz().GetLikeNumByTargetGuidAsync(request.CourseGuid); response.VisitTotal = hotModel?.VisitCount ?? 0; //await new BehaviorBiz().GetViewNumByTargetGuidAsync(request.CourseGuid); //var doctor = await new DoctorBiz().GetAsync(info.AuthorGuid); //if (doctor != null) //{ // var doctorAccessory = await accessoryBiz.GetAsync(doctor.PortraitGuid); // response.DoctorPortrait = $"{doctorAccessory?.BasePath }{doctorAccessory?.RelativePath }"; // response.HospitalName = doctor.HospitalName; //} return(Success(response)); }
public IActionResult GetDoctorArticleDetails(string articleGuid) { ArticleBiz articleBiz = new ArticleBiz(); var model = articleBiz.GetModel(articleGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var doctorBiz = new DoctorBiz(); var accessoryBiz = new AccessoryBiz(); var userBiz = new UserBiz(); var likeBiz = new LikeBiz(); var richtextBiz = new RichtextBiz(); var dto = model.ToDto <GetDoctorArticleDetailsResponseDto>(); dto.Content = richtextBiz.GetModel(model.ContentGuid)?.Content; dto.DoctorName = userBiz.GetUser(model.AuthorGuid)?.UserName; var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); dto.DoctorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; dto.HospitalGuid = doctorModel.HospitalGuid; dto.HospitalName = doctorModel.HospitalName; dto.OfficeGuid = doctorModel.OfficeGuid; dto.OfficeName = doctorModel.OfficeName; } dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(articleGuid); dto.Liked = likeBiz.GetLikeState(UserID, articleGuid); return(Success(dto)); }
public IActionResult GetAskedDoctorClassicQa([FromBody] GetAskedDoctorClassicQaRequestDto requestDto) { QaBiz qaBiz = new QaBiz(); var qaModels = qaBiz.GetQaModels(requestDto.PageIndex, requestDto.PageSize, "where enable=true", "last_updated_date desc"); if (qaModels == null) { return(Failed(ErrorCode.Empty)); } DoctorBiz doctorBiz = new DoctorBiz(); UserBiz userBiz = new UserBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); LikeBiz likeBiz = new LikeBiz(); List <GetAskedDoctorClassicQaResponseDto> dtos = new List <GetAskedDoctorClassicQaResponseDto>(); foreach (var model in qaModels) { var dto = model.ToDto <GetAskedDoctorClassicQaResponseDto>(); dto.DoctorName = userBiz.GetUser(model.AuthorGuid)?.UserName; dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(model.QaGuid); var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); dto.DoctorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; } dtos.Add(dto); } return(Success(dtos)); }
public IActionResult GetUserInfo(string userId) { if (string.IsNullOrWhiteSpace(userId)) { userId = UserID; } var uBiz = new UserBiz(); var uModel = uBiz.GetUser(userId); if (uModel == null || !uModel.Enable) { return(Failed(ErrorCode.DataBaseError, "用户状态不可用。")); } var accBiz = new AccessoryBiz(); var accModel = accBiz.GetAccessoryModelByGuid(uModel.PortraitGuid); var outDto = new GetUserInfoResponseDto { Portrait = $"{accModel?.BasePath}{accModel?.RelativePath}", // +"/" 格式确认, NickName = uModel.NickName, Gender = uModel.Gender, Birthday = uModel.Birthday, UserName = uModel.UserName, IdentityNumber = uModel.IdentityNumber, Phone = uModel.Phone }; return(Success(outDto)); }
public IActionResult GetDoctorDetails(string doctorGuid) { var doctorBiz = new DoctorBiz(); var model = doctorBiz.GetDoctor(doctorGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var userBiz = new UserBiz(); var dictionaryBiz = new DictionaryBiz(); var accessoryBiz = new AccessoryBiz(); var topicBiz = new TopicBiz(); var dto = model.ToDto <GetDoctorDetailsResponseDto>(); var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(model.PortraitGuid); dto.DoctorName = userBiz.GetUser(doctorGuid)?.UserName; dto.Title = dictionaryBiz.GetModelById(model.TitleGuid)?.ConfigName; dto.Portrait = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}"; var signature = accessoryBiz.GetAccessoryModelByGuid(model.SignatureGuid); dto.SignatureUrl = $"{signature?.BasePath}{signature?.RelativePath}"; dto.CommentScore = new CommentBiz().GetTargetAvgScoreAsync(model.DoctorGuid).Result; dto.FansVolume = new CollectionBiz().GetListCountByTarget(model.DoctorGuid); dto.ConsultationVolume = doctorBiz.GetDocotrConsultationVolumeAsync(model.DoctorGuid).Result; return(Success(dto)); }
public IActionResult GetUserArticles([FromBody] GetUserArticleRequestDto requestDto) { ArticleBiz articleBiz = new ArticleBiz(); var sourceTypeWhere = string.Empty; if (requestDto.SourceType != null) { sourceTypeWhere = $"and source_type='{requestDto.SourceType.Value.ToString()}'"; } var models = articleBiz.GetArticles(requestDto.PageIndex, requestDto.PageSize, $"where author_guid=@author_guid and actcle_release_status='Release' {sourceTypeWhere}", "last_updated_date desc", new { author_guid = requestDto.AuthorGuid }); if (models == null) { return(Failed(ErrorCode.Empty)); } var accessoryBiz = new AccessoryBiz(); var dictionaryBiz = new DictionaryBiz(); var responseDtos = new List <GetUserArticlesResponseDto>(); foreach (var model in models) { var dto = model.ToDto <GetUserArticlesResponseDto>(); var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(model.PictureGuid); dto.Picture = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}"; dto.ArticleType = dictionaryBiz.GetModelById(model.ArticleTypeDic)?.ConfigName; dto.PageView = new ArticleViewBiz().CountNumByTargetIDAsync(model.ArticleGuid).Result; responseDtos.Add(dto); } return(Success(responseDtos)); }
public async Task <IActionResult> GetClientArticleDetailAsync(string articleGuid, ArticleModel.ArticleSourceTypeEnum articleSource = ArticleModel.ArticleSourceTypeEnum.Doctor) { if (string.IsNullOrWhiteSpace(articleGuid)) { return(Failed(ErrorCode.UserData, "文章Id articleGuid 不可为空")); } var response = new GetClientArticleDetailResponseDto(); ArticleBiz articleBiz = new ArticleBiz(); var model = articleBiz.GetModel(articleGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var doctorBiz = new DoctorBiz(); var accessoryBiz = new AccessoryBiz(); var userBiz = new UserBiz(); var likeBiz = new LikeBiz(); var richtextBiz = new RichtextBiz(); response.ArticleGuid = model.ArticleGuid; response.Title = model.Title; response.AuthorGuid = model.AuthorGuid; response.LastUpdatedDate = model.LastUpdatedDate; response.Content = richtextBiz.GetModel(model.ContentGuid)?.Content; response.LikeNumber = likeBiz.GetLikeNumByTargetGuid(articleGuid); response.Liked = likeBiz.GetLikeState(UserID, articleGuid); if (articleSource == ArticleModel.ArticleSourceTypeEnum.Doctor) { response.AuthorName = userBiz.GetUser(model.AuthorGuid)?.UserName; var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); response.AuthorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; response.HospitalName = doctorModel.HospitalName; response.OfficeName = doctorModel.OfficeName; } } else if (articleSource == ArticleModel.ArticleSourceTypeEnum.Manager) { response.AuthorName = (await new ManagerAccountBiz().GetAsync(model.AuthorGuid))?.UserName; } else { return(Failed(ErrorCode.UserData, $"文章来源 articleSource:{articleSource.ToString()} 数据值非法")); } return(Success(response)); }
public async Task <IActionResult> GetCommentDetailAsync(string commentGuid) { var item = await new CommentBiz().GetAsync(commentGuid); var dto = item.ToDto <GetTargetCommentResponseDto>(); var userModel = new UserBiz().GetUser(item.CreatedBy); var accessoryModel = new AccessoryBiz().GetAccessoryModelByGuid(userModel.PortraitGuid); dto.NickName = userModel.NickName; dto.Portrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; dto.LikeNumber = new LikeBiz().GetLikeNumByTargetGuid(item.CommentGuid); GetSonComment(dto); return(Success(dto)); }
public IActionResult ImprovePersonalInformationToSendIntergral(UserType userType = UserType.Consumer) { var scoreModel = new ScoreExBiz().GetIntergralRecordByCondition(UserID, SendIntergralEnum.完善个人信息送积分.ToString()).Result; if (scoreModel != null) { return(Success());//Failed(ErrorCode.Empty, "完善个人信息积分已送,该次无法赠送积分!"); } var uModel = new UserBiz().GetUser(UserID); if (uModel == null || !uModel.Enable) { return(Success()); //Failed(ErrorCode.DataBaseError, "用户状态不可用。"); } var accModel = new AccessoryBiz().GetAccessoryModelByGuid(uModel.PortraitGuid); var outDto = new GetUserInfoResponseDto { Portrait = $"{accModel?.BasePath}{accModel?.RelativePath}", // +"/" 格式确认, NickName = uModel.NickName, Gender = uModel.Gender, Birthday = uModel.Birthday, UserName = uModel.UserName, IdentityNumber = uModel.IdentityNumber, Phone = uModel.Phone }; var result = false; PropertyInfo[] properties = outDto.GetType().GetProperties(); foreach (var item in properties) { if (string.IsNullOrWhiteSpace(item.GetValue(outDto)?.ToString())) { result = true; } } if (result) { return(Success());//Failed(ErrorCode.DataBaseError, "信息未完善,送积分失败!"); } //完善个人信息,获50积分 if (!InsertIntergral(50, SendIntergralEnum.完善个人信息送积分, userType)) { Logger.Error($"完善个人信息送积分失败!{JsonConvert.SerializeObject(new { UserId = UserID })}"); } return(Success());//isSucc ? Success() : Failed(ErrorCode.DataBaseError, "完善个人信息送积分失败!"); }
private void GetSonComment(GetTargetCommentResponseDto dto) { var commentBiz = new CommentBiz(); var userBiz = new UserBiz(); var accessoryBiz = new AccessoryBiz(); var tmpModels = commentBiz.GetModelsByTargetGuid(dto.CommentGuid); var lst = new List <GetTargetCommentResponseDto>(); foreach (var item in tmpModels) { var tmpDto = item.ToDto <GetTargetCommentResponseDto>(); var userModel = userBiz.GetUser(item.CreatedBy); var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(userModel.PortraitGuid); tmpDto.NickName = userModel.NickName; tmpDto.Portrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; GetSonComment(tmpDto); lst.Add(tmpDto); } dto.SonComments = lst; }
public IActionResult GetCupationalDiseaseKnowledge([FromBody] GetCcupationalDiseaseKnowledgeRequestDto dto) { ArticleBiz articleBiz = new ArticleBiz(); var condition = "where article_type_dic=@article_type_dic and visible=true and enable=true "; var lst = articleBiz.GetArticles(dto.PageNumber, dto.PageSize, condition, "creation_date desc", new { article_type_dic = DictionaryType.OccupationalDiseaseKnowledge }); var accessoryBiz = new AccessoryBiz(); var dtos = new List <GetCcupationalDiseaseKnowledgeResponseDto>(); foreach (var item in lst) { var model = item.ToDto <GetCcupationalDiseaseKnowledgeResponseDto>(); var picture = MySqlHelper.GetModelById <AccessoryModel>(item.PictureGuid); model.Picture = $"{picture?.BasePath}{picture?.RelativePath}"; dtos.Add(model); } if (dtos.Count == 0) { return(Failed(ErrorCode.Empty)); } return(Success(dtos)); }
public IActionResult GetTargetComment([FromBody] GetTargetCommentRequestDto requestDto) { var commentBiz = new CommentBiz(); var userBiz = new UserBiz(); var accessoryBiz = new AccessoryBiz(); var commentModels = commentBiz.GetModels(requestDto.PageIndex, requestDto.PageSize, "where target_guid=@target_guid and enable=@enable", "last_updated_date desc", new { target_guid = requestDto.TargetGuid, enable = true }); var theDtos = new List <GetTargetCommentResponseDto>(); var likeBiz = new LikeBiz(); foreach (var item in commentModels) { var dto = item.ToDto <GetTargetCommentResponseDto>(); var userModel = userBiz.GetUser(item.CreatedBy); var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(userModel.PortraitGuid); dto.NickName = userModel.NickName; dto.Portrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(item.CommentGuid); GetSonComment(dto); theDtos.Add(dto); } return(Success(theDtos)); }
public IActionResult LoadHomePage(string userId) { if (string.IsNullOrWhiteSpace(userId)) { userId = UserID; } var uBiz = new UserBiz(); var uModel = uBiz.GetUser(userId); if (uModel == null || !uModel.Enable) { return(Failed(ErrorCode.DataBaseError, "用户状态不可用。")); } var accBiz = new AccessoryBiz(); var accModel = accBiz.GetAccessoryModelByGuid(uModel.PortraitGuid); var respData = new GetUserPortraitResponseDto() { Portrait = $"{accModel?.BasePath}{accModel?.RelativePath}", NickeName = uModel.NickName }; return(Success(respData)); }
public async Task <IActionResult> ModifyDoctorInfoAsync([FromBody] ModifyDoctorInfoRequestDto doctorDto) { var doctorModelGuid = UserID; var doctorBiz = new DoctorBiz(); var checkDoctor = await doctorBiz.GetAsync(doctorModelGuid); if (checkDoctor == null) { return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!")); } var userModel = await new UserBiz().GetModelAsync(UserID); userModel.UserName = doctorDto.UserName; userModel.IdentityNumber = doctorDto.IdentityNumber; userModel.Birthday = doctorDto.Birthday; userModel.Gender = doctorDto.Gender; var hospitalBiz = new HospitalBiz(); var officeBiz = new OfficeBiz(); var accessoryBiz = new AccessoryBiz(); var doctorModel = new DoctorModel(); doctorModel = checkDoctor; //医生数据 doctorModel.HospitalGuid = doctorDto.HospitalGuid; doctorModel.OfficeGuid = doctorDto.DocOffice; doctorModel.WorkCity = doctorDto.City; doctorModel.PractisingHospital = doctorDto.PractisingHospital; doctorModel.Honor = doctorDto.Honor; doctorModel.Background = doctorDto.Background; doctorModel.TitleGuid = doctorDto.DocTitle; doctorModel.AdeptTags = doctorDto.Adepts; doctorModel.Status = StatusEnum.Submit.ToString(); //doctorModel.SignatureGuid = doctorDto.SignatureGuid; doctorModel.CreatedBy = UserID; doctorModel.OrgGuid = ""; doctorModel.LastUpdatedBy = UserID; doctorModel.PortraitGuid = doctorDto.PortraitGuid; doctorModel.LastUpdatedDate = DateTime.Now; //医院名称 var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.Empty, "未查到医院数据")); } doctorModel.HospitalName = hospitalModel?.HosName; //科室名称 var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid); if (officeModel == null) { return(Failed(ErrorCode.Empty, "未查到科室数据")); } doctorModel.OfficeName = officeModel?.OfficeName; //医生证书配置项 & 附件 var lstCertificate = new List <CertificateModel>(); var lstAccessory = new List <AccessoryModel>(); if (doctorDto.Certificates.Any()) { foreach (var certificate in doctorDto.Certificates) { var certificateModel = new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = certificate.AccessoryGuid, OwnerGuid = doctorModel.DoctorGuid, DicGuid = certificate.DicGuid, CreatedBy = UserID, OrgGuid = "", LastUpdatedBy = UserID }; lstCertificate.Add(certificateModel); var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid); if (accModel != null) { accModel.OwnerGuid = certificateModel.CertificateGuid; accModel.LastUpdatedDate = DateTime.Now; lstAccessory.Add(accModel); } } } var doctorCompositeBiz = new DoctorCompositeBiz(); var result = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, false); return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生数据修改失败!")); }
public async Task <IActionResult> RegisterDoctor([FromBody] RegisterDoctorRequestDto doctorDto) { var doctorModelGuid = UserID; var doctorBiz = new DoctorBiz(); var checkModel = await doctorBiz.GetAsync(doctorModelGuid, true, true); bool isAdd = checkModel == null;;//当前为更新操作还是新增操作 var statusCheck = string.Equals(checkModel?.Status, StatusEnum.Submit.ToString(), StringComparison.OrdinalIgnoreCase) || string.Equals(checkModel?.Status, StatusEnum.Approved.ToString(), StringComparison.OrdinalIgnoreCase); if (checkModel != null && statusCheck && checkModel.Enable) { return(Failed(ErrorCode.DataBaseError, "该用户已注册过医生!")); } var doctorCertificates = await new DictionaryBiz().GetListByParentGuidAsync(DictionaryType.DoctorDicConfig); foreach (var item in doctorCertificates) { if (doctorDto.Certificates.FirstOrDefault(a => a.DicGuid == item.DicGuid) == null) { var eMsg = $"[{item.ConfigName}]没有上传"; return(Failed(ErrorCode.UserData, $"上传的医生证书项和系统配置的项不符,请核对,详情:{eMsg}")); } } var userModel = await new UserBiz().GetModelAsync(UserID); userModel.UserName = doctorDto.UserName; userModel.IdentityNumber = doctorDto.IdentityNumber; userModel.Birthday = doctorDto.Birthday; userModel.Gender = doctorDto.Gender; var hospitalBiz = new HospitalBiz(); var officeBiz = new OfficeBiz(); var accessoryBiz = new AccessoryBiz(); var doctorModel = new DoctorModel(); if (!isAdd) { doctorModel = checkModel; } //医生数据 doctorModel.DoctorGuid = doctorModelGuid; doctorModel.HospitalGuid = doctorDto.HospitalGuid; doctorModel.OfficeGuid = doctorDto.DocOffice; doctorModel.WorkCity = doctorDto.City; doctorModel.PractisingHospital = doctorDto.PractisingHospital; doctorModel.Honor = doctorDto.Honor; doctorModel.Background = doctorDto.Background; doctorModel.TitleGuid = doctorDto.DocTitle; doctorModel.AdeptTags = Newtonsoft.Json.JsonConvert.SerializeObject(doctorDto.Adepts); doctorModel.Status = StatusEnum.Submit.ToString(); doctorModel.SignatureGuid = doctorDto.SignatureGuid; doctorModel.CreatedBy = UserID; doctorModel.OrgGuid = ""; doctorModel.LastUpdatedBy = UserID; doctorModel.PortraitGuid = doctorDto.PortraitGuid; doctorModel.LastUpdatedDate = DateTime.Now; doctorModel.Enable = true; //医院名称 var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.Empty, "未查到医院数据")); } doctorModel.HospitalName = hospitalModel?.HosName; //科室名称 var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid); if (officeModel == null) { return(Failed(ErrorCode.Empty, "未查到科室数据")); } doctorModel.OfficeName = officeModel?.OfficeName; //医生证书配置项 & 附件 var lstCertificate = new List <CertificateModel>(); var lstAccessory = new List <AccessoryModel>(); if (doctorDto.Certificates.Any()) { foreach (var certificate in doctorDto.Certificates) { var certificateModel = new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = certificate.AccessoryGuid, OwnerGuid = doctorModel.DoctorGuid, DicGuid = certificate.DicGuid, CreatedBy = UserID, OrgGuid = "", LastUpdatedBy = UserID }; lstCertificate.Add(certificateModel); var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid); if (accModel != null) { accModel.OwnerGuid = certificateModel.CertificateGuid; accModel.LastUpdatedDate = DateTime.Now; lstAccessory.Add(accModel); } } } var doctorCompositeBiz = new DoctorCompositeBiz(); var result = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, isAdd); if (result) { new DoctorActionBiz().RegisterDoctor(this.UserID); } return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生注册数据插入不成功!")); }