带阿里标识的版本

This commit is contained in:
robin
2026-02-28 18:55:33 +08:00
parent 150799f41d
commit 5d0b7c7e91
477 changed files with 10813 additions and 4044 deletions

View File

@@ -38,6 +38,27 @@ func init() {
func (this *HTTPDNSAppSecretDAO) InitAppSecret(tx *dbs.Tx, appDbId int64, signEnabled bool) (string, uint64, error) {
signSecret := "ss_" + rands.HexString(12)
now := uint64(time.Now().Unix())
// 兼容历史数据:如果已存在(可能是停用状态)则直接恢复并更新,避免 UNIQUE(appId) 冲突
old, err := this.Query(tx).
Attr("appId", appDbId).
Find()
if err != nil {
return "", 0, err
}
if old != nil {
oldSecret := old.(*HTTPDNSAppSecret)
_, err = this.Query(tx).
Pk(oldSecret.Id).
Set("signEnabled", signEnabled).
Set("signSecret", signSecret).
Set("signUpdatedAt", now).
Set("updatedAt", now).
Set("state", HTTPDNSAppSecretStateEnabled).
Update()
return signSecret, now, err
}
var op = NewHTTPDNSAppSecretOperator()
op.AppId = appDbId
op.SignEnabled = signEnabled
@@ -45,7 +66,7 @@ func (this *HTTPDNSAppSecretDAO) InitAppSecret(tx *dbs.Tx, appDbId int64, signEn
op.SignUpdatedAt = now
op.UpdatedAt = now
op.State = HTTPDNSAppSecretStateEnabled
err := this.Save(tx, op)
err = this.Save(tx, op)
return signSecret, now, err
}