Mini.Crm/Mini.Web/Areas/Admin/Controllers/HomeController.cs

69 lines
2.2 KiB
C#

using Mini.Common;
using Air.Model.AirAdminViewModel;
using System.Collections.Generic;
using System.Linq;
using Mini.Services.Bas;
using Microsoft.AspNetCore.Mvc;
using Mini.Services;
using Microsoft.AspNetCore.Authentication;
using Newtonsoft.Json;
namespace Mini.Web.Areas.Admin.Controllers
{
public class HomeController : BaseController
{
private readonly IBasLeftMenuService _basLeftMenuService;
private readonly ICacheService _cacheservice;
public HomeController(IBasLeftMenuService basLeftMenuService, ICacheService cacheservice)
{
this._basLeftMenuService = basLeftMenuService;
this._cacheservice = cacheservice;
}
[Area("Admin")]
public ActionResult Index()
{
if (!userRightId.Contains("B099"))
{
return Redirect("Admin/Account/LogOff");
}
var modelist = new List<Bas_ModuleMenuModel>();
string[] rightid = userRightId;
decimal modulId = 0;
string title = "";
if (rightid != null)
{
modelist = _cacheservice.GetList_ModuleMenu();
modelist = modelist.Where(p => rightid.Contains(p.RightId)).ToList();
if (modelist.Count == 0)
{
modelist = new List<Bas_ModuleMenuModel>();
}
else
{
modulId = modelist[0].ModuleMenuId;
title = modelist[0].MName;
}
}
ViewBag.MainMenu = modelist;
ViewBag.ChooseID = modulId;
ViewBag.Title = title;
ViewBag.Eid = Eid;
ViewBag.Name = UserName;
return View();
}
[Area("Admin")]
public JsonResult GetTreeByModuleId(int id)
{
if (id == 0)
return Json(null);
var modelist = _basLeftMenuService.GetBasLeftMenuByModuleId(id, userRightId);
return Json(modelist, new JsonSerializerSettings() { DateFormatString = "yyyy-MM-dd HH:mm:ss" });
}
[Area("Admin")]
public ActionResult WelCome()
{
return View();
}
}
}