import { Column, Model, Table, DataType, CreatedAt, UpdatedAt, BelongsTo, ForeignKey } from "sequelize-typescript"; import Customer from "./customer.entity"; @Table({ tableName: "customer_department", comment: "客户部门表", timestamps: true, createdAt: "created_at", updatedAt: "updated_at", indexes: [ { name: "idx_dept_customer", fields: ["customer_id"] } ] }) export default class CustomerDepartment extends Model { @Column({ type: DataType.BIGINT, autoIncrement: true, primaryKey: true }) id!: number; @ForeignKey(() => Customer) @Column({ type: DataType.BIGINT, allowNull: false, field: "customer_id", comment: "所属客户ID" }) customerId!: number; @Column({ type: DataType.STRING(64), allowNull: false, field: "dept_name", comment: "部门名称" }) deptName!: string; @Column({ type: DataType.STRING(32), field: "contact_person", comment: "联系人" }) contactPerson!: string; @Column({ type: DataType.STRING(20), field: "contact_phone", comment: "联系电话" }) contactPhone!: string; @Column({ type: DataType.STRING(256), field: "function_desc", comment: "职能描述" }) functionDesc!: string; @BelongsTo(() => Customer) customer!: Customer; @CreatedAt created_at!: Date; @UpdatedAt updated_at!: Date; }