feat: 迁移plant
This commit is contained in:
@@ -2,7 +2,9 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
@@ -23,9 +25,32 @@ func NewGetTopicListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetT
|
||||
}
|
||||
}
|
||||
|
||||
// 话题
|
||||
// 话题列表
|
||||
func (l *GetTopicListLogic) GetTopicList(in *plant.IdReq) (*plant.TopicListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.TopicListResp{}, nil
|
||||
var list []plantModel.Topic
|
||||
if err := l.svcCtx.DB.Order("post_count desc").Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []*plant.TopicInfo
|
||||
for _, item := range list {
|
||||
start, end := "", ""
|
||||
if item.StartTime != nil {
|
||||
start = item.StartTime.Format(time.DateTime)
|
||||
}
|
||||
if item.EndTime != nil {
|
||||
end = item.EndTime.Format(time.DateTime)
|
||||
}
|
||||
result = append(result, &plant.TopicInfo{
|
||||
Id: item.ID,
|
||||
Name: item.Name,
|
||||
PostCount: int32(item.PostCount),
|
||||
Icon: item.Icon,
|
||||
Desc: item.Desc,
|
||||
Title: item.Title,
|
||||
Remark: item.Remark,
|
||||
StartTime: start,
|
||||
EndTime: end,
|
||||
})
|
||||
}
|
||||
return &plant.TopicListResp{List: result}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user