Skip to content

Commit

Permalink
Merge pull request #79 from refactor-group/fix_create_operations
Browse files Browse the repository at this point in the history
  • Loading branch information
jhodapp authored Dec 3, 2024
2 parents d69a2e2 + b383953 commit 313b8ca
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions entity/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ pub struct Model {
#[serde(skip_deserializing)]
pub status_changed_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}

Expand Down
3 changes: 3 additions & 0 deletions entity/src/coachees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use utoipa::ToSchema;
#[schema(as = entity::users::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "users")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
Expand All @@ -18,8 +19,10 @@ pub struct Model {
pub password: String,
pub github_username: Option<String>,
pub github_profile_url: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
3 changes: 3 additions & 0 deletions entity/src/coaches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use utoipa::ToSchema;
#[schema(as = entity::users::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "users")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
Expand All @@ -18,8 +19,10 @@ pub struct Model {
pub password: String,
pub github_username: Option<String>,
pub github_profile_url: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
3 changes: 3 additions & 0 deletions entity/src/coaching_relationships.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ use utoipa::ToSchema;
table_name = "coaching_relationships"
)]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
pub organization_id: Id,
pub coach_id: Id,
pub coachee_id: Id,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
5 changes: 5 additions & 0 deletions entity/src/coaching_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ use utoipa::ToSchema;
#[schema(as = entity::coaching_sessions::Model)]
#[sea_orm(schema_name = "refactor_platform", table_name = "coaching_sessions")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
pub coaching_relationship_id: Id,
pub date: DateTime,
pub timezone: String,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}

Expand Down
3 changes: 3 additions & 0 deletions entity/src/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ use utoipa::ToSchema;
#[schema(as = entity::organizations::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "organizations")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
pub name: String,
pub logo: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
5 changes: 4 additions & 1 deletion entity/src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ use utoipa::ToSchema;
#[schema(as = entity::users::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "users")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
pub email: String,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub display_name: Option<String>,
#[serde(skip)]
#[serde(skip_serializing)]
pub password: String,
pub github_username: Option<String>,
pub github_profile_url: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
4 changes: 2 additions & 2 deletions web/src/controller/user_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use service::config::ApiVersion;

use log::*;

/// CREATE a new User.
/// CREATE a new User
#[utoipa::path(
post,
path = "/users",
Expand All @@ -16,7 +16,7 @@ use log::*;
),
request_body = entity::users::Model,
responses(
(status = 200, description = "Successfully created a new Coaching Relationship", body = [entity::users::Model]),
(status = 200, description = "Successfully created a new User", body = [entity::users::Model]),
(status = 401, description = "Unauthorized"),
(status = 405, description = "Method not allowed")
),
Expand Down

0 comments on commit 313b8ca

Please sign in to comment.