mirror of https://github.com/chaitin/PandaWiki.git
Compare commits
2 Commits
d573111023
...
ebcd2d255d
| Author | SHA1 | Date |
|---|---|---|
|
|
ebcd2d255d | |
|
|
4cbe3fd5b5 |
|
|
@ -56,3 +56,11 @@ type NodePermissionEditReq struct {
|
|||
|
||||
type NodePermissionEditResp struct {
|
||||
}
|
||||
|
||||
type NodeRestudyReq struct {
|
||||
NodeIds []string `json:"node_ids"`
|
||||
KbId string `json:"kb_id"`
|
||||
}
|
||||
|
||||
type NodeRestudyResp struct {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2117,6 +2117,58 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/node/restudy": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "文档重新学习",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Node"
|
||||
],
|
||||
"summary": "文档重新学习",
|
||||
"operationId": "v1-NodeRestudy",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "para",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.NodeRestudyReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/domain.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/v1.NodeRestudyResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/node/summary": {
|
||||
"post": {
|
||||
"security": [
|
||||
|
|
@ -8271,6 +8323,23 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"v1.NodeRestudyReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kb_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"node_ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.NodeRestudyResp": {
|
||||
"type": "object"
|
||||
},
|
||||
"v1.ResetPasswordReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -2110,6 +2110,58 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/node/restudy": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "文档重新学习",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Node"
|
||||
],
|
||||
"summary": "文档重新学习",
|
||||
"operationId": "v1-NodeRestudy",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "para",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.NodeRestudyReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/domain.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/v1.NodeRestudyResp"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/node/summary": {
|
||||
"post": {
|
||||
"security": [
|
||||
|
|
@ -8264,6 +8316,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"v1.NodeRestudyReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kb_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"node_ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.NodeRestudyResp": {
|
||||
"type": "object"
|
||||
},
|
||||
"v1.ResetPasswordReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -2986,6 +2986,17 @@ definitions:
|
|||
$ref: '#/definitions/domain.NodeGroupDetail'
|
||||
type: array
|
||||
type: object
|
||||
v1.NodeRestudyReq:
|
||||
properties:
|
||||
kb_id:
|
||||
type: string
|
||||
node_ids:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
v1.NodeRestudyResp:
|
||||
type: object
|
||||
v1.ResetPasswordReq:
|
||||
properties:
|
||||
id:
|
||||
|
|
@ -4374,6 +4385,36 @@ paths:
|
|||
summary: Recommend Nodes
|
||||
tags:
|
||||
- node
|
||||
/api/v1/node/restudy:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 文档重新学习
|
||||
operationId: v1-NodeRestudy
|
||||
parameters:
|
||||
- description: para
|
||||
in: body
|
||||
name: param
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/v1.NodeRestudyReq'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/domain.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/v1.NodeRestudyResp'
|
||||
type: object
|
||||
security:
|
||||
- bearerAuth: []
|
||||
summary: 文档重新学习
|
||||
tags:
|
||||
- Node
|
||||
/api/v1/node/summary:
|
||||
post:
|
||||
consumes:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ func NewNodeHandler(
|
|||
group.POST("/batch_move", h.BatchMoveNode)
|
||||
|
||||
group.GET("/recommend_nodes", h.RecommendNodes)
|
||||
group.POST("/restudy", h.NodeRestudy)
|
||||
|
||||
// node permission
|
||||
group.GET("/permission", h.NodePermission)
|
||||
|
|
@ -384,3 +385,32 @@ func (h *NodeHandler) NodePermissionEdit(c echo.Context) error {
|
|||
}
|
||||
return h.NewResponseWithData(c, nil)
|
||||
}
|
||||
|
||||
// NodeRestudy 文档重新学习
|
||||
//
|
||||
// @Tags Node
|
||||
// @Summary 文档重新学习
|
||||
// @Description 文档重新学习
|
||||
// @ID v1-NodeRestudy
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security bearerAuth
|
||||
// @Param param body v1.NodeRestudyReq true "para"
|
||||
// @Success 200 {object} domain.Response{data=v1.NodeRestudyResp}
|
||||
// @Router /api/v1/node/restudy [post]
|
||||
func (h *NodeHandler) NodeRestudy(c echo.Context) error {
|
||||
var req v1.NodeRestudyReq
|
||||
if err := c.Bind(&req); err != nil {
|
||||
return h.NewResponseWithError(c, "request params is invalid", err)
|
||||
}
|
||||
|
||||
if err := c.Validate(req); err != nil {
|
||||
return h.NewResponseWithError(c, "validate request params failed", err)
|
||||
}
|
||||
|
||||
if err := h.usecase.NodeRestudy(c.Request().Context(), &req); err != nil {
|
||||
return h.NewResponseWithError(c, "validate request params failed", err)
|
||||
}
|
||||
|
||||
return h.NewResponseWithData(c, nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -573,3 +573,31 @@ func (u *NodeUsecase) SyncRagNodeStatus(ctx context.Context) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *NodeUsecase) NodeRestudy(ctx context.Context, req *v1.NodeRestudyReq) error {
|
||||
nodeReleases, err := u.nodeRepo.GetLatestNodeReleaseByNodeIDs(ctx, req.KbId, req.NodeIds)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get latest node release failed: %w", err)
|
||||
}
|
||||
|
||||
for _, nodeRelease := range nodeReleases {
|
||||
if nodeRelease.DocID == "" {
|
||||
continue
|
||||
}
|
||||
if err := u.ragRepo.AsyncUpdateNodeReleaseVector(ctx, []*domain.NodeReleaseVectorRequest{
|
||||
{
|
||||
KBID: nodeRelease.KBID,
|
||||
NodeReleaseID: nodeRelease.ID,
|
||||
Action: "upsert",
|
||||
},
|
||||
}); err != nil {
|
||||
u.logger.Error("async update node release vector failed",
|
||||
log.String("node_release_id", nodeRelease.ID),
|
||||
log.Error(err))
|
||||
continue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue