平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IndexService.cs 1.8 KiB

3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 
  2. //
  3. namespace SafeCampus.System;
  4. /// <summary>
  5. /// <inheritdoc cref="IIndexService"/>
  6. /// </summary>
  7. public class IndexService : DbRepository<SysRelation>, IIndexService
  8. {
  9. private readonly IRelationService _relationService;
  10. public IndexService(IRelationService relationService)
  11. {
  12. _relationService = relationService;
  13. }
  14. /// <inheritdoc/>
  15. public async Task<List<ScheduleListOutput>> ScheduleList(ScheduleListInput input)
  16. {
  17. var relations = await GetListAsync(
  18. it => it.Category == CateGoryConst.RELATION_SYS_USER_SCHEDULE_DATA && it.ObjectId == UserManager.UserId
  19. && it.TargetId == input.ScheduleDate,
  20. it => new SysRelation { ExtJson = it.ExtJson, Id = it.Id });//获取当前用户的日程列表
  21. var userSchedules = new List<ScheduleListOutput>();//结果集
  22. relations.ForEach(it =>
  23. {
  24. var extJson = it.ExtJson.ToJsonEntity<RelationUserSchedule>();//转成实体
  25. var userSchedule = extJson.Adapt<ScheduleListOutput>();//格式化
  26. userSchedule.Id = it.Id;//赋值ID
  27. userSchedules.Add(userSchedule);//添加到结果集
  28. });
  29. return userSchedules;
  30. }
  31. /// <inheritdoc/>
  32. public async Task AddSchedule(ScheduleAddInput input)
  33. {
  34. input.ScheduleUserId = UserManager.UserId;
  35. input.ScheduleUserName = UserManager.Name;
  36. //添加日程
  37. await _relationService.SaveRelation(CateGoryConst.RELATION_SYS_USER_SCHEDULE_DATA, UserManager.UserId, input.ScheduleDate, input.ToJson(),
  38. false, false);
  39. }
  40. /// <inheritdoc/>
  41. public async Task DeleteSchedule(BaseIdListInput input)
  42. {
  43. //获取所有ID
  44. var ids = input.Ids;
  45. await DeleteAsync(it => ids.Contains(it.Id) && it.ObjectId == UserManager.UserId);
  46. }
  47. }