blob: 8d6436c50485f457a2385f6c675e740cecf46700 (
plain)
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
|
-- Gemeinschaft 5 module: user class
-- (c) AMOOMA GmbH 2012
--
module(...,package.seeall)
Tenant = {}
-- Create Tenant object
function Tenant.new(self, arg)
arg = arg or {}
object = arg.object or {}
setmetatable(object, self)
self.__index = self;
self.class = 'tenant';
self.log = arg.log;
self.database = arg.database;
self.record = arg.record;
return object;
end
-- find tenant by id
function Tenant.find_by_id(self, id)
local sql_query = 'SELECT * FROM `tenants` WHERE `id`= ' .. tonumber(id) .. ' LIMIT 1';
local tenant = nil;
self.database:query(sql_query, function(account_entry)
tenant = Tenant:new(self);
tenant.record = account_entry;
tenant.id = tonumber(account_entry.id);
tenant.uuid = account_entry.uuid;
end);
return tenant;
end
-- find tenant by uuid
function Tenant.find_by_uuid(self, uuid)
tenant_id = tonumber(tenant_id)
local sql_query = 'SELECT * FROM `tenants` WHERE `id`= "' .. uuid .. '" LIMIT 1';
local tenant = nil;
self.database:query(sql_query, function(account_entry)
tenant = Tenant:new(self);
tenant.record = account_entry;
tenant.id = tonumber(account_entry.id);
tenant.uuid = account_entry.uuid;
end);
return tenant;
end
|