public async Task <IList <TopicTagEntity> > Query(TopicTagQueryModel model)
        {
            var paging = model.Paging();

            var query     = Db.Find();
            var joinQuery = query.LeftJoin <TopicEntity>((t1, t2) => t1.TopicId == t2.Id)
                            .LeftJoin <TagEntity>((t1, t2, t3) => t1.TagId == t3.Id)
                            .LeftJoin <UserEntity>((t1, t2, t3, t4) => t2.UserId == t4.Id);

            joinQuery.Where((t1, t2, t3, t4) => t1.TopicId == model.TopicId);

            if (!paging.OrderBy.Any())
            {
                joinQuery.OrderByDescending((t1, t2, t3, t4) => t1.Id);
            }

            joinQuery.Select((t1, t2, t3, t4) => new
            {
                t1,
                TopicTitle = t2.Title,
                TagName    = t3.Name,
                NickName   = t4.NickName
            });

            var result = await joinQuery.PaginationAsync(paging);

            model.TotalCount = paging.TotalCount;

            return(result);
        }
예제 #2
0
        public async Task <IResultModel> Query(TopicTagQueryModel model)
        {
            var result = new QueryResultModel <TopicTagEntity>
            {
                Rows  = await _repository.Query(model),
                Total = model.TotalCount
            };

            return(ResultModel.Success(result));
        }
예제 #3
0
 public Task <IResultModel> Query([FromQuery] TopicTagQueryModel model)
 {
     return(_service.Query(model));
 }