feat: 新增客户管理全模块功能
实现客户信息、客户部门、客户账号三个子模块的完整CRUD,包含: 1. 数据库实体、DTO、控制器、服务层代码 2. RBAC权限映射与菜单种子数据扩展 3. 前端路由与API封装 4. 数据权限隔离与鉴权逻辑 5. 配套工具脚本与测试验证清单
This commit is contained in:
1 parent
026ec34471
commit
1c80a24d1d
31 files changed
+26321
-653
No files matched your search
@@ -0,0 +1,126 @@
|
||||
import { Column, Model, Table, DataType, CreatedAt, UpdatedAt, HasMany } from "sequelize-typescript";
|
||||
import CustomerDepartment from "./customer_department.entity";
|
||||
import CustomerAccount from "./customer_account.entity";
|
||||
|
||||
@Table({
|
||||
tableName: "customer",
|
||||
comment: "客户信息表",
|
||||
timestamps: true,
|
||||
createdAt: "created_at",
|
||||
updatedAt: "updated_at",
|
||||
indexes: [
|
||||
{ name: "idx_customer_name", fields: ["customer_name"] },
|
||||
{ name: "idx_customer_salesman", fields: ["salesman_id"] },
|
||||
{ name: "idx_customer_status", fields: ["status"] },
|
||||
{ unique: true, name: "uk_customer_no", fields: ["customer_no"] }
|
||||
]
|
||||
})
|
||||
export default class Customer extends Model {
|
||||
@Column({
|
||||
type: DataType.BIGINT,
|
||||
autoIncrement: true,
|
||||
primaryKey: true
|
||||
})
|
||||
id!: number;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(64),
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
field: "customer_no",
|
||||
comment: "客户业务编号(KH+YYYYMMDD+序号)"
|
||||
})
|
||||
customerNo!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(128),
|
||||
allowNull: false,
|
||||
comment: "客户名称"
|
||||
})
|
||||
customerName!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(32),
|
||||
comment: "省"
|
||||
})
|
||||
province!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(32),
|
||||
comment: "市"
|
||||
})
|
||||
city!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(32),
|
||||
comment: "区"
|
||||
})
|
||||
district!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(256),
|
||||
comment: "详细地址"
|
||||
})
|
||||
address!: 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(10),
|
||||
field: "postal_code",
|
||||
comment: "邮编"
|
||||
})
|
||||
postalCode!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(32),
|
||||
comment: "传真"
|
||||
})
|
||||
fax!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(32),
|
||||
field: "customer_level",
|
||||
comment: "客户级别(学校/医院/企业等)"
|
||||
})
|
||||
customerLevel!: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.SMALLINT,
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
comment: "状态:1意向/2签约/3运维中/4终止"
|
||||
})
|
||||
status!: number;
|
||||
|
||||
@Column({
|
||||
type: DataType.BIGINT,
|
||||
field: "salesman_id",
|
||||
comment: "负责业务员(关联sys_user.id),references->sys_user.id"
|
||||
})
|
||||
salesmanId!: number;
|
||||
|
||||
@HasMany(() => CustomerDepartment, { foreignKey: "customerId" })
|
||||
customerDepartments!: CustomerDepartment[];
|
||||
|
||||
@HasMany(() => CustomerAccount, { foreignKey: "customerId" })
|
||||
customerAccounts!: CustomerAccount[];
|
||||
|
||||
@CreatedAt
|
||||
created_at!: Date;
|
||||
|
||||
@UpdatedAt
|
||||
updated_at!: Date;
|
||||
}
|
||||
Reference in new issue
Block a user