def getGroupById(self, groupId): cmd = Command(""" FROM Group g WHERE g.groupId = :groupId """) cmd.setInteger("groupId", groupId) group_list = cmd.open(1) if group_list == None or group_list.size() == 0: return None return group_list[0]
def get_comment_star(self): # 注意:如果没有记录,返回的结果是 StarCount 为 Null,StarNumber 为 0,所以 commentStar 永远不会为 None sql = """ SELECT SUM(star) AS StarCount, COUNT(star) AS StarNumber FROM Comment WHERE objId = :articleId """ cmd = Command(sql) cmd.setInteger("articleId", self.article.articleId) commentStar = cmd.first() if commentStar == None: return else: if commentStar[0] == None: return else: StarCount = int(commentStar[0]) if commentStar[1] == None: return else: StarNumber = int(commentStar[1]) if StarNumber < 1: return AveStar = StarCount / StarNumber request.setAttribute("StarCount", StarCount) request.setAttribute("StarNumber", StarNumber) request.setAttribute("AveStar", AveStar)
def getUserById(self, userId): cmd = Command(""" FROM User u WHERE u.userId = :userId """) cmd.setInteger("userId", userId) user_list = cmd.open(1) if user_list == None or user_list.size() == 0: return None return user_list[0]
def get_childs(self, group): hql = """ FROM Group WHERE parentId = :parentId ORDER BY id DESC """ cmd = Command(hql) cmd.setInteger("parentId", group.groupId) group_list = cmd.open(-1) request.setAttribute("group_list", group_list) return
def getArticleAndAuthor(self, articleId): cmd = Command("SELECT a, u FROM Article a, User u WHERE a.userId = u.userId AND a.articleId = :articleId") cmd.setInteger("articleId", articleId) list = cmd.open(1) if list == None or list.size() == 0: return None au = list[0] return ArticleAndUser(au[0], au[1])
def query_group_activity_list(self): # 活跃度算法 (g.userCount + g.articleCount + g.topicCount + g.resourceCount) / 10 hql = """ select new Map( g.groupId as groupId, g.groupTitle as groupTitle, g.parentId, (g.userCount + g.articleCount + g.topicCount + g.resourceCount) / 10 as totalCount) FROM Group g where g.groupState = 0 ORDER BY (g.userCount + g.articleCount + g.topicCount + g.resourceCount) DESC """ cmd = Command(hql) group_activity_list = cmd.open(25) request.setAttribute("group_activity_list", group_activity_list)
def getPhotoAndAuthor(self, photoId): cmd = Command( "SELECT p, u FROM Photo p, User u WHERE p.userId = u.userId AND p.photoId = :photoId" ) cmd.setInteger("photoId", photoId) list = cmd.open(1) if list == None or list.size() == 0: return None pu = list[0] return PhotoAndUser(pu[0], pu[1])
def getResourceAndAuthor(self, resourceId): cmd = Command( "SELECT r, u FROM Resource r, User u WHERE r.userId = u.userId AND r.resourceId = :resourceId" ) cmd.setInteger("resourceId", resourceId) list = cmd.open(1) if list == None or list.size() == 0: return None ru = list[0] return ResourceAndUser(ru[0], ru[1])
def subject_options(self): gradeId = self.params.safeGetStringParam("gradeId") if gradeId == None or gradeId == "": qry = Command(""" SELECT distinct metaSubject as metaSubject FROM Subject """) else: gradeId = gradeId[0] + "000" qry = Command(""" SELECT metaSubject as metaSubject FROM Subject Where metaGradeId =""" + gradeId) subjectList = qry.open() request.setAttribute("subject_list", subjectList) return "/WEB-INF/ftl/admin/subject_options_ajax.ftl"
def school_link(self): cache_key = "school_show" school_link = cache.get(cache_key) if school_link == None: # 机构风采 objectType = 100, objectId = 1. # cmd = Command(""" FROM Link WHERE objectType = 100 AND objectId = 1 ORDER BY linkId DESC """) cmd = Command(" FROM Unit Where parentId <> 0 ORDER BY rank DESC ") school_link = cmd.open(10) cache.put(cache_key, school_link) request.setAttribute("school_link", school_link)
def execute(self): accessControlService = __spring__.getBean("accessControlService") cmd = request.getParameter("cmd") isSystemAdmin = accessControlService.isSystemAdmin(self.loginUser) isChannelSystemAdminList = accessControlService.getAllAccessControlByUserAndObjectType( self.loginUser, 11) isChannelUserAdminList = accessControlService.getAllAccessControlByUserAndObjectType( self.loginUser, 12) isChannelContentAdminList = accessControlService.getAllAccessControlByUserAndObjectType( self.loginUser, 13) if isSystemAdmin == False and len( isChannelSystemAdminList) < 1 and len( isChannelSystemAdminList) < 1 and len( isChannelSystemAdminList) < 1: self.addActionError(u"你无权管理频道。") return self.ERROR if cmd == "menu": channel_list = None #判断是否是系统管理员 if isSystemAdmin: request.setAttribute("admin_type", "admin") channel_list = self.channelPageService.getChannelList() else: # 得到当前用户可以管理的频道列表 qry = Command( "SELECT DISTINCT objectId as objectId FROM AccessControl Where userId = " + str(self.loginUser.userId) + " And (objectType = 11 or objectType = 12 or objectType = 13) Order By objectId ASC" "") ChannelID = qry.open() channel_list = [] for id in ChannelID: channel = self.channelPageService.getChannel(id) channel_list.append(channel) if len(channel_list) > 0: request.setAttribute("admin_type", "channeladmin") else: request.setAttribute("admin_type", "") request.setAttribute("channel_list", channel_list) return "/WEB-INF/ftl/channel/menu.ftl" elif cmd == "main": return "/WEB-INF/ftl/channel/main.ftl" elif cmd == "head": return "/WEB-INF/ftl/channel/head.ftl" else: return "/WEB-INF/ftl/channel/index.ftl"
def get_subject_list(self): #self.subjectService = __jitar__.subjectService # 另外一种写法,数据显示存在问题 #cachekey_grade = "grade" #GradeList = None#self.cache.get(cachekey_grade) #if GradeList == None: # GradeList = self.subjectService.getGradeListOnlyIsGrade() # self.cache.put(cachekey_grade, GradeList) #SubjectArray = ArrayList() #for g in GradeList: # cachekey = "subject" + str(g.gradeId) # SubjectOfGrade = self.subjectService.getSubjectByGradeId(g.gradeId) # SubjectArray.add({"grade" : g, "subject": SubjectOfGrade}) #request.setAttribute("SubjectArray", SubjectArray) cache_key1 = "metaSubject" cache_key2 = "metaGrade" metaSubject = self.cache.get(cache_key1) MetaGrade = self.cache.get(cache_key2) if metaSubject == None: #先得到年级 subjectService = __spring__.getBean("subjectService") qry = Command( """ SELECT gradeId, gradeName FROM Grade Where isGrade = true Order By gradeId DESC""" ) MetaGrade = qry.open() self.cache.put(cache_key2, MetaGrade) #print "meta_Grade:", MetaGrade metaSubject = ArrayList() for grade in MetaGrade: subj = subjectService.getSubjectByGradeId(int(grade[0])) m = ArrayList() if subj != None: for sj in range(0, subj.size()): m.add(subj[sj].metaSubject) metaSubject.add({ "gradeName": grade[1], "gradeId": grade[0], "metaSubject": m }) self.cache.put(cache_key1, metaSubject) request.setAttribute("metaGrade", MetaGrade) request.setAttribute("meta_Grade", MetaGrade) request.setAttribute("SubjectNav", metaSubject)
def save_post(self): cmd = self.params.safeGetStringParam("cmd") guids = self.params.safeGetIntValues("guid") for g in guids: user = self.userService.getUserById(g) if user != None: if cmd == "delete": #检查用户是否创建了群组: sql = "SELECT COUNT(*) AS JoinedCount FROM Group WHERE createUserId=" + str( user.userId) JoinedCount = Command(sql).int_scalar() if JoinedCount > 0: response.getWriter().println( u"用户【" + user.trueName + u"(" + user.loginName + u")】还有创建的协作组没有处理,请先转让该用户创建的协作组。") return self.userService.deleteUser(user.userId) elif cmd == "audit": user.setUserStatus(0) self.userService.updateUser(user, False) self.userService.updateUserStatus(user, User.USER_STATUS_NORMAL) else: self.addActionError(u"无效的命令。") return self.ERROR
def user_list123(self): hql = """SELECT new Map(u.userId as userId, u.loginName as loginName, u.trueName as trueName) FROM User u ORDER BY u.userId """ user_list = Command(hql).open(6) request.setAttribute("userList", user_list) return "/WEB-INF/ftl/admin/Admin_Stat_List_1.ftl"
def execute(self): self.config = self.cfg_svc.getConfigure() # 群组 self.groupList() user_list = None singleuser = self.params.getIntParam("singleuser") #1 用户单选 2 用户多选 if singleuser == None: singleuser = 1 closewindow = self.params.getIntParam("closewindow") if closewindow == None: closewindow = 0 groupids = self.params.getStringParam("groupids") if groupids == None: closewindow = 0 else: if closewindow == 1: hql = """SELECT new Map(u.userId as userId,u.gender, u.loginName as loginName, u.trueName as trueName) FROM User u Where u.userId In(Select gm.userId from GroupMember gm Where gm.groupId In(""" + groupids + """))""" user_list = Command(hql).open() request.setAttribute("closewindow", closewindow) request.setAttribute("user_list", user_list) inputUser_Id = self.params.getStringParam("inputUser_Id") inputUserName_Id = self.params.getStringParam("inputUserName_Id") inputLoginName_Id = self.params.getStringParam("inputLoginName_Id") request.setAttribute("singleuser", singleuser) request.setAttribute("inputUser_Id", inputUser_Id) request.setAttribute("inputUserName_Id", inputUserName_Id) request.setAttribute("inputLoginName_Id", inputLoginName_Id) # 返回 response.contentType = "text/html; charset=UTF-8" return "/WEB-INF/ftl/searchUserList1.ftl"
def subject_options(self): gradeId = self.params.safeGetIntParam("gradeId") if gradeId == None or gradeId == 0: qry = Command( """ SELECT distinct metaSubject as metaSubject FROM Subject """ ) else: gradeId = CommonUtil.convertRoundMinNumber(gradeId) #gradeId=gradeId[0]+"000" qry = Command( """ SELECT metaSubject as metaSubject FROM Subject Where metaGradeId =""" + str(gradeId)) subjectList = qry.open() #print subjectList request.setAttribute("subject_list", subjectList) return "/WEB-INF/ftl/admin/subject_options_ajax.ftl"
def GenSubjectNav(self): strFile = request.getServletContext().getRealPath("/") strFile = URLDecoder.decode(strFile, "utf-8") strSubjectFile = strFile + "html" + File.separator file = File(strSubjectFile) if file.exists() == False: file.mkdirs() #创建学科导航 strSubjectFile = strSubjectFile + "subject_nav.html" file = File(strSubjectFile) #先得到年级 subjectService = __spring__.getBean("subjectService") qry = Command( " SELECT DISTINCT metaGrade.gradeId FROM Subject Order By metaGrade.gradeId ASC" ) mGradeId = qry.open() MetaGrade = ArrayList() metaSubject = ArrayList() for grade in mGradeId: mGrade = subjectService.getGrade(int(grade)) MetaGrade.add(mGrade) subj = subjectService.getSubjectByGradeId(int(grade)) m = ArrayList() if subj != None: for sj in range(0, subj.size()): m.add(subj[sj].metaSubject) metaSubject.add({ "gradeName": mGrade.gradeName, "gradeId": grade, "metaSubject": m }) map = HashMap() map.put("metaGrade", MetaGrade) map.put("meta_Grade", MetaGrade) map.put("SubjectNav", metaSubject) templateProcessor = __spring__.getBean("templateProcessor") str = templateProcessor.processTemplate( map, "/WEB-INF/ftl/site_subject_nav.ftl", "utf-8") try: fw = OutputStreamWriter(FileOutputStream(file), "utf-8") fw.flush() fw.write(str) fw.close() finally: file = None fw = None
def updateGroupResourceCategoryId(self, category): cmd = Command(""" UPDATE GroupResource SET groupCateId = NULL WHERE groupId = :groupId AND groupCateId = :groupCateId """) cmd.setInteger("groupId", self.group.groupId) cmd.setInteger("groupCateId", category.categoryId) count = cmd.update()
def execute(self): self.loginName = request.getAttribute("loginName") # 加载当前用户对象. self.user = user_svc.getUserByLoginName(self.loginName) request.setAttribute("user", self.user) pager = self.params.createPager() qry = ActionQuery(""" act.title, act.createDate, act.actionId, act.ownerId, act.ownerType, act.createUserId, act.actionType, act.description, act.userLimit, act.startDateTime,act.finishDateTime, act.attendLimitDateTime, act.place, act.status, act.visibility, act.attendCount """) qry.ownerType = "user" qry.status = 0 qry.createUserId = self.user.userId pager.setPageSize(16) pager.itemName = u"活动" pager.itemUnit = u"个" action_list = qry.query_map(pager) pager.totalRows = action_list.size() #print "group_list = " , group_list request.setAttribute("action_list", action_list) request.setAttribute("pager",pager) 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).first() #print "pageSkin = ", pageSkin if pageSkin == None or pageSkin == "": pageSkin = "skin1" # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据. #pages : [{id: ${page.pageId}, title: '${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": "placerholder1", "pageId":0, "columnIndex":2,"title":"","module":"placeholder", "ico":"", "data":""} ] request.setAttribute("widgets",widgets) request.setAttribute("widget_list",widgets) response.setContentType("text/html; charset=UTF-8") return "/WEB-INF/user/default/user_actions.ftl"
def list(self): if self.login_user == None: self.writer.write("logon") return favUser = self.login_user.userId fav_list = self.favo_svc.getUFavoritesList(favUser) pager = self.createPager() if fav_list == None: pager.totalRows = 0 else: pager.totalRows = fav_list.size() hql = """ from UFavorites Where favUser=:favUser ORDER BY favId DESC""" cmd = Command(hql) cmd.setInteger("favUser", favUser) fav_list = cmd.open(pager) request.setAttribute("pager", pager) request.setAttribute("fav_list", fav_list) return "/WEB-INF/ftl/user/fav_list.ftl"
def deleteChannelCategory(self, resType, category): if category == None: return cmd = Command( " UPDATE " + resType + " SET channelCate = NULL,channelCateId = NULL WHERE channelId = :channelId AND channelCateId = :channelCateId " ) cmd.setInteger("channelId", self.channel.channelId) cmd.setInteger("channelCateId", category.categoryId) count = cmd.update()
def get_links(self, group): hql = """ FROM Link WHERE objectType = :objectType AND objectId = :objectId ORDER BY linkId DESC """ cmd = Command(hql) cmd.setInteger("objectType", OBJECT_TYPE_GROUP) cmd.setInteger("objectId", group.groupId) # 取出最新 5 个友情链接. link_list = cmd.open(5) request.setAttribute("link_list", link_list) return
def main(self): qry = UserQuery( """ u.userId, u.loginName, u.userIcon, u.gender, u.trueName, u.email, u.blogName, u.blogIntroduce, u.myArticleCount, u.otherArticleCount, u.historyMyArticleCount, u.historyOtherArticleCount, u.visitCount,u.resourceCount, u.commentCount,u.photoCount,u.subjectId, u.gradeId, u.positionId, subj.subjectName, grad.gradeName, unit.unitTitle, sc.name """) qry.userStatus = None qry.loginName = self.loginUser.loginName users = qry.query_map() if users.size() == 0: response.sendRedirect("../login.jsp") user = users[0] request.setAttribute("user", user) # TODO: 下面的查询用 XxxQuery 改写, 现在统计不对. hql = """ select count(*) as groupCount FROM GroupMember gm where gm.userId = """ + str( self.loginUser.userId) + """ """ cmd = Command(hql) groupCount = cmd.int_scalar() request.setAttribute("groupCount", groupCount) hql = """ select count(*) as messageCount FROM Message m where m.receiveId = """ + str( self.loginUser.userId) + """ """ cmd = Command(hql) messageCount = cmd.int_scalar() request.setAttribute("messageCount", messageCount) hql = """ select count(*) as friendCount FROM Friend f where f.userId = """ + str( self.loginUser.userId) + """ """ cmd = Command(hql) friendCount = cmd.int_scalar() request.setAttribute("friendCount", friendCount) return "/WEB-INF/ftl/user/manage_main.ftl"
def execute(self): self.loginName = request.getAttribute("loginName") writer = response.getWriter() # 加载当前用户对象. self.user = user_svc.getUserByLoginName(self.loginName) request.setAttribute("user", self.user) 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() #print "pageSkin = ", pageSkin if pageSkin == None or pageSkin == "": pageSkin = "skin1" # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据. #pages : [{id: ${page.pageId}, title: '${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 = JSONValue.parse(self.page.customSkin) request.setAttribute("customSkin", customSkin) # 构造widgets . widgets = [ {"id": "1", "pageId":0, "columnIndex":1,"title":u"个人档案","module":"profile", "ico":"", "data":""}, {"id": "placerholder1", "pageId":0, "columnIndex":2,"title":"","module":"placeholder", "ico":"", "data":""} ] request.setAttribute("widgets",widgets) request.setAttribute("widget_list",widgets) #得到当前用户的创建的活动 pager = self.params.createPager() qry = PrepareCourseMemberQuery(""" pc.prepareCourseId,pc.title, pc.createDate,pc.memberCount,pc.articleCount,pc.resourceCount,pc.actionCount,pc.topicCount,pc.topicReplyCount """) qry.status = 0 qry.userId = self.user.userId pager.setPageSize(16) pager.itemName = u"备课" pager.itemUnit = u"个" course_list = qry.query_map(pager) pager.totalRows = course_list.size() request.setAttribute("course_list", course_list) request.setAttribute("pager", pager) response.setContentType("text/html; charset=UTF-8") return "/WEB-INF/user/default/user_joinedpreparecourse_list.ftl"
def execute(self): params = ParamUtil(request) cmt_svc = __jitar__.getCommentService() writer = response.getWriter() if self.loginUser == None: writer.write(u"请先登录。") return userName = self.loginUser.trueName if userName == None: userName = self.loginUser.loginName title = params.getStringParam("title") objtype = params.getIntParam("objtype") aboutUserId = params.getIntParam("aboutUserId") objId = params.getIntParam("photoId") star = params.getIntParam("star") content = params.getStringParam("content") userIP = request.getHeader("x-forwarded-for") if userIP == None or userIP == "": userIP = request.getRemoteAddr() if title == "": writer.write(u"请输入标题。") return if content == "" or content == "<span></span>": writer.write(u"请输入评论内容。") return cmt = Comment() cmt.setTitle(title) cmt.setAboutUserId(aboutUserId) cmt.setIp(userIP) cmt.setUserName(userName) cmt.setUserId(self.loginUser.userId) cmt.setCreateDate(Date()) cmt.setStar(star) cmt.setAudit(True) cmt.setContent(content) cmt.setObjId(objId) cmt.setObjType(objtype) cmt_svc.saveComment(cmt) # 评论计数器 cmd = Command( """ UPDATE Photo SET commentCount = commentCount + 1 WHERE photoId = :photoId """ ) cmd.setInteger("photoId", objId) cmd.update() photoUser = params.getStringParam("photoUser") if request.getHeader("Referer") != None: response.sendRedirect(request.getHeader("Referer")) return request.setAttribute( "redUrl", photoUser + "/py/user_photo_show.py?photoId=" + str(objId)) return "/WEB-INF/ftl/photo/PhotoComment_Success.ftl"
def create_subject_nav(self): subjectService = __spring__.getBean("subjectService") qry = Command(" SELECT DISTINCT metaGrade.gradeId FROM Subject Order By metaGrade.gradeId ASC") mGradeId = qry.open() MetaGrade = ArrayList() metaSubject = ArrayList() for grade in mGradeId: mGrade = subjectService.getGrade(int(grade)) MetaGrade.add(mGrade) subj = subjectService.getSubjectByGradeId(int(grade)) m = ArrayList() if subj != None: for sj in range(0, subj.size()): m.add(subj[sj].metaSubject) metaSubject.add({"gradeName" : mGrade.gradeName, "gradeId" : grade, "metaSubject" : m }) map = HashMap() map.put("metaGrade", MetaGrade) map.put("meta_Grade", MetaGrade) map.put("SubjectNav", metaSubject) map.put("SiteUrl", request.getContextPath() + "/") templateProcessor = __spring__.getBean("templateProcessor") str = templateProcessor.processTemplate(map, "/WEB-INF/ftl/site_subject_nav.ftl", "utf-8") rootPath = JitarRequestContext.getRequestContext().getServletContext().getRealPath("/") fileIndex = rootPath + "html" + File.separator + "subject_nav.html" try: file = File(fileIndex) fw = OutputStreamWriter(FileOutputStream(file), "utf-8") #fw = FileWriter(file, False) fw.flush() fw.write(str) fw.close() finally: file = None fw = None request.setAttribute("errorMessage", u"生成学科导航缓存文件完毕!")
def execute(self): #print "Hello" writer = response.writer #self.params = ParamUtil(request) loginName = request.getAttribute("loginName") if(loginName == None or loginName == ''): writer.write(u"没有该用户。") return user = __jitar__.userService.getUserByLoginName(loginName) if user == None: writer.write(u"无法加载当前用户。") return self.userName = user.loginName fc = FileCache() content = fc.getUserFileCacheContent(self.userName, "photo_category.html",144000) if content != "": response.getWriter().write(content) fc = None return hql = """select new Map(stap.id as id, stap.title as title) from PhotoStaple stap where stap.isHide = 0 and stap.userId = """ + str(user.userId) + """ ORDER BY stap.orderNum ASC """ photocate = Command(hql).open() templateProcessor = __spring__.getBean("templateProcessor") map = HashMap() map.put("photocate", photocate) map.put("user", user) map.put("UserSiteUrl", self.getUserSiteUrl()) content = templateProcessor.processTemplate(map, "/WEB-INF/user/default/photo_category.ftl", "utf-8") fc.writeUserFileCacheContent(self.userName, "photo_category.html",content) response.getWriter().write(content) fc = None
def execute(self): request.setAttribute("ChatRoomName", u"聊天室") if self.loginUser == None: return userName = self.loginUser.trueName if userName == None: userName = self.loginUser.loginName userId = self.loginUser.userId roomId = self.params.safeGetIntParam("roomId") if roomId == None or roomId == 0: roomId = 1 qry = Command( """ SELECT new Map(userId as userId,userName as userName) FROM ChatUser Where isLeave=0 and roomId=""" + str(roomId) + """ ORDER BY sayDate desc """) userList = qry.open() qry = Command( " SELECT new Map(colorName as colorName,colorValue as colorValue) FROM ChatColor " ) colorList = qry.open() #得到自己的颜色 chtuser = self.userchat_svc.getChatUser(roomId, userId) if chtuser == None: chatUser = ChatUser() chatUser.userId = userId chatUser.roomId = roomId chatUser.isLeave = False chatUser.isActived = True chatUser.userName = userName self.userchat_svc.saveChatUser(chatUser) elif chtuser.isActived == False: self.userchat_svc.updateChatUserIsLeave(roomId, userId, False) chtuser = self.userchat_svc.getChatUser(roomId, userId) mycolor = chtuser.fontColor if mycolor == None or mycolor == "": mycolor = "#000000" request.setAttribute("mycolor", mycolor) request.setAttribute("roomId", roomId) request.setAttribute("userList", userList) request.setAttribute("colorList", colorList) return "/WEB-INF/ftl/chat/manage.ftl"
def execute(self): site_config = SiteConfig() site_config.get_config() param = ParamUtil(request) newsId = param.getIntParam("newsId") if newsId == None or newsId == "": return self.sub_svc = __jitar__.getSubjectService() news = self.sub_svc.getSiteNews(newsId) if news == None: return sql = """ Update SiteNews Set viewCount = viewCount + 1 Where newsId = :newsId """ cmd = Command(sql) cmd.setInteger("newsId", newsId) cmd.update() request.setAttribute("news", news) response.setContentType("text/html; charset=UTF-8") return "/WEB-INF/ftl/show_news.ftl"
def execute(self): site_config = SiteConfig() site_config.get_config() photoId = self.params.getIntParam("photoId") photo = self.photo_svc.findById(photoId) request.setAttribute("photo", photo) #DEBUG print "photoId = ", photoId, ", photo = ", self.photo #print "===photo.sysCateId===:",photo.sysCateId if photo != None: if photo.sysCateId != None: category = self.cate_svc.getCategory(photo.sysCateId) request.setAttribute("category", category) # 更新访问计数 cmd = Command( """ UPDATE Photo SET viewCount = viewCount + 1 WHERE photoId = :photoId """ ) cmd.setInteger("photoId", photo.photoId) cmd.update() return "/WEB-INF/ftl/showPhoto.ftl"