Esempio n. 1
0
        public async Task <ActionResult <PagedResponseWrapper> > GetHotPostsAsync([FromQuery] PagingParameters pagingParameters)
        {
            //_logger.LogInformation("-----UserId: {UserId}-----", User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            //_logger.LogInformation("-----UserName: {UserName}-----", User.FindFirst(ClaimTypes.Name)?.Value);
            //_logger.LogInformation("-----Authed: {Authed}-----", User.Identity.IsAuthenticated);
            //_logger.LogInformation("-----AuthType: {AuthType}-----", User.Identity.AuthenticationType);
            var posts = await _postQueries.GetHotPostsAsync(pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
Esempio n. 2
0
        public async Task <ActionResult <PagedResponseWrapper> > GetAppointmentsAsync(
            [FromQuery(Name = "payertype")] PayerType?payerType,
            [FromQuery(Name = "appointmentedUserType")] AppointmentedUserType?appointmentedUserType,
            [FromQuery(Name = "appointmentseconds")] double?appointmentSeconds,
            [FromQuery] PagingParameters pagingParameters)
        {
            var appointments = await _appointmentQueries.GetAppointmentsAsync(payerType, appointmentedUserType, appointmentSeconds, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(appointments)));
        }
Esempio n. 3
0
        public async Task <ActionResult <PagedResponseWrapper> > GetSameCityPostsAsync(string cityCode, [FromQuery(Name = "key")] string key, [FromQuery] PagingParameters pagingParameters)
        {
            PagedList <PostViewModel> posts = null;

            if (string.IsNullOrWhiteSpace(key))
            {
                posts = await _postQueries.GetSameCityPostsAsync(cityCode, pagingParameters);
            }
            else
            {
                posts = await _postQueries.SearchPosts(null, key, cityCode, pagingParameters);
            }

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
        public async Task <ActionResult <PagedResponseWrapper> > GetUsersAsync([FromQuery] PagingParameters pagingParameters)
        {
            var queryableUsers = from u in _userManager.Users
                                 .OrderBy(u => u.UserName)
                                 .ThenBy(u => u.Id)
                                 select new UserViewModel
            {
                Id          = u.Id,
                UserName    = u.UserName,
                Email       = u.Email,
                PhoneNumber = u.PhoneNumber,
                Role        = u.Role
            };

            var pagedUsers = await PagedList <UserViewModel> .ToPagedListAsync(queryableUsers, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(pagedUsers)));
        }
Esempio n. 5
0
        public async Task <ActionResult <PagedResponseWrapper> > GetCirclePostsAsync(Guid circleId, string type, [FromQuery(Name = "key")] string key, [FromQuery] PagingParameters pagingParameters)
        {
            PagedList <PostViewModel> posts = null;

            type = type.ToLower();
            if (type == "good")
            {
                posts = await _postQueries.GetCirclePostsAsync(circleId, true, key, string.Empty, pagingParameters);
            }
            else if (type == "hot")
            {
                posts = await _postQueries.GetCirclePostsAsync(circleId, false, key, "score", pagingParameters);
            }
            else if (type == "newest")
            {
                posts = await _postQueries.GetCirclePostsAsync(circleId, false, key, string.Empty, pagingParameters);
            }

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
Esempio n. 6
0
        public async Task <ActionResult <PagedResponseWrapper> > SearchPostsAsync([FromQuery] Visibility?visibility, [FromQuery(Name = "key")] string key, [FromQuery] PagingParameters pagingParameters)
        {
            var posts = await _postQueries.SearchPosts(visibility, key, null, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
Esempio n. 7
0
        public async Task <ActionResult <ResponseWrapper> > GetShareDataAsync([FromQuery] string s, [FromQuery] string t, [FromQuery] string k, [FromQuery] bool c, [FromQuery] PagingParameters pagingParameters)
        {
            PagedList <PostViewModel> posts = null;

            var descryptedStr = Encryptor.DecryptDES(s, _decryptKey, _decryptKey);

            if (descryptedStr != s)
            {
                var shareInfo = JsonConvert.DeserializeObject <ShareInfo>(descryptedStr);

                _logger.LogInformation("GetShareDataAsync: {@ShareInfo}", shareInfo);

                // 优先搜索加密对象中的分类,若其无值,则搜索url参数中的分类
                // 其场景是:客户端可以分享三种类型,1. 单个帖子,2. 帖子分类,3. 用户的全部帖子
                // 当分享的是第三种时,加密对象中只有用户id(帖子id和帖子分类为空)
                // 在网页上查看分享时,对与第三种可以选择帖子分类来筛选,选择的分类通过url参数privateTag传上来
                if (string.IsNullOrWhiteSpace(shareInfo.PrivateTag))
                {
                    shareInfo.PrivateTag = t;
                }

                if (shareInfo.UserId != Guid.Empty && CheckShareTime(shareInfo.Timestamp))
                {
                    if (shareInfo.PostId != Guid.Empty)
                    {
                        _logger.LogInformation("GetShareDataAsync: single post");

                        // 统计访问次数
                        if (c)
                        {
                            await UpdateUserShareAsync(shareInfo.UserId, shareInfo.PostId, null);
                        }

                        // get share data and return
                        var post = await _postQueries.GetSharedPostAsync(shareInfo.PostId, shareInfo.UserId);

                        posts = new PagedList <PostViewModel>(new List <PostViewModel> {
                            post
                        }, 1, new PagingParameters {
                            PageNumber = 1, PageSize = 1
                        });
                        return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
                    }
                    else if (!string.IsNullOrWhiteSpace(shareInfo.PrivateTag))
                    {
                        _logger.LogInformation("GetShareDataAsync: tag posts");

                        // 统计访问次数
                        if (c)
                        {
                            await UpdateUserShareAsync(shareInfo.UserId, null, shareInfo.PrivateTag);
                        }

                        // get share data and return
                        posts = await _postQueries.GetSharedPostsAsync(shareInfo.PrivateTag, shareInfo.UserId, k, pagingParameters);

                        return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
                    }
                    else
                    {
                        _logger.LogInformation("GetShareDataAsync: user posts");

                        // 统计访问次数
                        if (c)
                        {
                            await UpdateUserShareAsync(shareInfo.UserId, null, null);
                        }

                        // get share data and return
                        posts = await _postQueries.GetSharedPostsAsync(shareInfo.UserId, k, pagingParameters);

                        return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
                    }
                }
            }

            return(new ObjectResult(ResponseWrapper.CreateErrorResponseWrapper((StatusCode)HttpStatusCode.BadRequest, "分享的帖子不存在或已过期")));
        }
Esempio n. 8
0
        public async Task <ActionResult <PagedResponseWrapper> > GetPostsByPublicTagAsync(string tag, [FromQuery] PagingParameters pagingParameters)
        {
            var posts = await _postQueries.GetPostsByPublicTagAsync(tag, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
Esempio n. 9
0
        public async Task <ActionResult <PagedResponseWrapper> > GetLikedPostsAsync([FromQuery] PagingParameters pagingParameters)
        {
            var posts = await _postQueries.GetLikedPostsAsync(pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
Esempio n. 10
0
        public async Task <ActionResult <PagedResponseWrapper> > GetReceivedAppointmentDealsAsync([FromQuery] PagingParameters pagingParameters)
        {
            var deals = await _appointmentDealQueries.GetReceivedAppointmentDealsAsync(pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(deals)));
        }
Esempio n. 11
0
        public async Task <ActionResult <PagedResponseWrapper> > GetFinishedOrdersAsync([FromQuery] PagingParameters pagingParameters)
        {
            var orders = await _orderQueries.GetOrdersAsync(OrderStage.Finished, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(orders)));
        }
Esempio n. 12
0
        public async Task <ActionResult <PagedResponseWrapper> > GetMyAppointmentsAsync([FromQuery] PagingParameters pagingParameters)
        {
            var appointments = await _appointmentQueries.GetMyAppointmentsAsync(pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(appointments)));
        }
        public async Task <ActionResult <PagedResponseWrapper> > GetCommentCommentsAsync(Guid commentId, int maxSubCommentsCount, [FromQuery] PagingParameters pagingParameters)
        {
            var comments = await _commentQueries.GetSubCommentsAsync(commentId, maxSubCommentsCount, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(comments)));
        }
Esempio n. 14
0
        public async Task <ActionResult <PagedResponseWrapper> > GetPagedAlbumPhotosAsync(Guid albumId, string orderBy, bool asc, [FromQuery] PagingParameters pagingParameters)
        {
            var photos = await _albumQueries.GetAlbumPhotosAsync(albumId, pagingParameters, orderBy, asc);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(photos)));
        }
Esempio n. 15
0
        public async Task <ActionResult <PagedResponseWrapper> > GetUserCategoryEventsAsync(EventCategory eventCategory, [FromQuery] PagingParameters pagingParameters)
        {
            var result = await _eventQueries.GetUserCategoryEventsAsync(eventCategory, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(result)));
        }
Esempio n. 16
0
        public async Task <ActionResult <ResponseWrapper> > GetFollowedUsersAsync(Guid userId, [FromQuery] PagingParameters pagingParameters)
        {
            var followedUsers = await _userQueries.GetFollowedUsersAsync(userId, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(followedUsers)));
        }
Esempio n. 17
0
        public async Task <ActionResult <PagedResponseWrapper> > GetExaminingUsersAsync([FromQuery] string key, [FromQuery] PagingParameters pagingParameters)
        {
            var users = await _userQueries.GetExaminingUsersAsync(key, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(users)));
        }
Esempio n. 18
0
        public async Task <ActionResult <PagedResponseWrapper> > GetMyPostsAsync(Guid userId, [FromQuery(Name = "privateTag")] string privateTag, [FromQuery(Name = "key")] string key, [FromQuery] PagingParameters pagingParameters)
        {
            var posts = await _postQueries.GetUserPostsAsync(userId, privateTag, key, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(posts)));
        }
Esempio n. 19
0
        public async Task <ActionResult <PagedResponseWrapper> > GetWaitingForUploadOriginalOrdersAsync([FromQuery] PagingParameters pagingParameters)
        {
            var orders = await _orderQueries.GetOrdersAsync(OrderStage.Selection, pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(orders)));
        }
        public async Task <ActionResult <PagedResponseWrapper> > GetMyCirclesAsync([FromQuery] PagingParameters pagingParameters)
        {
            var result = await _circleQueries.GetMyCirclesAsync(pagingParameters);

            return(Ok(PagedResponseWrapper.CreateOkPagedResponseWrapper(result)));
        }