test with kerkour architecture (https://kerkour.com/rust-web-application-clean-architecture)
This commit is contained in:
26
src/domain/rolle/service/create_user.rs
Normal file
26
src/domain/rolle/service/create_user.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use anyhow::Error;
|
||||
use chrono::Utc;
|
||||
use ulid::Ulid;
|
||||
|
||||
use super::Service;
|
||||
use crate::domain::rolle::entity;
|
||||
use crate::domain::rolle::model::CreateRolleInput;
|
||||
|
||||
impl Service {
|
||||
pub async fn create_rolle(&self, input: CreateRolleInput) -> Result<entity::Rolle, Error> {
|
||||
// let username_exists = self.check_username_exists(&self.db, &input.name).await?;
|
||||
// if username_exists {
|
||||
// return Err(Error::UsernameAlreadyExists.into());
|
||||
// }
|
||||
|
||||
let rolle_input = entity::Rolle {
|
||||
id: Ulid::new().into(),
|
||||
name: input.name,
|
||||
created_at: Utc::now(),
|
||||
updated_at: Utc::now(),
|
||||
};
|
||||
|
||||
let rolle = self.repo.create_rolle(&self.db, &rolle_input).await?;
|
||||
Ok(rolle)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user