Example #1
0
        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));
        }
Example #2
0
        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 IActionResult GetLikeNumber(string targetGuid)
        {
            var likeBiz = new LikeBiz();
            var num     = likeBiz.GetLikeNumByTargetGuid(targetGuid);

            return(Success(num));
        }
Example #4
0
        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 GetLikeState(string targetGuid)
        {
            var likeBiz = new LikeBiz();
            var state   = likeBiz.GetLikeState(UserID, targetGuid);

            return(Success(state));
        }
        public IActionResult LikeTarget(string targetGuid)
        {
            var    likeBiz  = new LikeBiz();
            var    tmpModel = likeBiz.GetOneLikeModelByUserId(UserID, targetGuid);
            string likeState;
            bool   result;

            if (tmpModel != null)
            {
                likeState                = tmpModel.Enable ? "取消点赞" : "点赞";
                tmpModel.Enable          = !tmpModel.Enable;
                tmpModel.LastUpdatedDate = DateTime.Now;
                tmpModel.LastUpdatedBy   = UserID;
                result = likeBiz.UpdateModel(tmpModel);
            }
            else
            {
                likeState = "点赞";
                var model = new LikeModel
                {
                    LikeGuid      = Guid.NewGuid().ToString("N"),
                    TargetGuid    = targetGuid,
                    CreatedBy     = UserID,
                    LastUpdatedBy = UserID,
                    OrgGuid       = ""
                };
                result = likeBiz.InsertModel(model);
            }
            if (result)
            {
                var upRes = new HotExBiz().UpdateLikeTotalAsync(targetGuid, likeState == "点赞");
            }
            return(result ? Success($"{likeState}操作成功!") : Failed(ErrorCode.DataBaseError, $"{likeState}操作失败!"));
        }
Example #7
0
        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
            }));
        }
Example #8
0
        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));
        }
Example #9
0
        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));
        }