Skip to content

Commit

Permalink
little tuning.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoutk committed Mar 22, 2019
1 parent 7702e4c commit ad3dbf5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default {
//支持 X-Forwarded-Host
app.proxy = true
const middlewares = [
'cors',
'logger', //记录所用方式与时间
'session',
'globalError', // 全局错误处理
'conditional', //配合etag
'etag', //etag 客户端缓存处理
'cors',
'bodyParser', //body解析
'rewrite', //url重写
'static',
Expand Down
8 changes: 6 additions & 2 deletions src/inits/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ enum STCODES {
SUCCESS = 200, //操作成功
QUERYEMPTY = 202, //查无结果
PRAMAERR = 301, //输入参数错误
NOTFOUND = 404,
JWTAUTHERR = 400,
NOTFOUND = 404, //获取资源不存在
JWTAUTHERR = 400, //授权错误或失效
PASSWORDERR = 411, //密码错误
USERNAMEERR = 412, //用户名错误或不存在
AUTHORIZATIONLESS = 413, //权限不够
USERNOTFOUND = 414, //用户不存在
EXCEPTION = 500, //发生异常
DATABASECOERR = 701, //数据库连接失败
DATABASEOPERR = 702, //数据库操作失败
Expand Down
51 changes: 0 additions & 51 deletions src/routers/router_op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,57 +25,6 @@ export default (() => {
ctx.body = G.jsResponse(G.STCODES.QUERYEMPTY, 'The user is missing.')
}
break
case 'batch':
return ctx.body = await new BaseDao().insertBatch('users', ctx.request.body)
case 'trans':
let trs = [
{
table: 'users',
method: 'Insert',
params: {
username: 'zhou1',
password: '1',
age: 1
}
},
{
table: 'users',
method: 'Insert',
params: {
username: 'zhou2',
password: '2',
age: 2
}
},
{
table: 'users',
method: 'Insert',
params: {
username: 'zhou3',
password: '3',
age: 3
}
},
{
table: 'users',
method: 'Insert',
params: {
username: 'zhou4',
password: '4',
age: 4
}
},
{
table: 'users',
method: 'Insert',
params: {
username: 'zhou5',
password: '5',
age: 5
}
}
]
return ctx.body = await new BaseDao().transGo(trs, true)
default:
ctx.body = G.jsResponse(G.STCODES.NOTFOUND, 'command is not found.')
break
Expand Down

0 comments on commit ad3dbf5

Please sign in to comment.