package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	plantModel "sundynix-micro-go/app/plant/model"
	"sundynix-micro-go/app/plant/rpc/internal/svc"
	"sundynix-micro-go/app/plant/rpc/plant"
)

type GetWikiClassDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetWikiClassDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiClassDetailLogic {
	return &GetWikiClassDetailLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
}

func (l *GetWikiClassDetailLogic) GetWikiClassDetail(in *plant.IdReq) (*plant.WikiClassInfo, error) {
	var wc plantModel.WikiClass
	if err := l.svcCtx.DB.First(&wc, "id = ?", in.Id).Error; err != nil {
		return nil, err
	}
	return &plant.WikiClassInfo{Id: wc.ID, Name: wc.Name, OssId: wc.OssID}, nil
}
