实现客户信息、客户部门、客户账号三个子模块的完整CRUD,包含: 1. 数据库实体、DTO、控制器、服务层代码 2. RBAC权限映射与菜单种子数据扩展 3. 前端路由与API封装 4. 数据权限隔离与鉴权逻辑 5. 配套工具脚本与测试验证清单
69 lines
1.3 KiB
TypeScript
69 lines
1.3 KiB
TypeScript
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;
|
|
}
|