mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 02:18:20 +01:00
fix
This commit is contained in:
parent
3d2e1299b1
commit
692d437c67
@ -1,38 +1,40 @@
|
|||||||
BaseController:subclass("IndexController",
|
BaseController:subclass(
|
||||||
|
"IndexController",
|
||||||
{
|
{
|
||||||
registry = {},
|
registry = {},
|
||||||
models = { "sections", "category" }
|
models = {"sections", "category"}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
local sectionsByCid = function(db, id)
|
local sectionsByCid = function(db, id)
|
||||||
local cond = { exp = { ["="] = { cid = id } } , order = { start = "DESC" } }
|
local cond = {exp = {["="] = {cid = id}}, order = {start = "DESC"}}
|
||||||
local data, a = db:find(cond)
|
local data, a = db:find(cond)
|
||||||
return data,a
|
return data, a
|
||||||
end
|
end
|
||||||
|
|
||||||
function IndexController:index(...)
|
function IndexController:index(...)
|
||||||
local args = {...}
|
local args = {...}
|
||||||
-- now read all the data
|
-- now read all the data
|
||||||
-- get all root sections as the toc
|
-- get all root sections as the toc
|
||||||
local cond = { exp = { ["="] = { pid = 0 } }, order = { name = "ASC" } }
|
local cond = {exp = {["="] = {pid = 0}}, order = {name = "ASC"}}
|
||||||
local data, a = self.category:find(cond)
|
local data, a = self.category:find(cond)
|
||||||
local toc = {}
|
local toc = {}
|
||||||
if not data then
|
if not data then
|
||||||
return self:error("Cannot query the ToC")
|
return self:error("Cannot query the ToC")
|
||||||
end
|
end
|
||||||
-- find all children category of the toc
|
-- find all children category of the toc
|
||||||
for key,cat in pairs(data) do
|
for key, cat in pairs(data) do
|
||||||
cat.name = cat.name:gsub("^%d+%.","")
|
cat.name = cat.name:gsub("^%d+%.", "")
|
||||||
table.insert( toc, {cat.name, cat.id} )
|
table.insert(toc, {cat.name, cat.id})
|
||||||
cond = { exp = { ["="] = { pid = cat.id } }, order = { name = "ASC" } }
|
cond = {exp = {["="] = {pid = cat.id}}, order = {name = "ASC"}}
|
||||||
local children, b = self.category:find(cond)
|
local children, b = self.category:find(cond)
|
||||||
if children and #children > 0 then
|
if children and #children > 0 then
|
||||||
for k,v in pairs(children) do
|
for k, v in pairs(children) do
|
||||||
v.sections = sectionsByCid(self.sections,v.id)
|
v.sections = sectionsByCid(self.sections, v.id)
|
||||||
end
|
end
|
||||||
cat.children = children
|
cat.children = children
|
||||||
else
|
else
|
||||||
cat.sections = sectionsByCid(self.sections,cat.id)
|
cat.sections = sectionsByCid(self.sections, cat.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.template:set("data", data)
|
self.template:set("data", data)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
BaseController:subclass("UserController",{
|
BaseController:subclass(
|
||||||
models = {"user"}
|
"UserController",
|
||||||
})
|
{
|
||||||
|
models = {"user"}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
function UserController:index(...)
|
function UserController:index(...)
|
||||||
local args = {...}
|
local args = {...}
|
||||||
|
@ -21,6 +21,7 @@ end
|
|||||||
|
|
||||||
function BaseObject:error(msg, trace)
|
function BaseObject:error(msg, trace)
|
||||||
html()
|
html()
|
||||||
|
--local line = debug.getinfo(1).currentline
|
||||||
echo(msg)
|
echo(msg)
|
||||||
self:log(msg,"ERROR")
|
self:log(msg,"ERROR")
|
||||||
if trace then
|
if trace then
|
||||||
|
Loading…
Reference in New Issue
Block a user