'use strict'; module.exports = app => { const { STRING, INTEGER, BIGINT, TINYINT, DATE } = app.Sequelize; const AfterSaleKeyword = app.model.define('afterSaleKeyword', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: true, defaultValue: null, comment: '仓库ID(NULL=系统级,全部仓库可见;非NULL=该仓库自定义,仅该仓库可见)', }, sub_type_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '售后子类型ID(关联 wms_after_sale_sub_type.id)', }, keyword: { type: STRING(100), allowNull: false, comment: '关键词,命中即映射到对应售后子类型', }, is_system: { type: TINYINT(1), allowNull: false, defaultValue: 0, comment: '是否系统级:1=系统级(全部仓库可读,不允许编辑/删除),0=仓库自定义', }, is_enabled: { type: TINYINT(1), allowNull: false, defaultValue: 1, comment: '是否启用:1=启用,0=停用', }, sort_order: { type: INTEGER(11), allowNull: false, defaultValue: 0, comment: '匹配优先级,数值小者优先(同长度命中时生效)', }, created_at: { type: DATE, comment: '创建时间', }, updated_at: { type: DATE, comment: '更新时间', }, }, { tableName: 'wms_after_sale_keyword', underscored: true, timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', paranoid: false, comment: '售后关键词表(关键词 → 售后子类型映射)', indexes: [ { unique: true, fields: [ 'keyword', 'warehouse_id' ], name: 'uk_keyword_warehouse', }, { fields: [ 'sub_type_id' ], name: 'idx_sub_type_id', }, { fields: [ 'warehouse_id' ], name: 'idx_warehouse_id', }, ], }); return AfterSaleKeyword; };