lin-cms-test
Version:
The core library of Lin CMS, this package is just for test!
168 lines (167 loc) • 4.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const sequelize_1 = tslib_1.__importDefault(require("sequelize"));
const lodash_1 = require("lodash");
const enums_1 = require("./enums");
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
const passwordHash_1 = require("./passwordHash");
exports.InfoCrudMixin = {
attributes: {
delete_time: sequelize_1.default.DATE
},
options: {
createdAt: "create_time",
updatedAt: "update_time",
getterMethods: {
createTime() {
// @ts-ignore
return dayjs_1.default(this.getDataValue("create_time")).unix();
}
}
}
};
exports.UserInterface = {
attributes: lodash_1.merge({
id: {
type: sequelize_1.default.INTEGER,
primaryKey: true,
autoIncrement: true
},
nickname: {
type: sequelize_1.default.STRING({ length: 24 }),
allowNull: false,
unique: true
},
admin: {
type: sequelize_1.default.TINYINT,
allowNull: false,
defaultValue: 1
},
active: {
type: sequelize_1.default.TINYINT,
allowNull: false,
defaultValue: 1
},
email: {
type: sequelize_1.default.STRING({ length: 100 }),
unique: true,
allowNull: true
},
group_id: {
type: sequelize_1.default.INTEGER,
allowNull: true
},
password: {
type: sequelize_1.default.STRING({ length: 100 }),
set(ps) {
// @ts-ignore
this.setDataValue("password", passwordHash_1.generate(ps));
},
get() {
// @ts-ignore
return this.getDataValue("password");
}
}
}, exports.InfoCrudMixin.attributes),
options: lodash_1.merge({
tableName: "lin_user",
getterMethods: {
isAdmin() {
// @ts-ignore
return this.getDataValue("admin") === enums_1.UserAdmin.ADMIN;
},
isActive() {
// @ts-ignore
return this.getDataValue("active") === enums_1.UserActive.ACTIVE;
}
}
}, exports.InfoCrudMixin.options)
};
exports.AuthInterface = {
attributes: {
id: {
type: sequelize_1.default.INTEGER,
primaryKey: true,
autoIncrement: true
},
group_id: {
type: sequelize_1.default.INTEGER,
allowNull: true
},
auth: {
type: sequelize_1.default.STRING({ length: 60 })
},
module: {
type: sequelize_1.default.STRING({ length: 50 })
}
},
options: {
tableName: "lin_auth",
createdAt: false,
updatedAt: false
}
};
exports.GroupInterface = {
attributes: {
id: {
type: sequelize_1.default.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: sequelize_1.default.STRING({ length: 60 })
},
info: {
type: sequelize_1.default.STRING({ length: 255 }),
allowNull: true
}
},
options: {
tableName: "lin_group",
createdAt: false,
updatedAt: false
}
};
exports.LogInterface = {
attributes: {
id: {
type: sequelize_1.default.INTEGER,
primaryKey: true,
autoIncrement: true
},
message: {
type: sequelize_1.default.STRING({ length: 450 })
},
user_id: {
type: sequelize_1.default.INTEGER,
allowNull: false
},
user_name: {
type: sequelize_1.default.STRING(20)
},
status_code: {
type: sequelize_1.default.INTEGER
},
method: {
type: sequelize_1.default.STRING(20)
},
path: {
type: sequelize_1.default.STRING(50)
},
authority: {
type: sequelize_1.default.STRING(100)
}
},
options: {
tableName: "lin_log",
createdAt: "time",
updatedAt: false,
getterMethods: {
time() {
// @ts-ignore
return dayjs_1.default(this.getDataValue("time")).unix();
}
}
}
};