120 lines
3.2 KiB
C#
120 lines
3.2 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 MiPunchRecordApp : SqlSugarBaseApp<MiPunchRecord, SugarDbContext>
|
||
|
|
{
|
||
|
|
public MiPunchRecordApp(
|
||
|
|
ISugarUnitOfWork<SugarDbContext> unitWork,
|
||
|
|
ISimpleClient<MiPunchRecord> repository,
|
||
|
|
IAuth auth
|
||
|
|
) : base(unitWork, repository, auth)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 查询
|
||
|
|
/// <summary>
|
||
|
|
/// 分页
|
||
|
|
/// </summary>
|
||
|
|
public async Task<Response<PageInfo<List<MiPunchRecord>>>> 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<MiPunchRecord>>>
|
||
|
|
{
|
||
|
|
Result = new PageInfo<List<MiPunchRecord>>
|
||
|
|
{
|
||
|
|
Items = list,
|
||
|
|
Total = totalCount
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
public async Task<MiPunchRecord> Get(object id)
|
||
|
|
{
|
||
|
|
return await Repository.GetByIdAsync(id);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 添加
|
||
|
|
/// </summary>
|
||
|
|
public async Task<Response<bool>> Add(MiPunchRecord model)
|
||
|
|
{
|
||
|
|
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<MiPunchRecord> 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(MiPunchRecord 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"
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|