com.xnx3.BaseVO Java Examples
The following examples show how to use
com.xnx3.BaseVO.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TemplateCompute.java From templatespider with Apache License 2.0 | 6 votes |
/** * 将某行的字符串,在所有模板页面中进行对比,看此行在模板页面中有几个模板页匹配 * @param list 要挨个对比的模板 * @param diffElement 对比的元素 * @return 字符串匹配的模板的数量,个数 */ public ElementDiffListVO findElementByAllTemplate(Element diffElement){ ElementDiffListVO vo = new ElementDiffListVO(); List<ElementDiffVO> list = new ArrayList<ElementDiffVO>(); //首先便利出所有模板来 for (Map.Entry<String, Template> entry : Global.templateMap.entrySet()) { Template t = entry.getValue(); ElementDiffVO edVO = findElementByTemplate(t, diffElement); list.add(edVO); if(edVO.getResult() - BaseVO.SUCCESS == 0){ vo.setDiffEqualNum(vo.getDiffEqualNum()+edVO.getD()); // System.out.println(edVO.getD()+"----"+(edVO.getD())); if(edVO.getD() - 0.99999 > 0){ vo.setIpentityNum(vo.getIpentityNum()+1); } } } vo.setList(list); return vo; }
Example #2
Source File: MNSUtil.java From xnx3 with Apache License 2.0 | 6 votes |
/** * 创建订阅 * @param topicName 要在哪个主题下创建订阅,这个是主题的名字 * @param subMeta 要创建的订阅的对象 * @return */ public BaseVO createSubScription(String topicName, SubscriptionMeta subMeta){ BaseVO vo = new BaseVO(); CloudTopic topic = getMNSClient().getTopicRef(topicName); try { // SubscriptionMeta subMeta = new SubscriptionMeta(); // subMeta.setSubscriptionName("TestSub"); // subMeta.setEndpoint(HttpEndpoint.GenEndpointLocal()); // subMeta.setNotifyContentFormat(SubscriptionMeta.NotifyContentFormat.XML); // //subMeta.setFilterTag("filterTag"); //设置订阅的filterTag String subUrl = topic.subscribe(subMeta); vo.setBaseVO(BaseVO.SUCCESS, subUrl); } catch (Exception e) { vo.setBaseVO(BaseVO.FAILURE, e.getMessage()); System.out.println("subscribe/unsubribe error"); e.printStackTrace(); } return vo; }
Example #3
Source File: XiaoChengXuUtil.java From xnx3 with Apache License 2.0 | 6 votes |
/** * https://api.weixin.qq.com/sns/jscode2session 根据code ,获取 openid、session_key 、 unionid * @param code 微信小程序端,通过js获取到的code,也就是 wx.login 获取到的 code * @return {@link Jscode2sessionResultVO} 微信jscode2session接口所返回的结果。 * <ul> * <li>result : {@link Jscode2sessionResultVO}.FAILURE 调用失败,通过 .getInfo() 返回失败结果</li> * <li>result : {@link Jscode2sessionResultVO}.SUCCESS 调用成功。即可正常获得 openid、session_key 等</li> * </ul> */ public static Jscode2sessionResultVO jscode2session(String code){ Jscode2sessionResultVO vo = new Jscode2sessionResultVO(); HttpsUtil https = new HttpsUtil(); HttpResponse hr = https.get("https://api.weixin.qq.com/sns/jscode2session?appid="+appId+"&secret="+appSecret+"&js_code="+code+"&grant_type=authorization_code"); if(hr.getCode() - 200 == 0 && hr.getContent() != null && hr.getContent().indexOf("session_key") > -1){ JSONObject json = JSONObject.fromObject(hr.getContent()); vo.setOpenid(json.get("openid") == null? "":json.getString("openid")); vo.setUnionid(json.get("unionid") == null ? "":json.getString("unionid")); vo.setSessionKey(json.get("session_key") == null? "":json.getString("session_key")); }else{ vo.setBaseVO(BaseVO.FAILURE, hr.getContent()); } return vo; }
Example #4
Source File: Cache.java From templatespider with Apache License 2.0 | 5 votes |
/** * 将资源加入缓存序列。 * @param rb 要加入的资源 * @return {@link ResourceBean} * <ul> * <li>若加入成功。等待进行缓存,则此处会返回null</li> * <li>若加入失败,因为之前已经缓存过了。也就是已经有当前的缓存文件了。那么将缓存文件中的 {@link ResourceBean}返回 </li> * </ul> */ public static synchronized ResourceVO addCache(Resource resource){ ResourceVO vo = new ResourceVO(); if(resource.getNetUrl() == null){ //无远程资源,退出不缓存 vo.setResult(BaseVO.FAILURE); return vo; } if(resource.getNetUrl().length() > 255){ //远程资源可能不是一个正常的url,可能是图片的base64存在,退出不缓存。因为本身就跟随其父文件进行了缓存了 vo.setResult(BaseVO.FAILURE); return vo; } //找cacheMap中是否缓存了 Resource cacheResource = cacheMap.get(resource.getNetUrl()); if(cacheResource == null){ cacheResource = cacheMap.get(resource.getOriginalUrl()); if(cacheResource != null){ System.out.println("cacheResource-->"+cacheResource); } } //如果缓存中有,那么要将之前的缓存返回 if(cacheResource != null){ //已经缓存过了,不用再进行缓存 vo.setResource(cacheResource); }else{ //如果缓存中没有,那么进行缓存,将其下载下来 downFile(resource); //将绝对路径其加入缓存 cacheMap.put(resource.getNetUrl(), resource); //将其原始引用路径加入缓存 cacheMap.put(resource.getOriginalUrl(), resource); vo.setResource(resource); } return vo; }
Example #5
Source File: PageSpider.java From templatespider with Apache License 2.0 | 5 votes |
/** * 将css文件进行过滤替换,下载其中的图片 * @param text css的内容 * @param thisUrl 当前文件在网上的绝对路径 * @param cacheFilePath 缓存下来的文件,在text中引用的路径(缓存路径)。如/css/...css文件的引用为 ../images/ /..html文件引用为 "images/" * @return */ public static String replaceCss(String cssText, String thisUrl, String cacheFilePath){ String uriPath = UrlUtil.getPath(thisUrl); //当前的url的路径 // Pattern pattern = Pattern.compile("background[-image]*: *url\\('?\"?(.*?)'?\"?\\)"); Pattern pattern = Pattern.compile("url\\('?\"?(.*?)'?\"?\\)"); Matcher matcher = pattern.matcher(cssText); while (matcher.find()) { String src = matcher.group(1); //src的地址 if(src != null && src.length() > 2){ String srcUrl = StringUtil.hierarchyReplace(uriPath, src); if(srcUrl.indexOf(CACHE_STRING) == -1){ //如果没有缓存过,那才进行缓存 Resource res = new Resource(srcUrl, thisUrl, ""); if(res.getNetUrl() == null){ continue; } ResourceVO vo = Cache.addCache(res); if(vo.getResult() - BaseVO.SUCCESS == 0){ //将其进行替换为相对路径 cssText = StringUtil.replaceAll(cssText, src, CACHE_STRING+cacheFilePath+vo.getResource().getLocalFile()); } } } } //完事后,将 _XNX3CACHE_ 去除 cssText = StringUtil.replaceAll(cssText, CACHE_STRING, ""); return cssText; }
Example #6
Source File: TemplateCompute.java From templatespider with Apache License 2.0 | 5 votes |
/** * 判断某个模板(body)中,是否有此Element存在 * @param bodyElement 要判断的模板的body元素 * @param diff 要判断寻找的元素 * @return 0~1 越相似,越靠近1 */ public ElementDiffVO findElementByTemplate(Template template, Element diff){ Element bodyElement = template.getBodyElement(); ElementDiffVO vo = new ElementDiffVO(); vo.setDiffElement(diff); vo.setTargetFile(template.getFile()); Elements es = bodyElement.getElementsByTag(diff.tagName()); if(es.size() == 0){ //没有找到这个Element的Tag,那么直接返回0 vo.setResult(BaseVO.FAILURE); return vo; } for (int i = 0; i < es.size(); i++) { Element e = es.get(i); //进行对比 double d1 = com.xnx3.util.StringUtil.similarity(diff, e); if(d1 > vo.getD()){ vo.setD(d1); vo.setTargetElement(e); } } return vo; }
Example #7
Source File: NewsController.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 根据news.id删除信息 */ @RequestMapping(value="deleteNews${url.suffix}", method = RequestMethod.POST) public String deleteNews(HttpServletRequest request,Model model, @RequestParam(value = "id", required = false , defaultValue="0") int id){ NewsVO vo = newsService.deleteNews(id, true); if(vo.getResult() - BaseVO.SUCCESS == 0){ News news = vo.getNews(); SiteColumn siteColumn = sqlService.findById(SiteColumn.class, news.getCid()); Site site = sqlService.findById(Site.class, siteColumn.getSiteid()); List<News> newsList = sqlService.findBySqlQuery("SELECT * FROM news WHERE cid = "+siteColumn.getId()+" ORDER BY id DESC", News.class); //刷新列表页 newsService.generateListHtml(site, siteColumn); //刷新首页的列表数据 IndexNews.refreshIndexData(site, siteColumn, newsList); //日志 AliyunLog.addActionLog(news.getId(), "删除文章成功,文章:"+news.getTitle()); //删除OSS的html、头图文件 AttachmentFile.deleteObject("site/"+news.getSiteid()+"/"+news.getId()+".html"); if(news.getTitlepic() != null && news.getTitlepic().length() > 0 && news.getTitlepic().indexOf("http:") == -1){ AttachmentFile.deleteObject("site/"+news.getSiteid()+"/news/"+news.getTitlepic()); } //刷新sitemap siteService.refreshSiteMap(site); return success(model, "删除信息成功","news/list.do?cid="+siteColumn.getId()+"&editMode=edit&client=pc"); }else{ return error(model, vo.getInfo()); } }
Example #8
Source File: NewsController.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 根据news.id删除信息,Ajax方式,返回json * @param id 要删除的news.id */ @RequestMapping(value="deleteNewsForAjax${url.suffix}", method = RequestMethod.POST) @ResponseBody public NewsVO deleteNewsForAjax(HttpServletRequest request,Model model, @RequestParam(value = "id", required = false , defaultValue="0") int id){ NewsVO vo = newsService.deleteNews(id, true); if(vo.getResult() - BaseVO.SUCCESS == 0){ News news = vo.getNews(); //日志 AliyunLog.addActionLog(getSiteId(), "删除文章:"+news.getTitle()); //删除OSS的html、头图文件 AttachmentFile.deleteObject("site/"+news.getSiteid()+"/"+news.getId()+".html"); if(news.getTitlepic() != null && news.getTitlepic().length() > 0 && news.getTitlepic().indexOf("http:") == -1){ AttachmentFile.deleteObject("site/"+news.getSiteid()+"/news/"+news.getTitlepic()); } if(!Func.isCMS(getSite())){ //如果不是cms模式,那么还要刷新一堆 SiteColumn siteColumn = sqlService.findById(SiteColumn.class, news.getCid()); Site site = sqlService.findById(Site.class, siteColumn.getSiteid()); List<News> newsList = sqlService.findBySqlQuery("SELECT * FROM news WHERE cid = "+siteColumn.getId()+" ORDER BY id DESC", News.class); //刷新列表页 newsService.generateListHtml(site, siteColumn); //刷新首页的列表数据 IndexNews.refreshIndexData(site, siteColumn, newsList); } } return vo; }
Example #9
Source File: NewsController.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 服务于 {@link #newsChangeColumnForSelectColumn(HttpServletRequest, Model, int, int)} 将文章转移到其他栏目,选择后提交保存 * @param newsid 要转移的文章id,news.id * @param targetColumnId 要转移到的目标栏目id */ @RequestMapping(value="newsChangeColumnForSelectColumnSubmit${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO newsChangeColumnForSelectColumnSubmit(HttpServletRequest request,Model model, @RequestParam(value = "newsid", required = true) int newsid, @RequestParam(value = "targetColumnId", required = true) int targetColumnId){ //判断要转移的文章是否存在以及是否属于本人 News news = sqlService.findById(News.class, newsid); if(news == null){ return error("要转移的文章不存在"); } Site site = getSite(); if(news.getSiteid() - site.getId() != 0){ return error("该文章不属于您,无法操作"); } //判断要转移至的栏目,是否存在,以及是否属于本人 SiteColumn column = sqlService.findById(SiteColumn.class, targetColumnId); if(column == null){ return error("目标栏目不存在"); } if(column.getSiteid() - site.getId() != 0){ return error("目标栏目不属于您,无法操作"); } //检测完毕,进行转移栏目 news.setCid(targetColumnId); sqlService.save(news); AliyunLog.addActionLog(news.getId(), "将文章转移栏目", "将文章"+news.getTitle()+"转移到栏目["+column.getName()+"]中"); return success(); }
Example #10
Source File: NewsController.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 更改文章发布的时间 * @param id news.id * @param addtime 修改后的时间,格式如 2018-12-12 22:22:22 * @return */ @RequestMapping(value="updateAddtime${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO updateAddtime(HttpServletRequest request, @RequestParam(value = "id", required = false , defaultValue="0") int id, @RequestParam(value = "addtime", required = false , defaultValue="") String addtime){ if(id < 1){ return error("请传入要操作的文章编号"); } if(addtime.length() == 0){ return error("请传入修改后的时间"); } News news = sqlService.findById(News.class, id); if(news == null){ return error("要操作的文章不存在"); } if(news.getSiteid() - getSiteId() != 0){ return error("文章不属于您,无法操作"); } //将2018-12-12 22:22:22 转化为10位时间戳 int time = DateUtil.StringToInt(addtime, "yyyy-MM-dd HH:mm:ss"); news.setAddtime(time); sqlService.save(news); //记录日志 AliyunLog.insert(request, news.getId(), "更改文章发布时间", time+""); return success(); }
Example #11
Source File: AttachmentFile.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 判断要上传的文件是否超出大小限制,若超出大小限制,返回出错原因 * @param lengthKB 要上传的文件的大小,判断其大小是否超过系统指定的最大限制,单位是KB * @return 若超出大小,则返回result:Failure ,info为出错原因 */ public static UploadFileVO verifyFileMaxLength(int lengthKB){ UploadFileVO vo = new UploadFileVO(); if(getMaxFileSizeKB() > 0 && lengthKB > getMaxFileSizeKB()){ vo.setBaseVO(BaseVO.FAILURE, "文件大小超出限制!上传大小在 "+maxFileSize+" 以内"); return vo; } return vo; }
Example #12
Source File: NewsSearchPluginController.java From wangmarket with Apache License 2.0 | 4 votes |
/** * 进行搜索,网站 ajax 方式请求,搜索当前网站中,栏目类型为新闻、图文列表下的信息 * @param siteid 站点编号,id * @param title 要从标题中搜索的关键词 * @param everyPageNumber 每页显示多少条信息。取值范围限制 2 ~ 30 之间 */ @RequestMapping("search${url.suffix}") @ResponseBody public SearchResultVO search(HttpServletRequest request,HttpServletResponse response, @RequestParam(value = "siteid", required = false , defaultValue="0") int siteid, @RequestParam(value = "title", required = false , defaultValue="") String title, @RequestParam(value = "everyPageNumber", required = false , defaultValue="10") int everyPageNumber){ response.addHeader("Access-Control-Allow-Origin", "*"); SearchResultVO vo = new SearchResultVO(); if(siteid == 0){ vo.setBaseVO(BaseVO.FAILURE, "请传入站点编号{site.id}"); return vo; } if(title.length() == 0){ vo.setBaseVO(BaseVO.FAILURE, "请传入要搜索的关键词"); return vo; } if(everyPageNumber > 30 || everyPageNumber < 2){ vo.setBaseVO(BaseVO.FAILURE, "everyPageNumber 每页显示多少条信息,范围必须在 2~30 之间"); return vo; } Sql sql = new Sql(request); sql.setSearchTable("news"); sql.appendWhere("siteid = "+siteid+" AND status = "+News.STATUS_NORMAL); sql.appendWhere("( type = "+News.TYPE_NEWS+" OR type = "+News.TYPE_IMAGENEWS+" OR type = "+SiteColumn.TYPE_LIST+")"); sql.setSearchColumn(new String[]{"title"}); int count = sqlService.count("news", sql.getWhere()); Page page = new Page(count, everyPageNumber, request); //创建查询语句,只有SELECT、FROM,原生sql查询。其他的where、limit等会自动拼接 sql.setSelectFromAndPage("SELECT id,addtime,title,titlepic,intro,cid FROM news", page); //v4.4版本以前,没有自定义内容排序功能,只有按时间倒序排列 sql.setDefaultOrderBy("addtime DESC"); //因联合查询,结果集是没有实体类与其对应,故而用List<Map>接收 List<Map<String, Object>> list = sqlService.findMapBySql(sql); vo.setList(list); vo.setPage(page); return vo; }
Example #13
Source File: NewsServiceImpl.java From wangmarket with Apache License 2.0 | 4 votes |
public NewsVO deleteNews(int id, boolean authCheck) { NewsVO baseVO = new NewsVO(); if(id == 0){ baseVO.setBaseVO(BaseVO.FAILURE, "请传入要删除信息的编号"); return baseVO; } News news = sqlDAO.findById(News.class, id); if(news == null){ baseVO.setBaseVO(BaseVO.FAILURE, "信息不存在"); return baseVO; } Site site = Func.getUserBeanForShiroSession().getSite(); //需要验证此信息是本人发布 if(authCheck){ if(news.getSiteid() - site.getId() != 0){ baseVO.setBaseVO(BaseVO.FAILURE, "信息不属于你,无权删除"); return baseVO; } } //获取当前信息所属的栏目 SiteColumn siteColumn = sqlDAO.findById(SiteColumn.class, news.getCid()); if(siteColumn != null){ if(siteColumn.getType() - SiteColumn.TYPE_PAGE == 0 || siteColumn.getType() - SiteColumn.TYPE_ALONEPAGE == 0){ baseVO.setBaseVO(BaseVO.FAILURE, "该信息所属的栏目,栏目类型为独立页面,无法删除此信息。如果你想删除,可以删除其所属的栏目,此信息自然就没了"); return baseVO; } }else{ //如果siteColumn 为null,那么可能就是栏目已经被删除了,当然,这条信息自然也就可以删除掉的 } sqlDAO.delete(news); NewsData newsData = sqlDAO.findById(NewsData.class, id); if(newsData == null){ baseVO.setBaseVO(BaseVO.FAILURE, "信息内容不存在"); return baseVO; } sqlDAO.delete(newsData); //删除titlepic文件 if(news.getTitlepic() != null && news.getTitlepic().indexOf("http://") == -1){ AttachmentFile.deleteObject("site/"+news.getSiteid()+"/news/"+news.getTitlepic()); } baseVO.setNews(news); return baseVO; }