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
74 lines
2.5 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.ObjectMapping;
|
|
|
|
namespace Shentun.Peis.Books
|
|
{
|
|
[ApiExplorerSettings(GroupName = "Sys")]
|
|
public class StudentAppService : ApplicationService, IStudentAppService
|
|
{
|
|
private readonly IRepository<Student> _repository;
|
|
|
|
public StudentAppService(IRepository<Student> repository)
|
|
{
|
|
_repository = repository;
|
|
}
|
|
|
|
public async Task<StudentDto> CreateAsync(CreateStudentDto input)
|
|
{
|
|
var studentinfo = await _repository.InsertAsync(new Student(input.Sid, input.Uid, input.Cid, input.Name));
|
|
return ObjectMapper.Map<Student, StudentDto>(studentinfo);
|
|
}
|
|
|
|
public async Task DeleteAsync(Guid Sid, Guid Uid, string Cid)
|
|
{
|
|
|
|
var studentinfo = (await _repository.GetQueryableAsync())
|
|
.Where(x => x.Sid == Sid)
|
|
.Where(x => x.Uid == Uid)
|
|
.Where(x => x.Cid == Cid).FirstOrDefault();
|
|
|
|
await _repository.DeleteAsync(studentinfo); //软删除
|
|
|
|
//await _repository.HardDeleteAsync(studentinfo); //物理删除
|
|
}
|
|
|
|
public async Task<List<StudentDto>> GetAsync(StudentDto studentDto)
|
|
{
|
|
|
|
var studentlist = (await _repository.GetQueryableAsync())
|
|
.Where(x => x.Sid == studentDto.Sid)
|
|
.Where(x => x.Uid == studentDto.Uid)
|
|
.Where(x => x.Cid == studentDto.Cid).ToList();
|
|
|
|
|
|
return ObjectMapper.Map<List<Student>, List<StudentDto>>(studentlist);
|
|
|
|
// List<LandInfo> landInfos = (await _landInfoRepository.GetQueryableAsync())
|
|
//.WhereIf(!string.IsNullOrEmpty(input.Name), x => x.landName.Contains(input.Name) || x.landName == input.Name)
|
|
//.WhereIf(!string.IsNullOrEmpty(input.Description), x => x.remark.Contains(input.Description) || x.remark == input.Description)
|
|
//.Skip((input.pageNo - 1) * input.pageSize)
|
|
//.Take(input.pageSize)
|
|
//.ToList();
|
|
|
|
|
|
}
|
|
|
|
public async Task<StudentDto> GetAsyncMyName(string Name)
|
|
{
|
|
var studentinfo = (await _repository.GetQueryableAsync())
|
|
.WhereIf(!string.IsNullOrEmpty(Name), x => x.Name == Name).FirstOrDefault();
|
|
|
|
return ObjectMapper.Map<Student, StudentDto>(studentinfo);
|
|
}
|
|
|
|
|
|
}
|
|
}
|