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 user: Uuid,
|
||||
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)]
|
||||
#[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))]
|
||||
pub struct UserAccountInfo {
|
||||
@ -40,8 +32,8 @@ pub struct ReducedAccountInfo {
|
||||
impl PaginationType for UserAccountInfo {
|
||||
const NAME: &str = "UserAccounts";
|
||||
}
|
||||
impl PaginationType for AccountInfo {
|
||||
impl PaginationType for Account {
|
||||
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 util;
|
||||
pub use error::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use util::*;
|
||||
|
||||
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_and_id_index on chat_messages(chat, id);
|
||||
|
||||
create table chat_members(
|
||||
chat uuid not null,
|
||||
|
||||
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use axum::{Router, extract::Path, routing::get};
|
||||
use bank_core::{
|
||||
ApiError,
|
||||
account::AccountInfo,
|
||||
account::Account,
|
||||
pagination::Pagination,
|
||||
transaction::{FullTransaction, TransactionQuery},
|
||||
};
|
||||
@ -52,7 +52,7 @@ pub async fn list_accounts(
|
||||
EState(state): State,
|
||||
_: Auth,
|
||||
PaginationQuery(pagination): PaginationQuery,
|
||||
) -> Result<Json<Pagination<AccountInfo>>, Error> {
|
||||
) -> Result<Json<Pagination<Account>>, Error> {
|
||||
let conn = state.conn().await?;
|
||||
let result = Accounts::list_all(&conn, pagination).await?;
|
||||
Ok(Json(result))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use bank_core::{
|
||||
account::{AccountInfo, UserAccountInfo},
|
||||
account::{Account, UserAccountInfo},
|
||||
pagination::{Pagination, RequestPagination},
|
||||
};
|
||||
use deadpool_postgres::GenericClient;
|
||||
@ -11,8 +11,8 @@ use crate::api::TransactionBuilder;
|
||||
|
||||
use super::count;
|
||||
|
||||
fn account_info_from_row(row: Row) -> AccountInfo {
|
||||
AccountInfo {
|
||||
fn account_info_from_row(row: Row) -> Account {
|
||||
Account {
|
||||
id: row.get("id"),
|
||||
user: row.get("user"),
|
||||
name: row.get("name"),
|
||||
@ -55,7 +55,7 @@ impl Accounts {
|
||||
pub async fn list_all(
|
||||
client: &impl GenericClient,
|
||||
pagination: RequestPagination,
|
||||
) -> Result<Pagination<AccountInfo>, tokio_postgres::Error> {
|
||||
) -> Result<Pagination<Account>, tokio_postgres::Error> {
|
||||
let stmt = client
|
||||
.prepare_cached("select id,\"user\",name from accounts limit $1 offset $2")
|
||||
.await?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user