HomeController.cs
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using WebApp;
using WebRepository;
namespace WebMvc
{
public class HomeController : BaseController
{
private readonly string _appKey = "hhweb";
private IUnitWork _unitWork;
private IAuth _myauthUtil;
public HomeController(IUnitWork unitWork, IAuth authUtil) : base(authUtil)
{
_unitWork = unitWork;
_myauthUtil = authUtil;
}
public ActionResult Index()
{
SysInfo sysInfo = _unitWork.FindSingle<SysInfo>(u => u.AppKey.Equals(_appKey));
ViewBag.CopyRight = sysInfo.Copyright;
ViewBag.SystemNameCn = sysInfo.Title;
ViewBag.SystemNameUs = sysInfo.TitleUs;
ViewBag.IndexLogo = sysInfo.IndexLogo;
AuthStrategyContext authStrategyContext = _myauthUtil.GetCurrentUser();
if (authStrategyContext != null)
{
ViewBag.Account = authStrategyContext.User.Account;
ViewBag.Name = authStrategyContext.User.Name;
}
return View();
}
public ActionResult Main()
{
return View();
}
[HttpPost]
public string GetQuickFunc()
{
var result = new TableData();
try
{
List<SysModule> sysModules = new List<SysModule>();
AuthStrategyContext authStrategyContext = _myauthUtil.GetCurrentUser();
if (authStrategyContext != null)
{
foreach (var item in authStrategyContext.Modules)
{
if (item.Status)
{
sysModules.Add(item);
}
}
}
var data = sysModules.Select(u => new { u.Name, u.NameUs, u.IconName, u.Url });
result.code = 200;
result.data = data;
result.count = data.Count();
}
catch (Exception ex)
{
result.code = 500;
result.msg = ex.Message;
}
return JsonHelper.Instance.Serialize(result);
}
}
}