feat: 迁移plant
This commit is contained in:
@@ -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"
|
||||
)
|
||||
@@ -28,7 +29,13 @@ func NewCreateTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
|
||||
}
|
||||
|
||||
func (l *CreateTopicLogic) CreateTopic(req *types.TopicReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
name := req.Name
|
||||
if name == "" {
|
||||
name = req.Title
|
||||
}
|
||||
_, err := l.svcCtx.PlantRpc.CreateTopic(l.ctx, &plant.CreateTopicReq{
|
||||
Name: name, Icon: req.Icon, Desc: req.Desc,
|
||||
Title: req.Title, Remark: req.Remark, StartTime: req.StartTime, EndTime: req.EndTime,
|
||||
})
|
||||
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"
|
||||
)
|
||||
@@ -28,7 +29,6 @@ func NewDeleteTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
|
||||
}
|
||||
|
||||
func (l *DeleteTopicLogic) DeleteTopic(req *types.IdsReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
_, err := l.svcCtx.PlantRpc.DeleteTopic(l.ctx, &plant.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
)
|
||||
|
||||
type GetTopicListLogic struct {
|
||||
@@ -25,8 +26,10 @@ func NewGetTopicListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetT
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetTopicListLogic) GetTopicList() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
func (l *GetTopicListLogic) GetTopicList() (interface{}, error) {
|
||||
result, err := l.svcCtx.PlantRpc.GetTopicList(l.ctx, &plant.IdReq{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]interface{}{"list": result.List}, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package topic
|
||||
|
||||
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 GetTopicDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetTopicDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTopicDetailLogic {
|
||||
return &GetTopicDetailLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetTopicDetailLogic) GetTopicDetail(req *types.IdPathReq) (*plantPb.TopicInfo, error) {
|
||||
return l.svcCtx.PlantRpc.GetTopicDetail(l.ctx, &plantPb.IdReq{Id: req.Id})
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package topic
|
||||
|
||||
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 UpdateTopicLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateTopicLogic {
|
||||
return &UpdateTopicLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateTopicLogic) UpdateTopic(req *types.UpdateTopicReq) error {
|
||||
name := req.Name
|
||||
if name == "" {
|
||||
name = req.Title
|
||||
}
|
||||
_, err := l.svcCtx.PlantRpc.UpdateTopic(l.ctx, &plantPb.UpdateTopicReq{
|
||||
Id: req.Id, Name: name, Icon: req.Icon, Desc: req.Desc,
|
||||
Title: req.Title, Remark: req.Remark, StartTime: req.StartTime, EndTime: req.EndTime,
|
||||
})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user