AdminListSkillLibraries godoc @Summary 后台技能列表 @Description 后台分页查询技能列表 @Tags 技能库-后台 @Accept json @Produce json @Security BearerAuth @Param keyword query string false "关键词(匹配技能名、显示名)" @Param publish_status query string false "发布状态:draft/published/rejected" default(published) @Param admin_status query
(c *gin.Context)
| 294 | // @Success 200 {object} model.CommonResponse |
| 295 | // @Router /api/admin/skill-library/list [get] |
| 296 | func AdminListSkillLibraries(c *gin.Context) { |
| 297 | var query AdminSkillListQuery |
| 298 | if err := c.ShouldBindQuery(&query); err != nil { |
| 299 | c.JSON(http.StatusBadRequest, model.ParamError.ToErrorResponse(err)) |
| 300 | return |
| 301 | } |
| 302 | if query.Offset < 0 { |
| 303 | query.Offset = 0 |
| 304 | } |
| 305 | if query.Limit <= 0 { |
| 306 | query.Limit = 20 |
| 307 | } |
| 308 | |
| 309 | eid := config.GetEID(c) |
| 310 | |
| 311 | var filterSkillIDs []int64 |
| 312 | groupIDs := parseCommaSeparatedInt64IDs(query.GroupID) |
| 313 | if strings.TrimSpace(query.GroupID) != "" && len(groupIDs) == 0 { |
| 314 | c.JSON(http.StatusOK, model.Success.ToResponse(gin.H{ |
| 315 | "count": 0, |
| 316 | "items": []*model.SkillLibrary{}, |
| 317 | })) |
| 318 | return |
| 319 | } |
| 320 | if len(groupIDs) > 0 { |
| 321 | var err error |
| 322 | filterSkillIDs, err = model.GetDistinctResourceIDsByGroupsAndType(groupIDs, model.ResourceTypeSkillLibrary) |
| 323 | if err != nil { |
| 324 | c.JSON(http.StatusInternalServerError, model.DBError.ToErrorResponse(err)) |
| 325 | return |
| 326 | } |
| 327 | if len(filterSkillIDs) == 0 { |
| 328 | c.JSON(http.StatusOK, model.Success.ToResponse(gin.H{ |
| 329 | "count": 0, |
| 330 | "items": []*model.SkillLibrary{}, |
| 331 | })) |
| 332 | return |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | svc := service.NewSkillLibraryService() |
| 337 | items, count, err := svc.ListAdminSkillsWithFilter(c.Request.Context(), eid, query.Keyword, strings.TrimSpace(query.PublishStatus), strings.TrimSpace(query.AdminStatus), filterSkillIDs, query.Offset, query.Limit) |
| 338 | if err != nil { |
| 339 | toSkillAdminErrorResponse(c, err) |
| 340 | return |
| 341 | } |
| 342 | |
| 343 | c.JSON(http.StatusOK, model.Success.ToResponse(gin.H{ |
| 344 | "count": count, |
| 345 | "items": items, |
| 346 | })) |
| 347 | } |
| 348 | |
| 349 | // AdminGetSkillLibrary godoc |
| 350 | // @Summary 后台技能详情 |
nothing calls this directly
no test coverage detected