带阿里标识的版本
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user