public ActionResult GetCurrentUser() { var user = Operator.GetCurrent(); if (user.IsEmpty()) { return(null); } if (user != null && user.IsSystem) { user.DutyId = "admin"; } //老师用户绑定班级 var classes = TeacherApp.GetBindClass(user.Id); var orgName = OrgApp.GetById(user.OrganId)?.Name; //缓存原因,重新取用户最新头像 var userLatest = UserApp.GetById(user.Id); return(Content(new { Duty = user.DutyId, //user.HeadIcon, userLatest?.HeadIcon, user.Id, user.IsSystem, LoginIPAddress = user.Ip, LoginIPAddressName = user.IpLocation, user.LoginTime, user.LoginToken, user.MobilePhone, Organ = user.OrganId, user.Roles, user.SetUp, UserCode = user.Account, UserName = user.Name, //user.Classes, Classes = classes.Select(p => new { Id = p.Id, CategoryId = p.Type, Name = p.Name, ParentName = p.Parent.Name }).ToList(), UserId = user.Id, OrgName = orgName, //机构名称 Num = GetNum(user.DutyId, user.Id) //学工号 }.ToJson())); }
public ActionResult GetTreeJson(string keyword) { var data = App.GetList(); var data_deeps = ""; var role = RoleApp.Get(keyword); if (!role.IsEmpty()) { data_deeps = role.DataDeps; } else { var user = UserApp.GetById(keyword); } var treeList = new List <ViewTree>(); foreach (var item in data) { var tree = new ViewTree(); var hasChildren = data.Count(t => t.ParentId == item.Id) != 0; tree.Id = item.Id; tree.Text = item.Name; tree.Value = item.Code; tree.ParentId = item.ParentId; tree.Isexpand = true; tree.Complete = false; tree.HasChildren = hasChildren; tree.Showcheck = true; if (!data_deeps.IsEmpty() && (data_deeps.IndexOf(item.Id, StringComparison.Ordinal) != -1)) { tree.Checkstate = 1; } else { tree.Checkstate = 0; } treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }