1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#include "usersimpl.h"
#include <modifycommand.h>
#include <sql/users/authenticate.sql.h>
#include <sql/users/verify.sql.h>
#include <sql/users/create.sql.h>
#include <sql/users/get.sql.h>
#include <sql/users/find.sql.h>
#include <sql/users/safeDelete.sql.h>
#include <sql/users/track.sql.h>
#include <sql/users/untrack.sql.h>
#include <sql/users/tracked.sql.h>
namespace Gentoo {
namespace Service {
Users::Users(boost::shared_ptr<AdHoc::ResourcePool<DB::Connection>> d) :
IceTray::AbstractCachingDatabaseClient(d)
{
}
Gentoo::UserPtr
Users::authenticate(const std::string & username, const std::string & password, const Ice::Current &)
{
return fetchCache<Gentoo::UserPtr>(sql::users::authenticate, 30, username, password);
}
Gentoo::UserPtr
Users::verify(const std::string & username, const std::string & verifyguid, const Ice::Current &)
{
return fetch<Gentoo::UserPtr>(sql::users::verify, username, verifyguid);
}
Gentoo::UserPtr
Users::get(Ice::Int id, const Ice::Current &)
{
return fetch<Gentoo::UserPtr>(sql::users::get, id);
}
Gentoo::UserPtr
Users::find(const std::string & username, const Ice::Current &)
{
return fetch<Gentoo::UserPtr>(sql::users::find, username);
}
Gentoo::NewUserPtr
Users::create(const std::string & username, const std::string & password, const std::string & realname, const std::string & email, const Ice::Current &)
{
return fetch<Gentoo::NewUserPtr>(sql::users::create, username, password, realname, email);
}
void
Users::remove(Ice::Int id, const std::string & password, const Ice::Current &)
{
auto dbc = db->get();
auto del = dbc->modify(sql::users::safeDelete.getSql());
del->bindParamI(0, id);
del->bindParamS(1, password);
del->execute();
}
void
Users::track(Ice::Int userId, Ice::Int packageId, const Ice::Current &)
{
auto dbc = db->get();
auto track = dbc->modify(sql::users::track.getSql());
track->bindParamI(0, userId);
track->bindParamI(1, packageId);
track->execute();
}
void
Users::untrack(Ice::Int userId, Ice::Int packageId, const Ice::Current &)
{
auto dbc = db->get();
auto untrack = dbc->modify(sql::users::untrack.getSql());
untrack->bindParamI(0, userId);
untrack->bindParamI(1, packageId);
untrack->execute();
}
Gentoo::PackageIds
Users::tracked(Ice::Int userId, const Ice::Current &)
{
return fetchCache<Gentoo::PackageIds>(sql::users::tracked, 10, userId);
}
}
}
|