平安校园
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.
 
 
 
 
 
 

59 line
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. }