| | |
| | | break; |
| | | case "getHomeType": |
| | | homeParser.getHomeType(acceptData, request, out); |
| | | case "getHomeVideoList": |
| | | homeParser.getHomeVideoList(acceptData, request, out); |
| | | break; |
| | | case "getVideoDetail": |
| | | homeParser.getVideoDetail(acceptData, request, out); |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), resourceList, |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), acceptData.getPlatform(), acceptData.getVersion(), resourceList, |
| | | CacheUtil.getMD5Long(resourceList), -1, special != null ? special.getDataKey() : null); |
| | | List<HomeType> list = new ArrayList<>(); |
| | | for (HomeType ht : list1) |
| | |
| | | type.setVideoList(vlist); |
| | | return type; |
| | | } |
| | | |
| | | |
| | | // 首页类型获取 |
| | | public void getHomeVideoList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | // 20170914 一级视频分类ID |
| | | String homeTypeId = request.getParameter("Id"); |
| | | int page = Integer.parseInt(request.getParameter("Page")); |
| | | |
| | | if (StringUtil.isNullOrEmpty(homeTypeId)) { |
| | | out.print(JsonUtil.loadFalseJson("")); |
| | | return; |
| | | } |
| | | |
| | | HomeType homeType = homeTypeService.getHomeTypeById(homeTypeId); |
| | | if (homeType == null) { |
| | | out.print(JsonUtil.loadFalseJson("")); |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | //查询大图 |
| | | List<HomeVideo> bigPictureVideos = homeTypeService.getHomeVideoList(homeTypeId, resourceList, true, page, homeType.getNumber()); |
| | | |
| | | |
| | | //大图需要每次都返回 |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | Long count = homeTypeService.getHomeVideoListCount(homeTypeId, resourceList, null); |
| | | List<HomeVideo> list1 = homeTypeService.getHomeVideoList(homeTypeId, resourceList, false, page, homeType.getNumber()); |
| | | List<HomeVideo> list = new ArrayList<>(); |
| | | list.addAll(bigPictureVideos); |
| | | list.addAll(list1); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < list.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | object.put("list", array); |
| | | |
| | | //判断是否还有下一页 |
| | | int totalPage = (int) ((count - bigPictureVideos.size()) % homeType.getNumber() == 0 ? (count - bigPictureVideos.size()) / homeType.getNumber() : (count - bigPictureVideos.size()) / homeType.getNumber() + 1); |
| | | |
| | | if (page >= totalPage) { |
| | | page = 0; |
| | | } |
| | | data.put("page", page); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | |
| | | @RequireUid |
| | | public void getMoreVideo(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | |
| | | JSONObject obj = new JSONObject(); |
| | | |
| | | if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), new VideoDetailVO.VideoAdInfo(true,false), null)), array.toString(), |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), new VideoDetailVO.VideoAdInfo(true, false), null)), array.toString(), |
| | | obj.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), |
| | |
| | | } |
| | | UserInfo user = userService.getUserInfo(acceptData.getUid()); |
| | | if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), new VideoDetailVO.VideoAdInfo(true,true), attention)), array.toString(), |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), new VideoDetailVO.VideoAdInfo(true, true), attention)), array.toString(), |
| | | obj.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), |
| | |
| | | vt.setId(0); |
| | | vt.setName("全部"); |
| | | typeList.add(vt); |
| | | Set<Long> set = new HashSet<>(); |
| | | for (VideoInfo videoInfo : list) { |
| | | if (videoInfo.getShowType() == 1 && videoInfo.getVideoType() != null) |
| | | set.add(videoInfo.getVideoType().getId()); |
| | | List<Long> set = new ArrayList<>(); |
| | | //将视频内容分类并排序 |
| | | Map<Long, List<VideoInfo>> videoMap = new HashMap<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | VideoInfo videoInfo = list.get(i); |
| | | if (videoInfo.getShowType() == 1 && videoInfo.getVideoType() != null) { |
| | | if (videoMap.get(videoInfo.getVideoType().getId()) == null) |
| | | videoMap.put(videoInfo.getVideoType().getId(), new ArrayList<>()); |
| | | videoMap.get(videoInfo.getVideoType().getId()).add(videoInfo); |
| | | if (!set.contains(videoInfo.getVideoType().getId())) |
| | | set.add(videoInfo.getVideoType().getId()); |
| | | |
| | | if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion()) && (StringUtil.isNullOrEmpty(type) || type.equalsIgnoreCase("0"))) { |
| | | list.remove(i); |
| | | i--; |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (Iterator<Long> its = set.iterator(); its.hasNext(); ) { |
| | | Long typeId = its.next(); |
| | | //重新组织数据 |
| | | if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion()) && (StringUtil.isNullOrEmpty(type) || type.equalsIgnoreCase("0"))) { |
| | | List<VideoInfo> albumVideoList = new ArrayList<>(); |
| | | for (int i = 0; i < set.size(); i++) { |
| | | Long typeId = set.get(i); |
| | | String typeName = VideoConstant.getMainCategoryName(typeId); |
| | | if (!StringUtil.isNullOrEmpty(typeName)) { |
| | | videoMap.get(typeId).get(0).setAlbumMoreInfo(new VideoInfo.VideoAlbumMoreInfo(typeName, i + 1)); |
| | | albumVideoList.addAll(videoMap.get(typeId)); |
| | | } |
| | | } |
| | | list.addAll(0, albumVideoList); |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < set.size(); i++) { |
| | | Long typeId = set.get(i); |
| | | String typeName = VideoConstant.getMainCategoryName(typeId); |
| | | if (!StringUtil.isNullOrEmpty(typeName)) { |
| | | vt = new VideoType(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | vt = new VideoType(); |
| | | vt.setId(Constant.SEARCH_RESULT_TYPE_HIGH_DEFINITION); |
| | | vt.setName("高清"); |
| | |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName); |
| | | |
| | | List<HomeAd> list = homeAdService.getHomeAdList(detailSystem,"recommend"); |
| | | List<HomeAd> list = homeAdService.getHomeAdList(detailSystem, "recommend"); |
| | | |
| | | for (HomeAd ad : list) { |
| | | if (ad.getVideo() != null) { |
| | |
| | | private JSONArray getHomeType(String uid, String platform, String detailsystemid) { |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1); |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailsystemid, resourceList, |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailsystemid, platform, 1, resourceList, |
| | | CacheUtil.getMD5Long(resourceList), 10, "recommend"); |
| | | List<HomeType> list = new ArrayList<>(); |
| | | for (HomeType ht : list1) |
| | |
| | | |
| | | /** |
| | | * 首页分类下面的视频 |
| | | * |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | @Entity |
| | | public class HomeVideo implements Serializable{ |
| | | public HomeVideo(String id) { |
| | | this.id = id; |
| | | } |
| | | public class HomeVideo implements Serializable { |
| | | public HomeVideo(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public HomeVideo() { |
| | | } |
| | | public HomeVideo() { |
| | | } |
| | | |
| | | @Expose |
| | | private String id; |
| | | private HomeType type; |
| | | @Expose |
| | | private VideoInfo video; |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private String tag; |
| | | @Expose |
| | | private int orderby; |
| | | |
| | | public int getOrderby() { |
| | | return orderby; |
| | | } |
| | | @Expose |
| | | private String id; |
| | | private HomeType type; |
| | | @Expose |
| | | private VideoInfo video; |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private String tag; |
| | | @Expose |
| | | private int orderby; |
| | | @Expose |
| | | private Boolean bigPicture;//是否为大图显示 |
| | | |
| | | public void setOrderby(int orderby) { |
| | | this.orderby = orderby; |
| | | } |
| | | public Boolean getBigPicture() { |
| | | return bigPicture; |
| | | } |
| | | |
| | | public String getTag() { |
| | | return tag; |
| | | } |
| | | public void setBigPicture(Boolean bigPicture) { |
| | | this.bigPicture = bigPicture; |
| | | } |
| | | |
| | | public void setTag(String tag) { |
| | | this.tag = tag; |
| | | } |
| | | public int getOrderby() { |
| | | return orderby; |
| | | } |
| | | |
| | | @ManyToOne |
| | | public VideoInfo getVideo() { |
| | | return video; |
| | | } |
| | | public void setOrderby(int orderby) { |
| | | this.orderby = orderby; |
| | | } |
| | | |
| | | public void setVideo(VideoInfo video) { |
| | | this.video = video; |
| | | } |
| | | public String getTag() { |
| | | return tag; |
| | | } |
| | | |
| | | private String beizhu; |
| | | private AdminInfo admin; |
| | | @Expose |
| | | private String createtime; |
| | | public void setTag(String tag) { |
| | | this.tag = tag; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | @ManyToOne |
| | | public VideoInfo getVideo() { |
| | | return video; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | public void setVideo(VideoInfo video) { |
| | | this.video = video; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | private String beizhu; |
| | | private AdminInfo admin; |
| | | @Expose |
| | | private String createtime; |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | @ManyToOne |
| | | public HomeType getType() { |
| | | return type; |
| | | } |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public void setType(HomeType type) { |
| | | this.type = type; |
| | | } |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | @ManyToOne |
| | | public HomeType getType() { |
| | | return type; |
| | | } |
| | | |
| | | @ManyToOne |
| | | public AdminInfo getAdmin() { |
| | | return admin; |
| | | } |
| | | public void setType(HomeType type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public void setAdmin(AdminInfo admin) { |
| | | this.admin = admin; |
| | | } |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | @ManyToOne |
| | | public AdminInfo getAdmin() { |
| | | return admin; |
| | | } |
| | | |
| | | public void setAdmin(AdminInfo admin) { |
| | | this.admin = admin; |
| | | } |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | } |
| | |
| | | @Transient |
| | | private int definition; |
| | | |
| | | //搜索结果适用 |
| | | @Expose |
| | | private VideoAlbumMoreInfo albumMoreInfo; |
| | | |
| | | |
| | | @Transient |
| | | private VideoResourceMapExtraInfo videoResourceMapExtraInfo; |
| | | |
| | |
| | | |
| | | public void setVideoResourceMapExtraInfo(VideoResourceMapExtraInfo videoResourceMapExtraInfo) { |
| | | this.videoResourceMapExtraInfo = videoResourceMapExtraInfo; |
| | | } |
| | | |
| | | public VideoAlbumMoreInfo getAlbumMoreInfo() { |
| | | return albumMoreInfo; |
| | | } |
| | | |
| | | public void setAlbumMoreInfo(VideoAlbumMoreInfo albumMoreInfo) { |
| | | this.albumMoreInfo = albumMoreInfo; |
| | | } |
| | | |
| | | public Integer getVideocount() { |
| | |
| | | public void setDefinition(int definition) { |
| | | this.definition = definition; |
| | | } |
| | | |
| | | public static class VideoAlbumMoreInfo { |
| | | private String name; |
| | | private int jumpPosition; |
| | | |
| | | public VideoAlbumMoreInfo(String name, int jumpPosition) { |
| | | this.name = name; |
| | | this.jumpPosition = jumpPosition; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public int getJumpPosition() { |
| | | return jumpPosition; |
| | | } |
| | | |
| | | public void setJumpPosition(int jumpPosition) { |
| | | this.jumpPosition = jumpPosition; |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.service.inter.video.VideoInfoExtraService; |
| | | import com.yeshi.buwan.util.VersionUtil; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Session; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | @Cacheable(value = "homeCache", key = "'getHomeType'+'-'+#detailSystem+'-'+#cacheMd5+'-'+#maxNumber+'-'+#dataKey") |
| | | public List<HomeType> getHomeType(final String detailSystem, final List<Long> resourceIds, String cacheMd5, |
| | | @Cacheable(value = "homeCache", key = "'getHomeType'+'-'+#detailSystem+'-'+#version+'-'+#cacheMd5+'-'+#maxNumber+'-'+#dataKey") |
| | | public List<HomeType> getHomeType(final String detailSystem, final String platform, final int version, final List<Long> resourceIds, String cacheMd5, |
| | | final int maxNumber, final String dataKey) { |
| | | List<HomeType> homeTypeList = (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() { |
| | | public List<HomeType> doInHibernate(Session session) throws HibernateException { |
| | |
| | | resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2); |
| | | List resultList = session |
| | | .createSQLQuery( |
| | | "SELECT ht.`id` as htid,ht.`name` as htname,ht.`columns` as htcolumns ,ht.`hasmore`,ht.`activity` ,ht.`params` ,ht.`ioscontrol`,ht.number,hvideo.id as hvid,hvideo.`videoid` AS hvvideoid,hvideo.`picture`as hvpicture ,hvideo.`tag` as hvtag, v.`id` as vid ,v.`picture` as vpicture ,v.`name` as vname ,v.`tag` as vtag ,v.`hpicture` as vhpicture ,v.`latest_hpicture` as vlatest_hpicture ,v.`watchcount` as vwatchcount,v.commentcount,ht.icon as hicon,ht.orderby as htorder,hvideo.orderby as hvorder,need_ad FROM (SELECT hv.* FROM `wk_resource_video` rv LEFT JOIN `wk_video_homevideo` hv ON rv.`videoid` =hv.`videoid` LEFT JOIN `wk_video_video` v ON v.`id` =hv.`videoid` LEFT JOIN `wk_video_banquan_video` bv ON bv.`videoid`=hv.`videoid` AND bv.`detailsystemid`=" |
| | | "SELECT ht.`id` as htid,ht.`name` as htname,ht.`columns` as htcolumns ,ht.`hasmore`,ht.`activity` ,ht.`params` ,ht.`ioscontrol`,ht.number,hvideo.id as hvid,hvideo.`videoid` AS hvvideoid,hvideo.`picture`as hvpicture ,hvideo.`tag` as hvtag, v.`id` as vid ,v.`picture` as vpicture ,v.`name` as vname ,v.`tag` as vtag ,v.`hpicture` as vhpicture ,v.`latest_hpicture` as vlatest_hpicture ,v.`watchcount` as vwatchcount,v.commentcount,ht.icon as hicon,ht.orderby as htorder,hvideo.orderby as hvorder,need_ad,big_picture FROM (SELECT hv.* FROM `wk_resource_video` rv LEFT JOIN `wk_video_homevideo` hv ON rv.`videoid` =hv.`videoid` LEFT JOIN `wk_video_video` v ON v.`id` =hv.`videoid` LEFT JOIN `wk_video_banquan_video` bv ON bv.`videoid`=hv.`videoid` AND bv.`detailsystemid`=" |
| | | + detailSystem |
| | | + " AND bv.`show`=1 LEFT JOIN `wk_video_hometype` ht ON ht.id=hv.hometype WHERE (hv.`id`>0 AND v.`show` =1 AND ht.special_data_key='" |
| | | + dataKey + "' AND (" + resourceWhere |
| | | + " ) AND bv.`videoid` IS NULL ) GROUP BY (hv.`id`) ORDER BY hv.`orderby` desc,v.createtime DESC ) hvideo LEFT JOIN `wk_video_super_hometype` sht ON sht.`hometypeid`=hvideo.hometype LEFT JOIN `wk_video_hometype` ht ON sht.`hometypeid` =ht.`id` LEFT JOIN wk_video_video v ON v.`id`=hvideo.videoid WHERE sht.`detailsystemid` =" + detailSystem + " ORDER BY hvideo.`orderby` DESC,v.orderby desc,v.updatetime desc") |
| | | + " ) AND bv.`videoid` IS NULL ) GROUP BY (hv.`id`) ORDER BY hv.big_picture desc, hv.`orderby` desc,v.createtime DESC ) hvideo LEFT JOIN `wk_video_super_hometype` sht ON sht.`hometypeid`=hvideo.hometype LEFT JOIN `wk_video_hometype` ht ON sht.`hometypeid` =ht.`id` LEFT JOIN wk_video_video v ON v.`id`=hvideo.videoid WHERE sht.`detailsystemid` =" + detailSystem + " ORDER BY hvideo.`orderby` DESC,v.orderby desc,v.updatetime desc") |
| | | .list(); |
| | | List<HomeType> homeTypeList = new ArrayList<>(); |
| | | Map<String, Integer> homeTypeVideoCountMap = new HashMap<>(); |
| | | for (int i = 0; i < resultList.size(); i++) { |
| | | Object[] obj = (Object[]) resultList.get(i); |
| | | HomeType ht = new HomeType(); |
| | |
| | | ht.setIosControl(obj[6] + ""); |
| | | ht.setNumber(Integer.parseInt(obj[7] + "")); |
| | | |
| | | |
| | | ht.setOrderby(obj[21] + ""); |
| | | ht.setNeedAd(Boolean.parseBoolean(obj[23] + "")); |
| | | |
| | |
| | | hv.setId(obj[8] + ""); |
| | | hv.setPicture(obj[10] + ""); |
| | | hv.setTag(obj[11] + ""); |
| | | hv.setBigPicture(Boolean.parseBoolean(obj[24] + "")); |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | video.setId(obj[12] + ""); |
| | |
| | | if (maxNumber > -1)// 根据maxNumber的数量来,适用于网页 |
| | | mn = maxNumber; |
| | | |
| | | if (VersionUtil.isGraterThan390(platform, version)) { |
| | | //计算已有大图数量 |
| | | int bigCount = 0; |
| | | for (HomeVideo hv1 : eHomeType.getHomeVideoList()) { |
| | | if (hv.getBigPicture()) { |
| | | bigCount++; |
| | | } |
| | | } |
| | | mn += bigCount; |
| | | } |
| | | |
| | | if (homeTypeVideoCountMap.get(eHomeType.getId()) == null) { |
| | | homeTypeVideoCountMap.put(eHomeType.getId(), 0); |
| | | } |
| | | homeTypeVideoCountMap.put(eHomeType.getId(), homeTypeVideoCountMap.get(eHomeType.getId()) + 1); |
| | | if (eHomeType.getHomeVideoList().size() < mn)// 加入指定的数量的数据 |
| | | { |
| | | eHomeType.getHomeVideoList().add(hv); |
| | | } |
| | | |
| | | |
| | | } else { |
| | | List<HomeVideo> videolist = new ArrayList<>(); |
| | |
| | | // } |
| | | orderByType(homeTypeList); |
| | | |
| | | for (HomeType ht : homeTypeList) { |
| | | //设置数量 |
| | | if (homeTypeVideoCountMap.containsKey(ht.getId())) |
| | | ht.setCount(homeTypeVideoCountMap.get(ht.getId())); |
| | | } |
| | | return homeTypeList; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | public List<HomeVideo> getHomeVideoList(String homeId, int page) { |
| | | |
| | | return homeVideoDao.list( |
| | | "from HomeVideo h where h.type.id=? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc", |
| | | "from HomeVideo h where h.type.id=? order by h.video.orderby desc,h.createtime desc", |
| | | (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{homeId}); |
| | | } |
| | | |
| | |
| | | return homeVideoDao.list( |
| | | "from HomeVideo h where h.type.id=? and h.video.name like ? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc", |
| | | (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{homeId, "%" + key + "%"}); |
| | | } |
| | | |
| | | |
| | | public List<HomeVideo> getHomeVideoList(String homeId, List<Long> resourceIds, Boolean bigPicture, int page, int pageSize) { |
| | | List<HomeVideo> homeVideos = (List<HomeVideo>) homeVideoDao.excute(new HibernateCallback<List<HomeVideo>>() { |
| | | @Override |
| | | public List<HomeVideo> doInHibernate(Session session) throws HibernateException { |
| | | |
| | | List<String> rids = new ArrayList<>(); |
| | | for (Long rid : resourceIds) { |
| | | rids.add("rv.`resourceid`=" + rid); |
| | | } |
| | | |
| | | String sql = String.format("SELECT hv.* FROM wk_video_homevideo hv LEFT JOIN wk_resource_video rv ON rv.`videoid`=hv.`videoid` LEFT JOIN wk_video_video v ON v.`id`=hv.`videoid` WHERE v.show=1 and hv.`hometype`=%s AND (%s) ", homeId, org.yeshi.utils.StringUtil.concat(rids, " or ")); |
| | | |
| | | if (bigPicture != null) { |
| | | sql += " and hv.big_picture=" + (bigPicture ? 1 : 0); |
| | | } |
| | | sql += "GROUP BY hv.id ORDER BY hv.big_picture desc,hv.`orderby` DESC,hv.`createtime` DESC"; |
| | | |
| | | return session.createSQLQuery(sql).addEntity(HomeVideo.class).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list(); |
| | | } |
| | | }); |
| | | |
| | | List<VideoInfo> videoInfoList = new ArrayList<>(); |
| | | for (HomeVideo hv : homeVideos) { |
| | | if (hv.getVideo() != null) |
| | | videoInfoList.add(hv.getVideo()); |
| | | } |
| | | videoInfoExtraService.batchExtra(videoInfoList, resourceIds); |
| | | return homeVideos; |
| | | } |
| | | |
| | | |
| | | public long getHomeVideoListCount(String homeId, List<Long> resourceIds, Boolean bigPicture) { |
| | | return (Long) homeVideoDao.excute(new HibernateCallback<Long>() { |
| | | @Override |
| | | public Long doInHibernate(Session session) throws HibernateException { |
| | | |
| | | List<String> rids = new ArrayList<>(); |
| | | for (Long rid : resourceIds) { |
| | | rids.add("rv.`resourceid`=" + rid); |
| | | } |
| | | |
| | | String sql = String.format("SELECT count(distinct(hv.id)) FROM wk_video_homevideo hv LEFT JOIN wk_resource_video rv ON rv.`videoid`=hv.`videoid` LEFT JOIN wk_video_video v ON v.`id`=hv.`videoid` WHERE v.show=1 and hv.`hometype`=%s AND (%s)", homeId, org.yeshi.utils.StringUtil.concat(rids, " or ")); |
| | | |
| | | if (bigPicture != null) { |
| | | sql += " and hv.big_picture=" + (bigPicture ? 1 : 0); |
| | | |
| | | } |
| | | |
| | | return Long.parseLong(session.createSQLQuery(sql).uniqueResult() + ""); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public long getHomeVideoListCount(String homeId, String key) { |
| | |
| | | andList.add("sh.homeType.name like ?"); |
| | | andList.add("sh.detailSystem.id=" + detailSystem); |
| | | if (dataKey != null) { |
| | | andList.add("sh.homeType.specialDataKey='" + dataKey+"'"); |
| | | andList.add("sh.homeType.specialDataKey='" + dataKey + "'"); |
| | | } |
| | | sql = "select sh.homeType from SuperHomeType sh where " + org.yeshi.utils.StringUtil.concat(andList, " and ") + " order by sh.homeType.orderby desc"; |
| | | } else { |
| | | andList.add("zb.name like ?"); |
| | | andList.add("zb.system.id=" + systemId); |
| | | if (dataKey != null) { |
| | | andList.add("zb.specialDataKey='" + dataKey+"'"); |
| | | andList.add("zb.specialDataKey='" + dataKey + "'"); |
| | | } |
| | | sql = "from HomeType zb where " + org.yeshi.utils.StringUtil.concat(andList, " and ") + " order by zb.orderby desc"; |
| | | } |
| | |
| | | <many-to-one name="admin" column="adminid"></many-to-one> |
| | | <property name="icon" type="string"></property> |
| | | <property name="specialDataKey" type="string" column="special_data_key"></property> |
| | | <property name="refreshPosition" type="int" column="refresh_position"></property> |
| | | <property name="moreTag" type="string" column="more_tag"></property> |
| | | |
| | | |
| | | <list name="homeVideoList" lazy="false" inverse="true" cascade="delete"> |
| | |
| | | <property name="createtime" type="string"></property> |
| | | <property name="orderby"></property> |
| | | <property name="tag" type="string"></property> |
| | | |
| | | <property name="bigPicture" type="boolean" column="big_picture"></property> |
| | | |
| | | |
| | | |
| | | <many-to-one name="type" column="hometype" lazy="false" |
| | | unique="true"></many-to-one> |
| | | <many-to-one name="video" column="videoid" lazy="false" |