-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(express-typeorm): update example.
- Loading branch information
1 parent
246ecc1
commit 6f0162b
Showing
16 changed files
with
505 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
|
||
@baseUrl = http://localhost:3000/api | ||
@contentType = application/json | ||
|
||
### 用户登录 | ||
|
||
# @name login | ||
@auth = {{login.response.body.$.token}} | ||
POST {{baseUrl}}/login | ||
Content-Type: {{contentType}} | ||
|
||
{ | ||
"username": "wcj", | ||
"password": "123456" | ||
} | ||
|
||
### 员工信息列表 | ||
|
||
@userId = {{getList.response.body.$[0].id}} | ||
|
||
# @name getList | ||
GET {{baseUrl}}/user/staff?page=1&per_page=30 | ||
Content-Type: {{contentType}} | ||
Authorization: token {{auth}} | ||
|
||
|
||
### 更新员工信息 | ||
|
||
PUT {{baseUrl}}/user/staff | ||
Content-Type: {{contentType}} | ||
Authorization: token {{auth}} | ||
|
||
{ | ||
"id": "{{userId}}", | ||
"name": "周杰伦", | ||
"mobile": "1366666{{$randomInt 5 200}}", | ||
"age": {{$randomInt 5 200}} | ||
} | ||
|
||
|
||
### 添加员工信息 | ||
|
||
POST {{baseUrl}}/user/staff | ||
Content-Type: {{contentType}} | ||
Authorization: token {{auth}} | ||
|
||
{ | ||
"name": "周杰伦{{$randomInt 1 200}}", | ||
"mobile": "136666{{$randomInt 5 200}}6666", | ||
"age": 18 | ||
} | ||
|
||
### 获取员工信息 | ||
|
||
GET {{baseUrl}}/user/staff/{{userId}} | ||
Content-Type: {{contentType}} | ||
Authorization: token {{auth}} | ||
|
||
### 删除员工信息 | ||
|
||
DELETE {{baseUrl}}/user/staff/{{userId}}?token={{auth}} | ||
Content-Type: application/json |
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,40 @@ | ||
import { RoutesData } from './'; | ||
import { UserStaffController } from '../controller/UserStaffController'; | ||
|
||
export const userStaff: RoutesData<UserStaffController, typeof UserStaffController>[] = [ | ||
{ | ||
method: 'post', | ||
route: '/api/user/staff', | ||
auth: true, | ||
controller: UserStaffController, | ||
action: 'create', | ||
}, | ||
{ | ||
method: 'put', | ||
route: '/api/user/staff', | ||
auth: true, | ||
controller: UserStaffController, | ||
action: 'update', | ||
}, | ||
{ | ||
method: 'get', | ||
route: '/api/user/staff', | ||
auth: true, | ||
controller: UserStaffController, | ||
action: 'all', | ||
}, | ||
{ | ||
method: 'get', | ||
route: '/api/user/staff/:id', | ||
auth: true, | ||
controller: UserStaffController, | ||
action: 'one', | ||
}, | ||
{ | ||
method: 'delete', | ||
route: '/api/user/staff/:id', | ||
auth: true, | ||
controller: UserStaffController, | ||
action: 'remove', | ||
}, | ||
]; |
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,16 @@ | ||
import { Express } from 'express'; | ||
import { user } from './User'; | ||
import { userStaff } from './UserStaff'; | ||
|
||
export interface RoutesData<T, E, K = keyof T> { | ||
method: Extract<keyof Express, 'get' | 'post' | 'delete' | 'put' | 'patch'>; | ||
route: string; | ||
auth?: boolean; | ||
controller: E; | ||
action: K; | ||
} | ||
|
||
export const Routes = [ | ||
...userStaff, | ||
...user, | ||
]; |
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
Oops, something went wrong.