AdminGenerateSkillLibraryContent godoc @Summary 后台 AI 生成技能文案 @Description 按单一类型生成技能文案(capabilities/usage_example/best_practice/faq/document_summary,不直接写库) @Tags 技能库-后台 @Accept json @Produce json @Security BearerAuth @Param id path int true "技能ID" @Param request body AdminAIGenerateSkillRequest true
(c *gin.Context)
| 543 | // @Success 200 {object} model.CommonResponse |
| 544 | // @Router /api/admin/skill-library/{id}/ai-generate [post] |
| 545 | func AdminGenerateSkillLibraryContent(c *gin.Context) { |
| 546 | skillID, err := strconv.ParseInt(c.Param("id"), 10, 64) |
| 547 | if err != nil || skillID <= 0 { |
| 548 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(nil)) |
| 549 | return |
| 550 | } |
| 551 | |
| 552 | var req AdminAIGenerateSkillRequest |
| 553 | if err := c.ShouldBindJSON(&req); err != nil { |
| 554 | c.JSON(http.StatusBadRequest, model.ParamError.ToErrorResponse(err)) |
| 555 | return |
| 556 | } |
| 557 | |
| 558 | eid := config.GetEID(c) |
| 559 | svc := service.NewSkillLibraryService() |
| 560 | result, err := svc.GenerateSkillContent(c.Request.Context(), eid, skillID, &service.SkillAIGenerateRequest{ |
| 561 | GenerationType: strings.TrimSpace(req.GenerationType), |
| 562 | SkillMD: req.SkillMD, |
| 563 | TitleMaxChars: req.TitleMaxChars, |
| 564 | DescriptionMaxChars: req.DescriptionMaxChars, |
| 565 | QuestionMaxChars: req.QuestionMaxChars, |
| 566 | AnswerMaxChars: req.AnswerMaxChars, |
| 567 | CaseMaxChars: req.CaseMaxChars, |
| 568 | TargetChars: req.TargetChars, |
| 569 | Document: req.Document, |
| 570 | }) |
| 571 | if err != nil { |
| 572 | toSkillAdminErrorResponse(c, err) |
| 573 | return |
| 574 | } |
| 575 | |
| 576 | c.JSON(http.StatusOK, model.Success.ToResponse(result)) |
| 577 | } |
| 578 | |
| 579 | // SkillFileTreeResponse represents the response for file tree |
| 580 | type SkillFileTreeResponse struct { |
nothing calls this directly
no test coverage detected