You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB
C#

using OpenAuth.App.Base;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using OpenAuth.App.Interface;
using Infrastructure;
using OpenAuth.App;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.Request;
namespace OpenAuth.App
{
public class SysPosGroupApp : SqlSugarBaseApp<SysPosGroup, SugarDbContext>
{
public SysPosGroupApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<SysPosGroup> repository, IAuth auth) : base(unitWork, repository, auth)
{
}
public async Task<Response<List<SysPosGroup>>> Load(string name)
{
var groups = await base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(name), g => g.Name.Contains(name))
.ToListAsync();
return new Response<List<SysPosGroup>>
{
Result = groups
};
}
public async Task<Response<bool>> Add(PosGroupForm pos)
{
var userId = base._auth.GetCurrentUser().User.Id;
var model = pos.MapTo<SysPosGroup>();
model.Id = Yitter.IdGenerator.YitIdHelper.NextId();
model.CreateId = userId;
model.CreateTime = DateTime.Now;
var flag = await base.Repository.InsertAsync(model);
return new Response<bool>
{
Result = flag,
Message = flag == true ? "success" : "error"
};
}
}
}