public ActionResult GetRoleByIds(string id) { var result = new ResultAdaptDto(); var data = _roleApp.GetRoleById(id.ToInt64()); result.data.Add("model", data); return(Json(result)); }
public ActionResult GetDataById(string id) { var result = new ResultJson(); result.Data = _roleApp.GetRoleById(id); result.statusCode = JuiJsonEnum.Ok; return(Content(result.ToJson())); }
public ActionResult Loginon(LoginDto loginModel) { if (string.IsNullOrEmpty(loginModel.uname)) { ModelState.AddModelError("err", "用户名不能为空"); } if (string.IsNullOrEmpty(loginModel.pwd)) { ModelState.AddModelError("err", "密码不能为空"); } try { login_info loginInfo = new login_info(); var userAgent = RequestHelper.UserAgent(); if (userAgent != null) { loginInfo.login_name = loginModel.uname.Trim(); loginInfo.browser = userAgent.Browser; loginInfo.device_info = userAgent.Device; loginInfo.osinfo = userAgent.OS; loginInfo.request_ip = userAgent.Ip; loginInfo.request_time = DateTime.Now; if (NetHelper.IsIntranetIP(loginInfo.request_ip)) { loginInfo.real_address = "本地局域网"; } else { var ipInfo = IpTool.Search(loginInfo.request_ip); if (ipInfo != null) { loginInfo.real_address = $"{ipInfo.Province}-{ipInfo.City}"; } //string filePath = AppDomain.CurrentDomain.BaseDirectory + @"data\ip2region.db"; //DbSearcher dbSearcher = new DbSearcher(filePath); //var dataBlock = dbSearcher.BtreeSearch("120.195.209.125"); //loginInfo.real_address = dataBlock.ToString(); } } var user = _userApp.LoginValidate(loginModel.uname.Trim(), loginModel.pwd.Trim()); var loginUserDto = new LoginUserDto(); if (user != null) { if (user.user_avatar.IsEmpty()) { user.user_avatar = "/ui/images/profile.jpg"; } loginUserDto.Id = user.id; loginUserDto.LoginName = user.login_name; loginUserDto.UserName = user.user_name; loginUserDto.IsSuper = user.is_super == 1; loginUserDto.DeptId = user.dept_id; loginUserDto.Avatar = user.user_avatar; loginUserDto.RoleId = user.role_id; loginUserDto.DeptName = user.dept_name; loginUserDto.Gender = user.gender; loginUserDto.Phone = user.mobile_phone; loginUserDto.Email = user.email; if (user.role_id > 0) { sys_role role = _roleApp.GetRoleById(user.role_id); if (role != null) { loginUserDto.RoleCode = role.role_code; loginUserDto.RoleName = role.role_name; } } //插入登录信息 loginInfo.login_status = 1; loginInfo.login_message = "登录成功"; loginInfoApp.InsertLoginInfo(loginInfo); //设置cookie // FormsAuthentication.SetAuthCookie(loginUserDto.AccountName, false); string claimstr = loginUserDto.ToJson(); RequestHelper.SetCookie(claimstr); return(Redirect("/admin/Home/Index")); } //插入登录信息 loginInfo.login_message = "用户名或密码错误"; loginInfoApp.InsertLoginInfo(loginInfo); ModelState.AddModelError("err", "用户名或密码错误"); } catch (Exception e) { LoggerHelper.Exception(e); ModelState.AddModelError("err", "登录异常"); } return(View("Index", loginModel)); }