setup

package
v0.33.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAdminUsernameExists = errors.New("用户名已存在")
	ErrAdminEmailExists    = errors.New("邮箱已存在")
	ErrAlreadyInitialized  = errors.New("系统已初始化,禁止重复初始化")
)

系统初始化的**业务拒绝**哨兵错误:撞名/重复初始化是客户端可见的冲突 (409),不是服务端故障。2026-11-02 与 user 注册面同批收口(此前 handler 一律映射 500「系统初始化失败」)。

View Source
var OnInitialized func()

OnInitialized 首启成功后的回调(由装配层注入)。

用途:首启面关闭时做**收尾**动作——当前唯一消费方是 bootstrap 清理 一次性首启令牌(进程内 + 数据目录下的 .setup_token 文件)。

为何用钩子而不是直接 import bootstrap:app/setup 是领域服务,反向依赖 装配层会成环(bootstrap 已 import app/setup)。

Functions

This section is empty.

Types

type InitializeSystemReq

type InitializeSystemReq struct {
	AdminUsername string
	AdminPassword string
	AdminEmail    string
}

InitializeSystemReq 系统初始化请求

type Service

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

func NewService

func NewService(gormDB *gorm.DB) *Service

func (*Service) InitializeSystem

func (s *Service) InitializeSystem(ctx context.Context, req *InitializeSystemReq) error

InitializeSystem 初始化系统,创建第一个管理员

func (*Service) IsSystemInitialized

func (s *Service) IsSystemInitialized(ctx context.Context) (bool, error)

IsSystemInitialized 检查系统是否已初始化 通过检查是否存在管理员用户来判断

Jump to

Keyboard shortcuts

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