|
|
|
@ -31,7 +31,7 @@ public:
|
|
|
|
|
m_pluginId = pluginId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QSharedPointer<T> > all(const QString &where = "") {
|
|
|
|
|
QList<QSharedPointer<T> > all(const QString &where = "", const QString &order = "") {
|
|
|
|
|
QList<QSharedPointer<T> > ret;
|
|
|
|
|
|
|
|
|
|
if (!checkPermission(PERM_READ)) {
|
|
|
|
@ -47,14 +47,35 @@ public:
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
odb::result<T> res;
|
|
|
|
|
QString ord = defaultSort();
|
|
|
|
|
|
|
|
|
|
if (where.isEmpty())
|
|
|
|
|
if (!order.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
ord = order;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (where.isEmpty() && ord.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
res = db->template query<T>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
res = db->template query<T>(where.toStdString());
|
|
|
|
|
QString cond;
|
|
|
|
|
|
|
|
|
|
if (where.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
cond = "1 ORDER BY " + ord;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cond = where;
|
|
|
|
|
if (!ord.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
cond += "ORDER BY " + ord;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = db->template query<T>(cond.toStdString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (typename odb::result<T>::iterator it = res.begin(); it != res.end(); it++) {
|
|
|
|
@ -259,6 +280,10 @@ protected:
|
|
|
|
|
obj->setProperty("updated", QDateTime::currentDateTime());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual QString defaultSort() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SERVICE_H
|
|
|
|
|