Beispiel #1
0
        public object Any(LoginRequest request)
        {
            using (var client = new OrmClient())
            {
                if (string.IsNullOrEmpty(request.UserName) || string.IsNullOrEmpty(request.Password))
                {
                    return(Util.CreateExceptionResponse("U001", "账号或者密码不能为空!"));
                }

                string userAccount = request.UserName;
                string userPwd     = Util.CreateDbPassword(request.UserName, request.Password);
                var    user        = client.Select <SysUser>(u => u.UserAccount == userAccount && u.UserPwd == userPwd).FirstOrDefault();

                if (user == null)
                {
                    return(Util.CreateExceptionResponse("U002", "账号密码错误!"));
                }
                if (user.Status != 1)
                {
                    return(Util.CreateExceptionResponse("U003", "用户未激活,不允许登录!"));
                }
                else
                {
                    log.Info(Util.InitLogMessage("Login", "登录", user.UserName, "", "登录成功"));
                    return(new LoginResponse()
                    {
                        status = "ok",
                        type = request.Type,
                        currentAuthority = "admin"
                    });
                }
            }
        }
Beispiel #2
0
 public object Get(GetUserListRequest request)
 {
     using (var client = new OrmClient())
     {
         var q = client.Select <SysUser>();
         return(PageGrid(request, q));
     }
 }
Beispiel #3
0
 public GetUserResponse Get(GetUserRequest request)
 {
     using (var client = new OrmClient())
     {
         var q = client.Select <SysUser>(u => u.UserName == request.UserName).FirstOrDefault();
         return(new GetUserResponse
         {
             data = q
         });
     }
 }