mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
build: trident-sync prepare
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Inject } from '@midwayjs/decorator';
|
||||
import { Context } from '@midwayjs/koa';
|
||||
import { Constants } from './constants';
|
||||
|
||||
export abstract class BaseController {
|
||||
@Inject()
|
||||
ctx: Context;
|
||||
|
||||
/**
|
||||
* 成功返回
|
||||
* @param data 返回数据
|
||||
*/
|
||||
ok(data) {
|
||||
const res = {
|
||||
...Constants.res.success,
|
||||
data: undefined,
|
||||
};
|
||||
if (data) {
|
||||
res.data = data;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* 失败返回
|
||||
* @param message
|
||||
*/
|
||||
fail(msg, code) {
|
||||
return {
|
||||
code: code ? code : Constants.res.error.code,
|
||||
msg: msg ? msg : Constants.res.error.code,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user