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.

74 lines
2.5 KiB

  1. using Microsoft.AspNetCore.Mvc;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Security.Cryptography;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Volo.Abp.Application.Services;
  9. using Volo.Abp.Domain.Repositories;
  10. using Volo.Abp.ObjectMapping;
  11. namespace Shentun.Peis.Books
  12. {
  13. [ApiExplorerSettings(GroupName = "Sys")]
  14. public class StudentAppService : ApplicationService, IStudentAppService
  15. {
  16. private readonly IRepository<Student> _repository;
  17. public StudentAppService(IRepository<Student> repository)
  18. {
  19. _repository = repository;
  20. }
  21. public async Task<StudentDto> CreateAsync(CreateStudentDto input)
  22. {
  23. var studentinfo = await _repository.InsertAsync(new Student(input.Sid, input.Uid, input.Cid, input.Name));
  24. return ObjectMapper.Map<Student, StudentDto>(studentinfo);
  25. }
  26. public async Task DeleteAsync(Guid Sid, Guid Uid, string Cid)
  27. {
  28. var studentinfo = (await _repository.GetQueryableAsync())
  29. .Where(x => x.Sid == Sid)
  30. .Where(x => x.Uid == Uid)
  31. .Where(x => x.Cid == Cid).FirstOrDefault();
  32. await _repository.DeleteAsync(studentinfo); //软删除
  33. //await _repository.HardDeleteAsync(studentinfo); //物理删除
  34. }
  35. public async Task<List<StudentDto>> GetAsync(StudentDto studentDto)
  36. {
  37. var studentlist = (await _repository.GetQueryableAsync())
  38. .Where(x => x.Sid == studentDto.Sid)
  39. .Where(x => x.Uid == studentDto.Uid)
  40. .Where(x => x.Cid == studentDto.Cid).ToList();
  41. return ObjectMapper.Map<List<Student>, List<StudentDto>>(studentlist);
  42. // List<LandInfo> landInfos = (await _landInfoRepository.GetQueryableAsync())
  43. //.WhereIf(!string.IsNullOrEmpty(input.Name), x => x.landName.Contains(input.Name) || x.landName == input.Name)
  44. //.WhereIf(!string.IsNullOrEmpty(input.Description), x => x.remark.Contains(input.Description) || x.remark == input.Description)
  45. //.Skip((input.pageNo - 1) * input.pageSize)
  46. //.Take(input.pageSize)
  47. //.ToList();
  48. }
  49. public async Task<StudentDto> GetAsyncMyName(string Name)
  50. {
  51. var studentinfo = (await _repository.GetQueryableAsync())
  52. .WhereIf(!string.IsNullOrEmpty(Name), x => x.Name == Name).FirstOrDefault();
  53. return ObjectMapper.Map<Student, StudentDto>(studentinfo);
  54. }
  55. }
  56. }