feat: 初次启动

This commit is contained in:
Blizzard
2026-04-27 21:23:13 +08:00
parent e515f6a287
commit bb8ad4d515
148 changed files with 8602 additions and 5678 deletions
@@ -0,0 +1,34 @@
package logic
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
sysModel "sundynix-micro-go/app/system/model"
"sundynix-micro-go/app/system/rpc/internal/svc"
"sundynix-micro-go/app/system/rpc/system"
)
type CreateRoleLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRoleLogic {
return &CreateRoleLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
}
func (l *CreateRoleLogic) CreateRole(in *system.RoleReq) (*system.CommonResp, error) {
role := sysModel.SundynixRole{Name: in.Name, Code: in.Code, Sort: int(in.Sort)}
if err := l.svcCtx.DB.Create(&role).Error; err != nil {
return nil, fmt.Errorf("创建角色失败")
}
// 关联菜单
if len(in.MenuIds) > 0 {
for _, mid := range in.MenuIds {
l.svcCtx.DB.Create(&sysModel.SundynixRoleMenu{RoleID: role.ID, MenuID: mid})
}
}
return &system.CommonResp{Code: 200, Msg: "success"}, nil
}