feat: 初次启动
This commit is contained in:
@@ -0,0 +1,536 @@
|
||||
#!/bin/bash
|
||||
# 批量生成 system-api logic,全部改为调用 SystemRpc
|
||||
BASE="/Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/system/api/internal/logic"
|
||||
|
||||
# Helper function
|
||||
gen() {
|
||||
local dir="$1" file="$2" content="$3"
|
||||
mkdir -p "$BASE/$dir"
|
||||
echo "$content" > "$BASE/$dir/$file"
|
||||
}
|
||||
|
||||
# ===== Client =====
|
||||
gen client createClientLogic.go 'package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateClientLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateClientLogic {
|
||||
return &CreateClientLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateClientLogic) CreateClient(req *types.ClientReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.CreateClient(l.ctx, &system.ClientReq{
|
||||
ClientId: req.ClientId, Name: req.Name, GrantType: req.GrantType,
|
||||
AdditionalInfo: req.AdditionalInfo, ActiveTimeout: req.ActiveTimeout,
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen client updateClientLogic.go 'package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateClientLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClientLogic {
|
||||
return &UpdateClientLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateClientLogic) UpdateClient(req *types.ClientUpdateReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.UpdateClient(l.ctx, &system.ClientUpdateReq{
|
||||
Id: req.Id, ClientId: req.ClientId, Name: req.Name, GrantType: req.GrantType,
|
||||
AdditionalInfo: req.AdditionalInfo, ActiveTimeout: req.ActiveTimeout,
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen client deleteClientLogic.go 'package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteClientLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClientLogic {
|
||||
return &DeleteClientLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteClientLogic) DeleteClient(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.DeleteClient(l.ctx, &system.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen client getClientListLogic.go 'package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetClientListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetClientListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClientListLogic {
|
||||
return &GetClientListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetClientListLogic) GetClientList(req *types.ClientListReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetClientList(l.ctx, &system.ClientListReq{
|
||||
Current: int32(req.Current), PageSize: int32(req.PageSize), Name: req.Name,
|
||||
})
|
||||
if err != nil { return nil, err }
|
||||
return map[string]interface{}{"list": resp.List, "total": resp.Total, "current": req.Current, "size": req.PageSize}, nil
|
||||
}'
|
||||
|
||||
echo "===Client done==="
|
||||
|
||||
# ===== Role =====
|
||||
gen role createRoleLogic.go 'package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRoleLogic {
|
||||
return &CreateRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateRoleLogic) CreateRole(req *types.RoleReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.CreateRole(l.ctx, &system.RoleReq{
|
||||
Name: req.Name, Code: req.Code, Sort: int32(req.Sort), MenuIds: req.MenuIds,
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen role updateRoleLogic.go 'package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRoleLogic {
|
||||
return &UpdateRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateRoleLogic) UpdateRole(req *types.RoleUpdateReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.UpdateRole(l.ctx, &system.RoleUpdateReq{
|
||||
Id: req.Id, Name: req.Name, Code: req.Code, Sort: int32(req.Sort), MenuIds: req.MenuIds,
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen role deleteRoleLogic.go 'package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRoleLogic {
|
||||
return &DeleteRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteRoleLogic) DeleteRole(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.DeleteRole(l.ctx, &system.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen role getRoleListLogic.go 'package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetRoleListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetRoleListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleListLogic {
|
||||
return &GetRoleListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetRoleListLogic) GetRoleList(req *types.RoleListReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetRoleList(l.ctx, &system.RoleListReq{
|
||||
Current: int32(req.Current), PageSize: int32(req.PageSize), Name: req.Name,
|
||||
})
|
||||
if err != nil { return nil, err }
|
||||
return map[string]interface{}{"list": resp.List, "total": resp.Total}, nil
|
||||
}'
|
||||
|
||||
echo "===Role done==="
|
||||
|
||||
# ===== Menu =====
|
||||
gen menu createMenuLogic.go 'package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateMenuLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMenuLogic {
|
||||
return &CreateMenuLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateMenuLogic) CreateMenu(req *types.MenuReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.CreateMenu(l.ctx, &system.MenuReq{
|
||||
ParentId: req.ParentId, Category: int32(req.Category), Name: req.Name, Title: req.Title,
|
||||
Code: req.Code, Path: req.Path, Permission: req.Permission, Locale: req.Locale,
|
||||
Icon: req.Icon, Sort: int32(req.Sort),
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen menu updateMenuLogic.go 'package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
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 {
|
||||
_, err := l.svcCtx.SystemRpc.UpdateMenu(l.ctx, &system.MenuUpdateReq{
|
||||
Id: req.Id, ParentId: req.ParentId, Category: int32(req.Category), Name: req.Name, Title: req.Title,
|
||||
Code: req.Code, Path: req.Path, Permission: req.Permission, Locale: req.Locale,
|
||||
Icon: req.Icon, Sort: int32(req.Sort),
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen menu deleteMenuLogic.go 'package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteMenuLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMenuLogic {
|
||||
return &DeleteMenuLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteMenuLogic) DeleteMenu(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.DeleteMenu(l.ctx, &system.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen menu getMenuListLogic.go 'package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetMenuListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetMenuListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuListLogic {
|
||||
return &GetMenuListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetMenuListLogic) GetMenuList() (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetMenuList(l.ctx, &system.IdReq{})
|
||||
if err != nil { return nil, err }
|
||||
return resp.Menus, nil
|
||||
}'
|
||||
|
||||
gen menu getMenuByRoleLogic.go 'package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetMenuByRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetMenuByRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuByRoleLogic {
|
||||
return &GetMenuByRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetMenuByRoleLogic) GetMenuByRole(req *types.MenuByRoleReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetMenusByRoleId(l.ctx, &system.GetMenusByRoleIdReq{RoleId: req.RoleId})
|
||||
if err != nil { return nil, err }
|
||||
return resp.Menus, nil
|
||||
}'
|
||||
|
||||
echo "===Menu done==="
|
||||
|
||||
# ===== Dict =====
|
||||
gen dict createDictLogic.go 'package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateDictLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDictLogic {
|
||||
return &CreateDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateDictLogic) CreateDict(req *types.DictReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.CreateDict(l.ctx, &system.DictReq{
|
||||
Type: req.Type, Label: req.Label, Value: req.Value, Sort: int32(req.Sort), Desc: req.Desc,
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen dict updateDictLogic.go 'package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateDictLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDictLogic {
|
||||
return &UpdateDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateDictLogic) UpdateDict(req *types.DictUpdateReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.UpdateDict(l.ctx, &system.DictUpdateReq{
|
||||
Id: req.Id, Type: req.Type, Label: req.Label, Value: req.Value, Sort: int32(req.Sort), Desc: req.Desc,
|
||||
})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen dict deleteDictLogic.go 'package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteDictLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictLogic {
|
||||
return &DeleteDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteDictLogic) DeleteDict(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.DeleteDict(l.ctx, &system.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen dict getDictListLogic.go 'package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDictListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetDictListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictListLogic {
|
||||
return &GetDictListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetDictListLogic) GetDictList(req *types.DictListReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetDictList(l.ctx, &system.DictListReq{
|
||||
Current: int32(req.Current), PageSize: int32(req.PageSize), Type: req.Type,
|
||||
})
|
||||
if err != nil { return nil, err }
|
||||
return map[string]interface{}{"list": resp.List, "total": resp.Total}, nil
|
||||
}'
|
||||
|
||||
echo "===Dict done==="
|
||||
|
||||
# ===== OperationRecord =====
|
||||
gen operationRecord deleteOperationRecordLogic.go 'package operationRecord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteOperationRecordLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteOperationRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOperationRecordLogic {
|
||||
return &DeleteOperationRecordLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteOperationRecordLogic) DeleteOperationRecord(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.DeleteOperationRecord(l.ctx, &system.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}'
|
||||
|
||||
gen operationRecord getOperationRecordListLogic.go 'package operationRecord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/pb/system"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetOperationRecordListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetOperationRecordListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOperationRecordListLogic {
|
||||
return &GetOperationRecordListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetOperationRecordListLogic) GetOperationRecordList(req *types.OperationRecordListReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetOperationRecordList(l.ctx, &system.OperationRecordListReq{
|
||||
Current: int32(req.Current), PageSize: int32(req.PageSize),
|
||||
Method: req.Method, Path: req.Path, Status: int32(req.Status),
|
||||
})
|
||||
if err != nil { return nil, err }
|
||||
return map[string]interface{}{"list": resp.List, "total": resp.Total}, nil
|
||||
}'
|
||||
|
||||
echo "===ALL SYSTEM-API LOGIC DONE==="
|
||||
Executable
+88
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
# Sundynix 微服务启动脚本
|
||||
# 用法: ./scripts/start.sh [服务名]
|
||||
# 例如: ./scripts/start.sh user-rpc
|
||||
# ./scripts/start.sh all (启动所有)
|
||||
# ./scripts/start.sh gateway
|
||||
|
||||
set -e
|
||||
|
||||
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
APP_DIR="$BASE_DIR/app"
|
||||
|
||||
start_service() {
|
||||
local name="$1"
|
||||
local dir="$2"
|
||||
local entry="$3"
|
||||
local config="$4"
|
||||
|
||||
echo "🚀 启动 $name ..."
|
||||
cd "$dir"
|
||||
go run "$entry" -f "$config" &
|
||||
echo " PID: $!"
|
||||
}
|
||||
|
||||
case "${1:-help}" in
|
||||
user-rpc)
|
||||
start_service "user-rpc" "$APP_DIR/user/rpc" "user.go" "etc/user.yaml"
|
||||
;;
|
||||
user-api)
|
||||
start_service "user-api" "$APP_DIR/user/api" "user.go" "etc/user-api.yaml"
|
||||
;;
|
||||
file-rpc)
|
||||
start_service "file-rpc" "$APP_DIR/file/rpc" "file.go" "etc/file.yaml"
|
||||
;;
|
||||
file-api)
|
||||
start_service "file-api" "$APP_DIR/file/api" "file.go" "etc/file-api.yaml"
|
||||
;;
|
||||
system-rpc)
|
||||
start_service "system-rpc" "$APP_DIR/system/rpc" "system.go" "etc/system.yaml"
|
||||
;;
|
||||
system-api)
|
||||
start_service "system-api" "$APP_DIR/system/api" "system.go" "etc/system-api.yaml"
|
||||
;;
|
||||
plant-rpc)
|
||||
start_service "plant-rpc" "$APP_DIR/plant/rpc" "plant.go" "etc/plant.yaml"
|
||||
;;
|
||||
plant-api)
|
||||
start_service "plant-api" "$APP_DIR/plant/api" "plant.go" "etc/plant-api.yaml"
|
||||
;;
|
||||
radio-rpc)
|
||||
start_service "radio-rpc" "$APP_DIR/radio/rpc" "radio.go" "etc/radio.yaml"
|
||||
;;
|
||||
radio-api)
|
||||
start_service "radio-api" "$APP_DIR/radio/api" "radio.go" "etc/radio-api.yaml"
|
||||
;;
|
||||
gateway)
|
||||
start_service "gateway" "$APP_DIR/gateway" "gateway.go" "etc/gateway.yaml"
|
||||
;;
|
||||
all)
|
||||
echo "===== 启动 RPC 层 ====="
|
||||
start_service "user-rpc" "$APP_DIR/user/rpc" "user.go" "etc/user.yaml"
|
||||
start_service "file-rpc" "$APP_DIR/file/rpc" "file.go" "etc/file.yaml"
|
||||
start_service "system-rpc" "$APP_DIR/system/rpc" "system.go" "etc/system.yaml"
|
||||
start_service "plant-rpc" "$APP_DIR/plant/rpc" "plant.go" "etc/plant.yaml"
|
||||
start_service "radio-rpc" "$APP_DIR/radio/rpc" "radio.go" "etc/radio.yaml"
|
||||
sleep 3
|
||||
echo "===== 启动 API 层 ====="
|
||||
start_service "user-api" "$APP_DIR/user/api" "user.go" "etc/user-api.yaml"
|
||||
start_service "file-api" "$APP_DIR/file/api" "file.go" "etc/file-api.yaml"
|
||||
start_service "system-api" "$APP_DIR/system/api" "system.go" "etc/system-api.yaml"
|
||||
start_service "plant-api" "$APP_DIR/plant/api" "plant.go" "etc/plant-api.yaml"
|
||||
start_service "radio-api" "$APP_DIR/radio/api" "radio.go" "etc/radio-api.yaml"
|
||||
sleep 2
|
||||
echo "===== 启动网关 ====="
|
||||
start_service "gateway" "$APP_DIR/gateway" "gateway.go" "etc/gateway.yaml"
|
||||
echo ""
|
||||
echo "✅ 全部启动完成,按 Ctrl+C 停止所有服务"
|
||||
wait
|
||||
;;
|
||||
stop)
|
||||
echo "停止所有 sundynix 服务..."
|
||||
pkill -f "sundynix-micro-go/app" 2>/dev/null || true
|
||||
echo "✅ 已停止"
|
||||
;;
|
||||
*)
|
||||
echo "用法: $0 {user-rpc|user-api|file-rpc|file-api|system-rpc|system-api|plant-rpc|plant-api|radio-rpc|radio-api|gateway|all|stop}"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user