init: init refactor

This commit is contained in:
Blizzard
2026-04-27 00:02:18 +08:00
commit e515f6a287
360 changed files with 30713 additions and 0 deletions
@@ -0,0 +1,61 @@
// Code scaffolded by goctl. Safe to edit.
package menu
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/system/api/internal/svc"
"sundynix-micro-go/app/system/api/internal/types"
sysModel "sundynix-micro-go/app/system/model"
)
type UpdateMenuLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUpdateMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateMenuLogic {
return &UpdateMenuLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}
func (l *UpdateMenuLogic) UpdateMenu(req *types.MenuUpdateReq) error {
updates := map[string]interface{}{}
if req.ParentId != "" {
updates["parent_id"] = req.ParentId
}
if req.Name != "" {
updates["name"] = req.Name
}
if req.Title != "" {
updates["title"] = req.Title
}
if req.Code != "" {
updates["code"] = req.Code
}
if req.Path != "" {
updates["path"] = req.Path
}
if req.Permission != "" {
updates["permission"] = req.Permission
}
if req.Locale != "" {
updates["locale"] = req.Locale
}
if req.Icon != "" {
updates["icon"] = req.Icon
}
if req.Sort > 0 {
updates["sort"] = req.Sort
}
if req.Category > 0 {
updates["category"] = req.Category
}
if len(updates) > 0 {
if err := l.svcCtx.DB.Model(&sysModel.SundynixMenu{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
return fmt.Errorf("更新菜单失败")
}
}
return nil
}