'use strict'; /** * 下属公司模型,对应 principal_subsidiaries 表(按主体隔离)。 * * 组织架构 → 下属公司:登记集团(当前主体)下属的公司档案, * 仅用于档案维护,不参与商品/订单等业务数据归属。 * @param {Egg.Application} app egg application * @return {object} principalSubsidiary model */ module.exports = app => { const { BIGINT, STRING, TINYINT, DATE } = app.Sequelize; const PrincipalSubsidiary = app.model.define('principal_subsidiary', { id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' }, principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体(集团)ID' }, name: { type: STRING(100), allowNull: false, comment: '公司名称' }, credit_code: { type: STRING(50), comment: '统一社会信用代码' }, contact_name: { type: STRING(50), comment: '联系人' }, contact_phone: { type: STRING(20), comment: '联系电话' }, address: { type: STRING(255), comment: '公司地址' }, status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' }, remark: { type: STRING(255), comment: '备注' }, created_at: { type: DATE, comment: '创建时间' }, updated_at: { type: DATE, comment: '更新时间' }, }, { tableName: 'principal_subsidiaries', comment: '下属公司', }); PrincipalSubsidiary.associate = () => { app.model.PrincipalSubsidiary.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' }); }; return PrincipalSubsidiary; };