-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5685b5
commit 373f6ca
Showing
11 changed files
with
111 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PostMapping, RequestLog, RequestMapping, RequestSecurityPermit } from '../../decorator'; | ||
|
||
@RequestMapping('https://auto.thatapi.cn/welcome') | ||
class UserMapper { | ||
@PostMapping('/login') | ||
@RequestLog | ||
@RequestSecurityPermit | ||
async login(userName: string = 'test', password: string = '123456', rememberMe: boolean = false) {} | ||
} | ||
|
||
export default new UserMapper(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 状态码枚举 | ||
export enum DATA_RESPONSE_STATUS { | ||
OK = 200, | ||
BAD_REQUEST = 400, | ||
UNAUTHORIZED = 401, | ||
FORBIDDEN = 403, | ||
NOT_FOUND = 404, | ||
ERROR = 500, | ||
} | ||
// 状态码与消息的映射,直接在 enum 中定义 | ||
export namespace DATA_RESPONSE_STATUS_MESSAGES { | ||
export const messages: { [key in DATA_RESPONSE_STATUS]: string } = { | ||
[DATA_RESPONSE_STATUS.OK]: '操作成功', | ||
[DATA_RESPONSE_STATUS.BAD_REQUEST]: '参数错误', | ||
[DATA_RESPONSE_STATUS.UNAUTHORIZED]: '鉴权失败', | ||
[DATA_RESPONSE_STATUS.FORBIDDEN]: '越权操作', | ||
[DATA_RESPONSE_STATUS.NOT_FOUND]: '寻址失败', | ||
[DATA_RESPONSE_STATUS.ERROR]: '系统错误', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './DATA_META_KEY'; | ||
export * from './DATA_LOG_LEVEL'; | ||
export * from './DATA_RESPONSE_STATUS'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// TODO: 实现安全的获取json值 | ||
function safeGetJsonValue(json: any, keys: string[]): any { | ||
let value = json; | ||
for (const key of keys) { | ||
if (value && typeof value === 'object' && key in value) { | ||
value = value[key]; | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
return value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters