package base_organ_school

import (
	"context"
	"git.i2edu.net/i2/i2-bill-erp/transform"

	"git.i2edu.net/i2/i2-bill-api/internal/svc"
	"git.i2edu.net/i2/i2-bill-api/internal/types"

	"git.i2edu.net/i2/go-zero/core/logx"
)

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

func NewGetErpSchTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetErpSchTreeLogic {
	return GetErpSchTreeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetErpSchTreeLogic) GetErpSchTree() (*types.Response, error) {
	// todo: add your logic here and delete this line
	res, err := l.svcCtx.GetErpOrganSchoolTree(l.ctx)
	if err != nil {
		logx.Error(err.Error())
		return &types.Response{500, err.Error(), nil}, nil
	}
	return &types.Response{200, "", transform.TreeNodes{Nodes: res}}, nil
}
