Merge pull request #1540 from coltea/feat-node-list-publisher

feat 文档相关页面支持直接跳转至前台
This commit is contained in:
Coltea 2025-11-19 18:47:43 +08:00 committed by GitHub
commit 0e64ff946f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 50 additions and 0 deletions

View File

@ -6582,6 +6582,9 @@ const docTemplate = `{
"position": {
"type": "number"
},
"publisher_id": {
"type": "string"
},
"rag_info": {
"$ref": "#/definitions/domain.RagInfo"
},

View File

@ -6575,6 +6575,9 @@
"position": {
"type": "number"
},
"publisher_id": {
"type": "string"
},
"rag_info": {
"$ref": "#/definitions/domain.RagInfo"
},

View File

@ -1763,6 +1763,8 @@ definitions:
$ref: '#/definitions/domain.NodePermissions'
position:
type: number
publisher_id:
type: string
rag_info:
$ref: '#/definitions/domain.RagInfo'
status:

View File

@ -174,6 +174,7 @@ type NodeListItemResp struct {
EditorId string `json:"editor_id"`
Creator string `json:"creator"`
Editor string `json:"editor"`
PublisherId string `json:"publisher_id" gorm:"-"`
Permissions NodePermissions `json:"permissions" gorm:"type:jsonb"`
}

View File

@ -157,6 +157,32 @@ func (r *NodeRepository) GetLatestNodeReleaseByNodeIDs(ctx context.Context, kbID
return nodeReleases, nil
}
func (r *NodeRepository) GetNodeReleasePublisherMap(ctx context.Context, kbID string) (map[string]string, error) {
type Result struct {
NodeID string `gorm:"column:node_id"`
PublisherID string `gorm:"column:publisher_id"`
}
var results []Result
if err := r.db.WithContext(ctx).
Model(&domain.NodeRelease{}).
Select("node_id, publisher_id").
Where("kb_id = ?", kbID).
Where("node_releases.doc_id != '' ").
Find(&results).Error; err != nil {
return nil, err
}
publisherMap := make(map[string]string)
for _, result := range results {
if result.PublisherID != "" {
publisherMap[result.NodeID] = result.PublisherID
}
}
return publisherMap, nil
}
func (r *NodeRepository) UpdateNodeContent(ctx context.Context, req *domain.UpdateNodeReq, userId string) error {
// Use transaction to ensure data consistency
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {

View File

@ -86,6 +86,21 @@ func (u *NodeUsecase) GetList(ctx context.Context, req *domain.GetNodeListReq) (
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
publisherMap, err := u.nodeRepo.GetNodeReleasePublisherMap(ctx, req.KBID)
if err != nil {
return nil, err
}
for _, node := range nodes {
if publisherID, exists := publisherMap[node.ID]; exists {
node.PublisherId = publisherID
}
}
return nodes, nil
}