'use strict'; /** * 商品品牌模型,对应 product_brands 表(按主体隔离) * 供商品选择品牌:落 brand_id(本表主键)+ brand_name(名称文本,冗余存储)。 * @param {Egg.Application} app egg application * @return {object} productBrand model */ module.exports = app => { const { BIGINT, STRING, TINYINT, INTEGER, DATE } = app.Sequelize; const ProductBrand = app.model.define('product_brand', { 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: '品牌名称' }, code: { type: STRING(50), comment: '品牌编码' }, status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' }, sort: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '排序(下拉展示顺序,越小越靠前)' }, remark: { type: STRING(255), comment: '备注' }, is_system: { type: TINYINT, allowNull: false, defaultValue: 0, comment: '是否系统默认:1系统数据(不可改/删,全部主体可见) 0自定义(按主体隔离)' }, created_at: { type: DATE, comment: '创建时间' }, updated_at: { type: DATE, comment: '更新时间' }, }, { tableName: 'product_brands', comment: '商品品牌', }); ProductBrand.associate = () => { app.model.ProductBrand.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' }); }; return ProductBrand; };