package hubrpc

import (
	"context"

	clitypes "gitlink.org.cn/cloudream/jcs-pub/client/types"
	"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
	stgtypes "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage/types"
)

type UserSpaceSvc interface {
	PublicStoreListAll(ctx context.Context, req *PublicStoreListAll) (*PublicStoreListAllResp, *rpc.CodeError)
	PublicStoreMkdirs(ctx context.Context, req *PublicStoreMkdirs) (*PublicStoreMkdirsResp, *rpc.CodeError)
}

// 列出指定PublicStore的指定位置内的所有文件
type PublicStoreListAll struct {
	UserSpace clitypes.UserSpaceDetail
	Path      string
}
type PublicStoreListAllResp struct {
	Entries []stgtypes.PublicStoreEntry
}

func (c *Client) PublicStoreListAll(ctx context.Context, req *PublicStoreListAll) (*PublicStoreListAllResp, *rpc.CodeError) {
	if c.fusedErr != nil {
		return nil, c.fusedErr
	}
	return rpc.UnaryClient[*PublicStoreListAllResp](c.cli.PublicStoreListAll, ctx, req)
}
func (s *Server) PublicStoreListAll(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
	return rpc.UnaryServer(s.svrImpl.PublicStoreListAll, ctx, req)
}

// 批量在指定PublicStore中创建文件夹
type PublicStoreMkdirs struct {
	UserSpace clitypes.UserSpaceDetail
	Pathes    []string
}

type PublicStoreMkdirsResp struct {
	Successes []bool
}

func (c *Client) PublicStoreMkdirs(ctx context.Context, req *PublicStoreMkdirs) (*PublicStoreMkdirsResp, *rpc.CodeError) {
	if c.fusedErr != nil {
		return nil, c.fusedErr
	}
	return rpc.UnaryClient[*PublicStoreMkdirsResp](c.cli.PublicStoreMkdirs, ctx, req)
}
func (s *Server) PublicStoreMkdirs(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
	return rpc.UnaryServer(s.svrImpl.PublicStoreMkdirs, ctx, req)
}
