PermissionsDao: Add clearForPage()
This commit is contained in:
джерело
9088154372
коміт
8998fb8793
@ -9,6 +9,8 @@ class PermissionsDao
|
||||
PermissionsDao();
|
||||
virtual std::optional<Permissions> find(std::string pagename, std::string username) = 0;
|
||||
virtual void save(std::string pagename, std::string username, Permissions perms) = 0;
|
||||
virtual void clearForPage(std::string pagename) = 0;
|
||||
|
||||
virtual ~PermissionsDao() = default;
|
||||
};
|
||||
|
||||
|
@ -59,3 +59,16 @@ void PermissionsDaoSqlite::save(std::string pagename, std::string username, Perm
|
||||
throwFrom(e);
|
||||
}
|
||||
}
|
||||
|
||||
void PermissionsDaoSqlite::clearForPage(std::string pagename)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto stmt = *db << "DELETE FROM permissions WHERE page = (SELECT id FROM page WHERE name = ?)" << pagename;
|
||||
stmt.execute();
|
||||
}
|
||||
catch(sqlite::sqlite_exception &e)
|
||||
{
|
||||
throwFrom(e);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ class PermissionsDaoSqlite : public PermissionsDao, protected SqliteDao
|
||||
|
||||
std::optional<Permissions> find(std::string pagename, std::string username) override;
|
||||
virtual void save(std::string pagename, std::string username, Permissions perms) override;
|
||||
virtual void clearForPage(std::string pagename) override;
|
||||
using SqliteDao::SqliteDao;
|
||||
};
|
||||
|
||||
|
Завантаження…
Посилання в новій задачі
Block a user