feat(webdav): add read-only option (#1629)

This commit is contained in:
WeidiDeng
2023-02-07 19:43:28 +08:00
committed by GitHub
parent ffbafca994
commit a93ea2cfa0
4 changed files with 43 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ type Webdav struct {
Password string `gorm:"unique_index:password_only_on"` // 应用密码
UserID uint `gorm:"unique_index:password_only_on"` // 用户ID
Root string `gorm:"type:text"` // 根目录
Readonly bool `gorm:"type:bool"` // 是否只读
}
// Create 创建账户
@@ -39,3 +40,8 @@ func ListWebDAVAccounts(uid uint) []Webdav {
func DeleteWebDAVAccountByID(id, uid uint) {
DB.Where("user_id = ? and id = ?", uid, id).Delete(&Webdav{})
}
// UpdateWebDAVAccountReadonlyByID 根据账户ID和UID更新账户的只读性
func UpdateWebDAVAccountReadonlyByID(id, uid uint, readonly bool) {
DB.Model(&Webdav{Model: gorm.Model{ID: id}, UserID: uid}).UpdateColumn("readonly", readonly)
}