def get_rcmd_list(self, topCount): minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId()) maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId()) strOrderBy = "UserId DESC" strWhereClause = "(UserStatus=0 And UserType LIKE '%/2/%' " strWhere1 = strWhereClause + " And GradeId >= " + str( minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str( self.get_current_subjectId()) strWhere1 += ")" strWhere2 = "" if self.userIds != "": strWhere2 = " And UserId In(" + self.userIds + ")" if strWhere2 != "": strWhere2 = strWhereClause + strWhere2 + ")" if strWhere2 == "": strWhereClause = strWhere1 else: strWhereClause = strWhere1 + " Or " + strWhere2 pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "UserId" pagingQuery.fetchFieldsName = "*" pagingQuery.spName = "findPagingUser" pagingQuery.tableName = "Jitar_User" pagingQuery.whereClause = strWhereClause pagingQuery.orderByFieldName = strOrderBy pagingQuery.topCount = topCount hot_list = pagingService.getPagingList(pagingQuery) return hot_list
def get_subject_comissioner(self): #qry = UserQuery(""" u.loginName, u.nickName, u.trueName,u.userIcon, u.blogName, u.createDate, # u.myArticleCount, u.otherArticleCount, u.resourceCount, u.blogIntroduce,u.articleCount """) #qry.setSubjectCondition(self.subject) #qry.isComissioner = True #qry.FuzzyMatch = True #qry.metaSubjectId = self.get_current_subjectId() #qry.metaGradeId = self.get_current_gradeId() #comissioner_list = qry.query_map(6) minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId()) maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId()) strOrderBy = "VisitCount DESC" strWhereClause = "(UserStatus=0 And UserType LIKE '%/4/%' " strWhere1 = strWhereClause + " And GradeId >= " + str( minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str( self.get_current_subjectId()) strWhere1 += ")" strWhere2 = "" if self.userIds != "": strWhere2 = " And UserId In(" + self.userIds + ")" if strWhere2 != "": strWhere2 = strWhereClause + strWhere2 + ")" if strWhere2 == "": strWhereClause = strWhere1 else: strWhereClause = strWhere1 + " Or " + strWhere2 pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "UserId" pagingQuery.fetchFieldsName = "*" pagingQuery.spName = "findPagingUser" pagingQuery.tableName = "Jitar_User" pagingQuery.whereClause = strWhereClause pagingQuery.orderByFieldName = strOrderBy pagingQuery.topCount = 6 comissioner_list = pagingService.getPagingList(pagingQuery) return comissioner_list
def get_expert_list(self): #qry = UserQuery(""" u.loginName, u.blogName, u.nickName,u.trueName, u.userIcon, u.blogIntroduce,u.articleCount, subj.subjectId """) #qry.isExpert = True #qry.FuzzyMatch = True #qry.metaSubjectId = self.get_current_subjectId() #qry.metaGradeId = self.get_current_gradeId() #expert_list = qry.query_map(3) minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId()) maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId()) strOrderBy = "UserId DESC" strWhereClause = "(UserStatus=0 And UserType LIKE '%/3/%' " strWhere1 = strWhereClause + " And GradeId >= " + str( minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str( self.get_current_subjectId()) strWhere1 += ")" strWhere2 = "" if self.userIds != "": strWhere2 = " And UserId In(" + self.userIds + ")" if strWhere2 != "": strWhere2 = strWhereClause + strWhere2 + ")" if strWhere2 == "": strWhereClause = strWhere1 else: strWhereClause = strWhere1 + " Or " + strWhere2 pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "UserId" pagingQuery.fetchFieldsName = "*" pagingQuery.spName = "findPagingUser" pagingQuery.tableName = "Jitar_User" pagingQuery.whereClause = strWhereClause pagingQuery.orderByFieldName = strOrderBy pagingQuery.topCount = 3 expert_list = pagingService.getPagingList(pagingQuery) return expert_list
def execute(self): self.categoryId = None self.userName = request.getAttribute("loginName") params = ParamUtil(request) title = params.safeGetStringParam("title") if title != "": request.setAttribute("title", title) # 解析 uri. if self.parseUri() == False: return self.sendNotFound(self.uri) # 得到要工作室主人, 并验证用户状态. self.user = user_svc.getUserByLoginName(self.userName) request.setAttribute("user", self.user) #print "self.user = "******"self.category = ", self.category if self.category == None: return self.sendNotFound() request.setAttribute("category", self.category) # 得到文章分类显示页面. page = self.getUserArticleCategoryPage(self.user) #print "page = ", page if page == None: return self.sendNotFound() request.setAttribute("page", page) # 得到页面功能块. #widget_list = self.getPageWidgets(page) #print "widget_list = ", widget_list widgets = [{ "id": "1", "pageId": page.pageId, "columnIndex": 1, "title": "", "module": "profile", "ico": "", "data": "" }, { "id": "2", "pageId": page.pageId, "columnIndex": 1, "title": u"文章分类", "module": "user_cate", "ico": "", "data": "" }, { "id": "3", "pageId": page.pageId, "columnIndex": 1, "title": u"文章搜索", "module": "blog_search", "ico": "", "data": "" }] request.setAttribute("widget_list", widgets) request.setAttribute("widgets", widgets) request.setAttribute("UserSiteUrl", self.getUserSiteUrl()) request.setAttribute("cateId", self.categoryId) pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "ArticleId" pagingQuery.fetchFieldsName = "*" pagingQuery.orderByFieldName = "ArticleId DESC" pagingQuery.spName = "findPagingArticleBase" pagingQuery.tableName = "HtmlArticleBase" pagingQuery.whereClause = "userId = " + str( self.user.userId ) + " And HideState = 0 And AuditState = 0 And DraftState = 0 And DelState = 0" if self.categoryId != None and self.categoryId > 0: pagingQuery.whereClause = pagingQuery.whereClause + " And UserCateId=" + str( self.categoryId) #得到记录总数 count = pagingService.getRowsCount(pagingQuery) if count % 20 == 0: pageCount = int(count / 20) else: pageCount = int(count / 20) + 1 request.setAttribute("pageCount", pageCount) return "/WEB-INF/user/default/show_user_article_category.ftl"
def execute(self): if self.loginUser == None: return ActionResult.LOGIN accessControlService = __spring__.getBean("accessControlService") if False == accessControlService.isSystemContentAdmin(self.loginUser): self.addActionError(u"您不具有文章管理权限, 或者您的信息填写不完整, 或未经系统管理员审核.") return ActionResult.ERROR year = self.params.safeGetIntParam("backYear") if year == 0: self.addActionError(u"请选择一个年份。") return ActionResult.ERROR if request.getMethod() == "POST": articleService = __jitar__.articleService articleIdList = self.params.safeGetIntValues("articleId") cmd = self.params.getStringParam("cmd") if cmd == "": cmd = None if cmd == "crash": for id in articleIdList: articleService.deleteArticleWithRelativeData(id, year) elif cmd == "audit": for id in articleIdList: article = articleService.getArticle(id) if article != None: articleService.auditArticle(article) elif cmd == "unaudit": for id in articleIdList: article = articleService.getArticle(id) if article != None: articleService.unauditArticle(article) su = self.params.getIntParamZeroAsNull("su") f = self.params.getStringParam("f", None) gradeId = self.params.getIntParamZeroAsNull("gradeId") sc = self.params.getIntParamZeroAsNull("sc") k = self.params.getStringParam("k") approved = self.params.getStringParam("approved", "") fieldName = None if f == "lname": fieldName = "LoginName" elif f == "uname": fieldName = "UserTrueName" else: fieldName = "Title" whereClause = "" if k != None and fieldName != None: k = k.replace("'", "") k = k.replace("%", "") k = k.replace(";", "") whereClause += "And " + fieldName + " LIKE '%" + k + "%'" if su != None: whereClause += " And subjectId = " + str(su) if gradeId != None: whereClause += " And gradeId = " + str(gradeId) if sc != None: whereClause += " And sysCateId = " + str(sc) if approved != "" and approved.isdigit(): whereClause += " And AuditState = " + approved if whereClause != "" and len(whereClause) > 4: whereClause = whereClause[4:len(whereClause)] else: whereClause = "" pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "ArticleId" pagingQuery.fetchFieldsName = "*" pagingQuery.orderByFieldName = "ArticleId DESC" pagingQuery.spName = "findPagingArticle" pagingQuery.tableName = "HtmlArticle" + str(year) pagingQuery.whereClause = whereClause totalCount = self.params.safeGetIntParam("totalCount") pager = Pager() pager.setCurrentPage(self.params.safeGetIntParam("page", 1)) pager.setPageSize(20) pager.setItemNameAndUnit(u"文章", u"篇") pager.setUrlPattern(self.params.generateUrlPattern()) if totalCount == 0: pager.setTotalRows(pagingService.getRowsCount(pagingQuery)) else: pager.setTotalRows(totalCount) article_list = pagingService.getPagingList(pagingQuery, pager) request.setAttribute("k", k) request.setAttribute("f", f) request.setAttribute("gradeId", gradeId) request.setAttribute("su", su) request.setAttribute("sc", sc) request.setAttribute("approved", approved) request.setAttribute("article_list", article_list) request.setAttribute("pager", pager) request.setAttribute("year", year) self.putSubjectList() self.putGradeList() self.putArticleCategoryTree() return "/WEB-INF/ftl/admin/admin_history_article.ftl"
def list_user(self): strWhereClause = "(1=1 " k = self.params.safeGetStringParam("k") f = self.params.safeGetStringParam("f") ustate = self.params.safeGetStringParam("ustate") if ustate == "": ustate = "-1" #qry = UserQuery(""" u.userId, u.loginName, u.nickName, u.trueName, u.userIcon, u.userStatus, # u.email, u.subjectId, u.gradeId, u.createDate, # u.isExpert ,u.isFamous,u.isRecommend,u.isComissioner,u.unitId # """) #qry.orderType = 0 if ustate == "0": strWhereClause += " And UserStatus = 0" #qry.userStatus = 0 elif ustate == "1": strWhereClause += " And UserStatus = 1" #qry.userStatus = 1 elif ustate == "2": strWhereClause += " And UserStatus = 2" #qry.userStatus = 2 elif ustate == "3": strWhereClause += " And UserStatus = 3" #qry.userStatus = 3 else: print "" #qry.userStatus = None if k != "": #qry.f = f #qry.k = k request.setAttribute("k", k) request.setAttribute("f", f) if f == "loginName": strWhereClause += " And LoginName LIKE '%" + k + "%'" elif f == "trueName": strWhereClause += " And TrueName LIKE '%" + k + "%'" minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId()) maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId()) strOrderBy = "UserId DESC" strWhere1 = strWhereClause + " And GradeId >= " + str( minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str( self.get_current_subjectId()) strWhere1 += ")" strWhere2 = "" #得到多学科用户 self.userIds = "" qry2 = UserSubjectGradeQuery("usg.userId") qry2.subjectId = self.get_current_subjectId() qry2.gradeId = self.get_current_gradeId() qry2.FuzzyMatch = True #匹配学段,包括年级 usg_list = qry2.query_map(qry2.count()) if usg_list != None and len(usg_list) > 0: for uu in usg_list: self.userIds += str(uu["userId"]) + "," if self.userIds != "" and self.userIds.endswith(","): self.userIds = self.userIds[0:len(self.userIds) - 1] if self.userIds != "": strWhere2 = " And UserId In(" + self.userIds + ")" if strWhere2 != "": strWhere2 = strWhereClause + strWhere2 + ")" if strWhere2 == "": strWhereClause = strWhere1 else: strWhereClause = strWhere1 + " Or " + strWhere2 pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "UserId" pagingQuery.fetchFieldsName = "*" pagingQuery.spName = "findPagingUser" pagingQuery.tableName = "Jitar_User" pagingQuery.whereClause = strWhereClause pagingQuery.orderByFieldName = strOrderBy totalCount = self.params.safeGetIntParam("totalCount") pager = Pager() pager.setCurrentPage(self.params.safeGetIntParam("page", 1)) pager.setPageSize(20) pager.setItemNameAndUnit(u"用户", u"个") pager.setUrlPattern(self.params.generateUrlPattern()) if totalCount == 0: pager.setTotalRows(pagingService.getRowsCount(pagingQuery)) else: pager.setTotalRows(totalCount) user_list = pagingService.getPagingList(pagingQuery, pager) print totalCount request.setAttribute("ustate", ustate) request.setAttribute("pager", pager) request.setAttribute("user_list", user_list)
def execute(self): self.loginName = request.getAttribute("loginName") if self.loginName == None or self.loginName == "": return self.sendNotFound(self.uri) self.user = userService.getUserByLoginName(self.loginName) #print "user = "******"k") if k == None or k == "": self.addActionError(u"请输入关键字。") self.addActionLink(u"返回","../") return self.ERROR request.setAttribute("user", self.user) request.setAttribute("loginUser", self.loginUser) hql = "SELECT p.skin FROM Page p WHERE p.name = 'index' and p.objId = :userId and p.objType = 1" #pageSkin = Command(hql).setInteger("userId", self.user.userId).scalar() list = [] list = Command(hql).setInteger("userId", self.user.userId).open(1); if list == None : pageSkin = None else : pageSkin = list[0] #print "pageSkin = ", pageSkin if pageSkin == None or pageSkin == "": pageSkin = "skin1" # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据. #pages : [{id: ${page.pageId}, title: '${self.user.blogName!?js_string}', layoutId: ${page.layoutId!0} }], page = { "pageId": 0, "layoutId": 2, # 固定是布局2 "isSystemPage" : "true", "owner" : "user", "title" :"", "skin": pageSkin } request.setAttribute("page", page) self.page = self.getUserProfilePage(self.user) if self.page.customSkin != None: customSkin = JSONObject.parse(self.page.customSkin) request.setAttribute("customSkin", customSkin) # 构造widgets . widgets = [ {"id": "1", "pageId":0, "columnIndex":1,"title":u"个人档案","module":"profile", "ico":"", "data":""}, {"id": "2", "pageId":self.page.pageId, "columnIndex":1, "title":u"文章搜索", "module":"blog_search", "ico":"", "data":""} ] request.setAttribute("widgets", widgets) request.setAttribute("widget_list", widgets) pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "ArticleId" pagingQuery.fetchFieldsName = "*" pagingQuery.orderByFieldName = "ArticleId DESC" pagingQuery.spName = "findPagingArticleBase" pagingQuery.tableName = "HtmlArticleBase" pagingQuery.whereClause = "userId = " + str(self.user.userId) + " And HideState = 0 And AuditState = 0 And DraftState = 0 And DelState = 0" if k != None and k != "": newKey = k.replace("%","[%]").replace("_","[_]").replace("[","[[]") pagingQuery.whereClause = pagingQuery.whereClause + " And Title LIKE '%" + newKey + "%'" #得到记录总数 count = pagingService.getRowsCount(pagingQuery) if count % 20 == 0: pageCount = int(count/20) else: pageCount = int(count/20) + 1 request.setAttribute("pageCount", pageCount) request.setAttribute("k", k) response.setContentType("text/html; charset=UTF-8") return "/WEB-INF/user/default/user_article_search.ftl"
def execute(self): if self.unitService == None: self.addActionError( u"无法加载组织机构服务,请检查 applicationContext.xml 配置文件,是否缺少 unitService 节点。" ) return self.ERROR self.unit = self.getUnit() if self.unit == None: self.addActionError(u"您所访问的机构不存在!") return self.ERROR if self.unit.delState == True: self.addActionError(u"您所访问的机构已经被删除!") return self.ERROR self.get_backyear_list() year = self.params.getIntParamZeroAsNull("year") if self.backYearList == None: year = None if self.backYearList != None: IsValidYear = False for y in self.backYearList: if year == y.backYear: IsValidYear = True break if IsValidYear == False: year = None strWhereClause = "ApprovedPathInfo Like '%/" + str( self.unit.unitId) + "/%'" strOrderBy = "ArticleId DESC" list_type = u"最新文章" type = self.params.getStringParam("type") if type == "" or type == None: type = "new" if type == "hot": strOrderBy = "ViewCount DESC" list_type = u"热门文章" elif type == "best": strWhereClause = strWhereClause + " And BestState = 1" list_type = u"精华文章" elif type == "rcmd": strWhereClause = strWhereClause + " And RcmdPathInfo Like '%/" + str( self.unit.unitId) + "/%'" list_type = u"推荐文章" elif type == "cmt": strOrderBy = "CommentCount DESC" list_type = u"评论最多文章" elif type == "famous": # 为了不增加额外的表,现在先得到全部名师的 id,然后再去查询。 qry = UserQuery("u.userId") qry.userTypeId = 1 user_count = qry.count() user_list = qry.list(user_count) if user_list == None or len(user_list) < 1: nodata = True strWhereClause = strWhereClause + " And UserId IN (0)" else: uid = "" for u in user_list: uid += str(u) + "," uid = uid[0:len(uid) - 1] strWhereClause = strWhereClause + " And UserId IN (" + uid + ")" list_type = u"名师文章" elif type == "digg": strOrderBy = "Digg DESC" list_type = u"按顶排序" elif type == "trample": strOrderBy = "Trample DESC" list_type = u"按踩排序" elif type == "star": strOrderBy = "(StarCount/CommentCount) DESC" list_type = u"按星排序" strWhereClause = strWhereClause + " And CommentCount>0" else: type = 'new' k = self.params.getStringParam("k") if k != "" and k != None: if len(k) > 25 or k.find("'") > -1: k = "" else: strWhereClause = strWhereClause + " And Title Like '%" + k + "%'" subjectId = self.params.getIntParamZeroAsNull("subjectId") sysCateId = self.params.getIntParamZeroAsNull("categoryId") gradeId = self.params.getIntParamZeroAsNull("gradeId") if subjectId != None: strWhereClause = strWhereClause + " And SubjectId = " + str( subjectId) if sysCateId != None: #只查询分类自己的 #strWhereClause = strWhereClause + " And SysCateId = " + str(sysCateId) #查询包含子孙分类的 list = self.cate_svc.getCategoryIds(sysCateId) cateIds = "" for c in list: if cateIds == "": cateIds = cateIds + str(c) else: cateIds = cateIds + "," + str(c) strWhereClause = strWhereClause + " And SysCateId IN (" + cateIds + ")" if gradeId != None: strWhereClause = strWhereClause + " And GradeId = " + str(gradeId) pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "ArticleId" pagingQuery.fetchFieldsName = "*" pagingQuery.orderByFieldName = strOrderBy pagingQuery.spName = "findPagingArticle" if year == None: pagingQuery.tableName = "Jitar_Article" else: pagingQuery.tableName = "HtmlArticle" + str(year) pagingQuery.whereClause = strWhereClause totalCount = self.params.safeGetIntParam("totalCount") pager = Pager() pager.setCurrentPage(self.params.safeGetIntParam("page", 1)) pager.setPageSize(20) pager.setItemNameAndUnit(u"文章", u"篇") pager.setUrlPattern(self.params.generateUrlPattern()) if totalCount <= 0: pager.setTotalRows(pagingService.getRowsCount(pagingQuery)) else: pager.setTotalRows(totalCount) article_list = pagingService.getPagingList(pagingQuery, pager) request.setAttribute("type", type) request.setAttribute("list_type", list_type) request.setAttribute("article_list", article_list) request.setAttribute("categoryId", sysCateId) request.setAttribute("subjectId", subjectId) request.setAttribute("k", k) request.setAttribute("pager", pager) request.setAttribute("year", year) # 文章分类. blog_cates = self.cate_svc.getCategoryTree("default") request.setAttribute("blog_cates", blog_cates) request.setAttribute("head_nav", "unit_article") request.setAttribute("unit", self.unit) self.putGradeList() self.putSubjectList() templateName = "template1" if self.unit.templateName != None: templateName = self.unit.templateName return "/WEB-INF/unitspage/" + templateName + "/unit_article.ftl"
def execute(self): if self.loginUser == None: return self.LOGIN self.unit = self.getUnit() if self.unit == None: self.addActionError(u"您所访问的机构不存在!") return self.ERROR if self.isContentAdmin() == False: self.addActionError(u"你没有管理的权限。") return self.ERROR year = self.params.safeGetIntParam("backYear") if year == 0: self.addActionError(u"请选择一个年份。") return self.ERROR if request.getMethod() == "POST": articleService = __jitar__.articleService articleIdList = self.params.safeGetIntValues("articleId") for id in articleIdList: articleService.deleteArticleWithRelativeData(id,year) su = self.params.getIntParamZeroAsNull("su") f = self.params.getStringParam("f",None) gradeId = self.params.getIntParamZeroAsNull("gradeId") sc = self.params.getIntParamZeroAsNull("sc") k = self.params.getStringParam("k") fieldName = None if f == "lname": fieldName = "LoginName" elif f == "uname": fieldName = "UserTrueName" else: fieldName = "Title" whereClause = "UnitId=" + str(self.unit.unitId) if k != None and fieldName != None: k = k.replace("'","") k = k.replace("%","") k = k.replace(";","") whereClause += "And " + fieldName + " LIKE '%" + k + "%'" if su != None: whereClause += " And subjectId = " + str(su) if gradeId != None: whereClause += " And gradeId = " + str(gradeId) if sc != None: whereClause += " And sysCateId = " + str(sc) pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "ArticleId" pagingQuery.fetchFieldsName = "*" pagingQuery.orderByFieldName = "ArticleId DESC" pagingQuery.spName = "findPagingArticle" pagingQuery.tableName = "HtmlArticle" + str(year) pagingQuery.whereClause = whereClause totalCount = self.params.safeGetIntParam("totalCount") pager = Pager() pager.setCurrentPage(self.params.safeGetIntParam("page", 1)) pager.setPageSize(20) pager.setItemNameAndUnit(u"文章", u"篇") pager.setUrlPattern(self.params.generateUrlPattern()) if totalCount == 0: pager.setTotalRows(pagingService.getRowsCount(pagingQuery)) else: pager.setTotalRows(totalCount) article_list = pagingService.getPagingList(pagingQuery, pager) request.setAttribute("k", k) request.setAttribute("f", f) request.setAttribute("gradeId", gradeId) request.setAttribute("su", su) request.setAttribute("sc", sc) request.setAttribute("article_list", article_list) request.setAttribute("pager", pager) request.setAttribute("year", year) request.setAttribute("unit", self.unit) self.putSubjectList() self.putGradeList() self.putArticleCategoryTree() return "/WEB-INF/unitsmanage/admin_history_article_unit.ftl"
def get_article_list(self): year = self.params.getIntParamZeroAsNull("year") if self.backYearList == None: year = None if self.backYearList != None: IsValidYear = False for y in self.backYearList: if year == y.backYear: IsValidYear = True break if IsValidYear == False: year = None blogUserId = self.params.getIntParamZeroAsNull("userId") strWhereClause = "HideState=0 And AuditState=0 And DraftState=0 And DelState=0 And ApprovedPathInfo Like '%/" + str( self.unit.unitId) + "/%'" if blogUserId != None: strWhereClause += " And UserId=" + str(blogUserId) strOrderBy = "ArticleId DESC" list_type = u"最新文章" type = self.params.getStringParam("type") if type == "" or type == None: type = "new" if type == "hot": strOrderBy = "ViewCount DESC" list_type = u"热门文章" elif type == "best": strWhereClause = strWhereClause + " And BestState = 1" list_type = u"精华文章" elif type == "rcmd": strWhereClause = strWhereClause + " And RcmdPathInfo Like '%/" + str( self.unit.unitId) + "/%'" list_type = u"推荐文章" elif type == "cmt": strOrderBy = "CommentCount DESC" list_type = u"评论最多文章" elif type == "famous": # 为了不增加额外的表,现在先得到全部名师的 id,然后再去查询。 qry = UserQuery("u.userId") qry.userTypeId = 1 user_count = qry.count() user_list = qry.list(user_count) if user_list == None or len(user_list) < 1: nodata = True else: uid = "" for u in user_list: uid += str(u) + "," uid = uid[0:len(uid) - 1] strWhereClause = strWhereClause + " And UserId IN (" + uid + ")" list_type = u"名师文章" elif type == "digg": strOrderBy = "Digg DESC" list_type = u"按顶排序" elif type == "trample": strOrderBy = "Trample DESC" list_type = u"按踩排序" elif type == "star": strOrderBy = "StarCount/CommentCount DESC" strWhereClause = strWhereClause + " And CommentCount > 0" list_type = u"按星排序" else: type = "new" k = self.params.getStringParam("k") if k != None and k != "": newKey = k.replace("'", "''").replace("%", "[%]").replace( "_", "[_]").replace("[", "[[]") strWhereClause = strWhereClause + " And Title Like '%" + newKey + "%'" subjectId = self.params.getIntParamZeroAsNull("subjectId") sysCateId = self.params.getIntParamZeroAsNull("categoryId") gradeId = self.params.getIntParamZeroAsNull("gradeId") if subjectId != None: strWhereClause = strWhereClause + " And SubjectId = " + str( subjectId) if sysCateId != None: #只查询分类自己的 #strWhereClause = strWhereClause + " And SysCateId = " + str(sysCateId) #查询包含子孙分类的 list = self.cate_svc.getCategoryIds(sysCateId) cateIds = "" for c in list: if cateIds == "": cateIds = cateIds + str(c) else: cateIds = cateIds + "," + str(c) strWhereClause = strWhereClause + " And SysCateId IN (" + cateIds + ")" if gradeId != None: strWhereClause = strWhereClause + " And GradeId = " + str(gradeId) pagingService = __spring__.getBean("pagingService") pagingQuery = PagingQuery() pagingQuery.keyName = "ArticleId" pagingQuery.fetchFieldsName = "*" pagingQuery.orderByFieldName = strOrderBy pagingQuery.spName = "findPagingArticle" if year == None: pagingQuery.tableName = "Jitar_Article" else: pagingQuery.tableName = "HtmlArticle" + str(year) pagingQuery.whereClause = strWhereClause totalCount = self.params.safeGetIntParam("totalCount") pager = Pager() pager.setCurrentPage(self.params.safeGetIntParam("page", 1)) pager.setPageSize(20) pager.setItemNameAndUnit(u"文章", u"篇") pager.setUrlPattern(self.params.generateUrlPattern()) if totalCount == 0: pager.setTotalRows(pagingService.getRowsCount(pagingQuery)) else: pager.setTotalRows(totalCount) article_list = pagingService.getPagingList(pagingQuery, pager) request.setAttribute("type", type) request.setAttribute("list_type", list_type) request.setAttribute("article_list", article_list) request.setAttribute("categoryId", sysCateId) request.setAttribute("subjectId", subjectId) request.setAttribute("k", k) request.setAttribute("pager", pager) request.setAttribute("year", year)