32 lines
874 B
Go
32 lines
874 B
Go
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
|
|
}
|