def genernate_video_content(self, webpart): cache_key = "unit" + str(self.unit.unitId) + "_" + str( webpart.getUnitWebpartId()) content = cache.get(cache_key) if content != None: request.setAttribute(cache_key, content) return map = HashMap() qry = VideoQuery( """ v.videoId, v.title, v.createDate, v.href, v.flvHref, v.userId, u.loginName, u.nickName, v.summary,v.flvThumbNailHref """ ) qry.orderType = VideoQuery.ORDER_TYPE_VIDEOID_DESC qry.unitId = self.unit.unitId new_video_list = qry.query_map(4) map.put("new_video_list", new_video_list) map.put("unit", self.unit) map.put("webpart", webpart) map.put("UnitRootUrl", self.unitRootUrl) content = self.templateProcessor.processTemplate( map, "/WEB-INF/unitspage/" + self.templateName + "/video.ftl", "utf-8") request.setAttribute(cache_key, content) cache.put(cache_key, content)
def get_video_querylist(self): qry = VideoQuery( " v.videoId, v.title, v.createDate, v.href, v.flvHref, v.userId, v.flvThumbNailHref,v.auditState " ) qry.auditState = None qry.orderType = VideoQuery.ORDER_TYPE_VIDEOID_DESC vIds = self.params.getStringParam("id") qry.videoIds = vIds video_list = qry.query_map() request.setAttribute("video_list", video_list)
def get_video_list(self): qry = VideoQuery( """ v.videoId, v.title, v.createDate, v.href, v.flvHref, v.userId, u.loginName, u.nickName, v.summary,v.flvThumbNailHref """ ) qry.orderType = VideoQuery.ORDER_TYPE_VIDEOID_DESC qry.unitId = self.unit.unitId pager = self.createPager() pager.totalRows = qry.count() video_list = qry.query_map(pager) request.setAttribute("video_list", video_list) request.setAttribute("pager", pager)
def get_video_with_pager(self): pager = self.params.createPager() pager.itemName = u"视频" pager.itemUnit = u"个" pager.pageSize = 24 qry = VideoQuery( """ v.videoId, v.title, v.createDate, v.href, v.userId, u.loginName, u.nickName, v.summary,v.flvThumbNailHref """ ) if ((self.categoryName != None) and (self.categoryName != "")): qry.sysCateTitle = self.categoryName if self.type == "new": qry.orderType = 1 elif self.type == "hot": qry.orderType = 2 else: qry.orderType = 0 pager.totalRows = qry.count() video_list = qry.query_map(pager) request.setAttribute("video_list", video_list) request.setAttribute("pager", pager)
def genernate_jiaoyanshipin_content(self, webpart): cache_key = "sbj" + str(self.subject.subjectId) + "_" + str(webpart.getSubjectWebpartId()) + self.cacheKeyFix content = cache.get(cache_key) if content != None: request.setAttribute(cache_key, content) return map = HashMap() qry = VideoQuery(""" v.videoId, v.title, v.createDate, v.href, v.flvHref, v.userId, u.loginName, u.nickName, v.summary,v.flvThumbNailHref """) qry.orderType = VideoQuery.ORDER_TYPE_VIDEOID_DESC qry.subjectId = self.metaSubjectId qry.gradeId = self.metaGradeId if self.unitId != None and self.unitId != 0: qry.unitId = self.unitId new_video_list = qry.query_map(4) map.put("new_video_list", new_video_list) map.put("subject", self.subject) map.put("SubjectRootUrl", self.subjectRootUrl) map.put("webpart", webpart) map.put("unitId", self.unitId) content = self.templateProcessor.processTemplate(map, "/WEB-INF/subjectpage/" + self.templateName + "/video.ftl", "utf-8") request.setAttribute(cache_key, content) cache.put(cache_key, content)
def execute(self): self.params = ParamUtil(request) userId = self.params.safeGetIntParam("userId", 0) listCount = self.params.safeGetIntParam("count", 2) if(userId == 0) : request.setAttribute("MessageText", "没有找到所查询的视频!") return "/WEB-INF/ftl/show_message.ftl"; user = __jitar__.userService.getUserById(userId) if user == None: request.setAttribute("MessageText", "没有找到所查询的图片") return "/WEB-INF/ftl/show_message.ftl"; self.userName = user.loginName fc = FileCache() # 14400 为10 天 content = fc.getUserFileCacheContent(self.userName, "user_video.html",30) if content != "": response.getWriter().write(content) fc = None return qry = VideoQuery(""" v.videoId, v.title, v.createDate, v.lastModified, v.flvThumbNailHref, v.href, u.nickName, u.loginName, u.userIcon """) qry.userId = userId qry.orderType = 0 qry.isPrivateShow = None video_list = qry.query_map(int(listCount)) templateProcessor = __spring__.getBean("templateProcessor") map = HashMap() map.put("video_list", video_list) map.put("UserSiteUrl", self.getUserSiteUrl()) content = templateProcessor.processTemplate(map, "/WEB-INF/user/default/user_video.ftl", "utf-8") fc.writeUserFileCacheContent(self.userName, "user_video.html",content) response.getWriter().write(content) fc = None
def execute(self): self.params = ParamUtil(request) self.loginName = request.getAttribute("loginName") # 解析 uri if self.parseUri() == False: return self.sendNotFound(self.uri) # 得到要工作室主人, 并验证用户状态 self.user = user_svc.getUserByLoginName(self.loginName) request.setAttribute("user", self.user) request.setAttribute("loginUser", self.loginUser) #print "self.user = "******"loginUser", self.loginUser) # 创建分页对象 pager = self.params.createPager() pager.setPageSize(18) qry = VideoQuery( """ v.videoId, v.title, v.createDate, v.lastModified, v.flvThumbNailHref, v.href, v.commentCount, v.viewCount, u.nickName, u.loginName, u.userIcon """ ) qry.userId = self.user.userId qry.isPrivateShow = None if self.categoryId != 0: qry.userStapleId = self.categoryId #print "userStapleId = ", userStapleId pager.totalRows = qry.count() pager.itemName = u"视频" pager.itemUnit = u"个" qry.orderType = 0 result = qry.query_map(pager) request.setAttribute("video_list", result) request.setAttribute("pager", pager) hql = """SELECT new Map(p.skin as 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() # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据. #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["skin"] } 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":0, "columnIndex":1, "title":"视频分类", "module":"video_cate", "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_videos.ftl"
def video_list(self): qry = VideoQuery(" v.videoId, v.flvHref, v.flvThumbNailHref, v.title,v.userId,v.createDate") qry.specialSubjectId = self.specialSubject.specialSubjectId v_list = qry.query_map(5) if len(v_list) > 0: request.setAttribute("video_list", v_list)
def get_hot_video_list(self): qry = VideoQuery( " v.videoId, v.title , u.loginName,v.flvThumbNailHref ") qry.orderType = VideoQuery.ORDER_TYPE_VIEWCOUNT_DESC hot_video_list = qry.query_map(10) request.setAttribute("hot_video_list", hot_video_list)