优化结构
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"kra/internal/biz/system"
|
||||
dataprovider "kra/internal/data/provider"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -11,10 +12,7 @@ import (
|
||||
|
||||
// DatabaseProvider is the smaller seam used by security settings, which also
|
||||
// need to work before the primary database is initialized.
|
||||
type DatabaseProvider interface {
|
||||
DB() *gorm.DB
|
||||
DatabaseReady() bool
|
||||
}
|
||||
type DatabaseProvider = dataprovider.Database
|
||||
|
||||
type SecurityConfigPO struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
@@ -62,9 +60,7 @@ func securityToPO(v *system.SecurityConfig) SecurityConfigPO {
|
||||
|
||||
func (r *securityRepo) SecurityConfig(ctx context.Context) (*system.SecurityConfig, error) {
|
||||
if !r.data.DatabaseReady() {
|
||||
po := DefaultSecurityConfig()
|
||||
po.ID = 0
|
||||
return securityFromPO(po), errors.New("数据库未初始化")
|
||||
return nil, errors.New("数据库未初始化")
|
||||
}
|
||||
db := r.data.DB().WithContext(ctx)
|
||||
var po SecurityConfigPO
|
||||
|
||||
Reference in New Issue
Block a user