Example #1
0
 def list_join(self):
     # 提交的时候删除
     if self.params.existParam("groupArticleId"):            
         groupArticleId = self.params.safeGetIntParam("groupArticleId") 
         if groupArticleId > 0:
             groupArticle = self.groupService.getGroupArticle(groupArticleId)
             if groupArticle != None:
                 self.groupService.deleteGroupArticle(groupArticle)
                 
     qry = GroupArticleQuery(" ga.id, g.groupId, g.groupTitle,ga.pubDate ")
     articleId = self.params.safeGetIntParam("articleId")
     if articleId == 0:
         self.addActionError(u"缺少文章Id参数")
         return ActionResult.ERROR
     qry.articleId = articleId
     qry.articleState = None
     group_list = qry.query_map(-1)
     request.setAttribute("group_list", group_list)
     request.setAttribute("articleId", articleId)
     return "/WEB-INF/ftl/article/articleGroupList.ftl"
 def getArticleList(self, visitor_role):
   qry = GroupArticleQuery("ga.articleId, ga.title, ga.loginName, ga.userTrueName, ga.createDate, ga.typeState")
   if self.isKtGroup==1:
     qry.includeChildGroup=True    
   qry.groupId = self.group.groupId
   if self.category != None and self.category.categoryId != 0:
     if self.isKtGroup==1:
       #需要汇聚下级组的文章,只能汇聚同名分类的文章
       qry.gartCateName = self.category.name
     else:
       qry.gartCateId = self.category.categoryId
   pager = self.createPager()
   pager.totalRows = qry.count()
   article_list = qry.query_map(pager)
   #print "article_list = ", article_list    
   request.setAttribute("article_list", article_list) 
   request.setAttribute("pager", pager)    
Example #3
0
 def article_list(self):        
     self.collectionQueryString()
     if self.rcmdState == "-1":
         #print "Create GroupArticleQuery..."
         qry = GroupArticleQuery(""" a.articleId, a.title, a.createDate,a.pushState,
                            a.gradeId, a.hideState, a.topState, a.bestState, a.delState, a.recommendState,
                             a.typeState, a.unitId, sc.name as sysCateName,
                             a.userId, a.auditState, u.userId, ga.isGroupBest 
                        """)
     else:
         qry = ArticleQuery(""" a.articleId, a.title, a.createDate,a.pushState,
                            a.gradeId, a.hideState, a.topState, a.bestState, a.delState, a.recommendState,
                            a.typeState, a.unitId, sc.name as sysCateName,
                            a.userId, a.auditState, u.userId 
                        """)
     
     if self.sysCateId != "" and self.sysCateId.isdigit() == True:
         qry.sysCateId = int(self.sysCateId)            
     
     if self.approveState == "" or self.approveState.isdigit() == False:
         qry.auditState = None
     else:
         qry.auditState = int(self.approveState)        
     
     if self.bestState == "" or self.bestState.isdigit() == False:
         qry.bestState = None
     else:
         qry.bestState = self.triblesimu(self.bestState)
     
     if self.rcmdState == "-1":
         #小组文章的精华 GroupArticle 中的  isGroupBest = True
         qry.groupBest = True
     else:     
         if self.rcmdState == "" or self.rcmdState.isdigit() == False:       #凭什么说 -1 不是数字??????
             qry.rcmdState = None
         else:
             qry.rcmdState = self.triblesimu(self.rcmdState)
     
     if self.deleteState == "" or self.deleteState.isdigit() == False:
         qry.delState = None
     else:
         qry.delState = self.triblesimu(self.deleteState)
     
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     pager = self.params.createPager()
     pager.itemName = u"文章"
     pager.itemUnit = u"篇"
     pager.pageSize = 25
     pager.totalRows = qry.count()
     article_list = qry.query_map(pager)
     groupbest_list = []
     if self.rcmdState != "-1":
         #增加小组文章精华的字段
         for a in article_list :
             artId = a['articleId']
             groupbest_list.append(self.groupArticleService.isBestInGroupArticle(artId))
             
     grade_list = self.subjectService.getMainGradeList()
     article_categories = self.categoryService.getCategoryTree('default')        
     request.setAttribute("article_categories", article_categories)
     request.setAttribute("grade_list", grade_list)
     request.setAttribute("groupbest_list", groupbest_list)     
     request.setAttribute("article_list", article_list)
     request.setAttribute("pager", pager)
     request.setAttribute("subject", self.subject)
     return "/WEB-INF/subjectmanage/article.ftl"
Example #4
0
    def execute(self):
        # 完整的调用参数:
        # js_article.py?top=4&count=4&type=0&cateid=13&author=1&date=1&groupId=42

        # 默认支持 subjectId,gradeId,参数带这些值,默认是支持的
        # 更多参数请参见 article_query的成员定义。

        self.params = ParamUtil(request)
        ShowCount = self.params.getIntParam("count")
        ShowTop = self.params.getIntParam("top")
        ShowType = self.params.getIntParam("type")
        ShowAuthor = self.params.getIntParamZeroAsNull("author")
        ShowDate = self.params.getIntParamZeroAsNull("date")

        unitId = self.params.getIntParamZeroAsNull("unitid")
        cateid = self.params.getIntParamZeroAsNull("cateid")
        groupId = self.params.getIntParamZeroAsNull("groupId")
        unitService = __spring__.getBean("unitService")
        if unitId == None:
            rootUnit = unitService.getRootUnit()
        else:
            rootUnit = unitService.getUnitById(unitId)

        if rootUnit == None:
            response.getWriter().println(u"document.write('没有根单位。')")
            return

        if ShowTop == None or ShowTop == 0:
            ShowTop = 10
        if ShowCount == None or ShowCount == 0:
            ShowCount = 10
        if ShowType == None:
            ShowType = 0

        if groupId != None and groupId != 0:
            qry = GroupArticleQuery(
                """ ga.articleId, ga.title, ga.createDate, ga.userId, ga.loginName, ga.userTrueName as trueName  """
            )
            qry.groupId = groupId
        else:
            qry = __PrivateArticleQuery(
                """ a.articleId, a.title, a.createDate, u.userId, u.loginName, u.trueName """
            )
            qry.unitId = unitId
            qry.sysCateId = cateid

            if ShowType == 1:
                #推荐文章
                #qry.rcmdState = True
                qry.custormAndWhereClause = "a.rcmdPathInfo Like '%/" + str(
                    rootUnit.unitId
                ) + "/%' and a.approvedPathInfo Like '%/" + str(
                    rootUnit.unitId) + "/%'"

            elif ShowType == 2:
                #名师文章
                qry.userIsFamous = 1
                qry.custormAndWhereClause = "a.approvedPathInfo Like '%/" + str(
                    rootUnit.unitId) + "/%'"
            elif ShowType == 3:
                #精华文章
                qry.bestState = True
                qry.custormAndWhereClause = "a.approvedPathInfo Like '%/" + str(
                    rootUnit.unitId) + "/%'"

        article_list = qry.query_map(ShowTop)
        request.setAttribute("article_list", article_list)
        request.setAttribute("ShowAuthor", ShowAuthor)
        request.setAttribute("ShowDate", ShowDate)
        request.setAttribute("ShowCount", ShowCount)
        response.contentType = "text/html; charset=utf-8"
        return "/WEB-INF/ftl/js_article.ftl"
Example #5
0
 def __home_article_list(self):
   qry = GroupArticleQuery(""" ga.articleId, ga.title, ga.createDate """)
   qry.groupId = self.group.groupId
   article_list = qry.query_map(5)
   request.setAttribute("article_list", article_list)
   return    
Example #6
0
    def execute(self):

        if self.loginUser == None:
            response.addHeader("result", "error")
            response.getWriter().println(u"请先登录。")
            return

        groupService = __spring__.getBean("groupService")

        beginDate = self.params.safeGetStringParam("beginDate")
        endDate = self.params.safeGetStringParam("endDate")
        groupId = self.params.safeGetIntParam("groupId")
        guid = self.params.safeGetStringParam("guid")
        type = self.params.safeGetStringParam("type")
        u = self.params.safeGetIntParam("userId")

        #验证是否是日期格式:
        if CommonUtil.isYYYYMMDDDate(
                beginDate) == False or CommonUtil.isYYYYMMDDDate(
                    endDate) == False:
            response.addHeader("result", "error")
            response.getWriter().println(u"无效的日期格式。必须是yyyy-MM-dd格式。")
            return
        if beginDate == "":
            beginDate = "2008-01-01"
        if endDate == "":
            sdf = SimpleDateFormat("yyyy-MM-dd")
            endDate = sdf.format(Date())

        b = SimpleDateFormat("yyyy-MM-dd").parse(beginDate)
        b = SimpleDateFormat("yyyy-MM-dd").format(b)
        if beginDate != b:
            response.addHeader("result", "error")
            response.getWriter().println(u"开始日期的日期格式无效:必须是yyyy-MM-dd格式。")
            return

        e = SimpleDateFormat("yyyy-MM-dd").parse(endDate)
        e = SimpleDateFormat("yyyy-MM-dd").format(e)
        if endDate != e:
            response.addHeader("result", "error")
            response.getWriter().println(u"结束日期的日期格式无效:必须是yyyy-MM-dd格式。")
            return

        #response.addHeader("beginDate", beginDate)
        #response.addHeader("endDate", endDate)
        beginDate = beginDate + " 0:0:0"
        endDate = endDate + " 23:59:59"

        if type == "check":
            if groupId == 0:
                response.addHeader("result", "error")
                response.getWriter().println(u"请输入协作组标识。")
                return
            if guid == "":
                response.addHeader("result", "error")
                response.getWriter().println(u"缺少 GUID 标识。")
                return
        elif type == "query":
            userService = __spring__.getBean("userService")
            user = userService.getUserById(u)
            if user == None:
                response.addHeader("result", "error")
                response.getWriter().println(u"无法加载该用户。")
                return
            LoginName = user.loginName
            TrueName = user.trueName
            UnitName = None
            UnitTitle = None
            MetaSubjectId = None
            MetaSubjectTitle = None
            GradeId = None
            GradeTitle = None
            if user.unitId != None:
                unitService = __spring__.getBean("unitService")
                unit = unitService.getUnitById(user.unitId)
                if unit != None:
                    UnitName = unit.unitName
                    UnitTitle = unit.unitTitle

            if user.subjectId != None:
                subjectService = __spring__.getBean("subjectService")
                subject = subjectService.getMetaSubjectById(user.subjectId)
                if subject != None:
                    MetaSubjectId = subject.msubjId
                    MetaSubjectTitle = subject.msubjName

            if user.gradeId != None:
                subjectService = __spring__.getBean("subjectService")
                grade = subjectService.getGrade(user.gradeId)
                if grade != None:
                    GradeId = grade.gradeId
                    GradeTitle = grade.gradeName

            qry = GroupArticleQuery("ga.articleId, ga.groupId")
            qry.groupId = groupId
            ArticleCount = qry.count()

            qry = GroupArticleQuery("ga.articleId, ga.groupId")
            qry.groupId = groupId
            qry.groupBest = True
            BestArticleCount = qry.count()

            qry = GroupResourceQuery("r.resourceId,gr.groupId")
            qry.groupId = groupId
            ResourceCount = qry.count()

            qry = GroupResourceQuery("r.resourceId,gr.groupId")
            qry.groupId = groupId
            qry.isGroupBest = True
            BestResourceCount = qry.count()

            sql = "SELECT COUNT(*) AS TopicCount FROM Topic WHERE createDate Between '" + beginDate + "' And '" + endDate + "' And userId = " + str(
                u) + " And groupId=" + str(groupId)
            TopicCount = Command(sql).int_scalar()

            sql = "SELECT COUNT(*) AS ReplyCount FROM Reply WHERE createDate Between '" + beginDate + "' And '" + endDate + "' And userId = " + str(
                u) + " And groupId=" + str(groupId)
            ReplyCount = Command(sql).int_scalar()
            #returnValue = returnValue + str(u) + "|" + str(ArticleCount) + "|" + str(BestArticleCount) + "|" + str(ResourceCount) + "|" + str(BestResourceCount) + "|" + str(TopicCount) + "|" + str(ReplyCount) + ","
            groupDataQuery = GroupDataQuery()
            groupDataQuery.setObjectGuid(guid)
            groupDataQuery.setBeginDate(beginDate)
            groupDataQuery.setEndDate(endDate)
            groupDataQuery.setLoginName(LoginName)
            groupDataQuery.setTrueName(TrueName)
            groupDataQuery.setUnitName(UnitName)
            groupDataQuery.setUnitTitle(UnitTitle)
            groupDataQuery.setMetaSubjectId(MetaSubjectId)
            groupDataQuery.setMetaSubjectTitle(MetaSubjectTitle)
            groupDataQuery.setGradeId(GradeId)
            groupDataQuery.setGradeTitle(GradeTitle)
            groupDataQuery.setArticleCount(ArticleCount)
            groupDataQuery.setBestArticleCount(BestArticleCount)
            groupDataQuery.setResourceCount(ResourceCount)
            groupDataQuery.setBestResourceCount(BestResourceCount)
            groupDataQuery.setTopicCount(TopicCount)
            groupDataQuery.setReplyCount(ReplyCount)
            groupService.saveOrUpdateGroupDataQuery(groupDataQuery)

        else:
            response.addHeader("result", "error")
            response.getWriter().println(u"无效的命令。")
            return