package author

import (
	"context"
	v1 "server/api/author/v1"
	"server/internal/model"
	"server/internal/service"
)

func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
	out, err := service.Author().List(ctx, &model.AuthorListIn{
		Page:    req.Page,
		Size:    req.Size,
		PenName: req.PenName,
		Status:  req.Status,
	})
	if err != nil {
		return nil, err
	}

	return &v1.ListRes{
		Total: out.Total,
		List:  out.List,
	}, nil
}
