MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / Update

Method Update

user/handler/organization.go:174–204  ·  view source on GitHub ↗

UpdateOrganization godoc @Security ApiKey @Summary Update organization @Description update organization @Tags Organization @Accept json @Produce json @Param namespace path string true "namespace" @Param current_user query string false "the op user" @Param

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

172// @Failure 500 {object} types.APIInternalServerError "Internal server error"
173// @Router /organization/{namespace} [put]
174func (h *OrganizationHandler) Update(ctx *gin.Context) {
175 currentUser := httpbase.GetCurrentUser(ctx)
176 if currentUser == "" {
177 httpbase.UnauthorizedError(ctx, errors.New("user not found, please login first"))
178 return
179 }
180 var req types.EditOrgReq
181 if err := ctx.ShouldBindJSON(&req); err != nil {
182 slog.Error("Bad request format", "error", err)
183 httpbase.BadRequest(ctx, err.Error())
184 return
185 }
186 var err error
187 _, err = h.sc.CheckRequest(ctx, &req)
188 if err != nil {
189 slog.Error("failed to check sensitive request", slog.Any("error", err))
190 httpbase.BadRequest(ctx, fmt.Errorf("sensitive check failed: %w", err).Error())
191 return
192 }
193 req.CurrentUser = currentUser
194 req.Name = ctx.Param("namespace")
195 org, err := h.c.Update(ctx, &req)
196 if err != nil {
197 slog.Error("Failed to update organizations", slog.Any("error", err))
198 httpbase.ServerError(ctx, err)
199 return
200 }
201
202 slog.Info("Update organizations succeed", slog.String("org_name", org.Nickname))
203 httpbase.OK(ctx, org)
204}
205
206// GetOrganizationModels godoc
207// @Security ApiKey

Callers

nothing calls this directly

Calls 7

GetCurrentUserFunction · 0.92
UnauthorizedErrorFunction · 0.92
BadRequestFunction · 0.92
ServerErrorFunction · 0.92
OKFunction · 0.92
ErrorMethod · 0.80
CheckRequestMethod · 0.65

Tested by

no test coverage detected