平安校园
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

59 satır
1.7 KiB

  1. namespace SafeCampus.Application.Services.Business.ClassTeacherService;
  2. public class ClassTeacherService:DbRepository<ClassTeacher>, IClassTeacherService
  3. {
  4. public async Task<bool> Add(ClassTeacherInput input)
  5. {
  6. var model = input.Adapt<ClassTeacher>();
  7. await InsertAsync(model);
  8. return true;
  9. }
  10. public async Task<bool> Update(ClassTeacherUpdateInput input)
  11. {
  12. if (!input.ID.HasValue)
  13. {
  14. throw Oops.Oh("请填写ID");
  15. }
  16. var model = await GetFirstAsync(p => p.Id == input.ID);
  17. if (model == null)
  18. {
  19. throw Oops.Oh("信息不存在");
  20. }
  21. var res = input.Adapt(model);
  22. await UpdateAsync(res);
  23. return true;
  24. }
  25. public async Task<bool> Delete(long id)
  26. {
  27. var model = await GetFirstAsync(x => x.Id == id);
  28. if (model == null)
  29. {
  30. throw Oops.Oh("信息不存在");
  31. }
  32. await DeleteAsync(model);
  33. return true;
  34. }
  35. public async Task<ClassTeacherDto> GetInfo(string personSetId)
  36. {
  37. var model = await Context.Queryable<ClassTeacher>()
  38. .Includes(x => x.SysUserItem)
  39. .Where(x => x.PersonSetId == personSetId).FirstAsync();
  40. if (model == null)
  41. {
  42. return null;
  43. //throw Oops.Oh("信息不存在!");
  44. }
  45. return model.Adapt<ClassTeacherDto>();
  46. }
  47. public async Task<List<ClassTeacherDto>> GetNoPageList()
  48. {
  49. var list = await Context.Queryable<ClassTeacher>()
  50. .Includes(x => x.SysUserItem)
  51. .ToListAsync();
  52. return list.Adapt<List<ClassTeacherDto>>();
  53. }
  54. }