89 lines
2.8 KiB
C#
89 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Air.Model;
|
|
using Mini.Model;
|
|
using Mini.Model.Entity;
|
|
|
|
namespace Mini.Services.Bas
|
|
{
|
|
public class BasRoleService : IBasRoleService
|
|
{
|
|
private readonly IAdminRepository<Bas_Role> _basRoleRepository;
|
|
public BasRoleService(IAdminRepository<Bas_Role> basRoleRepository)
|
|
{
|
|
this._basRoleRepository = basRoleRepository;
|
|
}
|
|
|
|
public void AddBasRole(Bas_Role basRole)
|
|
{
|
|
if (basRole == null)
|
|
throw new ArgumentNullException();
|
|
_basRoleRepository.Add(basRole);
|
|
}
|
|
|
|
public void DeleteBasRole(Bas_Role basRole)
|
|
{
|
|
basRole = _basRoleRepository.Get(p => p.RoleId == basRole.RoleId);
|
|
_basRoleRepository.Delete(basRole);
|
|
}
|
|
|
|
public Bas_Role Get(int id)
|
|
{
|
|
return _basRoleRepository.Get(p => p.RoleId == id);
|
|
}
|
|
|
|
public IList<Bas_Role> GetBasRoleList()
|
|
{
|
|
return _basRoleRepository.GetList().ToList();
|
|
}
|
|
|
|
public object GetRoleTree()
|
|
{
|
|
return (from model in _basRoleRepository.GetList().OrderBy(m => m.SortId)
|
|
select new
|
|
{
|
|
id = model.RoleId,
|
|
text = model.RName,
|
|
iconCls = "icon-man"
|
|
}).ToList();
|
|
}
|
|
|
|
public void Sort(string roleIdStr, string sortIdStr)
|
|
{
|
|
IList<Bas_Role> list = new List<Bas_Role>();
|
|
string[] roleIds = roleIdStr.Split(',');
|
|
string[] sortIds = sortIdStr.Split(',');
|
|
for (int i = 0; i < roleIds.Length; i++)
|
|
{
|
|
var roleid = Convert.ToInt32(roleIds[i]);
|
|
var sortid = Convert.ToInt32(sortIds[i]);
|
|
var model = _basRoleRepository.Get(m => m.RoleId == roleid);
|
|
if (model == null) continue;
|
|
model.SortId = sortid;
|
|
list.Add(model);
|
|
}
|
|
_basRoleRepository.Update(list);
|
|
}
|
|
|
|
public void UpdateBasRole(Bas_Role basRole)
|
|
{
|
|
var info = _basRoleRepository.Get(p => p.RoleId == basRole.RoleId);
|
|
if(info!=null)
|
|
{
|
|
info.RoleId = basRole.RoleId;
|
|
info.RName = basRole.RName;
|
|
info.SortId = basRole.SortId;
|
|
info.CTime = basRole.CTime;
|
|
info.CreateUser = basRole.CreateUser;
|
|
info.UpdateUser = basRole.UpdateUser;
|
|
info.UTime = basRole.UTime;
|
|
info.Code = basRole.Code;
|
|
}
|
|
_basRoleRepository.Update(basRole);
|
|
}
|
|
}
|
|
}
|