Skip to content

Commit d69088f

Browse files
committed
feat(project): add common enums and types for user management and system operations
1 parent 1d5acc1 commit d69088f

File tree

7 files changed

+170
-97
lines changed

7 files changed

+170
-97
lines changed

src/service/enums/common.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** Common enums */
2+
3+
/**
4+
* Enable status
5+
*
6+
* - "1": enabled
7+
* - "2": disabled
8+
*/
9+
export enum EnableStatus {
10+
/** Enabled */
11+
ENABLED = '1',
12+
/** Disabled */
13+
DISABLED = '2'
14+
}
15+
16+
export type EnableStatusValue = `${EnableStatus}`;

src/service/enums/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Service enums
3+
*
4+
* All service related enums
5+
*/
6+
7+
export * from './common';
8+
export * from './system-manage';

src/service/enums/system-manage.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/** System manage enums */
2+
3+
/**
4+
* User gender
5+
*
6+
* - "1": male
7+
* - "2": female
8+
*/
9+
export enum UserGender {
10+
/** Male */
11+
MALE = '1',
12+
/** Female */
13+
FEMALE = '2'
14+
}
15+
16+
export type UserGenderValue = `${UserGender}`;
17+
18+
/**
19+
* Menu type
20+
*
21+
* - "1": directory
22+
* - "2": menu
23+
*/
24+
export enum MenuType {
25+
/** Directory */
26+
DIRECTORY = '1',
27+
/** Menu */
28+
MENU = '2'
29+
}
30+
31+
export type MenuTypeValue = `${MenuType}`;
32+
33+
/**
34+
* Icon type
35+
*
36+
* - "1": iconify icon
37+
* - "2": local icon
38+
*/
39+
export enum IconType {
40+
/** Iconify icon */
41+
ICONIFY = '1',
42+
/** Local icon */
43+
LOCAL = '2'
44+
}
45+
46+
export type IconTypeValue = `${IconType}`;

src/service/types/auth.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Namespace Api.Auth
3+
*
4+
* Backend api module: "auth"
5+
*/
6+
declare namespace Api {
7+
namespace Auth {
8+
interface LoginToken {
9+
refreshToken: string;
10+
token: string;
11+
}
12+
13+
interface UserInfo {
14+
buttons: string[];
15+
roles: string[];
16+
userId: string;
17+
userName: string;
18+
}
19+
20+
type Info = {
21+
token: LoginToken['token'];
22+
userInfo: UserInfo;
23+
};
24+
}
25+
}

src/service/types/common.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Namespace Api.Common
3+
*
4+
* Common types and utilities
5+
*/
6+
declare namespace Api {
7+
namespace Common {
8+
/** common params of paginating */
9+
interface PaginatingCommonParams {
10+
/** current page number */
11+
current: number;
12+
/** page size */
13+
size: number;
14+
/** total count */
15+
total: number;
16+
}
17+
18+
/** common params of paginating query list data */
19+
interface PaginatingQueryRecord<T = any> extends PaginatingCommonParams {
20+
records: T[];
21+
}
22+
23+
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'current' | 'size'>;
24+
25+
/**
26+
* enable status
27+
*
28+
* - "1": enabled
29+
* - "2": disabled
30+
*/
31+
type EnableStatus = import('../enums').EnableStatusValue;
32+
33+
/** common record */
34+
type CommonRecord<T = any> = {
35+
/** record creator */
36+
createBy: string;
37+
/** record create time */
38+
createTime: string;
39+
/** record id */
40+
id: number;
41+
/** record status */
42+
status: EnableStatus | null;
43+
/** record updater */
44+
updateBy: string;
45+
/** record update time */
46+
updateTime: string;
47+
} & T;
48+
}
49+
}

src/service/types/route.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Namespace Api.Route
3+
*
4+
* Backend api module: "route"
5+
*/
6+
declare namespace Api {
7+
namespace Route {
8+
type ElegantConstRoute = import('@soybean-react/vite-plugin-react-router').ElegantConstRoute;
9+
10+
interface MenuRoute extends ElegantConstRoute {
11+
id: string;
12+
}
13+
14+
interface UserRoute {
15+
home: import('@soybean-react/vite-plugin-react-router').LastLevelRouteKey;
16+
routes: string[];
17+
}
18+
}
19+
}

src/types/api.d.ts renamed to src/service/types/system-manage.d.ts

Lines changed: 7 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,9 @@
11
/**
2-
* Namespace Api
2+
* Namespace Api.SystemManage
33
*
4-
* All backend api type
4+
* Backend api module: "systemManage"
55
*/
66
declare namespace Api {
7-
namespace Common {
8-
/** common params of paginating */
9-
interface PaginatingCommonParams {
10-
/** current page number */
11-
current: number;
12-
/** page size */
13-
size: number;
14-
/** total count */
15-
total: number;
16-
}
17-
18-
/** common params of paginating query list data */
19-
interface PaginatingQueryRecord<T = any> extends PaginatingCommonParams {
20-
records: T[];
21-
}
22-
23-
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'current' | 'size'>;
24-
25-
/**
26-
* enable status
27-
*
28-
* - "1": enabled
29-
* - "2": disabled
30-
*/
31-
type EnableStatus = '1' | '2';
32-
33-
/** common record */
34-
type CommonRecord<T = any> = {
35-
/** record creator */
36-
createBy: string;
37-
/** record create time */
38-
createTime: string;
39-
/** record id */
40-
id: number;
41-
/** record status */
42-
status: EnableStatus | null;
43-
/** record updater */
44-
updateBy: string;
45-
/** record update time */
46-
updateTime: string;
47-
} & T;
48-
}
49-
50-
/**
51-
* namespace Auth
52-
*
53-
* backend api module: "auth"
54-
*/
55-
namespace Auth {
56-
interface LoginToken {
57-
refreshToken: string;
58-
token: string;
59-
}
60-
61-
interface UserInfo {
62-
buttons: string[];
63-
roles: string[];
64-
userId: string;
65-
userName: string;
66-
}
67-
68-
type Info = {
69-
token: LoginToken['token'];
70-
userInfo: UserInfo;
71-
};
72-
}
73-
74-
/**
75-
* namespace Route
76-
*
77-
* backend api module: "route"
78-
*/
79-
namespace Route {
80-
type ElegantConstRoute = import('@soybean-react/vite-plugin-react-router').ElegantConstRoute;
81-
82-
interface MenuRoute extends ElegantConstRoute {
83-
id: string;
84-
}
85-
86-
interface UserRoute {
87-
home: import('@soybean-react/vite-plugin-react-router').LastLevelRouteKey;
88-
routes: string[];
89-
}
90-
}
91-
92-
/**
93-
* namespace SystemManage
94-
*
95-
* backend api module: "systemManage"
96-
*/
977
namespace SystemManage {
988
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'current' | 'size'>;
999

@@ -121,10 +31,10 @@ declare namespace Api {
12131
/**
12232
* user gender
12333
*
124-
* - "1": "male"
125-
* - "2": "female"
34+
* - "1": male
35+
* - "2": female
12636
*/
127-
type UserGender = '1' | '2';
37+
type UserGender = import('../enums').UserGenderValue;
12838

12939
/** user */
13040
type User = Common.CommonRecord<{
@@ -157,7 +67,7 @@ declare namespace Api {
15767
* - "1": directory
15868
* - "2": menu
15969
*/
160-
type MenuType = '1' | '2';
70+
type MenuType = import('../enums').MenuTypeValue;
16171

16272
type MenuButton = {
16373
/**
@@ -176,7 +86,7 @@ declare namespace Api {
17686
* - "1": iconify icon
17787
* - "2": local icon
17888
*/
179-
type IconType = '1' | '2';
89+
type IconType = import('../enums').IconTypeValue;
18090

18191
type MenuPropsOfRoute = Pick<
18292
import('@soybean-react/vite-plugin-react-router').RouteMeta,

0 commit comments

Comments
 (0)