oms/backend/app/model/principalExternalApi.js

31 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 主体外部接口模型,对应 principal_external_apis 表
* @param {Egg.Application} app egg application
* @return {object} principalExternalApi model
*/
module.exports = app => {
const { BIGINT, STRING, TINYINT, JSON, DATE } = app.Sequelize;
const PrincipalExternalApi = app.model.define('principal_external_api', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID' },
code: { type: STRING(50), allowNull: false, comment: '外部系统标识,如 wms / erp' },
name: { type: STRING(100), allowNull: false, comment: '接口名称' },
base_url: { type: STRING(255), comment: '接口基础地址' },
app_key: { type: STRING(100), comment: '应用Key' },
app_secret: { type: STRING(255), comment: '应用密钥' },
extra: { type: JSON, comment: '扩展配置' },
status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
});
PrincipalExternalApi.associate = () => {
app.model.PrincipalExternalApi.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' });
};
return PrincipalExternalApi;
};