添加dto模式的demo测试
This commit is contained in:
@@ -4,13 +4,13 @@ using System.Threading.Tasks;
|
||||
using System;
|
||||
using Yi.Framework.Common.Base;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service.Base;
|
||||
using Yi.Framework.Uow.Interceptors;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.DTOModel.Base.Dto;
|
||||
|
||||
namespace Yi.Framework.Service.RABC
|
||||
{
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Exceptions;
|
||||
using Yi.Framework.DTOModel.RABC.Student;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Service.RABC
|
||||
{
|
||||
public class StudentService : CrudAppService<StudentEntity, StudentGetOutput, StudentListOutput, Guid, StudentCreateInput, StudentUpdateInput>, IStudentService
|
||||
{
|
||||
public StudentService(IRepository<StudentEntity> repository, IMapper mapper) : base(repository, mapper)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<StudentListOutput>> GetListAsync()
|
||||
{
|
||||
return await MapToGetListOutputDtosAsync(await Repository.GetListAsync());
|
||||
}
|
||||
|
||||
public void GetError()
|
||||
{
|
||||
throw new ApplicationException("查询错误");
|
||||
}
|
||||
public void GetError2()
|
||||
{
|
||||
throw new UserFriendlyException("友好错误");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验配置项是否已存在
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
//private async Task ValidateKeyAsync(string key, Guid? id = null)
|
||||
//{
|
||||
// Expression<Func<StudentEntity, bool>> expression = e => e.Name == key;
|
||||
// if (id.HasValue)
|
||||
// {
|
||||
// expression = expression.And(e => e.Id != id.Value);
|
||||
// }
|
||||
// var existsData = await Repository.GetListAsync(expression);
|
||||
// if (existsData != null)
|
||||
// {
|
||||
// throw new UserFriendlyException();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@ using Yi.Framework.Common.Base;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service.Base;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.DTOModel.Base.Dto;
|
||||
|
||||
namespace Yi.Framework.Service.RABC
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user