package auth

import (
	"context"
	"server/internal/model"
	"server/internal/service"

	"server/api/auth/v1"
)

func (c *ControllerV1) AdminLogin(ctx context.Context, req *v1.AdminLoginReq) (res *v1.AdminLoginRes, err error) {
	out, err := service.Admin().Login(ctx, &model.AdminLoginIn{Username: req.Username, Password: req.Password})
	if err != nil {
		return nil, err
	}
	return &v1.AdminLoginRes{Token: out.Token}, nil
}
