Răsfoiți Sursa

Create the model for accounts.

Lee Morgan 1 an în urmă
părinte
comite
96e490fb8a

+ 8 - 0
src/controllers/account.rs

@@ -0,0 +1,8 @@
+use actix_web::{post, web, HttpResponse};
+
+#[post("/api/account")]
+pub async fn create_route(
+    db: web::Data<Database>,
+    payload: web::Json<NewUserInput>
+) -> Result<HttpResponse, AppError> {
+}

+ 1 - 0
src/controllers/mod.rs

@@ -1 +1,2 @@
 pub mod user;
+pub mod account;

+ 1 - 0
src/main.rs

@@ -23,6 +23,7 @@ async fn main() -> std::io::Result<()> {
             .app_data(web::Data::new(db.clone()))
             .configure(routes::other::config)
             .configure(routes::user::config)
+            .configure(routes::account::config)
     })
         .bind(("127.0.0.1", 8000))?
         .run()

+ 11 - 0
src/models/account.rs

@@ -0,0 +1,11 @@
+use serde::{Serialize, Deserialize};
+use bson::{oid::ObjectId, DateTime};
+
+#[derive(Serialize, Deserialize)]
+pub struct Account {
+    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
+    pub _id: Option<ObjectId>,
+    pub user: ObjectId,
+    pub data: String,
+    pub created_date: bson::DateTime
+}

+ 1 - 0
src/models/mod.rs

@@ -1 +1,2 @@
 pub mod user;
+pub mod account;

+ 8 - 0
src/routes/account.rs

@@ -0,0 +1,8 @@
+use actix_web::web;
+use crate::controllers::user::{
+    create_route
+}
+
+pub fn config(cfg: &mut web::ServiceConfig) {
+    cfg.service(create_route);
+}

+ 1 - 0
src/routes/mod.rs

@@ -1,2 +1,3 @@
 pub mod other;
 pub mod user;
+pub mod account;