feat(api-key): 增加 API Key 上次使用时间并补齐测试
This commit is contained in:
@@ -134,6 +134,26 @@ func (_u *APIKeyUpdate) SetNillableStatus(v *string) *APIKeyUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastUsedAt sets the "last_used_at" field.
|
||||
func (_u *APIKeyUpdate) SetLastUsedAt(v time.Time) *APIKeyUpdate {
|
||||
_u.mutation.SetLastUsedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
|
||||
func (_u *APIKeyUpdate) SetNillableLastUsedAt(v *time.Time) *APIKeyUpdate {
|
||||
if v != nil {
|
||||
_u.SetLastUsedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastUsedAt clears the value of the "last_used_at" field.
|
||||
func (_u *APIKeyUpdate) ClearLastUsedAt() *APIKeyUpdate {
|
||||
_u.mutation.ClearLastUsedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIPWhitelist sets the "ip_whitelist" field.
|
||||
func (_u *APIKeyUpdate) SetIPWhitelist(v []string) *APIKeyUpdate {
|
||||
_u.mutation.SetIPWhitelist(v)
|
||||
@@ -390,6 +410,12 @@ func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(apikey.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.LastUsedAt(); ok {
|
||||
_spec.SetField(apikey.FieldLastUsedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.LastUsedAtCleared() {
|
||||
_spec.ClearField(apikey.FieldLastUsedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.IPWhitelist(); ok {
|
||||
_spec.SetField(apikey.FieldIPWhitelist, field.TypeJSON, value)
|
||||
}
|
||||
@@ -655,6 +681,26 @@ func (_u *APIKeyUpdateOne) SetNillableStatus(v *string) *APIKeyUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastUsedAt sets the "last_used_at" field.
|
||||
func (_u *APIKeyUpdateOne) SetLastUsedAt(v time.Time) *APIKeyUpdateOne {
|
||||
_u.mutation.SetLastUsedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
|
||||
func (_u *APIKeyUpdateOne) SetNillableLastUsedAt(v *time.Time) *APIKeyUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetLastUsedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastUsedAt clears the value of the "last_used_at" field.
|
||||
func (_u *APIKeyUpdateOne) ClearLastUsedAt() *APIKeyUpdateOne {
|
||||
_u.mutation.ClearLastUsedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIPWhitelist sets the "ip_whitelist" field.
|
||||
func (_u *APIKeyUpdateOne) SetIPWhitelist(v []string) *APIKeyUpdateOne {
|
||||
_u.mutation.SetIPWhitelist(v)
|
||||
@@ -941,6 +987,12 @@ func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err erro
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(apikey.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.LastUsedAt(); ok {
|
||||
_spec.SetField(apikey.FieldLastUsedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.LastUsedAtCleared() {
|
||||
_spec.ClearField(apikey.FieldLastUsedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.IPWhitelist(); ok {
|
||||
_spec.SetField(apikey.FieldIPWhitelist, field.TypeJSON, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user