80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Air.Model.AirAdminViewModel;
|
|
using Air.Model;
|
|
using Mini.Model;
|
|
using Mini.Model.Entity;
|
|
|
|
namespace Mini.Services.Bas
|
|
{
|
|
public class BasRightService : IBasRightService
|
|
{
|
|
private readonly IAdminRepository<Bas_Right> _basRightRepository;
|
|
public BasRightService(IAdminRepository<Bas_Right> basRightRepository)
|
|
{
|
|
this._basRightRepository = basRightRepository;
|
|
}
|
|
|
|
public void Create(Bas_RightModel model)
|
|
{
|
|
var info = new Bas_Right() { RightId = model.RightId, GroupId = model.GroupId, RName = model.RName, SortId = model.SortId, CTime = model.CTime, CreateUser = model.CreateUser };
|
|
this._basRightRepository.Add(info);
|
|
}
|
|
|
|
public void CreateList(IList<Bas_RightModel> list)
|
|
{
|
|
var modelList = new List<Bas_Right>();
|
|
foreach (var item in list)
|
|
{
|
|
var model = new Bas_Right();
|
|
model.RightId = item.RightId;
|
|
model.GroupId = item.GroupId;
|
|
model.RName = item.RName;
|
|
model.SortId = item.SortId;
|
|
model.CTime = item.CTime;
|
|
model.CreateUser = item.CreateUser;
|
|
modelList.Add(model);
|
|
}
|
|
this._basRightRepository.AddList(modelList);
|
|
}
|
|
|
|
public void Delete(Bas_RightModel model)
|
|
{
|
|
var info = _basRightRepository.Get(p => p.RightId == model.RightId);
|
|
if (info != null)
|
|
_basRightRepository.Delete(info);
|
|
}
|
|
|
|
public Bas_RightModel Get(string id)
|
|
{
|
|
var model = _basRightRepository.Get(p => p.RightId == id);
|
|
if (model == null)
|
|
return null;
|
|
var info = new Bas_RightModel() { RightId = model.RightId, GroupId = model.GroupId, RName = model.RName, SortId = model.SortId, CTime = model.CTime, CreateUser = model.CreateUser };
|
|
return info;
|
|
}
|
|
|
|
public IList<Bas_RightModel> GetList()
|
|
{
|
|
return _basRightRepository.GetList()
|
|
.Select(p => new Bas_RightModel() { RightId = p.RightId, GroupId = p.GroupId, RName = p.RName, SortId = p.SortId, CTime = p.CTime, CreateUser = p.CreateUser })
|
|
.ToList();
|
|
}
|
|
|
|
public void Update(Bas_RightModel model)
|
|
{
|
|
var info = _basRightRepository.Get(p => p.RightId == model.RightId);
|
|
if (info != null)
|
|
{
|
|
info.RightId = model.RightId;
|
|
info.GroupId = model.GroupId;
|
|
info.RName = info.RName;
|
|
_basRightRepository.Update(info);
|
|
}
|
|
}
|
|
}
|
|
}
|