1use std::collections::HashSet;
2use serde::{Deserialize, Serialize};
3use sea_orm::FromQueryResult;
4use sea_orm::prelude::DateTime;
5use crate::database::BigIntPrimaryKey;
6
7#[derive(Clone,Debug, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct LoginUser {
10 pub user_id: BigIntPrimaryKey,
11 pub dept_id: BigIntPrimaryKey,
12 pub store_id: BigIntPrimaryKey,
13 pub personnel_number: Option<String>,
14 pub user_name: String,
15 pub nick_name: Option<String>,
16 pub user_type: Option<String>,
17 pub gender: Option<String>,
18 pub phone_number: Option<String>,
19 pub login_time: i64,
20 pub expire_time: i64,
21 pub token: String,
22 pub is_admin: bool,
23 pub is_super: bool,
24 pub permissions: HashSet<String>,
25 pub data_scope: DataScope,
26 pub roles: Vec<String>,
27 pub user: User,
28 pub customer: Option<Customer>,
29}
30#[derive(Clone,Debug, Serialize, Deserialize, Default)]
31#[serde(rename_all = "camelCase")]
32pub struct Customer {
33 pub store_id: BigIntPrimaryKey,
34 pub name: String,
35 pub second_name: Option<String>,
36 pub third_name: Option<String>,
37 pub suffix: String,
38}
39#[derive(Clone,Debug, Serialize, Deserialize, Default)]
40#[serde(rename_all = "camelCase")]
41pub struct User {
42 pub id: BigIntPrimaryKey,
43 pub dept_id: BigIntPrimaryKey,
44 pub dept_name: Option<String>,
45 pub store_id: BigIntPrimaryKey,
46 pub personnel_number: Option<String>,
47 pub user_name: String,
48 pub nick_name: Option<String>,
49 pub user_type: Option<String>,
50 pub gender: Option<String>,
51 pub date_of_birth: Option<String>,
52 pub email: Option<String>,
53 pub phone_number: Option<String>,
54 pub avatar: Option<String>,
55 pub status: i8,
56 pub first_name: Option<String>,
57 pub last_name: Option<String>,
58 pub dept: Option<SysDeptResponse>,
59 pub post_ids: Vec<BigIntPrimaryKey>,
60 pub roles: Vec<SysRoleResponse>,
61
62}
63
64#[derive(Clone,Debug, Serialize, Deserialize, Default)]
65#[serde(rename_all = "camelCase")]
66pub struct DataScope {
67 pub dept_ids: Vec<BigIntPrimaryKey>,
68 pub is_self_only: bool,
69}
70
71#[derive(Debug, Serialize, Deserialize,FromQueryResult,Clone)]
72#[serde(rename_all = "camelCase")]
73pub struct SysRoleResponse {
74 pub role_id: BigIntPrimaryKey,
75 pub role_name: String,
76 pub role_key: String,
77 pub data_scope: String,
78 pub role_sort: i32,
79 pub menu_check_strictly: Option<i8>,
80 pub dept_check_strictly: Option<i8>,
81 pub status: i8,
82 pub remark: Option<String>,
83 pub create_time: DateTime,
84 pub update_time: Option<DateTime>,
85}
86#[derive(Clone, Debug, Serialize, Deserialize, FromQueryResult, Default)]
87#[serde(rename_all = "camelCase")]
88pub struct SysDeptResponse {
89 pub id: BigIntPrimaryKey,
90 pub parent_id: BigIntPrimaryKey,
91 pub ancestors: String,
92 pub dept_name: String,
93 pub order_num: Option<i64>,
94 pub leader: Option<String>,
95 pub phone: Option<String>,
96 pub email: Option<String>,
97 pub status: i8,
98 pub del_flag: Option<String>,
99}