| | |
| | | package com.yeshi.buwan.aspect; |
| | | |
| | | import com.yeshi.buwan.log.LogHelper; |
| | | import net.sf.ehcache.CacheManager; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.lang.reflect.Method; |
| | | |
| | | /** |
| | | * 跨域 |
| | |
| | | package com.yeshi.buwan.aspect; |
| | | |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.service.imp.SystemService; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.util.Utils; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | |
| | | @Component |
| | | @Aspect |
| | | public class SignAspect { |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | | |
| | | |
| | | //签名验证 |
| | |
| | | public Object verifySign(ProceedingJoinPoint joinPoint) throws IOException { |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = servletContainer.getRequest(); |
| | | HttpServletResponse response = servletContainer.getResponse(); |
| | | PrintWriter out = null; |
| | | |
| | | Object[] args = joinPoint.getArgs(); |
| | | for (Object obj : args) { |
| | | if (obj instanceof AcceptData) { |
| | | AcceptData acceptData = (AcceptData) obj; |
| | | if (acceptData != null) { |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | acceptData.setChannel("appstore"); |
| | | } |
| | | //注入detailSystem |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | acceptData.setDetailSystem(detailSystem); |
| | | } |
| | | |
| | | } else if (obj instanceof PrintWriter) { |
| | | out = (PrintWriter) obj; |
| | | } |
| | | } |
| | | |
| | | if (!Utils.signIsRight(request)) { |
| | | if (out == null) |
| | | out = response.getWriter(); |
| | | out.print(JsonUtil.loadFalseJson("签名错误")); |
| | | return null; |
| | | } |
| | | |
| | | Object obj = null; |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, acceptData.getVersion()); |
| | | List<VideoInfo> list = starService.getStarVideo(detailSystem.getId(), starId, pageIndex, |
| | | CacheUtil.getMD5Long(resourceList)); |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | DetailSystem detailSystem = acceptData.getDetailSystem(); |
| | | UserInfo user = userService.getUserInfo(acceptData.getUid()); |
| | | if (Utils.isTest(request, user, detailSystem.getId())) |
| | | detailSystem = systemService.getDetailSystemById(40 + ""); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | String resourceMD5 = CacheUtil.getMD5Long(resourceList); |
| | | |
| | | String key = "videolist-" + StringUtil.Md5(String.format("%s#%s#%s#%s#%s#%s#%s#%s", starId + "", homeType + "", |
| | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), resourceList, |
| | | CacheUtil.getMD5Long(resourceList), -1, Long.parseLong(vtid)); |
| | | List<HomeType> list = new ArrayList<>(); |
| | |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | //获取优先展示的渠道 |
| | | if (StringUtil.isNullOrEmpty(resourceId)) { |
| | |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, acceptData.getVersion()); |
| | | String cacheMD5 = "0"; |
| | | if (resourceList != null && resourceList.size() > 0) |
| | | for (Long l : resourceList) |
| | |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, acceptData.getVersion()); |
| | | String cacheMD5 = "0"; |
| | | if (resourceList != null && resourceList.size() > 0) |
| | | for (Long l : resourceList) |
| | |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | List<VideoInfo> list1 = StringUtil.isNullOrEmpty(videoId) |
| | | ? recommendService.guessLikeList(ds.getId(), 4, resourceList, CacheUtil.getMD5Long(resourceList)) |
| | | : recommendService.guessLikeList(ds.getId(), 4, videoId, resourceList, |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<VideoInfo> list = recommendService.getRelativeVideoList(ds.getId(), 4, videoId, resourceList, |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<VideoInfo> list1 = recommendService.peopleSee(ds.getId(), 4, videoId, resourceList, |
| | |
| | | |
| | | HotStar hot = starService.getHotStarDetail(starId); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, Integer.parseInt("0")); |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, Integer.parseInt("1")); |
| | | List<VideoInfo> list1 = starService.getStarVideo(detailSystem.getId(), starId, pageIndex, resourceList, |
| | | CacheUtil.getMD5Long(resourceList)); |
| | | |
| | |
| | | // 首页类型获取 |
| | | private JSONArray getHomeType(String uid, String platform, String detailsystemid) { |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, 0); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1); |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailsystemid, resourceList, |
| | | CacheUtil.getMD5Long(resourceList),10,309); |
| | | List<HomeType> list = new ArrayList<>(); |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, 0); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1); |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName); |
| | | |
| | | List<VideoType> typeList = getFirstType(pid); |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, Integer.parseInt(version)); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), Integer.parseInt(version)); |
| | | |
| | | VideoInfo info = (videoDeailUtil.getVideoInfo(null,videoId, resourceId, resourceList, |
| | | CacheUtil.getMD5Long(resourceList))); |
| | |
| | | key = StringUtil.getUTF8String(key, "ISO-8859-1"); |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, Integer.parseInt("0")); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, Integer.parseInt("1")); |
| | | String cacheMD5 = "0"; |
| | | if (resourceList != null && resourceList.size() > 0) |
| | | for (Long l : resourceList) |
| | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, 0); |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, 1); |
| | | // 获取视频列表 |
| | | List<VideoInfo> list1; |
| | | if (type.equalsIgnoreCase("area")) { |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, 0); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1); |
| | | |
| | | VideoInfo info = (videoDeailUtil.getVideoInfo(null,videoId, resourceId, resourceList, |
| | | CacheUtil.getMD5Long(resourceList))); |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, 0); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1); |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(packageName); |
| | | // 猜你喜欢 |
New file |
| | |
| | | package com.yeshi.buwan.dao.video; |
| | | |
| | | import com.yeshi.buwan.domain.video.VideoResourceVersionMap; |
| | | import com.yeshi.buwan.dao.base.MongodbBaseDao; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class VideoResourceVersionMapDao extends MongodbBaseDao<VideoResourceVersionMap> { |
| | | |
| | | public void updateSelective(VideoResourceVersionMap bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if (bean.getDetailSystemId() != null) { |
| | | update.set("detailSystemId", bean.getDetailSystemId()); |
| | | } |
| | | if (bean.getVersion() != null) { |
| | | update.set("version", bean.getVersion()); |
| | | } |
| | | if (bean.getResourceId() != null) { |
| | | update.set("resourceId", bean.getResourceId()); |
| | | } |
| | | if (bean.getRemarks() != null) { |
| | | update.set("remarks", bean.getRemarks()); |
| | | } |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取有效的来源 |
| | | * |
| | | * @param detailSystemId |
| | | * @param version |
| | | * @return |
| | | */ |
| | | public List<VideoResourceVersionMap> listValid(String detailSystemId, Integer version) { |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().andOperator(Criteria.where("detailSystemId").is(detailSystemId), Criteria.where("version").lte(version))); |
| | | return findList(query); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.domain.video; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.index.Indexed; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 视频来源的版本映射 |
| | | */ |
| | | @Document(collection = "videoResourceVersionMap") |
| | | public class VideoResourceVersionMap { |
| | | @Id |
| | | private String id; |
| | | @Indexed |
| | | private String detailSystemId; |
| | | @Indexed |
| | | private Integer version; |
| | | private String resourceId; |
| | | private String remarks; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | public VideoResourceVersionMap() { |
| | | |
| | | } |
| | | |
| | | public VideoResourceVersionMap(String detailSystemId, Integer version, String resourceId) { |
| | | this.detailSystemId = detailSystemId; |
| | | this.version = version; |
| | | this.resourceId = resourceId; |
| | | } |
| | | |
| | | public static String createId(String detailSystemId, Integer version, String resourceId) { |
| | | return detailSystemId + "-" + version + "-" + resourceId; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getDetailSystemId() { |
| | | return detailSystemId; |
| | | } |
| | | |
| | | public void setDetailSystemId(String detailSystemId) { |
| | | this.detailSystemId = detailSystemId; |
| | | } |
| | | |
| | | public Integer getVersion() { |
| | | return version; |
| | | } |
| | | |
| | | public void setVersion(Integer version) { |
| | | this.version = version; |
| | | } |
| | | |
| | | public String getResourceId() { |
| | | return resourceId; |
| | | } |
| | | |
| | | public void setResourceId(String resourceId) { |
| | | this.resourceId = resourceId; |
| | | } |
| | | |
| | | public String getRemarks() { |
| | | return remarks; |
| | | } |
| | | |
| | | public void setRemarks(String remarks) { |
| | | this.remarks = remarks; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
| | |
| | | public static String getOpenId(String uid) { |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("uid", uid); |
| | | String result = baseRequest("https://coapi.pptv.com/coapi-web/api/http/sopRequest", params, "pptv.channel.openid.get"); |
| | | // String result = baseRequest("https://coapi.pptv.com/coapi-web/api/http/sopRequest", params, "pptv.channel.openid.get"); |
| | | String result = baseRequest("http://coapiwebsit.cnsuning.com/coapi-web/api/http/sopRequest", params, "pptv.channel.openid.get"); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | JSONObject response = resultJSON.optJSONObject("response"); |
| | |
| | | public static boolean buyGoods(String openId, String orderNo, String goodsNo, Date orderTime) { |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("openId", openId); |
| | | params.put("canal", CANAL); |
| | | params.put("canal", "253350"); |
| | | params.put("channel", "yeshi"); |
| | | params.put("goodsNo", goodsNo); |
| | | params.put("outOrderId", orderNo); |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | buyGoods("257dfd950c20ad25dee9f99ef926c0f8", "buwan_27", "DA7559531560894", new Date()); |
| | | // |
| | | buyGoods("257dfd950c20ad25dee9f99ef926c0f8", "buwan_29", "DA7559531560894", new Date()); |
| | | } |
| | | |
| | | |
| | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.service.inter.VideoResourceMapExtraInfoService; |
| | | import com.yeshi.buwan.util.JuHe.VideoResourceUtil; |
| | | import org.hibernate.HibernateException; |
| | |
| | | @Cacheable(value = "topCache", key = "'getVideoListByRank'+'-'+#videotype+'-'+#detailSystem+'-'+#platform+'-'+#version") |
| | | public List<VideoInfo> getVideoListByRank(final int videotype, final String detailSystem, String platform, Integer version) { |
| | | |
| | | List<Long> resourceList = videoResourceUtil.getAvailableResourceIds(platform, version); |
| | | List<Long> resourceList = videoResourceUtil.getAvailableResourceIds(new DetailSystem(detailSystem), version); |
| | | |
| | | final int count = categoryRecommendVideoService.getRankVideoNumber(videotype); |
| | | List<VideoInfo> videoInfoList = (List<VideoInfo>) dao.excute(new HibernateCallback<List<VideoInfo>>() { |
New file |
| | |
| | | package com.yeshi.buwan.service.imp.video; |
| | | |
| | | import com.yeshi.buwan.domain.video.VideoResourceVersionMap; |
| | | import com.yeshi.buwan.dao.video.VideoResourceVersionMapDao; |
| | | import com.yeshi.buwan.service.inter.video.VideoResourceVersionMapService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class VideoResourceVersionMapServiceImpl implements VideoResourceVersionMapService { |
| | | |
| | | @Resource |
| | | private VideoResourceVersionMapDao videoResourceVersionMapDao; |
| | | |
| | | @Override |
| | | public void add(VideoResourceVersionMap map) throws Exception { |
| | | if (map == null || map.getDetailSystemId() == null || map.getResourceId() == null || map.getVersion() == null) { |
| | | throw new Exception("参数不完整"); |
| | | } |
| | | map.setId(VideoResourceVersionMap.createId(map.getDetailSystemId(), map.getVersion(), map.getResourceId())); |
| | | if (map.getCreateTime() == null) { |
| | | map.setCreateTime(new Date()); |
| | | } |
| | | videoResourceVersionMapDao.save(map); |
| | | } |
| | | |
| | | @Override |
| | | public List<VideoResourceVersionMap> list(String detailSystemId, Integer version) { |
| | | |
| | | return videoResourceVersionMapDao.listValid(detailSystemId, version); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> listResourceId(String detailSystemId, Integer version) { |
| | | List<VideoResourceVersionMap> mapList = list(detailSystemId, version); |
| | | List<String> ids = new ArrayList<>(); |
| | | if (mapList != null) { |
| | | for (VideoResourceVersionMap map : mapList) { |
| | | ids.add(map.getResourceId()); |
| | | } |
| | | } |
| | | return ids; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.inter.video; |
| | | |
| | | import com.yeshi.buwan.domain.video.VideoResourceVersionMap; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface VideoResourceVersionMapService { |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param map |
| | | * @throws Exception |
| | | */ |
| | | public void add(VideoResourceVersionMap map) throws Exception; |
| | | |
| | | /** |
| | | * 根据系统和版本查询 |
| | | * |
| | | * @param detailSystemId |
| | | * @param version |
| | | * @return |
| | | */ |
| | | public List<VideoResourceVersionMap> list(String detailSystemId, Integer version); |
| | | |
| | | /** |
| | | * 根据系统和版本查询ResourceId |
| | | * |
| | | * @param detailSystemId |
| | | * @param version |
| | | * @return |
| | | */ |
| | | public List<String> listResourceId(String detailSystemId, Integer version); |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.util.JuHe; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.service.inter.video.VideoResourceVersionMapService; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.yeshi.buwan.dao.VideoResourceDao; |
| | | import com.yeshi.buwan.domain.VideoResource; |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class VideoResourceUtil { |
| | | @Resource |
| | | private VideoResourceDao videoResourceDao; |
| | | private VideoResourceVersionMapService videoResourceVersionMapService; |
| | | |
| | | public VideoResourceDao getVideoResourceDao() { |
| | | return videoResourceDao; |
| | | } |
| | | |
| | | public void setVideoResourceDao(VideoResourceDao videoResourceDao) { |
| | | this.videoResourceDao = videoResourceDao; |
| | | } |
| | | |
| | | @Cacheable(value = "homeCache", key = "'getAvailableResourceIds-'+'-'+#platform+'-'+#versionCode") |
| | | public List<Long> getAvailableResourceIds(String platform, int versionCode) { |
| | | List<VideoResource> resourceList = videoResourceDao.list("from VideoResource"); |
| | | List<Long> list = new ArrayList<>(); |
| | | if ("android".equalsIgnoreCase(platform)) {// Android |
| | | for (VideoResource vr : resourceList) { |
| | | String resourceName = vr.getName(); |
| | | if (resourceName.indexOf("爱奇艺") > -1) { |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } else if (resourceName.indexOf("腾讯") > -1) |
| | | list.add(Long.parseLong(vr.getId())); |
| | | else if (resourceName.indexOf("搜狐") > -1) |
| | | list.add(Long.parseLong(vr.getId())); |
| | | else if (resourceName.indexOf("AcFun") > -1) |
| | | list.add(Long.parseLong(vr.getId())); |
| | | else if (resourceName.indexOf("风行") > -1) |
| | | list.add(Long.parseLong(vr.getId())); |
| | | else if (resourceName.indexOf("PPTV") > -1) { |
| | | //3.8.7以后的Android支持 |
| | | if (versionCode >= 105) { |
| | | list.add(Long.parseLong(vr.getId())); |
| | | @Cacheable(value = "homeCache", key = "'getAvailableResourceIds-'+'-'+#detailSystem.id+'-'+#versionCode") |
| | | public List<Long> getAvailableResourceIds(DetailSystem detailSystem, int versionCode) { |
| | | List<String> ridList = videoResourceVersionMapService.listResourceId(detailSystem.getId(), versionCode); |
| | | List<Long> ids = new ArrayList<>(); |
| | | if (ridList != null) { |
| | | for (String id : ridList) { |
| | | ids.add(Long.parseLong(id)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } else if ("ios".equalsIgnoreCase(platform)) { |
| | | if (versionCode < 14) { |
| | | for (VideoResource vr : resourceList) { |
| | | if (vr.getName().contains("爱奇艺") || vr.getName().contains("搜狐") || vr.getName().contains("风行")) { |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | } else if (versionCode < 16) { |
| | | for (VideoResource vr : resourceList) { |
| | | if (vr.getName().contains("爱奇艺") || vr.getName().contains("搜狐") || vr.getName().contains("风行")) { |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | } else if (versionCode < 18) { |
| | | for (VideoResource vr : resourceList) { |
| | | if (vr.getName().contains("爱奇艺") |
| | | || vr.getName().contains( |
| | | "搜狐")/* || vr.getName().contains("PPTV") */ |
| | | || vr.getName().contains("腾讯") || vr.getName().contains("风行")) { |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | } else if (versionCode < 50) { |
| | | for (VideoResource vr : resourceList) { |
| | | if (vr.getName().contains("爱奇艺") |
| | | || vr.getName().contains( |
| | | "搜狐") /* || vr.getName().contains("PPTV") */ |
| | | || vr.getName().contains("腾讯") || vr.getName().contains("乐视") |
| | | ) {//|| vr.getName().contains("风行") |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | } else { |
| | | for (VideoResource vr : resourceList) { |
| | | if (vr.getName().contains("爱奇艺") |
| | | || vr.getName().contains( |
| | | "搜狐") /* || vr.getName().contains("PPTV") */ |
| | | || vr.getName().contains("腾讯") || vr.getName().contains("乐视") |
| | | || vr.getName().contains("AcFun") || vr.getName().contains("风行"))//|| vr.getName().contains("风行") |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | for (VideoResource vr : resourceList) { |
| | | if (vr.getName().contains("爱奇艺") || vr.getName().contains("搜狐") || vr.getName().contains("腾讯") |
| | | || vr.getName().contains("乐视") |
| | | || vr.getName().contains("AcFun") || vr.getName().contains("风行")) {// |
| | | // || vr.getName().contains("风行") |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | return ids; |
| | | } |
| | | |
| | | |
| | |
| | | package com.yeshi.buwan.vo; |
| | | |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | |
| | | public class AcceptData { |
| | | private String method; |
| | | private String device; |
| | |
| | | private String lng; |
| | | private Integer version; |
| | | private String Package; |
| | | |
| | | |
| | | private String uid; |
| | | |
| | | //注入detailSystem |
| | | private DetailSystem detailSystem; |
| | | |
| | | |
| | | public DetailSystem getDetailSystem() { |
| | | return detailSystem; |
| | | } |
| | | |
| | | public void setDetailSystem(DetailSystem detailSystem) { |
| | | this.detailSystem = detailSystem; |
| | | } |
| | | |
| | | |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | |
| | | |
| | | import com.yeshi.buwan.dao.juhe.funtv.VideoFunTVDao; |
| | | import com.yeshi.buwan.dao.juhe.funtv.VideoFunTVNewDao; |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.funtv.FunTVApi; |
| | | import com.yeshi.buwan.funtv.FunTVDataParseUtil; |
| | |
| | | public void test7() { |
| | | VideoDetailUtil videoDeailUtil = BeanUtil.getBean(VideoDetailUtil.class); |
| | | VideoResourceUtil videoResouceUtil = BeanUtil.getBean(VideoResourceUtil.class); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds("android", Integer.parseInt("48")); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), Integer.parseInt("48")); |
| | | VideoInfo info = (videoDeailUtil.getVideoInfo(null,227562 + "", "19", resourceList, |
| | | CacheUtil.getMD5Long(resourceList))); |
| | | System.out.println(info); |
New file |
| | |
| | | package com.hxh.spring.test; |
| | | |
| | | import com.yeshi.buwan.dao.base.MongodbBaseDao; |
| | | import com.yeshi.buwan.dao.video.VideoResourceVersionMapDao; |
| | | import com.yeshi.buwan.domain.video.VideoResourceVersionMap; |
| | | import com.yeshi.buwan.service.inter.video.VideoResourceVersionMapService; |
| | | import org.yeshi.utils.generater.SpringComponentGenerater; |
| | | import org.yeshi.utils.generater.entity.ExceptionData; |
| | | import org.yeshi.utils.generater.entity.MongoDBDaoData; |
| | | import org.yeshi.utils.generater.entity.ServiceData; |
| | | |
| | | public class GeneralTest { |
| | | |
| | | @org.junit.Test |
| | | public void createDao() { |
| | | try { |
| | | SpringComponentGenerater.createMongoDao(new MongoDBDaoData.Builder().setBaseDaoClass(MongodbBaseDao.class).setDaoPackageName("com.yeshi.buwan.dao.video").setEntityClass(VideoResourceVersionMap.class).create(), "D:\\workspace\\BuWan\\src\\main\\java\\com\\yeshi\\buwan\\dao\\video\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // |
| | | @org.junit.Test |
| | | public void createService() { |
| | | try { |
| | | SpringComponentGenerater.createService(new ServiceData.Builder().setPackageName("com.yeshi.buwan.service.inter.video").setDaoClass(VideoResourceVersionMapDao.class).setEntityClass(VideoResourceVersionMap.class).build(), "D:\\workspace\\BuWan\\src\\main\\java\\com\\yeshi\\buwan\\service\\inter\\video\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // |
| | | // |
| | | @org.junit.Test |
| | | public void createServiceImpl() { |
| | | try { |
| | | SpringComponentGenerater.createServiceImpl(new ServiceData.Builder().setPackageName("com.yeshi.buwan.service.impl.video").setServiceClass(VideoResourceVersionMapService.class).setDaoClass(VideoResourceVersionMapDao.class).setEntityClass(VideoResourceVersionMap.class).build(), "D:\\workspace\\BuWan\\src\\main\\java\\com\\yeshi\\buwan\\service\\imp\\video\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // |
| | | // @org.junit.Test |
| | | // public void createException() { |
| | | // try { |
| | | // SpringComponentGenerater.createException(new ExceptionData.Builder().setPackageName("com.yeshi.buwan.exception.video").setBaseClass(BaseException.class).setEntityClass(LuckySponsorMoneyRecord.class).build(), "D:\\workspace\\DayLucky\\facade-lucky\\src\\main\\java\\com\\ks\\lucky\\exception\\"); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | //@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | //@ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | //@WebAppConfiguration |
| | | public class PPTVTest { |
| | | |
| | | @Resource |
| | |
| | | //CODE:XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg= |
| | | // PPTVApiUtil.login("XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg="); |
| | | String pptvUid = PPTVUtil.decryptPPTVCode("XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg=").pptvUid; |
| | | // String openId = PPTVApiUtil.getOpenId(pptvUid); |
| | | // System.out.println(openId); |
| | | String openId = PPTVApiUtil.getOpenId(pptvUid); |
| | | System.out.println(openId); |
| | | |
| | | try { |
| | | loginUserService.updatePPTVOpenId("766693"); |
| | | } catch (PPTVException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // try { |
| | | // loginUserService.updatePPTVOpenId("766693"); |
| | | // } catch (PPTVException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.domain.VideoDetailInfo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.VideoType; |
| | |
| | | VideoDetailUtil videoDeailUtil = com.yeshi.buwan.util.BeanUtil.getBean(VideoDetailUtil.class); |
| | | ClassService classService = com.yeshi.buwan.util.BeanUtil.getBean(ClassService.class); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds("android", Integer.parseInt(70 + "")); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), Integer.parseInt(70 + "")); |
| | | |
| | | VideoInfo info = (videoDeailUtil.getVideoInfo(null,3400048 + "", 13 + "", resourceList, |
| | | CacheUtil.getMD5Long(resourceList))); |
New file |
| | |
| | | package com.hxh.spring.test.video; |
| | | |
| | | import com.yeshi.buwan.domain.video.VideoResourceVersionMap; |
| | | import com.yeshi.buwan.service.inter.video.VideoResourceVersionMapService; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | public class VideoResourceVersionTest { |
| | | |
| | | @Resource |
| | | private VideoResourceVersionMapService videoResourceVersionMapService; |
| | | |
| | | @Test |
| | | public void addBuWanAndroid() { |
| | | String[] resourceIds = new String[]{"13", "19", "21", "22", "24"}; |
| | | for (String rid : resourceIds) { |
| | | try { |
| | | videoResourceVersionMapService.add(new VideoResourceVersionMap("44", 1, rid)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | resourceIds = new String[]{"25"}; |
| | | for (String rid : resourceIds) { |
| | | try { |
| | | videoResourceVersionMapService.add(new VideoResourceVersionMap("44", 105, rid)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void addBuWanIOS() { |
| | | String[] resourceIds = new String[]{"13", "19", "21", "22", "24"}; |
| | | for (String rid : resourceIds) { |
| | | try { |
| | | videoResourceVersionMapService.add(new VideoResourceVersionMap("43", 1, rid)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void listValid() { |
| | | List<String> resourceIds = videoResourceVersionMapService.listResourceId("43", 105); |
| | | System.out.println(resourceIds); |
| | | |
| | | resourceIds = videoResourceVersionMapService.listResourceId("44", 1); |
| | | System.out.println(resourceIds); |
| | | |
| | | resourceIds = videoResourceVersionMapService.listResourceId("44", 2); |
| | | System.out.println(resourceIds); |
| | | |
| | | resourceIds = videoResourceVersionMapService.listResourceId("44", 106); |
| | | System.out.println(resourceIds); |
| | | } |
| | | |
| | | } |