MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / CreateMenu

Method CreateMenu

internal/api/menu.go:59–86  ·  view source on GitHub ↗

CreateMenu 创建菜单

(c *gin.Context)

Source from the content-addressed store, hash-verified

57
58// CreateMenu 创建菜单
59func (m *MenuHandler) CreateMenu(c *gin.Context) {
60 var req req.CreateMenuRequest
61 if err := c.ShouldBindJSON(&req); err != nil {
62 m.l.Error("绑定请求参数失败", zap.Error(err))
63 apiresponse.Error(c)
64 return
65 }
66
67 // 构建菜单对象
68 menu := &domain.Menu{
69 Name: req.Name,
70 Path: req.Path,
71 Component: req.Component,
72 SortOrder: req.SortOrder,
73 ParentID: req.ParentId,
74 Icon: req.Icon,
75 Hidden: req.Hidden,
76 RouteName: req.RouteName,
77 }
78
79 if err := m.svc.CreateMenu(c.Request.Context(), menu); err != nil {
80 m.l.Error("创建菜单失败", zap.Error(err))
81 apiresponse.Error(c)
82 return
83 }
84
85 apiresponse.Success(c)
86}
87
88// UpdateMenu 更新菜单
89func (m *MenuHandler) UpdateMenu(c *gin.Context) {

Callers

nothing calls this directly

Calls 3

ErrorFunction · 0.92
SuccessFunction · 0.92
CreateMenuMethod · 0.65

Tested by

no test coverage detected