package controller

import (
	"context"
	"fmt"
	"github.com/fonchain/fonchain-artistinfo/cmd/internal/old/logic"
	artwork2 "github.com/fonchain/fonchain-artistinfo/pb/old/artwork"
)

type ArtWorkProvider struct {
	artwork2.UnimplementedArtworkServer
	artWorkLogic *logic.Artwork
}

func (a *ArtWorkProvider) ArtworkAdd(ctx context.Context, req *artwork2.ArtworkAddRequest) (rep *artwork2.ArtworkAddRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.ArtworkAdd(req); err != nil {
		return nil, err
	}
	return rep, nil
}

func (a *ArtWorkProvider) UpdateArtwork(ctx context.Context, req *artwork2.UpdateArtworkRequest) (rep *artwork2.UpdateArtworkRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.UpdateArtwork(req); err != nil {
		return nil, err
	}
	return rep, nil
}

func (a *ArtWorkProvider) DelArtwork(ctx context.Context, req *artwork2.DelArtworkRequest) (rep *artwork2.DelArtworkRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.DelArtwork(req); err != nil {
		return nil, err
	}
	return rep, nil
}

func (a *ArtWorkProvider) GetArtworkList(ctx context.Context, req *artwork2.GetArtworkListRequest) (rep *artwork2.GetArtworkListRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.GetArtworkList(req); err != nil {
		return nil, err
	}
	return rep, nil
}

func (a *ArtWorkProvider) GetArtwork(ctx context.Context, req *artwork2.GetArtworkRequest) (rep *artwork2.GetArtworkRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.GetArtwork(req); err != nil {
		return nil, err
	}
	return rep, nil
}

func (a *ArtWorkProvider) UploadArtwork(ctx context.Context, req *artwork2.UploadArtworkRequest) (rep *artwork2.UploadArtworkRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.UploadArtwork(req); err != nil {
		return nil, err
	}
	return rep, nil
}

func (a *ArtWorkProvider) ApproveArtwork(ctx context.Context, req *artwork2.ApproveArtworkRequest) (rep *artwork2.ApproveArtworkRespond, err error) {
	fmt.Println("第一处")
	if rep, err = a.artWorkLogic.ApproveArtwork(req); err != nil {
		return nil, err
	}
	return rep, nil
}
