121 lines
3.3 KiB
C#
121 lines
3.3 KiB
C#
|
|
using Infrastructure;
|
|
using OpenAuth.App.BaseApp.Base;
|
|
using OpenAuth.App.Interface;
|
|
using OpenAuth.App.Request;
|
|
using OpenAuth.App.Response;
|
|
using OpenAuth.Repository;
|
|
using OpenAuth.Repository.Domain;
|
|
using SqlSugar;
|
|
|
|
namespace OpenAuth.App
|
|
{
|
|
public class MiParkingApp : SqlSugarBaseApp<MiParking, SugarDbContext>
|
|
{
|
|
public MiParkingApp(
|
|
ISugarUnitOfWork<SugarDbContext> unitWork,
|
|
ISimpleClient<MiParking> repository,
|
|
IAuth auth
|
|
) : base(unitWork, repository, auth)
|
|
{
|
|
|
|
}
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
public async Task<Response<PageInfo<List<MiParking>>>> LoadAllPage(PageReq request)
|
|
{
|
|
RefAsync<int> totalCount = 0;
|
|
var result = new PageInfo<SysRole>();
|
|
var list = await base.Repository.AsQueryable()
|
|
.ToPageListAsync(request.page, request.limit, totalCount);
|
|
|
|
return new Response<PageInfo<List<MiParking>>>
|
|
{
|
|
Result = new PageInfo<List<MiParking>>
|
|
{
|
|
Items = list,
|
|
Total = totalCount
|
|
}
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
public async Task<MiParking> Get(object id)
|
|
{
|
|
return await Repository.GetByIdAsync(id);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
public async Task<Response<bool>> Add(MiParking model)
|
|
{
|
|
model.Id = Guid.NewGuid().ToString();
|
|
var flag = await Repository.InsertAsync(model);
|
|
|
|
return new Response<bool>
|
|
{
|
|
Result = flag,
|
|
Message = flag == true ? "success" : "error"
|
|
};
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
public async Task<Response<bool>> Delete(List<MiParking> models)
|
|
{
|
|
var flag = await Repository.DeleteAsync(models);
|
|
|
|
return new Response<bool>
|
|
{
|
|
Result = flag,
|
|
Message = flag == true ? "success" : "error"
|
|
};
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public async Task<Response<bool>> Update(MiParking model)
|
|
{
|
|
bool flag = await base.Repository.UpdateAsync(model);
|
|
|
|
return new Response<bool>
|
|
{
|
|
Result = flag,
|
|
Message = flag == true ? "success" : "error"
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 事务示例
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public async Task<Response<bool>> AssignModule()
|
|
{
|
|
using (var uwo = UnitWork.CreateContext())
|
|
{
|
|
//await uwo.SysRoleElement.InsertRangeAsync(model.ElementIds.Select(a => new SysRoleElement { RoleId = model.RoleId, ElementId = a }).ToList());
|
|
|
|
var flag = uwo.Commit();
|
|
return new Response<bool>
|
|
{
|
|
Result = flag,
|
|
Message = flag == true ? "success" : "error"
|
|
};
|
|
}
|
|
}
|
|
|
|
}
|
|
} |