def query_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.userCount, g.visitCount, g.articleCount, g.topicCount, g.resourceCount, g.groupIntroduce, g.groupTags, subj.subjectName, grad.gradeName, sc.name as scName """ ) qry.subjectId = self.params.getIntParamZeroAsNull('subjectId') qry.categoryId = self.categoryId qry.gradeId = self.params.getIntParamZeroAsNull('gradeId') qry.searchtype = self.params.getStringParam('searchtype') qry.kk = self.params.getStringParam("k") pager = self.createPager() pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) ggg = [] for gg in group_list: gid = gg["groupId"] subqry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.userCount, g.visitCount, g.articleCount, g.topicCount, g.resourceCount, g.groupIntroduce, g.groupTags """) subqry.parentId = gid subgroup_list = subqry.query_map() ggg.append(subgroup_list) request.setAttribute("subgroups", ggg) request.setAttribute("pager", pager) request.setAttribute("subjectId", qry.subjectId) request.setAttribute("categoryId", qry.categoryId) request.setAttribute("gradeId", qry.gradeId) request.setAttribute("searchtype", qry.searchtype) request.setAttribute("k", qry.kk)
def groupList(self): # 构造查询对象. qry = GroupQuery( """ g.groupId, g.groupName, g.groupTitle, g.groupIcon, g.createDate, g.subjectId, g.gradeId, g.createUserId, g.groupTags, g.groupIntroduce, g.groupState, g.userCount, g.visitCount, g.isBestGroup, g.isRecommend, u.trueName, u.loginName, subj.subjectName, sc.name as categoryName """) qry.groupState = 0 qry.kk = self.params.getStringParam("k") request.setAttribute("k", qry.kk) # 构造分页并查询数据. pager = self.createPager() pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) request.setAttribute("pager", pager)