MCPcopy Create free account
hub / github.com/53AI/53AIHub / BatchDeleteUserRecentUsed

Function BatchDeleteUserRecentUsed

api/controller/user_recent_used.go:122–157  ·  view source on GitHub ↗

BatchDeleteUserRecentUsed @Summary 批量删除最近使用记录 @Description 传 ids 参数则按 ID 删除,不传则删除用户所有最近使用记录 @Tags 最近使用 @Accept json @Produce json @Security BearerAuth @Param ids query string false "要删除的ID列表,逗号分隔(不传则删除全部)" @Success 200 {object} model.CommonResponse "成功" @Failure 400 {object} model.CommonResponse "参数

(c *gin.Context)

Source from the content-addressed store, hash-verified

120// @Failure 500 {object} model.CommonResponse "系统错误"
121// @Router /api/recent-used [delete]
122func BatchDeleteUserRecentUsed(c *gin.Context) {
123 eid := config.GetEID(c)
124 userID := config.GetUserId(c)
125
126 idsStr := c.Query("ids")
127 var ids []int64
128 if idsStr != "" {
129 parts := strings.Split(idsStr, ",")
130 for _, p := range parts {
131 p = strings.TrimSpace(p)
132 if p == "" {
133 continue
134 }
135 // 尝试 hashID 解码
136 if id, err := hashids.Decode(p); err == nil {
137 ids = append(ids, id)
138 continue
139 }
140 // 尝试原始 int64
141 if id, err := strconv.ParseInt(p, 10, 64); err == nil {
142 ids = append(ids, id)
143 continue
144 }
145 c.JSON(http.StatusBadRequest, model.ParamError.ToNewErrorResponse("无效的ID格式: "+p))
146 return
147 }
148 }
149
150 if err := service.BatchDeleteUserRecentUsed(eid, userID, ids); err != nil {
151 logger.Errorf(c.Request.Context(), "删除最近使用记录失败: %v", err)
152 c.JSON(http.StatusInternalServerError, model.SystemError.ToNewErrorResponse("删除失败"))
153 return
154 }
155
156 c.JSON(http.StatusOK, model.Success.ToResponse(nil))
157}

Callers

nothing calls this directly

Calls 6

GetEIDMethod · 0.80
DecodeMethod · 0.80
ToNewErrorResponseMethod · 0.80
ErrorfMethod · 0.80
ToResponseMethod · 0.80
QueryMethod · 0.65

Tested by

no test coverage detected