39 lines
684 B
JavaScript
39 lines
684 B
JavaScript
class ResultModel {
|
|
constructor(data, message) {
|
|
if (typeof data === "string") {
|
|
this.message = data;
|
|
data = null;
|
|
message = null;
|
|
}
|
|
if (data) {
|
|
this.data = data;
|
|
}
|
|
|
|
if (message) {
|
|
this.message = message;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 成功模型
|
|
class SuccessResult extends ResultModel {
|
|
constructor(data, message) {
|
|
super(data, message);
|
|
this.errno = 0;
|
|
}
|
|
}
|
|
|
|
// 失败模型
|
|
class ErrorResult extends ResultModel {
|
|
constructor(data, message) {
|
|
super(data, message);
|
|
this.errno = -1;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
SuccessResult,
|
|
ErrorResult,
|
|
};
|
|
|
|
|