This commit is contained in:
robin
2022-05-21 06:48:12 +08:00
parent b5f918776e
commit 96333ae7a9
45 changed files with 650 additions and 64 deletions
@@ -7,4 +7,8 @@ module.exports = {
"event2": (args) => {
console.log(args || 'event2')
},
//status定义的有限状态机
"start.ling": (args) => {
console.log(args || 'event2')
},
}
+13
View File
@@ -0,0 +1,13 @@
'use strict';
const Smf = require('bamboo_smf');
const smf = new Smf()
// 测试状态
smf.init('test', 'start')
.push('start', 'start.ling')
.push('ling', 'start.end')
.push('end')
module.exports = smf.getSmfData()
@@ -2,14 +2,14 @@
module.exports = {
doc : "默认页面",
path : "/",
path : "cms/index/",
method : ["get", "post"],
middleware: [],
params : {
"age": "int?"
},
return : {},
controller: async (ctx, app) => {
fun: async (ctx, app) => {
console.log(ctx.request.body);
// app.err.ParameterException()
// app.event.emit('test.event2')
@@ -59,6 +59,7 @@ module.exports = {
// }, "save": ""
// },
{
"as": "user_info",
"table" : "UserInfo",
"where" : {
"uid": "$as.user_data.id",//根据别名 user_data 返回的结果中的id值作为条件查询
View File
+1 -1
View File
@@ -1,8 +1,8 @@
module.exports = {
doc : "用户",
api : true,//是否需要生成api接口
model: {
uid: {type: "STRING", comment: '用户id'},
age: {type: "INTEGER", comment: '年龄', defaultValue: 0,},
}
}
-53
View File
@@ -1,53 +0,0 @@
class HttpException extends Error {
// message为异常信息,code 为错误码(开发人员内部约定),status 为HTTP状态码
constructor(message, code, status) {
super()
this.status = status || 500
this.code = code || 500
this.message = message || '服务器异常'
}
}
class ParameterException extends HttpException {
constructor(message, code, status) {
super()
this.status = status || 402
this.code = code
this.message = message || '参数错误'
}
}
class NotFound extends HttpException {
constructor(message, code, status) {
super()
this.status = status || 404
this.code = 404
this.message = message || '资源未找到'
}
}
class AuthFailed extends HttpException {
constructor(message, code, status) {
super()
this.status = status || 401
this.message = message || '授权失败'
this.code = 401
}
}
class Forbidden extends HttpException {
constructor(message, code, status) {
super()
this.status = status || 403
this.message = message || '禁止访问'
this.code = 403
}
}
module.exports = {
HttpException,
ParameterException,
NotFound,
AuthFailed,
Forbidden,
}
-4
View File
@@ -1,4 +0,0 @@
'use strict';
const bodyParser = require('koa-bodyparser')
// 错误处理
module.exports = bodyParser()
-12
View File
@@ -1,12 +0,0 @@
'use strict';
const error = require('koa-json-error')
// 错误处理
module.exports = error((err) => {
return {
status : err.status,
message : err.message,
code : err.code,
res : false,
// postFormat: (e, obj) => process.env.NODE_ENV === 'production' ? _.omit(obj, 'stack') : obj
}
})
-3
View File
@@ -1,3 +0,0 @@
'use strict';
const logger = require('koa-logger')
module.exports = logger()
-10
View File
@@ -1,10 +0,0 @@
'use strict';
/*响应时间*/
module.exports = async (ctx, next, app) => {
// console.log(ctx, next, options);
// const timetaken = `${ctx.request.method}${ctx.request.url} 响应时间`
// console.time(timetaken)
// app.logger.debug("123")
await next()
// console.timeEnd(timetaken)
}
View File
View File
View File
-9
View File
@@ -1,9 +0,0 @@
'use strict';
// 监听事件
module.exports = {
time : "*/3 * * * * *",
run : true,//系统启动时立即执行一次
schedule: (app) => {
// console.log('每3秒我执行一次' + app.utils.VERSION)
}
}
Binary file not shown.
-8
View File
@@ -1,8 +0,0 @@
module.exports = {
doc : "mysql模型文件的m5记录",
model: {
fileName: {type: "STRING", comment: '文件名称'},
md5 : {type: "TEXT", comment: 'md5记录'},
md5json : {type: "JSON", comment: 'md5记录'},
}
}