32 lines
966 B
Go
32 lines
966 B
Go
package myPlant
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"sundynix-micro-go/app/plant/api/internal/svc"
|
|
"sundynix-micro-go/app/plant/api/internal/types"
|
|
"sundynix-micro-go/app/plant/rpc/plant"
|
|
)
|
|
|
|
type GetMyPlantListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetMyPlantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMyPlantListLogic {
|
|
return &GetMyPlantListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
|
}
|
|
|
|
func (l *GetMyPlantListLogic) GetMyPlantList(req *types.PlantListReq) (resp interface{}, err error) {
|
|
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
|
result, err := l.svcCtx.PlantRpc.GetPlantList(l.ctx, &plant.PlantListReq{
|
|
UserId: userId, Current: int32(req.Current), PageSize: int32(req.PageSize), Name: req.Name,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]interface{}{"list": result.List, "total": result.Total}, nil
|
|
}
|