MCPcopy Index your code
hub / github.com/53AI/53AIHub / Create

Method Create

api/controller/approval_controller.go:32–63  ·  view source on GitHub ↗

@Summary 创建审批 @Description 发起资源权限审批申请 @Tags 审批 @Accept json @Security BearerAuth @Param request body service.CreateApprovalRequest true "审批创建请求" @Success 200 {object} model.CommonResponse "创建成功" @Router /api/approvals [post]

(c *gin.Context)

Source from the content-addressed store, hash-verified

30// @Success 200 {object} model.CommonResponse "创建成功"
31// @Router /api/approvals [post]
32func (ac *ApprovalController) Create(c *gin.Context) {
33 userID := config.GetUserId(c)
34 if userID == 0 {
35 respErr(c, http.StatusUnauthorized, "unauthorized")
36 return
37 }
38 eid := config.GetEID(c)
39 if eid == 0 {
40 respErr(c, http.StatusUnauthorized, "unauthorized")
41 return
42 }
43
44 var req service.CreateApprovalRequest
45 if err := c.ShouldBindJSON(&req); err != nil {
46 c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(errors.New("invalid json body")))
47 return
48 }
49
50 id, _, _, err := ac.Svc.CreateApproval(c, eid, userID, req)
51 if err != nil {
52 logger.Errorf(c, "approvals.Create error: %v", err)
53 switch {
54 case errors.Is(err, service.ErrApprovalAlreadyApplied):
55 c.JSON(http.StatusConflict, model.ParamError.ToResponse(err))
56 return
57 default:
58 respErr(c, http.StatusInternalServerError, "internal error")
59 return
60 }
61 }
62 c.JSON(http.StatusOK, gin.H{"code": 0, "msg": "ok", "data": gin.H{"id": id, "status": model.ApprovalStatusPending}})
63}
64
65type ApproveBody struct {
66 Permission int `json:"permission" binding:"required"`

Callers 15

createVectorIndexingJobFunction · 0.45
InitSystemNavigationFunction · 0.45
CreatePromptFunction · 0.45
UpdatePromptLikeFunction · 0.45
CreatePersonalAgentFunction · 0.45
AddAgentsToGroupFunction · 0.45
AddResourcesToGroupFunction · 0.45
BatchAddUsersToGroupFunction · 0.45
CreatePipelineMethod · 0.45
CreateStrategyMethod · 0.45

Calls 6

respErrFunction · 0.85
GetEIDMethod · 0.80
ToResponseMethod · 0.80
ErrorfMethod · 0.80
CreateApprovalMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected