post services integrations
This commit is contained in:
@@ -109,8 +109,7 @@ pub async fn create(
|
||||
.ok_or(HTTPError::BadRequest("Category not found".to_string()))?;
|
||||
}
|
||||
|
||||
let active_model = mapper::create_request_to_am(payload);
|
||||
let channel = state.repositories.channel.create(active_model).await?;
|
||||
let channel = state.services.channel.create_channel(payload).await?;
|
||||
Ok((
|
||||
StatusCode::CREATED,
|
||||
Json(mapper::channel_model_to_channel_response(channel)),
|
||||
@@ -170,8 +169,7 @@ pub async fn update(
|
||||
.ok_or(HTTPError::BadRequest("Category not found".to_string()))?;
|
||||
}
|
||||
|
||||
let active_model = mapper::update_request_to_am(id, payload);
|
||||
let channel = state.repositories.channel.update(active_model).await?;
|
||||
let channel = state.services.channel.update_channel(id, payload).await?;
|
||||
|
||||
Ok(Json(mapper::channel_model_to_channel_response(channel)))
|
||||
}
|
||||
@@ -198,7 +196,7 @@ pub async fn delete(
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<Uuid>,
|
||||
) -> Result<StatusCode, HTTPError> {
|
||||
if state.repositories.channel.delete(id).await? {
|
||||
if state.services.channel.delete_channel(id).await? {
|
||||
Ok(StatusCode::NO_CONTENT)
|
||||
} else {
|
||||
Err(HTTPError::NotFound)
|
||||
@@ -257,7 +255,7 @@ pub async fn set_user_permission(
|
||||
Json(payload): Json<SetChannelPermissionRequest>,
|
||||
) -> Result<Json<ChannelUserPermissionResponse>, HTTPError> {
|
||||
state
|
||||
.repositories
|
||||
.services
|
||||
.channel
|
||||
.set_user_permission(channel_id, user_id, payload.permissions)
|
||||
.await?;
|
||||
@@ -304,7 +302,7 @@ pub async fn remove_user_permission(
|
||||
}
|
||||
|
||||
state
|
||||
.repositories
|
||||
.services
|
||||
.channel
|
||||
.remove_user_permission(channel_id, user_id)
|
||||
.await?;
|
||||
@@ -364,7 +362,7 @@ pub async fn set_role_permission(
|
||||
Json(payload): Json<SetChannelPermissionRequest>,
|
||||
) -> Result<Json<ChannelRolePermissionResponse>, HTTPError> {
|
||||
state
|
||||
.repositories
|
||||
.services
|
||||
.channel
|
||||
.set_role_permission(channel_id, role_id, payload.permissions)
|
||||
.await?;
|
||||
@@ -411,7 +409,7 @@ pub async fn remove_role_permission(
|
||||
}
|
||||
|
||||
state
|
||||
.repositories
|
||||
.services
|
||||
.channel
|
||||
.remove_role_permission(channel_id, role_id)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user