mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-29 04:08:12 +08:00
feat[Go]: implement create_connector API (#15285)
### What problem does this PR solve? implement create_connector API ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -16,7 +16,10 @@
|
||||
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Connector connector model
|
||||
type Connector struct {
|
||||
@@ -39,6 +42,53 @@ func (Connector) TableName() string {
|
||||
return "connector"
|
||||
}
|
||||
|
||||
// MarshalJSON formats connector timestamps to match the Python API contract.
|
||||
func (c Connector) MarshalJSON() ([]byte, error) {
|
||||
type connectorJSON struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
Name string `json:"name"`
|
||||
Source string `json:"source"`
|
||||
InputType string `json:"input_type"`
|
||||
Config JSONMap `json:"config"`
|
||||
RefreshFreq int64 `json:"refresh_freq"`
|
||||
PruneFreq int64 `json:"prune_freq"`
|
||||
TimeoutSecs int64 `json:"timeout_secs"`
|
||||
IndexingStart *string `json:"indexing_start"`
|
||||
Status string `json:"status"`
|
||||
CreateTime *int64 `json:"create_time,omitempty"`
|
||||
CreateDate *string `json:"create_date,omitempty"`
|
||||
UpdateTime *int64 `json:"update_time,omitempty"`
|
||||
UpdateDate *string `json:"update_date,omitempty"`
|
||||
}
|
||||
|
||||
return json.Marshal(connectorJSON{
|
||||
ID: c.ID,
|
||||
TenantID: c.TenantID,
|
||||
Name: c.Name,
|
||||
Source: c.Source,
|
||||
InputType: c.InputType,
|
||||
Config: c.Config,
|
||||
RefreshFreq: c.RefreshFreq,
|
||||
PruneFreq: c.PruneFreq,
|
||||
TimeoutSecs: c.TimeoutSecs,
|
||||
IndexingStart: formatConnectorTime(c.IndexingStart),
|
||||
Status: c.Status,
|
||||
CreateTime: c.CreateTime,
|
||||
CreateDate: formatConnectorTime(c.CreateDate),
|
||||
UpdateTime: c.UpdateTime,
|
||||
UpdateDate: formatConnectorTime(c.UpdateDate),
|
||||
})
|
||||
}
|
||||
|
||||
func formatConnectorTime(value *time.Time) *string {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
formatted := value.Format("2006-01-02T15:04:05")
|
||||
return &formatted
|
||||
}
|
||||
|
||||
// Connector2Kb connector to knowledge base mapping model
|
||||
type Connector2Kb struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user