更新各项内容
This commit is contained in:
@@ -10,8 +10,8 @@ type ErpCompanyContact struct {
|
||||
CompanyID uint64 `orm:"column(company_id)" json:"company_id"`
|
||||
Name string `orm:"column(name);size(50)" json:"name"`
|
||||
Gender int8 `orm:"column(gender);default(0)" json:"gender"` // 0-未知 1-男 2-女
|
||||
Phone string `orm:"column(phone);size(20)" json:"phone"`
|
||||
Mobiles string `orm:"column(mobiles);type(text);null" json:"mobiles"` // JSON数组,最多5个
|
||||
Phone string `orm:"column(phone);size(20)" json:"phone"` // 座机(与 ERP 联系人语义一致)
|
||||
Mobiles string `orm:"column(mobiles);type(text);null" json:"mobiles"` // 手机号,JSON数组,最多5个
|
||||
Wechat string `orm:"column(wechat);size(50)" json:"wechat"`
|
||||
QQ string `orm:"column(qq);size(50)" json:"qq"`
|
||||
Dingtalk string `orm:"column(dingtalk);size(50)" json:"dingtalk"`
|
||||
|
||||
@@ -132,4 +132,50 @@ func Init(_ string) {
|
||||
EnsureAdminRoleTenantColumn()
|
||||
EnsureAdminRoleCustomColumn()
|
||||
EnsureTenantUserOrgColumn()
|
||||
EnsureCrmCustomerPoolColumns()
|
||||
EnsureCrmCreateUserColumn()
|
||||
}
|
||||
|
||||
|
||||
// EnsureCrmCreateUserColumn 补齐客户/供应商的创建人字段(用于删除权限校验)。
|
||||
// 同样兼容历史表名差异,表不存在或列已存在时忽略错误。
|
||||
func EnsureCrmCreateUserColumn() {
|
||||
tables := []string{
|
||||
new(TenantCrmCustomer).TableName(), "yz_tenant_crm_customer",
|
||||
new(TenantCrmSupplier).TableName(), "yz_tenant_crm_supplier",
|
||||
}
|
||||
for _, table := range tables {
|
||||
sql := "ALTER TABLE " + table +
|
||||
" ADD COLUMN create_user_id varchar(64) NOT NULL DEFAULT '' COMMENT '创建人用户ID,用于删除权限校验'"
|
||||
if _, err := Orm.Raw(sql).Exec(); err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EnsureCrmCustomerPoolColumns 补齐客户公海相关字段。
|
||||
// 兼容历史表名差异:模型 TableName 为 yz_backend_erp_customer,初始化 SQL 中为 yz_tenant_crm_customer,
|
||||
// 对两个候选表名都执行 ALTER(表不存在或列已存在时忽略错误)。
|
||||
func EnsureCrmCustomerPoolColumns() {
|
||||
candidates := []string{
|
||||
new(TenantCrmCustomer).TableName(),
|
||||
"yz_tenant_crm_customer",
|
||||
}
|
||||
cols := []string{
|
||||
"in_pool tinyint NOT NULL DEFAULT 0 COMMENT '是否在公海:0-否 1-是'",
|
||||
"owner_user_id varchar(64) NOT NULL DEFAULT '' COMMENT '负责人ID,公海中为空'",
|
||||
"owner_user_name varchar(128) NOT NULL DEFAULT '' COMMENT '负责人姓名'",
|
||||
"last_owner_name varchar(128) NOT NULL DEFAULT '' COMMENT '移入公海前的原负责人'",
|
||||
"pool_in_time datetime DEFAULT NULL COMMENT '进入公海时间'",
|
||||
"pool_reason varchar(200) NOT NULL DEFAULT '' COMMENT '移入公海原因'",
|
||||
}
|
||||
for _, table := range candidates {
|
||||
for _, col := range cols {
|
||||
sql := fmt.Sprintf("ALTER TABLE %s ADD COLUMN %s", table, col)
|
||||
if _, err := Orm.Raw(sql).Exec(); err != nil {
|
||||
// 列已存在或表不存在时忽略
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,14 @@ type TenantCrmCustomer struct {
|
||||
BankAccount string `orm:"column(bank_account);size(50)" json:"bank_account"`
|
||||
RegisteredAddress string `orm:"column(registered_address);size(255)" json:"registered_address"`
|
||||
RegisteredPhone string `orm:"column(registered_phone);size(50)" json:"registered_phone"`
|
||||
// 公海相关:in_pool=1 表示客户在公海中(租户共享,无个人负责人)
|
||||
InPool int8 `orm:"column(in_pool);default(0)" json:"in_pool"` // 是否在公海:0-否 1-是
|
||||
OwnerUserID string `orm:"column(owner_user_id);size(64);null" json:"owner_user_id"` // 当前负责人ID,公海中为空
|
||||
OwnerUserName string `orm:"column(owner_user_name);size(128);null" json:"owner_user_name"` // 当前负责人姓名
|
||||
LastOwnerName string `orm:"column(last_owner_name);size(128);null" json:"last_owner_name"` // 移入公海前的原负责人
|
||||
PoolInTime *time.Time `orm:"column(pool_in_time);type(datetime);null" json:"pool_in_time"` // 进入公海时间
|
||||
PoolReason string `orm:"column(pool_reason);size(200);null" json:"pool_reason"` // 移入公海原因
|
||||
CreateUserID string `orm:"column(create_user_id);size(64);null" json:"create_user_id"` // 创建人用户ID,用于删除权限校验
|
||||
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
|
||||
@@ -32,6 +32,7 @@ type TenantCrmSupplier struct {
|
||||
BankAccount string `orm:"column(bank_account);size(50)" json:"bank_account"`
|
||||
RegisteredAddress string `orm:"column(registered_address);size(255)" json:"registered_address"`
|
||||
RegisteredPhone string `orm:"column(registered_phone);size(50)" json:"registered_phone"`
|
||||
CreateUserID string `orm:"column(create_user_id);size(64);null" json:"create_user_id"` // 创建人用户ID,用于删除权限校验
|
||||
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
|
||||
Reference in New Issue
Block a user