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

PersonSetInfoService.cs 1.7 KiB

пре 3 месеци
пре 3 месеци
пре 3 месеци
пре 3 месеци
пре 2 месеци
пре 3 месеци
пре 1 месец
пре 3 месеци
пре 2 месеци
пре 3 месеци
пре 3 месеци
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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, string setName)
  37. {
  38. var list =await Context.Queryable<PersonSetInfo>()
  39. .Includes(x=>x.MajorInfoItem,x=>x.DepartmentInfoItem)
  40. .Includes(x => x.ClassTeacherItem, st => st.SysUserItem)
  41. .Where(x=>x.PersonSetId!=SafeCampusConst.ZDRY)
  42. .WhereIF(majorId.HasValue,x=>x.MajorId==majorId)
  43. .WhereIF(!string.IsNullOrEmpty(setName),x=>x.PersonSetName.Contains(setName))
  44. .ToListAsync();
  45. return list.Adapt<List<PersonSetInfoDto>>();
  46. }
  47. }