WIP
This commit is contained in:
parent
d6714aa7d9
commit
1ad0e4400a
7 changed files with 62 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
use actix_web::{Responder, delete, get, post};
|
use actix_web::{Responder, delete, get, post, put};
|
||||||
|
|
||||||
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
cfg.service(get_classes)
|
cfg.service(get_classes)
|
||||||
|
@ -22,6 +22,11 @@ async fn create_class() -> impl Responder {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[put("")]
|
||||||
|
async fn change_class() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
#[delete("/{id}")]
|
#[delete("/{id}")]
|
||||||
async fn delete_class() -> impl Responder {
|
async fn delete_class() -> impl Responder {
|
||||||
""
|
""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use actix_web::{Responder, delete, get, post};
|
use actix_web::{Responder, delete, get, post, put};
|
||||||
|
|
||||||
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
cfg.service(get_groups)
|
cfg.service(get_groups)
|
||||||
|
@ -22,6 +22,11 @@ async fn create_group() -> impl Responder {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[put("")]
|
||||||
|
async fn change_group() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
#[delete("/{id}")]
|
#[delete("/{id}")]
|
||||||
async fn delete_group() -> impl Responder {
|
async fn delete_group() -> impl Responder {
|
||||||
""
|
""
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use actix_web::{Result, delete, get, post, web};
|
use actix_web::{Responder, Result, delete, get, post, put, web};
|
||||||
use log::debug;
|
|
||||||
use sea_orm::prelude::Uuid;
|
use sea_orm::prelude::Uuid;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -11,6 +10,12 @@ struct CreateProject {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct UpdateProject {
|
||||||
|
id: Uuid,
|
||||||
|
name: String,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
cfg.service(get_project)
|
cfg.service(get_project)
|
||||||
.service(get_projects)
|
.service(get_projects)
|
||||||
|
@ -49,6 +54,18 @@ async fn create_project(
|
||||||
Ok(web::Json(result))
|
Ok(web::Json(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[put("")]
|
||||||
|
async fn change_project(
|
||||||
|
db: web::Data<Database>,
|
||||||
|
update_project_struct: web::Json<UpdateProject>,
|
||||||
|
) -> Result<web::Json<entity::project::Model>, ApiError> {
|
||||||
|
let updated_project = db
|
||||||
|
.update_project(update_project_struct.into_inner())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(web::Json(updated_project))
|
||||||
|
}
|
||||||
|
|
||||||
#[delete("/{id}")]
|
#[delete("/{id}")]
|
||||||
async fn delete_project(
|
async fn delete_project(
|
||||||
db: web::Data<Database>,
|
db: web::Data<Database>,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use actix_web::{Responder, delete, get, post};
|
use actix_web::{Responder, delete, get, post, put};
|
||||||
|
|
||||||
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
cfg.service(get_templates)
|
cfg.service(get_templates)
|
||||||
|
@ -22,6 +22,11 @@ async fn create_template() -> impl Responder {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[put("")]
|
||||||
|
async fn change_template() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
#[delete("/{id}")]
|
#[delete("/{id}")]
|
||||||
async fn delete_template() -> impl Responder {
|
async fn delete_template() -> impl Responder {
|
||||||
""
|
""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use actix_web::{Responder, delete, get, post};
|
use actix_web::{Responder, delete, get, post, put};
|
||||||
|
|
||||||
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
cfg.service(get_users)
|
cfg.service(get_users)
|
||||||
|
@ -22,6 +22,11 @@ async fn create_user() -> impl Responder {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[put("")]
|
||||||
|
async fn change_user() -> impl Responder {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
#[delete("/{id}")]
|
#[delete("/{id}")]
|
||||||
async fn delete_user() -> impl Responder {
|
async fn delete_user() -> impl Responder {
|
||||||
""
|
""
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
fn add_user_to_group() {}
|
use super::Database;
|
||||||
|
|
||||||
fn create_group() {}
|
impl Database {
|
||||||
|
async fn add_user_to_group(&self) {}
|
||||||
|
|
||||||
|
async fn create_group(&self) {}
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,19 @@ impl Database {
|
||||||
Ok(project)
|
Ok(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn update_project(&self, project: UpdateProject) -> Result<project::Model, ApiError> {
|
||||||
|
debug!("Updating project with id: {}", &project.id);
|
||||||
|
|
||||||
|
let active_model = project::ActiveModel {
|
||||||
|
id: NotSet,
|
||||||
|
name: Set(project.name.to_owned()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let project = active_model.update(&self.conn).await?;
|
||||||
|
|
||||||
|
Ok(project)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn delete_project(&self, id: &Uuid) -> Result<DeleteResult, ApiError> {
|
pub async fn delete_project(&self, id: &Uuid) -> Result<DeleteResult, ApiError> {
|
||||||
debug!("Deleting project with id: {}", id);
|
debug!("Deleting project with id: {}", id);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue