Beispiel #1
0
        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
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateCourseAsync([FromBody] UpdateCourseRequestDto request)
        {
            var CourseBiz   = new CourseBiz();
            var contentBiz  = new RichtextBiz();
            var CourseModel = await CourseBiz.GetAsync(request.CourseGuid);

            if (CourseModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }

            var richtextModel = await contentBiz.GetAsync(CourseModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.CourseGuid;

            CourseModel.Summary         = request.Abstract;
            CourseModel.LastUpdatedBy   = UserID;
            CourseModel.LastUpdatedDate = DateTime.Now;
            CourseModel.Title           = request.Title;
            CourseModel.Visible         = request.Visible;
            CourseModel.Enable          = request.Enable;
            CourseModel.LogoGuid        = request.PictureGuid;

            var response = await new CourseBiz().UpdateAsync(richtextModel, CourseModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            return(Success(response));
        }
Beispiel #3
0
        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
            }));
        }
Beispiel #4
0
        public async Task <IActionResult> GetRichtextAsync(string richtextId)
        {
            var richtextBiz   = new RichtextBiz();
            var richtextModel = await richtextBiz.GetAsync(richtextId);

            if (richtextModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查询到此富文本信息"));
            }
            var response = richtextModel.ToDto <GetRichtextResponseDto>();

            return(Success(response));
        }
Beispiel #5
0
        public async Task <IActionResult> ModifyRichtextAsync([FromBody] ModifyRichtextRequestDto requestDto)
        {
            var richtextBiz   = new RichtextBiz();
            var richtextModel = await richtextBiz.GetAsync(requestDto.TextGuid);

            if (richtextModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查询到此富文本信息"));
            }
            richtextModel.Content = requestDto.Content;
            var result = await richtextBiz.UpdateAsync(richtextModel);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "更新失败"));
        }
Beispiel #6
0
        public async Task <IActionResult> UpdateArticleAsync([FromBody] UpdateArticleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var contentBiz   = new RichtextBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }

            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.ArticleGuid;

            articleModel.Abstract            = request.Abstract;
            articleModel.ArticleTypeDic      = request.ArticleTypeDic;
            articleModel.LastUpdatedBy       = UserID;
            articleModel.LastUpdatedDate     = DateTime.Now;
            articleModel.Sort                = 1;
            articleModel.Title               = request.Title;
            articleModel.Visible             = request.Visible;
            articleModel.PictureGuid         = request.PictureGuid;
            articleModel.ActcleReleaseStatus = Enum.Parse <ReleaseStatus>(request.ActcleReleaseStatus);

            var response = await new ArticleBiz().UpdateAsync(richtextModel, articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            //发布时才添加积分
            if (articleModel.ActcleReleaseStatus == ReleaseStatus.Release)
            {
                new DoctorActionBiz().AddArticleAsync(this.UserID);
            }
            return(Success(response));
        }
Beispiel #7
0
        public async Task <IActionResult> UpdateArticleAsync([FromBody] UpdateArticleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var contentBiz   = new RichtextBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.ArticleGuid;

            articleModel.Abstract            = request.Abstract;
            articleModel.ArticleTypeDic      = request.ArticleTypeDic;
            articleModel.LastUpdatedBy       = UserID;
            articleModel.LastUpdatedDate     = DateTime.Now;
            articleModel.Sort                = 1;
            articleModel.Title               = request.Title;
            articleModel.Enable              = request.Enable;
            articleModel.Visible             = request.Visible;
            articleModel.PictureGuid         = request.PictureGuid;
            articleModel.ActcleReleaseStatus = Enum.Parse <Models.Utility.ReleaseStatus>(request.ActcleReleaseStatus.ToString());
            articleModel.Keyword             = JsonConvert.SerializeObject(request.Keyword);
            articleModel.ExternalLink        = request.ExternalLink ?? string.Empty;

            var response = await new ArticleBiz().UpdateAsync(richtextModel, articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            return(Success(response));
        }
Beispiel #8
0
        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));
        }