MCPcopy Create free account
hub / github.com/PGshen/thinking-map / CreateNode

Method CreateNode

server/internal/handler/node.go:65–106  ·  view source on GitHub ↗

CreateNode handles creating a new node

(c *gin.Context)

Source from the content-addressed store, hash-verified

63
64// CreateNode handles creating a new node
65func (h *NodeHandler) CreateNode(c *gin.Context) {
66 mapID := c.Param("mapID")
67 if mapID == "" {
68 c.JSON(http.StatusBadRequest, dto.Response{
69 Code: http.StatusBadRequest,
70 Message: "map ID is required",
71 Data: nil,
72 Timestamp: time.Now(),
73 RequestID: uuid.New().String(),
74 })
75 return
76 }
77 var req dto.CreateNodeRequest
78 if err := c.ShouldBindJSON(&req); err != nil {
79 c.JSON(http.StatusBadRequest, dto.Response{
80 Code: http.StatusBadRequest,
81 Message: "invalid request parameters",
82 Data: dto.ErrorData{Error: err.Error()},
83 Timestamp: time.Now(),
84 RequestID: uuid.New().String(),
85 })
86 return
87 }
88 resp, err := h.NodeService.CreateNode(c.Request.Context(), mapID, req)
89 if err != nil {
90 c.JSON(http.StatusInternalServerError, dto.Response{
91 Code: http.StatusInternalServerError,
92 Message: err.Error(),
93 Data: nil,
94 Timestamp: time.Now(),
95 RequestID: uuid.New().String(),
96 })
97 return
98 }
99 c.JSON(http.StatusOK, dto.Response{
100 Code: http.StatusOK,
101 Message: "success",
102 Data: resp,
103 Timestamp: time.Now(),
104 RequestID: uuid.New().String(),
105 })
106}
107
108// UpdateNode handles updating a node
109func (h *NodeHandler) UpdateNode(c *gin.Context) {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.80

Tested by

no test coverage detected