muscles
This commit is contained in:
79
data.json
79
data.json
@@ -1,79 +0,0 @@
|
||||
[
|
||||
{
|
||||
"major_group": "Upper Body",
|
||||
"group_name": "Chest",
|
||||
"muscles": [
|
||||
"Pectoralis major",
|
||||
"Pectoralis minor"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Upper Body",
|
||||
"group_name": "Back",
|
||||
"muscles": [
|
||||
"Latissimus dorsi",
|
||||
"Trapezius",
|
||||
"Rhomboids",
|
||||
"Erector spinae",
|
||||
"Teres major"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Upper Body",
|
||||
"group_name": "Shoulders",
|
||||
"muscles": [
|
||||
"Deltoids",
|
||||
"Rotator cuff muscles"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Upper Body",
|
||||
"group_name": "Arms",
|
||||
"muscles": [
|
||||
"Biceps brachii",
|
||||
"Brachialis",
|
||||
"Triceps brachii",
|
||||
"Brachioradialis",
|
||||
"Forearm flexors/extensors"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Core",
|
||||
"group_name": "Abdominals",
|
||||
"muscles": [
|
||||
"Rectus abdominis",
|
||||
"Transverse abdominis",
|
||||
"External obliques",
|
||||
"Internal obliques"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Core",
|
||||
"group_name": "Lower Back",
|
||||
"muscles": [
|
||||
"Quadratus lumborum",
|
||||
"Erector spinae"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Lower Body",
|
||||
"group_name": "Legs",
|
||||
"muscles": [
|
||||
"Quadriceps",
|
||||
"Hamstrings",
|
||||
"Gluteus maximus",
|
||||
"Gluteus medius",
|
||||
"Gluteus minimus",
|
||||
"Adductors",
|
||||
"Abductors"
|
||||
]
|
||||
},
|
||||
{
|
||||
"major_group": "Lower Body",
|
||||
"group_name": "Calves",
|
||||
"muscles": [
|
||||
"Gastrocnemius",
|
||||
"Soleus"
|
||||
]
|
||||
}
|
||||
]
|
||||
8
gen.ts
8
gen.ts
@@ -16,8 +16,8 @@ const data: MuscleGroup[] = [
|
||||
major_group: "Upper Body",
|
||||
group_name: "Chest",
|
||||
muscles: [
|
||||
{ colloquial_name: "Pecs", scientific_name: "Pectoralis major" },
|
||||
{ colloquial_name: "Pec Minor", scientific_name: "Pectoralis minor" }
|
||||
{ colloquial_name: "Upper Pecs", scientific_name: "Clavicular Pectoralis Major" },
|
||||
{ colloquial_name: "Pecs", scientific_name: "Sternal Pectoralis Major" },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -35,7 +35,9 @@ const data: MuscleGroup[] = [
|
||||
major_group: "Upper Body",
|
||||
group_name: "Shoulders",
|
||||
muscles: [
|
||||
{ colloquial_name: "Delts", scientific_name: "Deltoideus" },
|
||||
{ colloquial_name: "Front Delts", scientific_name: "Anterior deltoid" },
|
||||
{ colloquial_name: "Rear Delts", scientific_name: "Posterior deltoid" },
|
||||
{ colloquial_name: "Side Delts", scientific_name: "Lateral deltoid" },
|
||||
{ colloquial_name: "Rotator Cuff", scientific_name: "Rotator cuff" }
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"Upper Body": {
|
||||
"Chest": {
|
||||
"Pectoralis major": "Pecs",
|
||||
"Pectoralis minor": "Pecs"
|
||||
},
|
||||
"Back": {
|
||||
"Latissimus dorsi": "Lats",
|
||||
"Trapezius": "Traps",
|
||||
"Rhomboids": "Upper/mid-back muscles",
|
||||
"Erector spinae": "Spinal erectors",
|
||||
"Teres major": "Upper lats"
|
||||
},
|
||||
"Shoulders": {
|
||||
"Deltoids": "Delts",
|
||||
"Rotator cuff muscles": "Rotator cuff"
|
||||
},
|
||||
"Arms": {
|
||||
"Biceps brachii": "Biceps",
|
||||
"Brachialis": "Biceps’ under-muscle",
|
||||
"Triceps brachii": "Triceps",
|
||||
"Brachioradialis": "Forearm muscles",
|
||||
"Forearm flexors/extensors": "Forearm muscles"
|
||||
}
|
||||
},
|
||||
"Core": {
|
||||
"Abdominals": {
|
||||
"Rectus abdominis": "Abs",
|
||||
"Transverse abdominis": "Deep core abs",
|
||||
"External obliques": "Side abs",
|
||||
"Internal obliques": "Inner side abs"
|
||||
},
|
||||
"Lower Back": {
|
||||
"Quadratus lumborum": "QL/Lower back muscles",
|
||||
"Erector spinae": "Spinal erectors"
|
||||
}
|
||||
},
|
||||
"Lower Body": {
|
||||
"Legs": {
|
||||
"Quadriceps": "Quads",
|
||||
"Hamstrings": "Quads",
|
||||
"Gluteus maximus": "Glutes/Butt muscles",
|
||||
"Gluteus medius": "Glutes/Butt muscles",
|
||||
"Gluteus minimus": "Glutes/Butt muscles",
|
||||
"Adductors": "Adductors",
|
||||
"Abductors": "Adductors"
|
||||
},
|
||||
"Calves": {
|
||||
"Gastrocnemius": "Calves",
|
||||
"Soleus": "Calves"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use utoipa_axum::{router::OpenApiRouter, routes};
|
||||
use utoipa_swagger_ui::SwaggerUi;
|
||||
|
||||
// tags
|
||||
use v1::{auth::AUTH_TAG, body_parts::BODY_PARTS_TAG, exercises::EXERCISES_TAG};
|
||||
use v1::{auth::AUTH_TAG, exercises::EXERCISES_TAG, muscles::MUSCLES_TAG};
|
||||
|
||||
mod v1;
|
||||
mod structs;
|
||||
@@ -28,7 +28,7 @@ pub(crate) use utoipa::ToSchema;
|
||||
tags(
|
||||
(name = AUTH_TAG, description = "Authentication API endpoints"),
|
||||
(name = EXERCISES_TAG, description = "Exercise API endpoints"),
|
||||
(name = BODY_PARTS_TAG, description = "Body part API endpoints"),
|
||||
(name = MUSCLES_TAG, description = "Muscle API endpoints"),
|
||||
// (name = CUSTOMER_TAG, description = "Customer API endpoints"),
|
||||
// (name = ORDER_TAG, description = "Order API endpoints")
|
||||
),
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
use extractors::users::UserId;
|
||||
use sqlx::query;
|
||||
|
||||
use crate::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct CreateBodyPartBody {
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[utoipa::path(post, path = "/create", responses((status = OK, body = String)), tag = super::BODY_PARTS_TAG)]
|
||||
pub async fn create(
|
||||
State(state): State<AppState>,
|
||||
UserId(user_id): UserId,
|
||||
Json(body): Json<CreateBodyPartBody>,
|
||||
) -> Result<String, AppError> {
|
||||
let is_admin = query!("SELECT is_admin FROM users WHERE id = $1", user_id)
|
||||
.fetch_one(&*state.db)
|
||||
.await?
|
||||
.is_admin;
|
||||
|
||||
if !is_admin {
|
||||
return Err(AppError::Error(Errors::Unauthorized));
|
||||
}
|
||||
|
||||
let out = query!(
|
||||
"INSERT INTO body_parts (name) VALUES ($1) RETURNING id",
|
||||
body.name
|
||||
)
|
||||
.fetch_one(&*state.db)
|
||||
.await?;
|
||||
|
||||
Ok(out.id.to_string())
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
use crate::AppState;
|
||||
|
||||
pub(super) use super::*;
|
||||
|
||||
pub mod create;
|
||||
|
||||
pub const BODY_PARTS_TAG: &str = "body_parts";
|
||||
|
||||
pub(super) fn router(state: AppState) -> OpenApiRouter {
|
||||
OpenApiRouter::new()
|
||||
.routes(routes!(create::create))
|
||||
.with_state(state)
|
||||
}
|
||||
@@ -4,7 +4,6 @@ pub(super) use utoipa_axum::routes;
|
||||
use crate::AppState;
|
||||
|
||||
pub mod auth;
|
||||
pub mod body_parts;
|
||||
pub mod exercises;
|
||||
pub mod muscles;
|
||||
|
||||
@@ -13,6 +12,5 @@ pub fn router(state: AppState) -> OpenApiRouter {
|
||||
.with_state(state.clone())
|
||||
.nest("/auth", auth::router(state.clone()))
|
||||
.nest("/exercises", exercises::router(state.clone()))
|
||||
.nest("/body_parts", body_parts::router(state.clone()))
|
||||
.nest("/muscles", muscles::router(state.clone()))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ use crate::*;
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct CreateMuscleBody {
|
||||
name: String,
|
||||
body_parts: Vec<String>,
|
||||
scientific_name: String,
|
||||
major_group: String,
|
||||
minor_group: String,
|
||||
}
|
||||
|
||||
#[utoipa::path(post, path = "/create", responses((status = OK, body = String)), tag = super::MUSCLES_TAG)]
|
||||
@@ -25,8 +27,11 @@ pub async fn create(
|
||||
}
|
||||
|
||||
let out = query!(
|
||||
"INSERT INTO muscles (name) VALUES ($1) RETURNING id",
|
||||
body.name
|
||||
"INSERT INTO muscles (name, scientific_name, major_group, minor_group) VALUES ($1, $2, $3, $4) RETURNING id",
|
||||
body.name,
|
||||
body.scientific_name,
|
||||
body.major_group,
|
||||
body.minor_group,
|
||||
)
|
||||
.fetch_one(&*state.db)
|
||||
.await?;
|
||||
|
||||
23
src/v1/muscles/get_all.rs
Normal file
23
src/v1/muscles/get_all.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
// use extractors::users::UserId;
|
||||
use sqlx::query_as;
|
||||
|
||||
use crate::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct Muscle {
|
||||
id: String,
|
||||
name: String,
|
||||
scientific_name: Option<String>,
|
||||
major_group: Option<String>,
|
||||
minor_group: String,
|
||||
}
|
||||
|
||||
#[utoipa::path(get, path = "/all", responses((status = OK, body = Muscle)), tag = super::MUSCLES_TAG)]
|
||||
pub async fn get_all(State(state): State<AppState>) -> Result<Json<Vec<Muscle>>, AppError> {
|
||||
let muscles = query_as!(Muscle, "SELECT * FROM muscles")
|
||||
.fetch_all(&*state.db)
|
||||
.await?;
|
||||
|
||||
Ok(Json(muscles))
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ use crate::AppState;
|
||||
pub(super) use super::*;
|
||||
|
||||
pub mod create;
|
||||
pub mod get_all;
|
||||
|
||||
pub const MUSCLES_TAG: &str = "muscles";
|
||||
|
||||
pub(super) fn router(state: AppState) -> OpenApiRouter {
|
||||
OpenApiRouter::new()
|
||||
.routes(routes!(create::create))
|
||||
.routes(routes!(get_all::get_all))
|
||||
.with_state(state)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user