mirror of
https://git.dirksys.ovh/dirk/bankserver.git
synced 2025-12-20 02:59:20 +01:00
remove Account and rename AccountInfo to Account
This commit is contained in:
parent
c6971c8b73
commit
4c0e44e542
@ -12,16 +12,8 @@ pub struct Account {
|
|||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub user: Uuid,
|
pub user: Uuid,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub balance: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
|
||||||
#[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))]
|
|
||||||
pub struct AccountInfo {
|
|
||||||
pub id: Uuid,
|
|
||||||
pub user: Uuid,
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))]
|
||||||
pub struct UserAccountInfo {
|
pub struct UserAccountInfo {
|
||||||
@ -40,8 +32,8 @@ pub struct ReducedAccountInfo {
|
|||||||
impl PaginationType for UserAccountInfo {
|
impl PaginationType for UserAccountInfo {
|
||||||
const NAME: &str = "UserAccounts";
|
const NAME: &str = "UserAccounts";
|
||||||
}
|
}
|
||||||
impl PaginationType for AccountInfo {
|
impl PaginationType for Account {
|
||||||
const NAME: &str = "Accounts";
|
const NAME: &str = "Accounts";
|
||||||
}
|
}
|
||||||
|
|
||||||
make_schemas!((); (Account, AccountInfo, UserAccountInfo, Pagination<AccountInfo>, Pagination<UserAccountInfo>));
|
make_schemas!((); (Account, UserAccountInfo, Pagination<Account>, Pagination<UserAccountInfo>));
|
||||||
|
|||||||
@ -9,7 +9,6 @@ pub use schemas::*;
|
|||||||
mod error;
|
mod error;
|
||||||
mod util;
|
mod util;
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
pub use util::*;
|
pub use util::*;
|
||||||
|
|
||||||
make_schemas!((Credentials); (ApiError, TokenResponse), [account::schemas, chat::schemas, transaction::schemas, user::schemas, meta::schemas]);
|
make_schemas!((Credentials); (ApiError, TokenResponse), [account::schemas, chat::schemas, transaction::schemas, user::schemas, meta::schemas]);
|
||||||
|
|||||||
@ -13,6 +13,7 @@ create table chat_messages(
|
|||||||
);
|
);
|
||||||
|
|
||||||
create index chat_messages_chat_index on chat_messages(chat);
|
create index chat_messages_chat_index on chat_messages(chat);
|
||||||
|
create index chat_messages_chat_and_id_index on chat_messages(chat, id);
|
||||||
|
|
||||||
create table chat_members(
|
create table chat_members(
|
||||||
chat uuid not null,
|
chat uuid not null,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
use axum::{Router, extract::Path, routing::get};
|
use axum::{Router, extract::Path, routing::get};
|
||||||
use bank_core::{
|
use bank_core::{
|
||||||
ApiError,
|
ApiError,
|
||||||
account::AccountInfo,
|
account::Account,
|
||||||
pagination::Pagination,
|
pagination::Pagination,
|
||||||
transaction::{FullTransaction, TransactionQuery},
|
transaction::{FullTransaction, TransactionQuery},
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ pub async fn list_accounts(
|
|||||||
EState(state): State,
|
EState(state): State,
|
||||||
_: Auth,
|
_: Auth,
|
||||||
PaginationQuery(pagination): PaginationQuery,
|
PaginationQuery(pagination): PaginationQuery,
|
||||||
) -> Result<Json<Pagination<AccountInfo>>, Error> {
|
) -> Result<Json<Pagination<Account>>, Error> {
|
||||||
let conn = state.conn().await?;
|
let conn = state.conn().await?;
|
||||||
let result = Accounts::list_all(&conn, pagination).await?;
|
let result = Accounts::list_all(&conn, pagination).await?;
|
||||||
Ok(Json(result))
|
Ok(Json(result))
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use bank_core::{
|
use bank_core::{
|
||||||
account::{AccountInfo, UserAccountInfo},
|
account::{Account, UserAccountInfo},
|
||||||
pagination::{Pagination, RequestPagination},
|
pagination::{Pagination, RequestPagination},
|
||||||
};
|
};
|
||||||
use deadpool_postgres::GenericClient;
|
use deadpool_postgres::GenericClient;
|
||||||
@ -11,8 +11,8 @@ use crate::api::TransactionBuilder;
|
|||||||
|
|
||||||
use super::count;
|
use super::count;
|
||||||
|
|
||||||
fn account_info_from_row(row: Row) -> AccountInfo {
|
fn account_info_from_row(row: Row) -> Account {
|
||||||
AccountInfo {
|
Account {
|
||||||
id: row.get("id"),
|
id: row.get("id"),
|
||||||
user: row.get("user"),
|
user: row.get("user"),
|
||||||
name: row.get("name"),
|
name: row.get("name"),
|
||||||
@ -55,7 +55,7 @@ impl Accounts {
|
|||||||
pub async fn list_all(
|
pub async fn list_all(
|
||||||
client: &impl GenericClient,
|
client: &impl GenericClient,
|
||||||
pagination: RequestPagination,
|
pagination: RequestPagination,
|
||||||
) -> Result<Pagination<AccountInfo>, tokio_postgres::Error> {
|
) -> Result<Pagination<Account>, tokio_postgres::Error> {
|
||||||
let stmt = client
|
let stmt = client
|
||||||
.prepare_cached("select id,\"user\",name from accounts limit $1 offset $2")
|
.prepare_cached("select id,\"user\",name from accounts limit $1 offset $2")
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user