Page: add id field
This commit is contained in:
부모
b6cdf9a088
커밋
099f6533f8
@ -11,9 +11,9 @@ class PageDao
|
|||||||
public:
|
public:
|
||||||
PageDao();
|
PageDao();
|
||||||
virtual bool exists(std::string page) const = 0;
|
virtual bool exists(std::string page) const = 0;
|
||||||
virtual bool exists(int id) const = 0;
|
virtual bool exists(unsigned int id) const = 0;
|
||||||
virtual std::optional<Page> find(std::string name) = 0;
|
virtual std::optional<Page> find(std::string name) = 0;
|
||||||
virtual std::optional<Page> find(int id) = 0;
|
virtual std::optional<Page> find(unsigned int id) = 0;
|
||||||
virtual std::vector<std::string> getPageList(QueryOption option) = 0;
|
virtual std::vector<std::string> getPageList(QueryOption option) = 0;
|
||||||
virtual std::vector<std::string> fetchCategories(std::string pagename, QueryOption option) = 0;
|
virtual std::vector<std::string> fetchCategories(std::string pagename, QueryOption option) = 0;
|
||||||
virtual void deletePage(std::string page) = 0;
|
virtual void deletePage(std::string page) = 0;
|
||||||
|
@ -26,7 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
/* TODO: copied from C version mostly, review whether access to table other than page is ok */
|
/* TODO: copied from C version mostly, review whether access to table other than page is ok */
|
||||||
|
|
||||||
bool PageDaoSqlite::exists(int id) const
|
bool PageDaoSqlite::exists(unsigned int id) const
|
||||||
{
|
{
|
||||||
auto binder = *db << "SELECT 1 from page WHERE id = ?" << id;
|
auto binder = *db << "SELECT 1 from page WHERE id = ?" << id;
|
||||||
return execBool(binder);
|
return execBool(binder);
|
||||||
@ -44,9 +44,10 @@ std::optional<Page> PageDaoSqlite::find(std::string name)
|
|||||||
return find(pageid);
|
return find(pageid);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Page> PageDaoSqlite::find(int id)
|
std::optional<Page> PageDaoSqlite::find(unsigned int id)
|
||||||
{
|
{
|
||||||
Page result;
|
Page result;
|
||||||
|
result.pageid = id;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto ps = *db << "SELECT name, lastrevision, visible FROM page WHERE id = ?";
|
auto ps = *db << "SELECT name, lastrevision, visible FROM page WHERE id = ?";
|
||||||
@ -88,8 +89,9 @@ void PageDaoSqlite::save(const Page &page)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
*db << "INSERT INTO page (name, lastrevision, visible) VALUES(?, ?, ?)" << page.name << page.current_revision
|
*db << "INSERT OR REPLACE INTO page (id, name, lastrevision, visible) VALUES((SELECT id FROM page WHERE name = "
|
||||||
<< page.listed;
|
"? OR id = ?), ?, ?, ?)"
|
||||||
|
<< page.name << page.pageid << page.name << page.current_revision << page.listed;
|
||||||
}
|
}
|
||||||
catch(sqlite::sqlite_exception &e)
|
catch(sqlite::sqlite_exception &e)
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,11 @@ class PageDaoSqlite : public PageDao, protected SqliteDao
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
void deletePage(std::string page) override;
|
void deletePage(std::string page) override;
|
||||||
bool exists(int id) const override;
|
bool exists(unsigned int id) const override;
|
||||||
bool exists(std::string name) const override;
|
bool exists(std::string name) const override;
|
||||||
void save(const Page &page) override;
|
void save(const Page &page) override;
|
||||||
std::optional<Page> find(std::string name) override;
|
std::optional<Page> find(std::string name) override;
|
||||||
std::optional<Page> find(int id) override;
|
std::optional<Page> find(unsigned int id) override;
|
||||||
std::vector<std::string> getPageList(QueryOption option) override;
|
std::vector<std::string> getPageList(QueryOption option) override;
|
||||||
std::vector<std::string> fetchCategories(std::string pagename, QueryOption option) override;
|
std::vector<std::string> fetchCategories(std::string pagename, QueryOption option) override;
|
||||||
using SqliteDao::SqliteDao;
|
using SqliteDao::SqliteDao;
|
||||||
|
불러오는 중...
Reference in New Issue
Block a user