Skip to content

Commit 100df9c

Browse files
committed
test
1 parent f2438b7 commit 100df9c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/controllers/DemoController.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ export default class LogsController {
2525
//
2626
}
2727

28+
static async test(ctx: Context) {
29+
console.log('ctx.path: ', ctx.path.length, ctx.params)
30+
ctx.body = ctx.params.id.length
31+
}
32+
2833
}

src/controllers/DoubleColorBallController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ export default class DoubleColorBallController {
5252
return pages
5353
}
5454

55+
/***
56+
* batch insert(test)
57+
*/
58+
static async batchInsert(ctx: Context) {
59+
const list = ctx.fields as object[]
60+
console.log(list, '----9999', ctx.state)
61+
for(let i = list.length - 1; i >= 0; i --) {
62+
await DoubleColorBallController.insert(list[i], ctx)
63+
}
64+
ctx.Json({ data: 999 })
65+
}
66+
5567
static async insert(args: any, ctx: Context) {
5668
const ball = await getRepository(Balls).findOne({issue: args.issue})
5769
if(ball) {

src/routes/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ import AccountCtrl from '../controllers/AccountController'
66
import FileCtrl from '../controllers/FileController'
77
import LogsCtrl from '../controllers/LogsController'
88
import ServerAPI from '../controllers/ServerAPIController'
9+
import DoubleColorBallController from '../controllers/DoubleColorBallController'
910

1011
const _PROD_ = process.env.NODE_ENV === 'production'
1112

1213
const router = new Router();
1314

1415
router
16+
.post('/api/testInsert', DoubleColorBallController.batchInsert)
1517
.post('/api/login', AccountCtrl.login)
1618
.post('/api/logout', AccountCtrl.logout)
1719
.get('/view/:site', DemoCtrl.views)
1820
.post('/api/compose', DemoCtrl.compose)
21+
.get('/api/test/:id', DemoCtrl.test)
1922
.post('/platform/*', ServerAPI.KDJZ)
2023
.get('/api/log-api', LogsCtrl.apiPages)
2124
.get('/api/log-errors', LogsCtrl.errorsPages)

0 commit comments

Comments
 (0)