feat: add expiration handling for database entries and enhance user model with rules

This commit is contained in:
krau
2025-04-12 11:14:13 +08:00
parent 50fba3f910
commit 3bdef20e85
4 changed files with 59 additions and 11 deletions

View File

@@ -37,7 +37,8 @@ type logConfig struct {
}
type dbConfig struct {
Path string `toml:"path" mapstructure:"path"`
Path string `toml:"path" mapstructure:"path"`
Expire int64 `toml:"expire" mapstructure:"expire"`
}
type telegramConfig struct {
@@ -93,6 +94,7 @@ func Init() error {
viper.SetDefault("log.backup_count", 7)
viper.SetDefault("db.path", "data/saveany.db")
viper.SetDefault("db.expire", 86400*5)
if err := viper.SafeWriteConfigAs("config.toml"); err != nil {
if _, ok := err.(viper.ConfigFileAlreadyExistsError); !ok {