平安校园
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

61 linhas
1.8 KiB

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