优化架构,新增路由
This commit is contained in:
+13
-9
@@ -1,16 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
doc : "默认页面",
|
||||
path : "cms/index/",
|
||||
method : ["get", "post"],
|
||||
middleware: [],
|
||||
params : {
|
||||
// path : "cms/api/index",//可以覆盖自动生成的路由地址
|
||||
params: {
|
||||
"age": "int?"
|
||||
},
|
||||
return : {},
|
||||
fun : async (ctx, app) => {
|
||||
const User = await app.table("User").where(where).findAll()
|
||||
ctx.body = {res}
|
||||
fun : async (ctx, app) => {
|
||||
|
||||
const body = ctx.params
|
||||
const User = await app.db.table("User").find()
|
||||
//成功返回的2种方式
|
||||
// ctx.body = app.res.success(User,"success",200)//"success",200可以省略
|
||||
return User
|
||||
|
||||
//异常返回的2种方式
|
||||
// ctx.body = app.res.error(User, "error", 400)//"error",400可以省略
|
||||
// return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// 定时任务
|
||||
module.exports = {
|
||||
time: {
|
||||
cron: '0/5 * * * * ?',
|
||||
cron: '0/2 * * * * ?',
|
||||
// every: 2000,
|
||||
// limit: 100,
|
||||
},
|
||||
fun: (app) => {
|
||||
console.log("test",new Date());
|
||||
// console.log("test",new Date());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// 定时任务
|
||||
module.exports = {
|
||||
time: {
|
||||
cron: '0/5 * * * * ?',
|
||||
cron: '0/2 * * * * ?',
|
||||
// every: 2000,
|
||||
// limit: 100,
|
||||
},
|
||||
fun: (app) => {
|
||||
console.log("test2",new Date());
|
||||
// console.log("test2",new Date());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user