Browse Source

在中间件中插入部门上下文

boweniac 8 months ago
parent
commit
f44a609e86

+ 5 - 5
ent/contact/contact.go

@@ -58,19 +58,19 @@ const (
 	// EdgeContactMessages holds the string denoting the contact_messages edge name in mutations.
 	EdgeContactMessages = "contact_messages"
 	// Table holds the table name of the contact in the database.
-	Table = "contacts"
+	Table = "contact"
 	// ContactRelationshipsTable is the table that holds the contact_relationships relation/edge.
-	ContactRelationshipsTable = "label_relationships"
+	ContactRelationshipsTable = "label_relationship"
 	// ContactRelationshipsInverseTable is the table name for the LabelRelationship entity.
 	// It exists in this package in order to avoid circular dependency with the "labelrelationship" package.
-	ContactRelationshipsInverseTable = "label_relationships"
+	ContactRelationshipsInverseTable = "label_relationship"
 	// ContactRelationshipsColumn is the table column denoting the contact_relationships relation/edge.
 	ContactRelationshipsColumn = "contact_id"
 	// ContactMessagesTable is the table that holds the contact_messages relation/edge.
-	ContactMessagesTable = "message_recordss"
+	ContactMessagesTable = "message_records"
 	// ContactMessagesInverseTable is the table name for the MessageRecords entity.
 	// It exists in this package in order to avoid circular dependency with the "messagerecords" package.
-	ContactMessagesInverseTable = "message_recordss"
+	ContactMessagesInverseTable = "message_records"
 	// ContactMessagesColumn is the table column denoting the contact_messages relation/edge.
 	ContactMessagesColumn = "contact_id"
 )

+ 3 - 3
ent/label/label.go

@@ -36,12 +36,12 @@ const (
 	// EdgeLabelRelationships holds the string denoting the label_relationships edge name in mutations.
 	EdgeLabelRelationships = "label_relationships"
 	// Table holds the table name of the label in the database.
-	Table = "labels"
+	Table = "label"
 	// LabelRelationshipsTable is the table that holds the label_relationships relation/edge.
-	LabelRelationshipsTable = "label_relationships"
+	LabelRelationshipsTable = "label_relationship"
 	// LabelRelationshipsInverseTable is the table name for the LabelRelationship entity.
 	// It exists in this package in order to avoid circular dependency with the "labelrelationship" package.
-	LabelRelationshipsInverseTable = "label_relationships"
+	LabelRelationshipsInverseTable = "label_relationship"
 	// LabelRelationshipsColumn is the table column denoting the label_relationships relation/edge.
 	LabelRelationshipsColumn = "label_id"
 )

+ 5 - 5
ent/labelrelationship/labelrelationship.go

@@ -32,19 +32,19 @@ const (
 	// EdgeLabels holds the string denoting the labels edge name in mutations.
 	EdgeLabels = "labels"
 	// Table holds the table name of the labelrelationship in the database.
-	Table = "label_relationships"
+	Table = "label_relationship"
 	// ContactsTable is the table that holds the contacts relation/edge.
-	ContactsTable = "label_relationships"
+	ContactsTable = "label_relationship"
 	// ContactsInverseTable is the table name for the Contact entity.
 	// It exists in this package in order to avoid circular dependency with the "contact" package.
-	ContactsInverseTable = "contacts"
+	ContactsInverseTable = "contact"
 	// ContactsColumn is the table column denoting the contacts relation/edge.
 	ContactsColumn = "contact_id"
 	// LabelsTable is the table that holds the labels relation/edge.
-	LabelsTable = "label_relationships"
+	LabelsTable = "label_relationship"
 	// LabelsInverseTable is the table name for the Label entity.
 	// It exists in this package in order to avoid circular dependency with the "label" package.
-	LabelsInverseTable = "labels"
+	LabelsInverseTable = "label"
 	// LabelsColumn is the table column denoting the labels relation/edge.
 	LabelsColumn = "label_id"
 )

+ 7 - 7
ent/messagerecords/messagerecords.go

@@ -54,26 +54,26 @@ const (
 	// EdgeMessageContact holds the string denoting the message_contact edge name in mutations.
 	EdgeMessageContact = "message_contact"
 	// Table holds the table name of the messagerecords in the database.
-	Table = "message_recordss"
+	Table = "message_records"
 	// SopStageTable is the table that holds the sop_stage relation/edge.
-	SopStageTable = "message_recordss"
+	SopStageTable = "message_records"
 	// SopStageInverseTable is the table name for the SopStage entity.
 	// It exists in this package in order to avoid circular dependency with the "sopstage" package.
-	SopStageInverseTable = "sop_stages"
+	SopStageInverseTable = "sop_stage"
 	// SopStageColumn is the table column denoting the sop_stage relation/edge.
 	SopStageColumn = "source_id"
 	// SopNodeTable is the table that holds the sop_node relation/edge.
-	SopNodeTable = "message_recordss"
+	SopNodeTable = "message_records"
 	// SopNodeInverseTable is the table name for the SopNode entity.
 	// It exists in this package in order to avoid circular dependency with the "sopnode" package.
-	SopNodeInverseTable = "sop_nodes"
+	SopNodeInverseTable = "sop_node"
 	// SopNodeColumn is the table column denoting the sop_node relation/edge.
 	SopNodeColumn = "sub_source_id"
 	// MessageContactTable is the table that holds the message_contact relation/edge.
-	MessageContactTable = "message_recordss"
+	MessageContactTable = "message_records"
 	// MessageContactInverseTable is the table name for the Contact entity.
 	// It exists in this package in order to avoid circular dependency with the "contact" package.
-	MessageContactInverseTable = "contacts"
+	MessageContactInverseTable = "contact"
 	// MessageContactColumn is the table column denoting the message_contact relation/edge.
 	MessageContactColumn = "contact_id"
 )

+ 141 - 141
ent/migrate/schema.go

@@ -39,8 +39,8 @@ var (
 			},
 		},
 	}
-	// ContactsColumns holds the columns for the "contacts" table.
-	ContactsColumns = []*schema.Column{
+	// ContactColumns holds the columns for the "contact" table.
+	ContactColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -62,36 +62,36 @@ var (
 		{Name: "gname", Type: field.TypeString, Comment: "群组名称", Default: ""},
 		{Name: "v3", Type: field.TypeString, Comment: "v3数据", Default: ""},
 	}
-	// ContactsTable holds the schema information for the "contacts" table.
-	ContactsTable = &schema.Table{
-		Name:       "contacts",
-		Columns:    ContactsColumns,
-		PrimaryKey: []*schema.Column{ContactsColumns[0]},
+	// ContactTable holds the schema information for the "contact" table.
+	ContactTable = &schema.Table{
+		Name:       "contact",
+		Columns:    ContactColumns,
+		PrimaryKey: []*schema.Column{ContactColumns[0]},
 		Indexes: []*schema.Index{
 			{
 				Name:    "contact_wx_wxid_wxid",
 				Unique:  true,
-				Columns: []*schema.Column{ContactsColumns[5], ContactsColumns[7]},
+				Columns: []*schema.Column{ContactColumns[5], ContactColumns[7]},
 			},
 			{
 				Name:    "contact_wxid",
 				Unique:  false,
-				Columns: []*schema.Column{ContactsColumns[7]},
+				Columns: []*schema.Column{ContactColumns[7]},
 			},
 			{
 				Name:    "contact_type",
 				Unique:  false,
-				Columns: []*schema.Column{ContactsColumns[6]},
+				Columns: []*schema.Column{ContactColumns[6]},
 			},
 			{
 				Name:    "contact_gid",
 				Unique:  false,
-				Columns: []*schema.Column{ContactsColumns[17]},
+				Columns: []*schema.Column{ContactColumns[17]},
 			},
 		},
 	}
-	// LabelsColumns holds the columns for the "labels" table.
-	LabelsColumns = []*schema.Column{
+	// LabelColumns holds the columns for the "label" table.
+	LabelColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -103,21 +103,21 @@ var (
 		{Name: "mode", Type: field.TypeInt, Comment: "标签模式:1动态 2静态", Default: 1},
 		{Name: "conditions", Type: field.TypeString, Nullable: true, Comment: "标签的触达条件", Default: ""},
 	}
-	// LabelsTable holds the schema information for the "labels" table.
-	LabelsTable = &schema.Table{
-		Name:       "labels",
-		Columns:    LabelsColumns,
-		PrimaryKey: []*schema.Column{LabelsColumns[0]},
+	// LabelTable holds the schema information for the "label" table.
+	LabelTable = &schema.Table{
+		Name:       "label",
+		Columns:    LabelColumns,
+		PrimaryKey: []*schema.Column{LabelColumns[0]},
 		Indexes: []*schema.Index{
 			{
 				Name:    "label_name_from_mode",
 				Unique:  true,
-				Columns: []*schema.Column{LabelsColumns[6], LabelsColumns[7], LabelsColumns[8]},
+				Columns: []*schema.Column{LabelColumns[6], LabelColumns[7], LabelColumns[8]},
 			},
 		},
 	}
-	// LabelRelationshipsColumns holds the columns for the "label_relationships" table.
-	LabelRelationshipsColumns = []*schema.Column{
+	// LabelRelationshipColumns holds the columns for the "label_relationship" table.
+	LabelRelationshipColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -126,22 +126,22 @@ var (
 		{Name: "contact_id", Type: field.TypeUint64, Comment: "联系人 ID", Default: 1},
 		{Name: "label_id", Type: field.TypeUint64, Comment: "标签 ID", Default: 1},
 	}
-	// LabelRelationshipsTable holds the schema information for the "label_relationships" table.
-	LabelRelationshipsTable = &schema.Table{
-		Name:       "label_relationships",
-		Columns:    LabelRelationshipsColumns,
-		PrimaryKey: []*schema.Column{LabelRelationshipsColumns[0]},
+	// LabelRelationshipTable holds the schema information for the "label_relationship" table.
+	LabelRelationshipTable = &schema.Table{
+		Name:       "label_relationship",
+		Columns:    LabelRelationshipColumns,
+		PrimaryKey: []*schema.Column{LabelRelationshipColumns[0]},
 		ForeignKeys: []*schema.ForeignKey{
 			{
-				Symbol:     "label_relationships_contacts_contact_relationships",
-				Columns:    []*schema.Column{LabelRelationshipsColumns[5]},
-				RefColumns: []*schema.Column{ContactsColumns[0]},
+				Symbol:     "label_relationship_contact_contact_relationships",
+				Columns:    []*schema.Column{LabelRelationshipColumns[5]},
+				RefColumns: []*schema.Column{ContactColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
 			{
-				Symbol:     "label_relationships_labels_label_relationships",
-				Columns:    []*schema.Column{LabelRelationshipsColumns[6]},
-				RefColumns: []*schema.Column{LabelsColumns[0]},
+				Symbol:     "label_relationship_label_label_relationships",
+				Columns:    []*schema.Column{LabelRelationshipColumns[6]},
+				RefColumns: []*schema.Column{LabelColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
 		},
@@ -149,12 +149,12 @@ var (
 			{
 				Name:    "labelrelationship_label_id",
 				Unique:  false,
-				Columns: []*schema.Column{LabelRelationshipsColumns[6]},
+				Columns: []*schema.Column{LabelRelationshipColumns[6]},
 			},
 			{
 				Name:    "labelrelationship_contact_id",
 				Unique:  false,
-				Columns: []*schema.Column{LabelRelationshipsColumns[5]},
+				Columns: []*schema.Column{LabelRelationshipColumns[5]},
 			},
 		},
 	}
@@ -171,8 +171,8 @@ var (
 		Columns:    MessagesColumns,
 		PrimaryKey: []*schema.Column{MessagesColumns[0]},
 	}
-	// MessageRecordssColumns holds the columns for the "message_recordss" table.
-	MessageRecordssColumns = []*schema.Column{
+	// MessageRecordsColumns holds the columns for the "message_records" table.
+	MessageRecordsColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -191,28 +191,28 @@ var (
 		{Name: "sub_source_id", Type: field.TypeUint64, Nullable: true, Comment: "次源 ID", Default: 1},
 		{Name: "source_id", Type: field.TypeUint64, Nullable: true, Comment: "源 ID", Default: 1},
 	}
-	// MessageRecordssTable holds the schema information for the "message_recordss" table.
-	MessageRecordssTable = &schema.Table{
-		Name:       "message_recordss",
-		Columns:    MessageRecordssColumns,
-		PrimaryKey: []*schema.Column{MessageRecordssColumns[0]},
+	// MessageRecordsTable holds the schema information for the "message_records" table.
+	MessageRecordsTable = &schema.Table{
+		Name:       "message_records",
+		Columns:    MessageRecordsColumns,
+		PrimaryKey: []*schema.Column{MessageRecordsColumns[0]},
 		ForeignKeys: []*schema.ForeignKey{
 			{
-				Symbol:     "message_recordss_contacts_contact_messages",
-				Columns:    []*schema.Column{MessageRecordssColumns[14]},
-				RefColumns: []*schema.Column{ContactsColumns[0]},
+				Symbol:     "message_records_contact_contact_messages",
+				Columns:    []*schema.Column{MessageRecordsColumns[14]},
+				RefColumns: []*schema.Column{ContactColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
 			{
-				Symbol:     "message_recordss_sop_nodes_node_messages",
-				Columns:    []*schema.Column{MessageRecordssColumns[15]},
-				RefColumns: []*schema.Column{SopNodesColumns[0]},
+				Symbol:     "message_records_sop_node_node_messages",
+				Columns:    []*schema.Column{MessageRecordsColumns[15]},
+				RefColumns: []*schema.Column{SopNodeColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
 			{
-				Symbol:     "message_recordss_sop_stages_stage_messages",
-				Columns:    []*schema.Column{MessageRecordssColumns[16]},
-				RefColumns: []*schema.Column{SopStagesColumns[0]},
+				Symbol:     "message_records_sop_stage_stage_messages",
+				Columns:    []*schema.Column{MessageRecordsColumns[16]},
+				RefColumns: []*schema.Column{SopStageColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
 		},
@@ -220,12 +220,12 @@ var (
 			{
 				Name:    "messagerecords_source_type",
 				Unique:  false,
-				Columns: []*schema.Column{MessageRecordssColumns[13]},
+				Columns: []*schema.Column{MessageRecordsColumns[13]},
 			},
 		},
 	}
-	// ServersColumns holds the columns for the "servers" table.
-	ServersColumns = []*schema.Column{
+	// ServerColumns holds the columns for the "server" table.
+	ServerColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -236,31 +236,31 @@ var (
 		{Name: "private_ip", Type: field.TypeString, Comment: "内网ip"},
 		{Name: "admin_port", Type: field.TypeString, Comment: "管理端口"},
 	}
-	// ServersTable holds the schema information for the "servers" table.
-	ServersTable = &schema.Table{
-		Name:       "servers",
-		Columns:    ServersColumns,
-		PrimaryKey: []*schema.Column{ServersColumns[0]},
+	// ServerTable holds the schema information for the "server" table.
+	ServerTable = &schema.Table{
+		Name:       "server",
+		Columns:    ServerColumns,
+		PrimaryKey: []*schema.Column{ServerColumns[0]},
 		Indexes: []*schema.Index{
 			{
 				Name:    "server_name",
 				Unique:  false,
-				Columns: []*schema.Column{ServersColumns[5]},
+				Columns: []*schema.Column{ServerColumns[5]},
 			},
 			{
 				Name:    "server_private_ip",
 				Unique:  false,
-				Columns: []*schema.Column{ServersColumns[7]},
+				Columns: []*schema.Column{ServerColumns[7]},
 			},
 			{
 				Name:    "server_public_ip",
 				Unique:  true,
-				Columns: []*schema.Column{ServersColumns[6]},
+				Columns: []*schema.Column{ServerColumns[6]},
 			},
 		},
 	}
-	// SopNodesColumns holds the columns for the "sop_nodes" table.
-	SopNodesColumns = []*schema.Column{
+	// SopNodeColumns holds the columns for the "sop_node" table.
+	SopNodeColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -275,16 +275,16 @@ var (
 		{Name: "action_label", Type: field.TypeJSON, Nullable: true, Comment: "命中后需要打的标签"},
 		{Name: "stage_id", Type: field.TypeUint64, Comment: "阶段 ID"},
 	}
-	// SopNodesTable holds the schema information for the "sop_nodes" table.
-	SopNodesTable = &schema.Table{
-		Name:       "sop_nodes",
-		Columns:    SopNodesColumns,
-		PrimaryKey: []*schema.Column{SopNodesColumns[0]},
+	// SopNodeTable holds the schema information for the "sop_node" table.
+	SopNodeTable = &schema.Table{
+		Name:       "sop_node",
+		Columns:    SopNodeColumns,
+		PrimaryKey: []*schema.Column{SopNodeColumns[0]},
 		ForeignKeys: []*schema.ForeignKey{
 			{
-				Symbol:     "sop_nodes_sop_stages_stage_nodes",
-				Columns:    []*schema.Column{SopNodesColumns[12]},
-				RefColumns: []*schema.Column{SopStagesColumns[0]},
+				Symbol:     "sop_node_sop_stage_stage_nodes",
+				Columns:    []*schema.Column{SopNodeColumns[12]},
+				RefColumns: []*schema.Column{SopStageColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
 		},
@@ -292,12 +292,12 @@ var (
 			{
 				Name:    "sopnode_name",
 				Unique:  false,
-				Columns: []*schema.Column{SopNodesColumns[6]},
+				Columns: []*schema.Column{SopNodeColumns[6]},
 			},
 		},
 	}
-	// SopStagesColumns holds the columns for the "sop_stages" table.
-	SopStagesColumns = []*schema.Column{
+	// SopStageColumns holds the columns for the "sop_stage" table.
+	SopStageColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -312,16 +312,16 @@ var (
 		{Name: "index_sort", Type: field.TypeInt, Nullable: true, Comment: "阶段顺序", Default: 1},
 		{Name: "task_id", Type: field.TypeUint64, Comment: "SOP 任务 ID"},
 	}
-	// SopStagesTable holds the schema information for the "sop_stages" table.
-	SopStagesTable = &schema.Table{
-		Name:       "sop_stages",
-		Columns:    SopStagesColumns,
-		PrimaryKey: []*schema.Column{SopStagesColumns[0]},
+	// SopStageTable holds the schema information for the "sop_stage" table.
+	SopStageTable = &schema.Table{
+		Name:       "sop_stage",
+		Columns:    SopStageColumns,
+		PrimaryKey: []*schema.Column{SopStageColumns[0]},
 		ForeignKeys: []*schema.ForeignKey{
 			{
-				Symbol:     "sop_stages_sop_tasks_task_stages",
-				Columns:    []*schema.Column{SopStagesColumns[12]},
-				RefColumns: []*schema.Column{SopTasksColumns[0]},
+				Symbol:     "sop_stage_sop_task_task_stages",
+				Columns:    []*schema.Column{SopStageColumns[12]},
+				RefColumns: []*schema.Column{SopTaskColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
 		},
@@ -329,12 +329,12 @@ var (
 			{
 				Name:    "sopstage_name",
 				Unique:  false,
-				Columns: []*schema.Column{SopStagesColumns[5]},
+				Columns: []*schema.Column{SopStageColumns[5]},
 			},
 		},
 	}
-	// SopTasksColumns holds the columns for the "sop_tasks" table.
-	SopTasksColumns = []*schema.Column{
+	// SopTaskColumns holds the columns for the "sop_task" table.
+	SopTaskColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -347,21 +347,21 @@ var (
 		{Name: "plan_end_time", Type: field.TypeTime, Nullable: true, Comment: "任务计划结束时间"},
 		{Name: "creator_id", Type: field.TypeString, Nullable: true, Comment: "创建者 id"},
 	}
-	// SopTasksTable holds the schema information for the "sop_tasks" table.
-	SopTasksTable = &schema.Table{
-		Name:       "sop_tasks",
-		Columns:    SopTasksColumns,
-		PrimaryKey: []*schema.Column{SopTasksColumns[0]},
+	// SopTaskTable holds the schema information for the "sop_task" table.
+	SopTaskTable = &schema.Table{
+		Name:       "sop_task",
+		Columns:    SopTaskColumns,
+		PrimaryKey: []*schema.Column{SopTaskColumns[0]},
 		Indexes: []*schema.Index{
 			{
 				Name:    "soptask_name",
 				Unique:  false,
-				Columns: []*schema.Column{SopTasksColumns[5]},
+				Columns: []*schema.Column{SopTaskColumns[5]},
 			},
 		},
 	}
-	// WxsColumns holds the columns for the "wxs" table.
-	WxsColumns = []*schema.Column{
+	// WxColumns holds the columns for the "wx" table.
+	WxColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
@@ -377,16 +377,16 @@ var (
 		{Name: "head_big", Type: field.TypeString, Comment: "微信头像", Default: ""},
 		{Name: "server_id", Type: field.TypeUint64, Nullable: true, Comment: "服务器id", Default: 0},
 	}
-	// WxsTable holds the schema information for the "wxs" table.
-	WxsTable = &schema.Table{
-		Name:       "wxs",
-		Columns:    WxsColumns,
-		PrimaryKey: []*schema.Column{WxsColumns[0]},
+	// WxTable holds the schema information for the "wx" table.
+	WxTable = &schema.Table{
+		Name:       "wx",
+		Columns:    WxColumns,
+		PrimaryKey: []*schema.Column{WxColumns[0]},
 		ForeignKeys: []*schema.ForeignKey{
 			{
-				Symbol:     "wxs_servers_wxs",
-				Columns:    []*schema.Column{WxsColumns[13]},
-				RefColumns: []*schema.Column{ServersColumns[0]},
+				Symbol:     "wx_server_wxs",
+				Columns:    []*schema.Column{WxColumns[13]},
+				RefColumns: []*schema.Column{ServerColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
 		},
@@ -394,43 +394,43 @@ var (
 			{
 				Name:    "wx_server_id_port",
 				Unique:  true,
-				Columns: []*schema.Column{WxsColumns[13], WxsColumns[5]},
+				Columns: []*schema.Column{WxColumns[13], WxColumns[5]},
 			},
 			{
 				Name:    "wx_wxid",
 				Unique:  true,
-				Columns: []*schema.Column{WxsColumns[8]},
+				Columns: []*schema.Column{WxColumns[8]},
 			},
 			{
 				Name:    "wx_account",
 				Unique:  false,
-				Columns: []*schema.Column{WxsColumns[9]},
+				Columns: []*schema.Column{WxColumns[9]},
 			},
 			{
 				Name:    "wx_nickname",
 				Unique:  false,
-				Columns: []*schema.Column{WxsColumns[10]},
+				Columns: []*schema.Column{WxColumns[10]},
 			},
 			{
 				Name:    "wx_tel",
 				Unique:  false,
-				Columns: []*schema.Column{WxsColumns[11]},
+				Columns: []*schema.Column{WxColumns[11]},
 			},
 		},
 	}
 	// Tables holds all the tables in the schema.
 	Tables = []*schema.Table{
 		BatchMsgTable,
-		ContactsTable,
-		LabelsTable,
-		LabelRelationshipsTable,
+		ContactTable,
+		LabelTable,
+		LabelRelationshipTable,
 		MessagesTable,
-		MessageRecordssTable,
-		ServersTable,
-		SopNodesTable,
-		SopStagesTable,
-		SopTasksTable,
-		WxsTable,
+		MessageRecordsTable,
+		ServerTable,
+		SopNodeTable,
+		SopStageTable,
+		SopTaskTable,
+		WxTable,
 	}
 )
 
@@ -438,42 +438,42 @@ func init() {
 	BatchMsgTable.Annotation = &entsql.Annotation{
 		Table: "batch_msg",
 	}
-	ContactsTable.Annotation = &entsql.Annotation{
-		Table: "contacts",
+	ContactTable.Annotation = &entsql.Annotation{
+		Table: "contact",
 	}
-	LabelsTable.Annotation = &entsql.Annotation{
-		Table: "labels",
+	LabelTable.Annotation = &entsql.Annotation{
+		Table: "label",
 	}
-	LabelRelationshipsTable.ForeignKeys[0].RefTable = ContactsTable
-	LabelRelationshipsTable.ForeignKeys[1].RefTable = LabelsTable
-	LabelRelationshipsTable.Annotation = &entsql.Annotation{
-		Table: "label_relationships",
+	LabelRelationshipTable.ForeignKeys[0].RefTable = ContactTable
+	LabelRelationshipTable.ForeignKeys[1].RefTable = LabelTable
+	LabelRelationshipTable.Annotation = &entsql.Annotation{
+		Table: "label_relationship",
 	}
 	MessagesTable.Annotation = &entsql.Annotation{
 		Table: "messages",
 	}
-	MessageRecordssTable.ForeignKeys[0].RefTable = ContactsTable
-	MessageRecordssTable.ForeignKeys[1].RefTable = SopNodesTable
-	MessageRecordssTable.ForeignKeys[2].RefTable = SopStagesTable
-	MessageRecordssTable.Annotation = &entsql.Annotation{
-		Table: "message_recordss",
+	MessageRecordsTable.ForeignKeys[0].RefTable = ContactTable
+	MessageRecordsTable.ForeignKeys[1].RefTable = SopNodeTable
+	MessageRecordsTable.ForeignKeys[2].RefTable = SopStageTable
+	MessageRecordsTable.Annotation = &entsql.Annotation{
+		Table: "message_records",
 	}
-	ServersTable.Annotation = &entsql.Annotation{
-		Table: "servers",
+	ServerTable.Annotation = &entsql.Annotation{
+		Table: "server",
 	}
-	SopNodesTable.ForeignKeys[0].RefTable = SopStagesTable
-	SopNodesTable.Annotation = &entsql.Annotation{
-		Table: "sop_nodes",
+	SopNodeTable.ForeignKeys[0].RefTable = SopStageTable
+	SopNodeTable.Annotation = &entsql.Annotation{
+		Table: "sop_node",
 	}
-	SopStagesTable.ForeignKeys[0].RefTable = SopTasksTable
-	SopStagesTable.Annotation = &entsql.Annotation{
-		Table: "sop_stages",
+	SopStageTable.ForeignKeys[0].RefTable = SopTaskTable
+	SopStageTable.Annotation = &entsql.Annotation{
+		Table: "sop_stage",
 	}
-	SopTasksTable.Annotation = &entsql.Annotation{
-		Table: "sop_tasks",
+	SopTaskTable.Annotation = &entsql.Annotation{
+		Table: "sop_task",
 	}
-	WxsTable.ForeignKeys[0].RefTable = ServersTable
-	WxsTable.Annotation = &entsql.Annotation{
-		Table: "wxs",
+	WxTable.ForeignKeys[0].RefTable = ServerTable
+	WxTable.Annotation = &entsql.Annotation{
+		Table: "wx",
 	}
 }

+ 1 - 1
ent/schema/contact.go

@@ -93,6 +93,6 @@ func (Contact) Edges() []ent.Edge {
 func (Contact) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "contacts"},
+		entsql.Annotation{Table: "contact"},
 	}
 }

+ 1 - 1
ent/schema/label.go

@@ -59,6 +59,6 @@ func (Label) Edges() []ent.Edge {
 func (Label) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "labels"},
+		entsql.Annotation{Table: "label"},
 	}
 }

+ 1 - 1
ent/schema/label_relationship.go

@@ -60,6 +60,6 @@ func (LabelRelationship) Edges() []ent.Edge {
 func (LabelRelationship) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "label_relationships"},
+		entsql.Annotation{Table: "label_relationship"},
 	}
 }

+ 1 - 1
ent/schema/message_records.go

@@ -92,6 +92,6 @@ func (MessageRecords) Edges() []ent.Edge {
 func (MessageRecords) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "message_recordss"},
+		entsql.Annotation{Table: "message_records"},
 	}
 }

+ 1 - 1
ent/schema/server.go

@@ -57,6 +57,6 @@ func (Server) Edges() []ent.Edge {
 func (Server) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "servers"},
+		entsql.Annotation{Table: "server"},
 	}
 }

+ 1 - 1
ent/schema/sop_node.go

@@ -74,6 +74,6 @@ func (SopNode) Edges() []ent.Edge {
 func (SopNode) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "sop_nodes"},
+		entsql.Annotation{Table: "sop_node"},
 	}
 }

+ 1 - 1
ent/schema/sop_stage.go

@@ -75,6 +75,6 @@ func (SopStage) Edges() []ent.Edge {
 func (SopStage) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "sop_stages"},
+		entsql.Annotation{Table: "sop_stage"},
 	}
 }

+ 1 - 1
ent/schema/sop_task.go

@@ -62,6 +62,6 @@ func (SopTask) Edges() []ent.Edge {
 func (SopTask) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "sop_tasks"},
+		entsql.Annotation{Table: "sop_task"},
 	}
 }

+ 1 - 1
ent/schema/wx.go

@@ -76,6 +76,6 @@ func (Wx) Edges() []ent.Edge {
 func (Wx) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
-		entsql.Annotation{Table: "wxs"},
+		entsql.Annotation{Table: "wx"},
 	}
 }

+ 3 - 3
ent/server/server.go

@@ -34,12 +34,12 @@ const (
 	// EdgeWxs holds the string denoting the wxs edge name in mutations.
 	EdgeWxs = "wxs"
 	// Table holds the table name of the server in the database.
-	Table = "servers"
+	Table = "server"
 	// WxsTable is the table that holds the wxs relation/edge.
-	WxsTable = "wxs"
+	WxsTable = "wx"
 	// WxsInverseTable is the table name for the Wx entity.
 	// It exists in this package in order to avoid circular dependency with the "wx" package.
-	WxsInverseTable = "wxs"
+	WxsInverseTable = "wx"
 	// WxsColumn is the table column denoting the wxs relation/edge.
 	WxsColumn = "server_id"
 )

+ 5 - 5
ent/sopnode/sopnode.go

@@ -44,19 +44,19 @@ const (
 	// EdgeNodeMessages holds the string denoting the node_messages edge name in mutations.
 	EdgeNodeMessages = "node_messages"
 	// Table holds the table name of the sopnode in the database.
-	Table = "sop_nodes"
+	Table = "sop_node"
 	// SopStageTable is the table that holds the sop_stage relation/edge.
-	SopStageTable = "sop_nodes"
+	SopStageTable = "sop_node"
 	// SopStageInverseTable is the table name for the SopStage entity.
 	// It exists in this package in order to avoid circular dependency with the "sopstage" package.
-	SopStageInverseTable = "sop_stages"
+	SopStageInverseTable = "sop_stage"
 	// SopStageColumn is the table column denoting the sop_stage relation/edge.
 	SopStageColumn = "stage_id"
 	// NodeMessagesTable is the table that holds the node_messages relation/edge.
-	NodeMessagesTable = "message_recordss"
+	NodeMessagesTable = "message_records"
 	// NodeMessagesInverseTable is the table name for the MessageRecords entity.
 	// It exists in this package in order to avoid circular dependency with the "messagerecords" package.
-	NodeMessagesInverseTable = "message_recordss"
+	NodeMessagesInverseTable = "message_records"
 	// NodeMessagesColumn is the table column denoting the node_messages relation/edge.
 	NodeMessagesColumn = "sub_source_id"
 )

+ 7 - 7
ent/sopstage/sopstage.go

@@ -46,26 +46,26 @@ const (
 	// EdgeStageMessages holds the string denoting the stage_messages edge name in mutations.
 	EdgeStageMessages = "stage_messages"
 	// Table holds the table name of the sopstage in the database.
-	Table = "sop_stages"
+	Table = "sop_stage"
 	// SopTaskTable is the table that holds the sop_task relation/edge.
-	SopTaskTable = "sop_stages"
+	SopTaskTable = "sop_stage"
 	// SopTaskInverseTable is the table name for the SopTask entity.
 	// It exists in this package in order to avoid circular dependency with the "soptask" package.
-	SopTaskInverseTable = "sop_tasks"
+	SopTaskInverseTable = "sop_task"
 	// SopTaskColumn is the table column denoting the sop_task relation/edge.
 	SopTaskColumn = "task_id"
 	// StageNodesTable is the table that holds the stage_nodes relation/edge.
-	StageNodesTable = "sop_nodes"
+	StageNodesTable = "sop_node"
 	// StageNodesInverseTable is the table name for the SopNode entity.
 	// It exists in this package in order to avoid circular dependency with the "sopnode" package.
-	StageNodesInverseTable = "sop_nodes"
+	StageNodesInverseTable = "sop_node"
 	// StageNodesColumn is the table column denoting the stage_nodes relation/edge.
 	StageNodesColumn = "stage_id"
 	// StageMessagesTable is the table that holds the stage_messages relation/edge.
-	StageMessagesTable = "message_recordss"
+	StageMessagesTable = "message_records"
 	// StageMessagesInverseTable is the table name for the MessageRecords entity.
 	// It exists in this package in order to avoid circular dependency with the "messagerecords" package.
-	StageMessagesInverseTable = "message_recordss"
+	StageMessagesInverseTable = "message_records"
 	// StageMessagesColumn is the table column denoting the stage_messages relation/edge.
 	StageMessagesColumn = "source_id"
 )

+ 3 - 3
ent/soptask/soptask.go

@@ -38,12 +38,12 @@ const (
 	// EdgeTaskStages holds the string denoting the task_stages edge name in mutations.
 	EdgeTaskStages = "task_stages"
 	// Table holds the table name of the soptask in the database.
-	Table = "sop_tasks"
+	Table = "sop_task"
 	// TaskStagesTable is the table that holds the task_stages relation/edge.
-	TaskStagesTable = "sop_stages"
+	TaskStagesTable = "sop_stage"
 	// TaskStagesInverseTable is the table name for the SopStage entity.
 	// It exists in this package in order to avoid circular dependency with the "sopstage" package.
-	TaskStagesInverseTable = "sop_stages"
+	TaskStagesInverseTable = "sop_stage"
 	// TaskStagesColumn is the table column denoting the task_stages relation/edge.
 	TaskStagesColumn = "task_id"
 )

+ 3 - 3
ent/wx/wx.go

@@ -44,12 +44,12 @@ const (
 	// EdgeServer holds the string denoting the server edge name in mutations.
 	EdgeServer = "server"
 	// Table holds the table name of the wx in the database.
-	Table = "wxs"
+	Table = "wx"
 	// ServerTable is the table that holds the server relation/edge.
-	ServerTable = "wxs"
+	ServerTable = "wx"
 	// ServerInverseTable is the table name for the Server entity.
 	// It exists in this package in order to avoid circular dependency with the "server" package.
-	ServerInverseTable = "servers"
+	ServerInverseTable = "server"
 	// ServerColumn is the table column denoting the server relation/edge.
 	ServerColumn = "server_id"
 )

+ 3 - 0
internal/logic/sop_task/get_sop_task_list_logic.go

@@ -2,6 +2,7 @@ package sop_task
 
 import (
 	"context"
+	"fmt"
 	"wechat-api/ent/predicate"
 	"wechat-api/ent/soptask"
 	"wechat-api/internal/svc"
@@ -29,6 +30,8 @@ func NewGetSopTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
 }
 
 func (l *GetSopTaskListLogic) GetSopTaskList(req *types.SopTaskListReq) (*types.SopTaskListResp, error) {
+	departmentId := l.ctx.Value("departmentId")
+	fmt.Printf("---------------departmentId2----------------: %d\n\n", departmentId)
 	var predicates []predicate.SopTask
 	if req.Name != nil {
 		predicates = append(predicates, soptask.NameContains(*req.Name))

+ 21 - 9
internal/middleware/authority_middleware.go

@@ -3,29 +3,32 @@ package middleware
 import (
 	"context"
 	"errors"
+	"github.com/suyuan32/simple-admin-core/rpc/coreclient"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"net/http"
 	"strings"
 
 	"github.com/casbin/casbin/v2"
 	"github.com/redis/go-redis/v9"
-	"github.com/zeromicro/go-zero/core/errorx"
-	"github.com/zeromicro/go-zero/core/logx"
-	"github.com/zeromicro/go-zero/rest/httpx"
-
 	"github.com/suyuan32/simple-admin-common/config"
 	"github.com/suyuan32/simple-admin-common/enum/errorcode"
 	"github.com/suyuan32/simple-admin-common/utils/jwt"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"github.com/zeromicro/go-zero/core/logx"
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
 type AuthorityMiddleware struct {
-	Cbn *casbin.Enforcer
-	Rds redis.UniversalClient
+	Cbn     *casbin.Enforcer
+	Rds     redis.UniversalClient
+	CoreRpc coreclient.Core
 }
 
-func NewAuthorityMiddleware(cbn *casbin.Enforcer, rds redis.UniversalClient) *AuthorityMiddleware {
+func NewAuthorityMiddleware(cbn *casbin.Enforcer, rds redis.UniversalClient, c coreclient.Core) *AuthorityMiddleware {
 	return &AuthorityMiddleware{
-		Cbn: cbn,
-		Rds: rds,
+		Cbn:     cbn,
+		Rds:     rds,
+		CoreRpc: c,
 	}
 }
 
@@ -56,6 +59,15 @@ func (m *AuthorityMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
 		if result {
 			logx.Infow("HTTP/HTTPS Request", logx.Field("UUID", r.Context().Value("userId").(string)),
 				logx.Field("path", obj), logx.Field("method", act))
+			userIdStr := r.Context().Value("userId").(string)
+			data, err := m.CoreRpc.GetUserById(r.Context(), &core.UUIDReq{Id: userIdStr})
+			if err != nil {
+				logx.Errorw("get user info error", logx.Field("detail", err.Error()))
+				httpx.Error(w, errorx.NewApiError(http.StatusInternalServerError, err.Error()))
+				return
+			}
+			// 将 data.DepartmentID 插入上下文,以供后续接口使用
+			r = r.WithContext(context.WithValue(r.Context(), "departmentId", *data.DepartmentId))
 			next(w, r)
 			return
 		} else {

+ 4 - 2
internal/svc/service_context.go

@@ -34,10 +34,12 @@ func NewServiceContext(c config.Config) *ServiceContext {
 		ent.Debug(), // debug mode
 	)
 
+	coreRpc := coreclient.NewCore(zrpc.NewClientIfEnable(c.CoreRpc))
+
 	return &ServiceContext{
 		Config:    c,
-		Authority: middleware.NewAuthorityMiddleware(cbn, rds).Handle,
+		Authority: middleware.NewAuthorityMiddleware(cbn, rds, coreRpc).Handle,
 		DB:        db,
-		CoreRpc:   coreclient.NewCore(zrpc.NewClientIfEnable(c.CoreRpc)),
+		CoreRpc:   coreRpc,
 	}
 }