feat: 新增FAQ条目获取接口,支持按ID查询单个FAQ条目;增强标签删除功能,支持content_only模式仅删除标签下内容
This commit is contained in:
@@ -351,6 +351,38 @@ func (h *FAQHandler) ExportEntries(c *gin.Context) {
|
||||
c.Data(http.StatusOK, "text/csv; charset=utf-8", append(bom, csvData...))
|
||||
}
|
||||
|
||||
// GetEntry godoc
|
||||
// @Summary 获取FAQ条目详情
|
||||
// @Description 根据ID获取单个FAQ条目的详情
|
||||
// @Tags FAQ管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "知识库ID"
|
||||
// @Param entry_id path string true "FAQ条目ID"
|
||||
// @Success 200 {object} map[string]interface{} "FAQ条目详情"
|
||||
// @Failure 400 {object} errors.AppError "请求参数错误"
|
||||
// @Failure 404 {object} errors.AppError "条目不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /knowledge-bases/{id}/faq/entries/{entry_id} [get]
|
||||
func (h *FAQHandler) GetEntry(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
kbID := secutils.SanitizeForLog(c.Param("id"))
|
||||
entryID := secutils.SanitizeForLog(c.Param("entry_id"))
|
||||
|
||||
entry, err := h.knowledgeService.GetFAQEntry(ctx, kbID, entryID)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, nil)
|
||||
c.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"data": entry,
|
||||
})
|
||||
}
|
||||
|
||||
// GetImportProgress godoc
|
||||
// @Summary 获取FAQ导入进度
|
||||
// @Description 获取FAQ导入任务的进度
|
||||
|
||||
@@ -157,15 +157,16 @@ func (h *TagHandler) UpdateTag(c *gin.Context) {
|
||||
|
||||
// DeleteTag godoc
|
||||
// @Summary 删除标签
|
||||
// @Description 删除标签,可使用force=true强制删除被引用的标签
|
||||
// @Description 删除标签,可使用force=true强制删除被引用的标签,content_only=true仅删除标签下的内容而保留标签本身
|
||||
// @Tags 标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "知识库ID"
|
||||
// @Param tag_id path string true "标签ID"
|
||||
// @Param force query bool false "强制删除"
|
||||
// @Success 200 {object} map[string]interface{} "删除成功"
|
||||
// @Failure 400 {object} errors.AppError "请求参数错误"
|
||||
// @Param id path string true "知识库ID"
|
||||
// @Param tag_id path string true "标签ID"
|
||||
// @Param force query bool false "强制删除"
|
||||
// @Param content_only query bool false "仅删除内容,保留标签"
|
||||
// @Success 200 {object} map[string]interface{} "删除成功"
|
||||
// @Failure 400 {object} errors.AppError "请求参数错误"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /knowledge-bases/{id}/tags/{tag_id} [delete]
|
||||
@@ -174,8 +175,9 @@ func (h *TagHandler) DeleteTag(c *gin.Context) {
|
||||
tagID := secutils.SanitizeForLog(c.Param("tag_id"))
|
||||
|
||||
force := c.Query("force") == "true"
|
||||
contentOnly := c.Query("content_only") == "true"
|
||||
|
||||
if err := h.tagService.DeleteTag(ctx, tagID, force); err != nil {
|
||||
if err := h.tagService.DeleteTag(ctx, tagID, force, contentOnly); err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
"tag_id": tagID,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user