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

51 rivejä
1.6 KiB

  1. namespace SafeCampus.Application.Services.Business.PersonSetInfoService;
  2. public class PersonSetInfoService:DbRepository<PersonSetInfo>, IPersonSetInfoService
  3. {
  4. public async Task<bool> Add(PersonSetInfoDto input)
  5. {
  6. var model = input.Adapt<PersonSetInfo>();
  7. var oldModel = await GetFirstAsync(x => x.PersonSetId == input.PersonSetId);
  8. if (oldModel != null)
  9. {
  10. throw Oops.Oh("该班级id已存在");
  11. }
  12. await InsertAsync(model);
  13. return true;
  14. }
  15. public async Task<bool> Delete(string id)
  16. {
  17. var model = await GetFirstAsync(x => x.PersonSetId == id);
  18. if (model == null)
  19. {
  20. throw Oops.Oh("信息不存在");
  21. }
  22. await DeleteAsync(model);
  23. return true;
  24. }
  25. public async Task<bool> Update(PersonSetInfoDto input)
  26. {
  27. var model = await GetFirstAsync(p => p.PersonSetId == input.PersonSetId);
  28. if (model == null)
  29. {
  30. throw Oops.Oh("信息不存在");
  31. }
  32. var res = input.Adapt(model);
  33. await UpdateAsync(res);
  34. return true;
  35. }
  36. public async Task<List<PersonSetInfoDto>> GetPageList(long? majorId)
  37. {
  38. var list =await Context.Queryable<PersonSetInfo>()
  39. .Includes(x=>x.MajorInfoItem,x=>x.DepartmentInfoItem)
  40. .Where(x=>x.PersonSetId!=SafeCampusConst.ZDRY)
  41. .WhereIF(majorId.HasValue,x=>x.MajorId==majorId)
  42. .Includes(x => x.ClassTeacherItem, st => st.SysUserItem)
  43. .ToListAsync();
  44. return list.Adapt<List<PersonSetInfoDto>>();
  45. }
  46. }