feat: 迁移plant
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type CreateBadgeConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateBadgeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateBadgeConfigLogic {
|
||||
return &CreateBadgeConfigLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateBadgeConfigLogic) CreateBadgeConfig(req *types.CreateBadgeConfigReq) error {
|
||||
_, err := l.svcCtx.PlantRpc.CreateBadgeConfig(l.ctx, &plantPb.CreateBadgeConfigReq{
|
||||
Name: req.Name, Description: req.Description, Dimension: req.Dimension,
|
||||
GroupId: req.GroupId, Tier: int32(req.Tier), TargetAction: req.TargetAction,
|
||||
Threshold: req.Threshold, RewardSunlight: req.RewardSunlight, IconId: req.IconId, Sort: int32(req.Sort),
|
||||
})
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type CreateLevelConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateLevelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLevelConfigLogic {
|
||||
return &CreateLevelConfigLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreateLevelConfigLogic) CreateLevelConfig(req *types.CreateLevelConfigReq) error {
|
||||
_, err := l.svcCtx.PlantRpc.CreateLevelConfig(l.ctx, &plantPb.CreateLevelConfigReq{
|
||||
Level: int32(req.Level), Title: req.Title, MinSunlight: req.MinSunlight, Perks: req.Perks,
|
||||
})
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type DeleteBadgeConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteBadgeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteBadgeConfigLogic {
|
||||
return &DeleteBadgeConfigLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteBadgeConfigLogic) DeleteBadgeConfig(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.PlantRpc.DeleteBadgeConfig(l.ctx, &plantPb.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type DeleteLevelConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteLevelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLevelConfigLogic {
|
||||
return &DeleteLevelConfigLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteLevelConfigLogic) DeleteLevelConfig(req *types.IdsReq) error {
|
||||
_, err := l.svcCtx.PlantRpc.DeleteLevelConfig(l.ctx, &plantPb.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -27,8 +28,17 @@ func NewGetBadgeConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetBadgeConfigListLogic) GetBadgeConfigList(req *types.BadgeConfigListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
func (l *GetBadgeConfigListLogic) GetBadgeConfigList(req *types.BadgeConfigListReq) (interface{}, error) {
|
||||
result, err := l.svcCtx.PlantRpc.GetBadgeConfigList(l.ctx, &plant.BadgeConfigListReq{
|
||||
Current: int32(req.Current),
|
||||
PageSize: int32(req.PageSize),
|
||||
Dimension: req.Dimension,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"list": result.List,
|
||||
"total": result.Total,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -27,8 +28,15 @@ func NewGetLevelConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetLevelConfigListLogic) GetLevelConfigList(req *types.LevelConfigListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
func (l *GetLevelConfigListLogic) GetLevelConfigList(req *types.LevelConfigListReq) (interface{}, error) {
|
||||
result, err := l.svcCtx.PlantRpc.GetLevelConfigList(l.ctx, &plant.PageReq{
|
||||
Current: int32(req.Current),
|
||||
PageSize: int32(req.PageSize),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"list": result.List,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type UpdateBadgeConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateBadgeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBadgeConfigLogic {
|
||||
return &UpdateBadgeConfigLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateBadgeConfigLogic) UpdateBadgeConfig(req *types.UpdateBadgeConfigReq) error {
|
||||
_, err := l.svcCtx.PlantRpc.UpdateBadgeConfig(l.ctx, &plantPb.UpdateBadgeConfigReq{
|
||||
Id: req.Id, Name: req.Name, Description: req.Description, Dimension: req.Dimension,
|
||||
GroupId: req.GroupId, Tier: int32(req.Tier), TargetAction: req.TargetAction,
|
||||
Threshold: req.Threshold, RewardSunlight: req.RewardSunlight, IconId: req.IconId, Sort: int32(req.Sort),
|
||||
})
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type UpdateLevelConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateLevelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLevelConfigLogic {
|
||||
return &UpdateLevelConfigLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateLevelConfigLogic) UpdateLevelConfig(req *types.UpdateLevelConfigReq) error {
|
||||
_, err := l.svcCtx.PlantRpc.UpdateLevelConfig(l.ctx, &plantPb.UpdateLevelConfigReq{
|
||||
Id: req.Id, Level: int32(req.Level), Title: req.Title, MinSunlight: req.MinSunlight, Perks: req.Perks,
|
||||
})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user