Files
go-gin-api/internal/services/menu/service_createaction.go
新亮 4c37a7e6b5 feature(1.2.8): swagger 接口文档新增 Security
- 将 middleware 命名为 interceptor
- 将 deploy 命名为 deployments
- 移除 pkg/errno
- 使用 proposal 目录
- 优化代码
2021-11-28 13:25:27 +08:00

28 lines
785 B
Go

package menu
import (
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/repository/mysql/menu_action"
)
type CreateMenuActionData struct {
MenuId int32 `json:"menu_id"` // 菜单栏ID
Method string `json:"method"` // 请求方法
API string `json:"api"` // 请求地址
}
func (s *service) CreateAction(ctx core.Context, menuActionData *CreateMenuActionData) (id int32, err error) {
model := menu_action.NewModel()
model.MenuId = menuActionData.MenuId
model.Method = menuActionData.Method
model.Api = menuActionData.API
model.CreatedUser = ctx.SessionUserInfo().UserName
model.IsDeleted = -1
id, err = model.Create(s.db.GetDbW().WithContext(ctx.RequestContext()))
if err != nil {
return 0, err
}
return
}