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" }); } } }
public object Get(GetUserListRequest request) { using (var client = new OrmClient()) { var q = client.Select <SysUser>(); return(PageGrid(request, q)); } }
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 }); } }
public object Post(RegisterUserRequest request) { using (var client = new OrmClient()) { SysUser user = Mapper.Map <SysUser>(request); user.UserPwd = Util.CreateDbPassword(request.UserAccount, request.UserAccount); var result = client.Insert <SysUser>(user); if (result > 0) { return(Util.Success("注册成功")); } else { return(Util.Success("注册失败")); } } }