TopicGroupService.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Entity.Topic;
  4. using GxPress.Repository.Interface.Topic;
  5. using GxPress.Service.Interface.Topic;
  6. namespace GxPress.Service.Implement.Topic
  7. {
  8. public class TopicGroupService : ITopicGroupService
  9. {
  10. private readonly ITopicGroupRepository topicGroupRepository;
  11. public TopicGroupService(ITopicGroupRepository topicGroupRepository)
  12. {
  13. this.topicGroupRepository = topicGroupRepository;
  14. }
  15. /// <summary>
  16. /// 根据用户ID获取分组
  17. /// </summary>
  18. /// <param name="userId"></param>
  19. /// <returns></returns>
  20. public async Task<IEnumerable<TopicGroup>> GetTopicGroupsAsync(int userId)
  21. {
  22. var result = new List<TopicGroup>() {
  23. new TopicGroup {Id=-1,Name="我的"},
  24. new TopicGroup {Id=-2,Name="同单位"},
  25. new TopicGroup {Id=-3,Name="推荐" } ,
  26. new TopicGroup {Id=0,Name="全部" }};
  27. result.AddRange(await topicGroupRepository.GetTopicGroupsAsync(userId));
  28. return result;
  29. }
  30. /// <summary>
  31. /// 根据用户ID获取分组
  32. /// </summary>
  33. /// <param name="userId"></param>
  34. /// <returns></returns>
  35. public async Task<IEnumerable<TopicGroup>> GetListTopicGroupsAsync(int userId)
  36. {
  37. var result = await topicGroupRepository.GetTopicGroupsAsync(userId);
  38. return result;
  39. }
  40. }
  41. }