Пример #1
0
        public PagedResultDto <TagListDto> GetSubscribeTags(UserSubscribeSearchDto userSubscribeDto)
        {
            List <Guid> userTagIds = _userTagRepository.Select
                                     .Where(u => u.CreateUserId == CurrentUser.Id)
                                     .ToList(r => r.TagId);

            List <TagListDto> tagListDtos = _userTagRepository.Select.Include(r => r.Tag)
                                            .Where(r => r.CreateUserId == userSubscribeDto.UserId)
                                            .OrderByDescending(r => r.CreateTime)
                                            .ToPagerList(userSubscribeDto, out long count)
                                            .Select(r =>
            {
                TagListDto tagDto = Mapper.Map <TagListDto>(r.Tag);
                if (tagDto != null)
                {
                    tagDto.ThumbnailDisplay = _fileRepository.GetFileUrl(tagDto.Thumbnail);
                    tagDto.IsSubscribe      = userTagIds.Any(tagId => tagId == tagDto.Id);
                }
                else
                {
                    return(new TagListDto()
                    {
                        Id = r.TagId,
                        TagName = "该标签已被拉黑",
                        IsSubscribe = userTagIds.Any(tagId => tagId == r.TagId)
                    });
                }
                return(tagDto);
            }).ToList();

            return(new PagedResultDto <TagListDto>(tagListDtos, count));
        }
Пример #2
0
        public async Task <TagListDto> GetAsync(Guid id)
        {
            Tag tag = await _tagRepository.Select.Where(a => a.Id == id).ToOneAsync();

            if (tag == null)
            {
                throw new LinCmsException("不存在此标签");
            }
            TagListDto tagDto = Mapper.Map <TagListDto>(tag);

            tagDto.IsSubscribe = await this.IsSubscribeAsync(id);

            tagDto.ThumbnailDisplay = _fileRepository.GetFileUrl(tagDto.Thumbnail);
            return(tagDto);
        }
Пример #3
0
        /// <summary>
        /// 根据状态得到标签列表
        /// </summary>
        /// <param name="searchDto"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <TagListDto> > GetListAsync(TagSearchDto searchDto)
        {
            if (searchDto.Sort.IsNullOrEmpty())
            {
                searchDto.Sort = "create_time desc";
            }

            List <TagListDto> tags = (await _tagRepository.Select.IncludeMany(r => r.UserTags, r => r.Where(u => u.CreateUserId == CurrentUser.Id))
                                      .WhereIf(searchDto.TagIds.IsNotNullOrEmpty(), r => searchDto.TagIds.Contains(r.Id))
                                      .WhereIf(searchDto.TagName.IsNotNullOrEmpty(), r => r.TagName.Contains(searchDto.TagName))
                                      .WhereIf(searchDto.Status != null, r => r.Status == searchDto.Status)
                                      .OrderBy(searchDto.Sort)
                                      .ToPagerListAsync(searchDto, out long totalCount))
                                     .Select(r =>
            {
                TagListDto tagDto       = Mapper.Map <TagListDto>(r);
                tagDto.ThumbnailDisplay = _fileRepository.GetFileUrl(tagDto.Thumbnail);
                tagDto.IsSubscribe      = r.UserTags.Any();
                return(tagDto);
            }).ToList();

            return(new PagedResultDto <TagListDto>(tags, totalCount));
        }