cscart_rs/service/
user_service.rs

1use crate::prelude::*;
2use crate::service::config::ServiceConfig;
3
4use crate::{
5    impl_create_method, impl_delete_by_id_method, impl_get_all_method, impl_get_by_id_method,
6    impl_update_by_id_method,
7};
8use serde::Deserialize;
9use serde_json::Value;
10
11use crate::types::User;
12
13pub struct UserService {
14    config: ServiceConfig<Authenticated>,
15}
16
17impl UserService {
18    pub fn with_config(service: ServiceConfig<Authenticated>) -> UserService {
19        Self { config: service }
20    }
21}
22
23#[derive(Deserialize, Debug)]
24pub struct CreateUserResponse {
25    pub user_id: i32,
26    pub profile_id: String,
27}
28
29#[derive(Deserialize, Debug)]
30pub struct UpdateUserResponse {
31    pub user_id: i32,
32    pub profile_id: String,
33}
34
35#[derive(Deserialize, Debug)]
36pub struct GetAllUsersResponse {
37    pub users: Vec<User>,
38}
39
40impl_create_method!(UserService, CreateUserResponse);
41impl_get_by_id_method!(UserService, User);
42impl_get_all_method!(UserService, GetAllUsersResponse);
43impl_update_by_id_method!(UserService, Value);
44impl_delete_by_id_method!(UserService, Value);