feat: (WIP) migrate storage configuration to user-specific models and remove deprecated storage loading

This commit is contained in:
krau
2025-02-18 19:45:06 +08:00
parent 968547b005
commit dfde65c28e
8 changed files with 193 additions and 36 deletions

View File

@@ -11,6 +11,12 @@ func CreateUser(chatID int64) error {
return db.Create(&types.User{ChatID: chatID}).Error
}
func GetAllUsers() ([]types.User, error) {
var users []types.User
err := db.Find(&users).Error
return users, err
}
// GetUserByUserID gets a user by their telegram user ID
//
// Return with active storages
@@ -29,3 +35,7 @@ func GetUserWithAllStoragesByChatID(chatID int64) (*types.User, error) {
func UpdateUser(user *types.User) error {
return db.Save(user).Error
}
func DeleteUser(user *types.User) error {
return db.Select("Storages").Delete(user).Error
}