WMS_MAIN/app/model/qimen_app.js

87 lines
1.8 KiB
JavaScript

'use strict';
/**
* 定义奇门应用配置模型。
* @param {import('egg').Application} app Egg 应用实例
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} 奇门应用配置模型
*/
module.exports = app => {
const { INTEGER, STRING, DATE } = app.Sequelize;
const QimenApp = app.model.define('qimen_app', {
id: {
type: INTEGER(11),
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '应用ID',
},
name: {
type: STRING(100),
allowNull: true,
validate: {
len: [ 0, 100 ],
},
comment: '应用名称',
},
app_key: {
type: STRING(50),
allowNull: true,
unique: 'uk_app_key',
validate: {
len: [ 0, 50 ],
},
comment: '应用密钥',
},
customer_id: {
type: STRING(100),
allowNull: true,
validate: {
len: [ 0, 100 ],
},
comment: '客户标识',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
}, {
tableName: 'wms_qimen_apps',
freezeTableName: true,
underscored: true,
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
comment: '奇门应用配置表',
indexes: [
{
name: 'uk_app_key',
unique: true,
fields: [ 'app_key' ],
},
{
name: 'idx_name',
fields: [ 'name' ],
},
],
});
/**
* 输出模型的 JSON 数据。
* @return {object} 当前实例的普通对象数据
*/
QimenApp.prototype.toJSON = function() {
const values = { ...this.get() };
return values;
};
return QimenApp;
};