usecase

package
v0.0.0-...-1f1dc5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package usecase coordinates system first initialization.

Index

Constants

View Source
const (
	// DefaultSiteName is used when setup does not provide a site name.
	DefaultSiteName = "Echo Admin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FirstAdministrator

type FirstAdministrator struct {
	Username     string
	DisplayName  string
	Email        string
	PasswordHash []byte
	RootRoleID   int64
}

FirstAdministrator is the normalized administrator created during setup.

type InitialSettings

type InitialSettings struct {
	SiteName string
}

InitialSettings contains the setup-owned initial setting values.

type RootRole

type RootRole struct {
	ID   int64
	Code string
}

RootRole is the minimal root-role identity setup needs for first admin creation.

type State

type State struct {
	Initialized bool `json:"initialized"`
}

State is the public setup-state DTO.

type StateReader

type StateReader interface {
	Initialized(context.Context) (bool, error)
}

StateReader reads persistent installation state.

type SubmitInput

type SubmitInput struct {
	Username    string
	DisplayName string
	Email       string
	Password    string
	SiteName    string
}

SubmitInput carries the setup form fields.

type Transaction

type Transaction interface {
	RequireOpenInstallation(context.Context) error
	InstallRootAuthorization(context.Context) (RootRole, error)
	CreateFirstAdministrator(context.Context, FirstAdministrator) error
	InstallInitialSettings(context.Context, InitialSettings) error
	CompleteInstallation(context.Context) error
}

Transaction contains the setup-owned write capabilities required inside the first-initialization transaction.

type TransactionRunner

type TransactionRunner interface {
	RunInitialization(context.Context, func(context.Context, Transaction) error) error
}

TransactionRunner executes setup writes in one database transaction.

type Usecase

type Usecase struct {
	// contains filtered or unexported fields
}

Usecase coordinates the one-time first-initialization workflow.

func New

func New(state StateReader, runner TransactionRunner) *Usecase

New creates a setup usecase.

func (*Usecase) State

func (u *Usecase) State(ctx context.Context) (State, error)

State returns whether setup has completed.

func (*Usecase) Submit

func (u *Usecase) Submit(ctx context.Context, input SubmitInput) (State, error)

Submit performs the one-time system first initialization.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL