jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
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
81
82
83
using HH.WMS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace HH.WMS.WebUI.Controllers
{
    public class PowerController : Controller
    {
        #region 获得当前用户有权限的菜单
        /// <summary>
        /// 获得当前用户有权限的菜单
        /// </summary>
        /// <returns></returns>
        public string GetMenu()
        {
            if (this.User == null || this.User.Identity == null || string.IsNullOrEmpty(this.User.Identity.Name))
            {
                Log.Info("Power", "为获取到用户名");
                Redirect("~/Login");
                return "";
            }
            var UserCode = this.User.Identity.Name;
            string appCode = HH.WMS.Common.Constants.appCode;
            string parentCode = "0";
            var entity = new
            {
                userName = UserCode,
                parentCode = parentCode,
                appCode = appCode
            };
            string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
            string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Menu/GetMenuByUser", jsonString);
            Log.Info("Power", result);
            return result;
        }
        #endregion
 
        #region 获得当前用户有权限的应用
        /// <summary>
        /// 获得当前用户有权限的应用
        /// </summary>
        /// <returns></returns>
        public string GetApp()
        {
            var userName = this.User.Identity.Name;
            string appCode = HH.WMS.Common.Constants.appCode;
            string jsonstring = "{\"userName\":\"" + userName + "\"}";
            string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/App/GetAppListByUser", jsonstring);
            if (!string.IsNullOrEmpty(result))
            {
                result += "|" + appCode;
            }
            return result;
        }
        #endregion
 
        #region  获得当前用户有权限的按钮
        /// <summary>
        /// 获得当前用户有权限的按钮
        /// </summary>
        /// <param name="menuid">菜单ID</param>
        /// <returns></returns>
        public string GetPower(string menuid)
        {
            var userCode = this.User.Identity.Name;
            var appCode = HH.WMS.Common.Constants.appCode;
 
            var entity = new
            {
                userName = userCode,
                appCode = appCode,
                menuid = menuid
            };
            string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
            string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Account/GetBottonCode", jsonString);
            return result;
        }
        #endregion
    }
}