148 lines
5.8 KiB
C#
148 lines
5.8 KiB
C#
using Air.Model;
|
|
using Air.Model.AirAdminViewModel;
|
|
using Mini.Common;
|
|
using Mini.Model;
|
|
using Mini.Model.Entity;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Mini.Services
|
|
{
|
|
public class CacheService : ICacheService
|
|
{
|
|
private readonly IAdminRepository<Bas_LeftMemu> _basLeftMenuRepository;
|
|
private readonly IAdminRepository<Bas_ModuleMenu> _basModuleMenuRepository;
|
|
private readonly IAdminRepository<Bas_Role> _basRoleRepository;
|
|
//private readonly IB2BRepository<Air_CityPort> _airCityRepository;
|
|
//private readonly IB2BRepository<Bas_ModuleMenu> _bas_ModuleMenuRepository;
|
|
private readonly IAdminRepository<Bas_Supplier> _basSupplierRepository;
|
|
|
|
public CacheService(IAdminRepository<Bas_LeftMemu> basLeftMenuRepository, IAdminRepository<Bas_ModuleMenu> basModuleMenuRepository, IAdminRepository<Bas_Role> basRoleRepository, /*IB2BRepository<Air_CityPort> airCityRepository, IB2BRepository<Bas_ModuleMenu> bas_ModuleMenuRepository,*/IAdminRepository<Bas_Supplier> basSupplierRepository)
|
|
{
|
|
this._basLeftMenuRepository = basLeftMenuRepository;
|
|
this._basModuleMenuRepository = basModuleMenuRepository;
|
|
this._basRoleRepository = basRoleRepository;
|
|
//this._airCityRepository = airCityRepository;
|
|
//this._bas_ModuleMenuRepository = bas_ModuleMenuRepository;
|
|
this._basSupplierRepository = basSupplierRepository;
|
|
}
|
|
public CacheService() { }
|
|
|
|
public List<Bas_LeftMemuModel> GetList_LeftMemu()
|
|
{
|
|
var cacheKey = "cache_LeftMemu_getList";
|
|
var list = CacheHelper.Get<List<Bas_LeftMemuModel>>(cacheKey);
|
|
if (list == null)
|
|
{
|
|
list = _basLeftMenuRepository.GetList()
|
|
.Select(p => new Bas_LeftMemuModel()
|
|
{
|
|
MenuId = p.MenuId,
|
|
ModuleMenuId = p.ModuleMenuId,
|
|
MName = p.MName,
|
|
Url = p.Url,
|
|
IsGroup = p.IsGroup,
|
|
IsShow = p.IsShow,
|
|
RightId = p.RightId,
|
|
ParentId = p.ParentId,
|
|
SortId = p.SortId,
|
|
CTime = p.CTime,
|
|
CreateUser = p.CreateUser
|
|
}).ToList();
|
|
CacheHelper.Set(cacheKey, list);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public List<Bas_ModuleMenuModel> GetList_ModuleMenu()
|
|
{
|
|
var cacheKey = "cache_ModuleMenu_getList";
|
|
var list = CacheHelper.Get<List<Bas_ModuleMenuModel>>(cacheKey);
|
|
if (list == null)
|
|
{
|
|
list = _basModuleMenuRepository.GetList()
|
|
.Select(p =>
|
|
new Bas_ModuleMenuModel()
|
|
{
|
|
ModuleMenuId = p.ModuleMenuId,
|
|
MName = p.MName,
|
|
RightId = p.RightId,
|
|
ImageUrl = p.ImageUrl,
|
|
SortId = p.SortId,
|
|
CTime = p.CTime
|
|
}
|
|
).ToList();
|
|
CacheHelper.Set(cacheKey, list);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
//public List<Bas_ModuleMenuModel> GetList_ModuleMenu_b2b()
|
|
//{
|
|
// var cacheKey = "cache_ModuleMenu_getList_b2b";
|
|
// List<Bas_ModuleMenuModel> list = CacheHelper.Get<List<Bas_ModuleMenuModel>>(cacheKey);
|
|
// if (list == null)
|
|
// {
|
|
// list = _bas_ModuleMenuRepository.GetList()
|
|
// .Select(p =>
|
|
// new Bas_ModuleMenuModel()
|
|
// {
|
|
// modulemenuid = p.modulemenuid,
|
|
// mname = p.mname,
|
|
// rightid = p.rightid,
|
|
// imageurl = p.imageurl,
|
|
// sortid = p.sortid,
|
|
// ctime = p.ctime,
|
|
// userIdentity = p.userIdentity
|
|
// }
|
|
// ).ToList();
|
|
// CacheHelper.Set(cacheKey, list);
|
|
// }
|
|
// return list;
|
|
//}
|
|
|
|
public string Get_RoleCodes(int[] roleIds)
|
|
{
|
|
var roleList = GetList_Role().Where(m => roleIds.Contains(m.RoleId)).ToList();
|
|
StringBuilder codes = new StringBuilder();
|
|
foreach (var role in roleList)
|
|
{
|
|
codes.AppendFormat("[{0}]", role.Code);
|
|
}
|
|
return codes.ToString();
|
|
}
|
|
|
|
public List<Bas_Role> GetList_Role()
|
|
{
|
|
string cacheKey = "cache_Role_getList";
|
|
var list = CacheHelper.Get<List<Bas_Role>>(cacheKey);
|
|
if (list == null)
|
|
{
|
|
list = _basRoleRepository.GetList().ToList();
|
|
CacheHelper.Set(cacheKey, list);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取供应商信息列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Bas_Supplier> GetList_BasSupplier()
|
|
{
|
|
string cacheKey = "cache_BasSupplier_getList";
|
|
var list = CacheHelper.Get<List<Bas_Supplier>>(cacheKey);
|
|
if (list == null)
|
|
{
|
|
list = _basSupplierRepository.GetList().ToList();
|
|
CacheHelper.Set(cacheKey, list);
|
|
}
|
|
return list;
|
|
|
|
}
|
|
}
|
|
}
|