50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
|
|
package config
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"muyu-apiserver/gateway/internal/svc"
|
||
|
|
"muyu-apiserver/gateway/internal/types"
|
||
|
|
"muyu-apiserver/rpc/system/pb"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type ListConfigLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewListConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListConfigLogic {
|
||
|
|
return &ListConfigLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *ListConfigLogic) ListConfig() (resp *types.ListConfigResp, err error) {
|
||
|
|
rpcResp, err := l.svcCtx.SystemRpc.ListConfig(l.ctx, &pb.ListConfigReq{})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
list := make([]types.ConfigInfo, 0, len(rpcResp.List))
|
||
|
|
for _, c := range rpcResp.List {
|
||
|
|
list = append(list, types.ConfigInfo{
|
||
|
|
ConfigId: c.ConfigId,
|
||
|
|
ConfigKey: c.ConfigKey,
|
||
|
|
ConfigValue: c.ConfigValue,
|
||
|
|
ConfigName: c.ConfigName,
|
||
|
|
ConfigGroup: c.ConfigGroup,
|
||
|
|
Remark: c.Remark,
|
||
|
|
UpdatedAt: c.UpdatedAt,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
return &types.ListConfigResp{
|
||
|
|
List: list,
|
||
|
|
}, nil
|
||
|
|
}
|