mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
style(core): align struct tags and fields
Standardize alignment of struct tags in models and field assignments in services for better readability. Additionally, include the Binding model in the test database auto-migration.
This commit is contained in:
@@ -42,16 +42,16 @@ func (s *MasterService) CreateMaster(name, group string, maxChildKeys, globalQPS
|
||||
masterKeyDigest := tokenhash.HashToken(rawMasterKey)
|
||||
|
||||
master := &model.Master{
|
||||
Name: name,
|
||||
MasterKey: string(hashedMasterKey),
|
||||
MasterKeyDigest: masterKeyDigest,
|
||||
Group: group,
|
||||
Name: name,
|
||||
MasterKey: string(hashedMasterKey),
|
||||
MasterKeyDigest: masterKeyDigest,
|
||||
Group: group,
|
||||
DefaultNamespace: "default",
|
||||
Namespaces: "default",
|
||||
MaxChildKeys: maxChildKeys,
|
||||
GlobalQPS: globalQPS,
|
||||
Status: "active",
|
||||
Epoch: 1,
|
||||
MaxChildKeys: maxChildKeys,
|
||||
GlobalQPS: globalQPS,
|
||||
Status: "active",
|
||||
Epoch: 1,
|
||||
}
|
||||
|
||||
if err := s.db.Create(master).Error; err != nil {
|
||||
@@ -147,16 +147,16 @@ func (s *MasterService) issueChildKey(masterID uint, group string, scopes string
|
||||
}
|
||||
|
||||
key := &model.Key{
|
||||
MasterID: masterID,
|
||||
KeySecret: string(hashedChildKey),
|
||||
TokenHash: tokenHash,
|
||||
Group: group,
|
||||
Scopes: scopes,
|
||||
MasterID: masterID,
|
||||
KeySecret: string(hashedChildKey),
|
||||
TokenHash: tokenHash,
|
||||
Group: group,
|
||||
Scopes: scopes,
|
||||
DefaultNamespace: strings.TrimSpace(master.DefaultNamespace),
|
||||
Namespaces: strings.TrimSpace(master.Namespaces),
|
||||
IssuedAtEpoch: master.Epoch,
|
||||
Status: "active",
|
||||
IssuedBy: strings.TrimSpace(issuedBy),
|
||||
IssuedAtEpoch: master.Epoch,
|
||||
Status: "active",
|
||||
IssuedBy: strings.TrimSpace(issuedBy),
|
||||
}
|
||||
if strings.TrimSpace(key.DefaultNamespace) == "" {
|
||||
key.DefaultNamespace = "default"
|
||||
|
||||
@@ -35,11 +35,11 @@ func (s *SyncService) SyncKey(key *model.Key) error {
|
||||
}
|
||||
|
||||
fields := map[string]interface{}{
|
||||
"master_id": key.MasterID,
|
||||
"issued_at_epoch": key.IssuedAtEpoch,
|
||||
"status": key.Status,
|
||||
"group": key.Group,
|
||||
"scopes": key.Scopes,
|
||||
"master_id": key.MasterID,
|
||||
"issued_at_epoch": key.IssuedAtEpoch,
|
||||
"status": key.Status,
|
||||
"group": key.Group,
|
||||
"scopes": key.Scopes,
|
||||
"default_namespace": key.DefaultNamespace,
|
||||
"namespaces": key.Namespaces,
|
||||
}
|
||||
@@ -259,11 +259,11 @@ func (s *SyncService) SyncAll(db *gorm.DB) error {
|
||||
return fmt.Errorf("token hash missing for key %d", k.ID)
|
||||
}
|
||||
pipe.HSet(ctx, fmt.Sprintf("auth:token:%s", tokenHash), map[string]interface{}{
|
||||
"master_id": k.MasterID,
|
||||
"issued_at_epoch": k.IssuedAtEpoch,
|
||||
"status": k.Status,
|
||||
"group": k.Group,
|
||||
"scopes": k.Scopes,
|
||||
"master_id": k.MasterID,
|
||||
"issued_at_epoch": k.IssuedAtEpoch,
|
||||
"status": k.Status,
|
||||
"group": k.Group,
|
||||
"scopes": k.Scopes,
|
||||
"default_namespace": k.DefaultNamespace,
|
||||
"namespaces": k.Namespaces,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user