cn.hutool.http.HttpUtil Java Examples

The following examples show how to use cn.hutool.http.HttpUtil. 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: AboutListener.java    From WePush with MIT License 6 votes vote down vote up
/**
 * 初始化二维码
 */
public static void initQrCode() {
    String qrCodeContent = HttpUtil.get(UiConsts.QR_CODE_URL);
    if (StringUtils.isNotEmpty(qrCodeContent)) {
        Map<String, String> urlMap = JSONUtil.toBean(qrCodeContent, Map.class);
        JLabel qrCodeLabel = AboutForm.getInstance().getQrCodeLabel();

        try {
            URL url = new URL(urlMap.get("url"));
            BufferedImage image = ImageIO.read(url);
            qrCodeLabel.setIcon(new ImageIcon(image));
        } catch (IOException e) {
            e.printStackTrace();
            logger.error(e);
        }

        MainWindow.getInstance().getAboutPanel().updateUI();
    }
}
 
Example #2
Source File: AddressUtil.java    From albedo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static String getRealAddressByIp(String ip) {
	String address = "XX XX";

	// 内网不查询
	if (NetUtil.isInnerIP(ip)) {
		return "内网IP";
	}
	if (ApplicationConfig.isAddressEnabled()) {
		String rspStr = HttpUtil.post(IP_URL, "ip=" + ip);
		if (StringUtil.isEmpty(rspStr)) {
			log.error("获取地理位置异常 {}", ip);
			return address;
		}
		JSONObject obj;
		try {
			obj = JSON.parseObject(rspStr, JSONObject.class);
			JSONObject data = obj.getJSONObject("data");
			String region = data.getString("region");
			String city = data.getString("city");
			address = region + " " + city;
		} catch (Exception e) {
			log.error("获取地理位置异常 {}", ip);
		}
	}
	return address;
}
 
Example #3
Source File: DeliveryController.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 查看物流接口
 */
@GetMapping("/check")
@ApiOperation(value="查看物流", notes="根据订单号查看物流")
@ApiImplicitParam(name = "orderNumber", value = "订单号", required = true, dataType = "String")
public ResponseEntity<DeliveryDto> checkDelivery(String orderNumber) {

	Order order = orderService.getOrderByOrderNumber(orderNumber);
	Delivery delivery = deliveryService.getById(order.getDvyId());
	String url = delivery.getQueryUrl().replace("{dvyFlowId}", order.getDvyFlowId());
	String deliveryJson = HttpUtil.get(url);

	DeliveryDto deliveryDto = Json.parseObject(deliveryJson, DeliveryDto.class);
	deliveryDto.setDvyFlowId(order.getDvyFlowId());
	deliveryDto.setCompanyHomeUrl(delivery.getCompanyHomeUrl());
	deliveryDto.setCompanyName(delivery.getDvyName());
    return ResponseEntity.ok(deliveryDto);
}
 
Example #4
Source File: PasswordDecoderFilter.java    From albedo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
	// 不是登录请求,直接向下执行
	if (!StrUtil.containsAnyIgnoreCase(request.getRequestURI(), applicationProperties.getAdminPath(SecurityConstants.AUTHENTICATE_URL))) {
		filterChain.doFilter(request, response);
		return;
	}

	String queryParam = request.getQueryString();
	Map<String, String> paramMap = HttpUtil.decodeParamMap(queryParam, CharsetUtil.CHARSET_UTF_8);

	String password = request.getParameter(PASSWORD);
	if (StrUtil.isNotBlank(password)) {
		try {
			password = decryptAes(password, applicationProperties.getSecurity().getEncodeKey());
		} catch (Exception e) {
			log.error("密码解密失败:{}", password);
			throw e;
		}
		paramMap.put(PASSWORD, password.trim());
	}
	ParameterRequestWrapper requestWrapper = new ParameterRequestWrapper(request, paramMap);
	filterChain.doFilter(requestWrapper, response);
}
 
Example #5
Source File: GiteeOAuth2Template.java    From pre with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected AccessGrant postForAccessGrant(String accessTokenUrl, MultiValueMap<String, String> parameters) {

    // https://gitee.com/oauth/token?grant_type=authorization_code&code={code}&client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret}
    // 自己拼接url
    String clientId = parameters.getFirst("client_id");
    String clientSecret = parameters.getFirst("client_secret");
    String code = parameters.getFirst("code");
    String redirectUri = parameters.getFirst("redirect_uri");

    String url = String.format("https://gitee.com/oauth/token?grant_type=authorization_code&code=%s&client_id=%s&redirect_uri=%s&client_secret=%s", code, clientId, redirectUri, clientSecret);
    String post = HttpUtil.post(url, "",5000);

    log.info("获取accessToke的响应:" + post);
    JSONObject object = JSONObject.parseObject(post);
    String accessToken = (String) object.get("access_token");
    String scope = (String) object.get("scope");
    String refreshToken = (String) object.get("refresh_token");
    int expiresIn = (Integer) object.get("expires_in");

    log.info("获取Toke的响应:{},scope响应:{},refreshToken响应:{},expiresIn响应:{}", accessToken, scope, refreshToken, expiresIn);
    return new AccessGrant(accessToken, scope, refreshToken, (long) expiresIn);
}
 
Example #6
Source File: PluginManager.java    From xJavaFxTool-spring with Apache License 2.0 6 votes vote down vote up
public void loadServerPlugins() {
    try {
        String json = HttpUtil.get(SERVER_PLUGINS_URL);
        JSON.parseArray(json, PluginJarInfo.class).forEach(plugin -> {
            this.addOrUpdatePlugin(plugin, exist -> {
                exist.setName(plugin.getName());
                exist.setSynopsis(plugin.getSynopsis());
                exist.setVersion(plugin.getVersion());
                exist.setVersionNumber(plugin.getVersionNumber());
                exist.setDownloadUrl(plugin.getDownloadUrl());
            });
        });
    } catch (Exception e) {
        log.error("下载插件列表失败", e);
    }
}
 
Example #7
Source File: ExpressService.java    From yshopmall with Apache License 2.0 6 votes vote down vote up
/**
 * Json方式 查询订单物流轨迹
 *
 * @throws Exception
 */
private String getOrderTracesByJson(String OrderCode,String ShipperCode, String LogisticCode) throws Exception {
    if (!properties.isEnable()) {
        return null;
    }

    String requestData = "{'OrderCode':'"+OrderCode+"','ShipperCode':'" + ShipperCode + "','LogisticCode':'" + LogisticCode + "'}";

    Map<String, Object> params = new HashMap<>();
    params.put("RequestData", URLEncoder.encode(requestData, "UTF-8"));
    params.put("EBusinessID", properties.getAppId());
    params.put("RequestType", "1002");
    String dataSign = encrypt(requestData, properties.getAppKey(), "UTF-8");
    params.put("DataSign", URLEncoder.encode(dataSign, "UTF-8"));
    params.put("DataType", "2");

    String result = HttpUtil.post(ReqURL, params);

    //根据公司业务处理返回的信息......

    return result;
}
 
Example #8
Source File: PluginManager.java    From xJavaFxTool-spring with Apache License 2.0 6 votes vote down vote up
public File downloadPlugin(PluginJarInfo pluginJarInfo) throws IOException {
    PluginJarInfo plugin = getPlugin(pluginJarInfo.getJarName());
    if (plugin == null) {
        throw new IllegalStateException("没有找到插件 " + pluginJarInfo.getJarName());
    }

    File file = new File("libs/", pluginJarInfo.getJarName() + "-" + pluginJarInfo.getVersion() + ".jar");
    HttpUtil.downloadFile(pluginJarInfo.getDownloadUrl(), file);

    plugin.setIsDownload(true);
    plugin.setIsEnable(true);
    plugin.setLocalVersionNumber(plugin.getVersionNumber());
    this.saveToFile();

    return file;
}
 
Example #9
Source File: CityStats.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
public static void parseCity(String url, Area provinceArea) {
    String htmlStr = HttpUtil.get(url, CHARSET);
    Document document = Jsoup.parse(htmlStr);
    Elements trs = document.getElementsByClass("citytr");
    List<Area> cities = new LinkedList<Area>();
    int sort = 1;
    for (Element tr : trs) {
        Elements links = tr.getElementsByTag("a");
        String href = links.get(0).attr("href");
        String cityCode = links.get(0).text().substring(0, 4);
        String cityName = links.get(1).text();

        Area cityArea = Area.builder().label(cityName).code(cityCode).source(url)
                .sortValue(sort++).level(new RemoteData<>("CITY")).fullName(provinceArea.getFullName() + cityName)
                .build();

        StaticLog.info("	市级数据:  {}  ", cityArea);

        parseCounty(COMMON_URL + href, cityArea);
        cities.add(cityArea);
    }
    provinceArea.setChildren(cities);
}
 
Example #10
Source File: CityStats.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
public static void parseCounty(String url, Area cityArea) {
    String htmlStr = HttpUtil.get(url, CHARSET);
    Document document = Jsoup.parse(htmlStr);
    Elements trs = document.getElementsByClass("countytr");
    List<Area> counties = new LinkedList<Area>();
    int sort = 1;
    for (Element tr : trs) {
        Elements links = tr.getElementsByTag("a");
        if (links == null || links.size() != 2) {
            continue;
        }
        String href = links.get(0).attr("href");
        String countyCode = links.get(0).text().substring(0, 6);
        String countyName = links.get(1).text();

        Area countyArea = Area.builder().label(countyName).code(countyCode).source(url)
                .sortValue(sort++).level(new RemoteData<>("COUNTY")).fullName(cityArea.getFullName() + countyName)
                .build();

        StaticLog.info("		县级数据:  {}  ", countyArea);

        parseTowntr(COMMON_URL + href.subSequence(2, 5).toString() + "/" + href, countyArea);
        counties.add(cityArea);
    }
    cityArea.setChildren(counties);
}
 
Example #11
Source File: CityStats.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
public static void parseVillagetr(String url, Area countyArea) {
    String htmlStr = HttpUtil.get(url, CHARSET);
    Document document = Jsoup.parse(htmlStr);
    Elements trs = document.getElementsByClass("villagetr");

    List<Area> counties = new LinkedList<Area>();
    int sort = 1;
    for (Element tr : trs) {
        Elements tds = tr.getElementsByTag("td");
        if (tds == null || tds.size() != 3) {
            continue;
        }
        String villagetrCode = tds.get(0).text();
        String villagetrName = tds.get(2).text();

        Area villagetrArea = Area.builder().code(villagetrCode).label(villagetrName).source(url)
                .sortValue(sort++).level(new RemoteData<>("VILLAGETR")).fullName(countyArea.getFullName() + villagetrName)
                .build();
        StaticLog.info("		村级数据:  {}  ", villagetrArea);

        counties.add(villagetrArea);

    }
    countyArea.setChildren(counties);
}
 
Example #12
Source File: CityStats.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
public static void parseCity(String url, Area provinceArea) {
    String htmlStr = HttpUtil.get(url, CHARSET);
    Document document = Jsoup.parse(htmlStr);
    Elements trs = document.getElementsByClass("citytr");
    List<Area> cities = new LinkedList<Area>();
    int sort = 1;
    for (Element tr : trs) {
        Elements links = tr.getElementsByTag("a");
        String href = links.get(0).attr("href");
        String cityCode = links.get(0).text().substring(0, 4);
        String cityName = links.get(1).text();

        Area cityArea = Area.builder().label(cityName).code(cityCode).source(url)
                .sortValue(sort++).level(new RemoteData<>("CITY")).fullName(provinceArea.getFullName() + cityName)
                .build();

        StaticLog.info("	市级数据:  {}  ", cityArea);

        parseCounty(COMMON_URL + href, cityArea);
        cities.add(cityArea);
    }
    provinceArea.setChildren(cities);
}
 
Example #13
Source File: QiniuUtils.java    From qiniu with MIT License 6 votes vote down vote up
/**
 * 下载文件
 *
 * @param url 文件链接
 */
public static void download(String url) {
    // 验证存储路径
    if (Validator.isEmpty(QiniuApplication.getConfigBean().getStoragePath())) {
        // 显示存储路径输入框
        String storagePath = DialogUtils.showInputDialog(null, QiniuValueConsts.CONFIG_DOWNLOAD_PATH,
                Utils.getCurrentWorkDir());
        if (Validator.isEmpty(storagePath)) {
            return;
        }
        QiniuApplication.getConfigBean().setStoragePath(storagePath);
        ConfigUtils.writeConfig();
    }
    final String dest = QiniuApplication.getConfigBean().getStoragePath();
    // 下载文件
    ThreadPool.executor.execute(() -> HttpUtil.downloadFile(url, dest));
}
 
Example #14
Source File: ManualOperateController.java    From spring-boot-demo with MIT License 6 votes vote down vote up
/**
 * 测试手动保存任务
 */
@GetMapping("/add")
public String xxlJobAdd() {
    Map<String, Object> jobInfo = Maps.newHashMap();
    jobInfo.put("jobGroup", 2);
    jobInfo.put("jobCron", "0 0/1 * * * ? *");
    jobInfo.put("jobDesc", "手动添加的任务");
    jobInfo.put("author", "admin");
    jobInfo.put("executorRouteStrategy", "ROUND");
    jobInfo.put("executorHandler", "demoTask");
    jobInfo.put("executorParam", "手动添加的任务的参数");
    jobInfo.put("executorBlockStrategy", ExecutorBlockStrategyEnum.SERIAL_EXECUTION);
    jobInfo.put("glueType", GlueTypeEnum.BEAN);

    HttpResponse execute = HttpUtil.createGet(baseUri + JOB_INFO_URI + "/add").form(jobInfo).execute();
    log.info("【execute】= {}", execute);
    return execute.body();
}
 
Example #15
Source File: OcrUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static String sogouWebOcr(byte[] imgData) {
    String url = "https://deepi.sogou.com/api/sogouService";
    String referer = "https://deepi.sogou.com/?from=picsearch&tdsourcetag=s_pctim_aiomsg";
    String imageData = Base64.encode(imgData);
    long t = System.currentTimeMillis();
    String sign = SecureUtil.md5("sogou_ocr_just_for_deepibasicOpenOcr" + t + imageData.substring(0, Math.min(1024, imageData.length())) + "4b66a37108dab018ace616c4ae07e644");
    Map<String, Object> data = new HashMap<>();
    data.put("image", imageData);
    data.put("lang", "zh-Chs");
    data.put("pid", "sogou_ocr_just_for_deepi");
    data.put("salt", t);
    data.put("service", "basicOpenOcr");
    data.put("sign", sign);
    HttpRequest request = HttpUtil.createPost(url).timeout(15000);
    request.form(data);
    request.header("Referer", referer);
    HttpResponse response = request.execute();
    return extractSogouResult(WebUtils.getSafeHtml(response));
}
 
Example #16
Source File: CommUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static String postMultiData(String url, byte[] data, String boundary, String cookie, String referer) {
    try {
        HttpRequest request = HttpUtil.createPost(url).timeout(15000);
        request.contentType("multipart/form-data; boundary=" + boundary);
        request.body(data);
        if (StrUtil.isNotBlank(referer)) {
            request.header("Referer", referer);
        }
        if (StrUtil.isNotBlank(cookie)) {
            request.cookie(cookie);
        }
        HttpResponse response = request.execute();
        return WebUtils.getSafeHtml(response);
    } catch (Exception ex) {
        StaticLog.error(ex);
        return null;
    }
}
 
Example #17
Source File: AbstractOneDriveServiceBase.java    From zfile with MIT License 6 votes vote down vote up
/**
 * 根据 RefreshToken 刷新 AccessToken, 返回刷新后的 Token.
 *
 * @return  刷新后的 Token
 */
public OneDriveToken getRefreshToken() {
    StorageConfig refreshStorageConfig =
            storageConfigRepository.findByDriveIdAndKey(driveId, StorageConfigConstant.REFRESH_TOKEN_KEY);

    String param = "client_id=" + getClientId() +
            "&redirect_uri=" + getRedirectUri() +
            "&client_secret=" + getClientSecret() +
            "&refresh_token=" + refreshStorageConfig.getValue() +
            "&grant_type=refresh_token";

    String fullAuthenticateUrl = AUTHENTICATE_URL.replace("{authenticateEndPoint}", getAuthenticateEndPoint());
    HttpRequest post = HttpUtil.createPost(fullAuthenticateUrl);

    post.body(param, "application/x-www-form-urlencoded");
    HttpResponse response = post.execute();
    return JSONObject.parseObject(response.body(), OneDriveToken.class);
}
 
Example #18
Source File: CityParser.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
private List<Area> parseCity(String provinceName, String url) {
        String htmlStr = HttpUtil.get(url, CHARSET);
        Document document = Jsoup.parse(htmlStr);
        Elements trs = document.getElementsByClass("citytr");

        List<Area> cities = new LinkedList<Area>();
        int sort = 1;
        for (Element tr : trs) {
            Elements links = tr.getElementsByTag("a");
            String href = links.get(0).attr("href");
            String cityCode = links.get(0).text();
//            String cityCode = links.get(0).text().substring(0, 4);
            String cityName = links.get(1).text();

            Area cityArea = Area.builder()
                    .label(cityName).code(cityCode).source(url).sortValue(sort++)
                    .level(new RemoteData<>("CITY"))
                    .fullName(provinceName + cityName)
                    .build();
            cityArea.setChildren(parseCounty(provinceName + cityName, COMMON_URL + href));
            StaticLog.info("	市级数据:  {}  ", cityArea);

            cities.add(cityArea);
        }
        return cities;
    }
 
Example #19
Source File: AbstractOneDriveServiceBase.java    From zfile with MIT License 6 votes vote down vote up
/**
 * OAuth2 协议中, 根据 code 换取 access_token 和 refresh_token.
 *
 * @param   code
 *          代码
 *
 * @return  获取的 Token 信息.
 */
public OneDriveToken getToken(String code) {
    String param = "client_id=" + getClientId() +
            "&redirect_uri=" + getRedirectUri() +
            "&client_secret=" + getClientSecret() +
            "&code=" + code +
            "&scope=" + getScope() +
            "&grant_type=authorization_code";

    String fullAuthenticateUrl = AUTHENTICATE_URL.replace("{authenticateEndPoint}", getAuthenticateEndPoint());
    HttpRequest post = HttpUtil.createPost(fullAuthenticateUrl);

    post.body(param, "application/x-www-form-urlencoded");
    HttpResponse response = post.execute();
    return JSONObject.parseObject(response.body(), OneDriveToken.class);
}
 
Example #20
Source File: CityStats.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
public static void parseVillagetr(String url, Area countyArea) {
    String htmlStr = HttpUtil.get(url, CHARSET);
    Document document = Jsoup.parse(htmlStr);
    Elements trs = document.getElementsByClass("villagetr");

    List<Area> counties = new LinkedList<Area>();
    int sort = 1;
    for (Element tr : trs) {
        Elements tds = tr.getElementsByTag("td");
        if (tds == null || tds.size() != 3) {
            continue;
        }
        String villagetrCode = tds.get(0).text();
        String villagetrName = tds.get(2).text();

        Area villagetrArea = Area.builder().code(villagetrCode).label(villagetrName).source(url)
                .sortValue(sort++).level(new RemoteData<>("VILLAGETR")).fullName(countyArea.getFullName() + villagetrName)
                .build();
        StaticLog.info("		村级数据:  {}  ", villagetrArea);

        counties.add(villagetrArea);

    }
    countyArea.setChildren(counties);
}
 
Example #21
Source File: ThirdPartyLoginHelper.java    From feiqu-opensource with Apache License 2.0 6 votes vote down vote up
/**
 * 获取新浪用户信息
 * 
 * @param token
 * @param uid
 * @return
 */
public static final ThirdPartyUser getSinaUserinfo(String token, String uid) throws Exception {
	ThirdPartyUser user = new ThirdPartyUser();
	String url = Global.getPropertiesConfig("getUserInfoURL_sina");
	url = url + "?access_token=" + token + "&uid=" + uid;
	String res = HttpUtil.get(url);
	logger.info("url:"+url+",获取到新浪用户信息:"+res);
	JSONObject json = JSONObject.parseObject(res);
	String name = json.getString("name");
	String nickName = StringUtils.isBlank(json.getString("screen_name")) ? name : json.getString("screen_name");
	user.setAvatarUrl(json.getString("avatar_large"));
	user.setUserName(nickName);
	if ("f".equals(json.getString("gender"))) {
		user.setGender("2");
	} else {
		user.setGender("1");
	}
	user.setDescription(json.getString("description"));
	user.setLocation(json.getString("location"));
	user.setToken(token);
	user.setOpenid(uid);
	return user;
}
 
Example #22
Source File: AjaxAuthenticationFailureHandler.java    From albedo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
									AuthenticationException exception) {
	String useruame = request.getParameter("username");
	LoginUtil.isValidateCodeLogin(useruame, true, false);
	String message = exception instanceof BadCredentialsException && "Bad credentials".equals(exception.getMessage()) ? "密码填写错误!" : exception.getMessage();
	LogOperate logOperate = SysLogUtils.getSysLog();
	logOperate.setParams(HttpUtil.toParams(request.getParameterMap()));
	logOperate.setUsername(useruame);
	try {
		UserDetail userDetails = (UserDetail) userDetailsService.loadUserByUsername(useruame);
		if (userDetails != null) {
			logOperate.setCreatedBy(userDetails.getId());
		}
	} catch (Exception e) {
	}
	logOperate.setLogType(LogType.WARN.name());
	logOperate.setTitle("用户登录失败");
	logOperate.setDescription(message);
	logOperate.setException(ExceptionUtil.stacktraceToString(exception));
	AsyncUtil.recordLogLogin(logOperate);
	response.setStatus(HttpServletResponse.SC_OK);
	WebUtil.renderJson(response, Result.buildFail(message));
}
 
Example #23
Source File: ThirdPartyLoginHelper.java    From feiqu-opensource with Apache License 2.0 6 votes vote down vote up
/**
	 * 获取新浪登录认证token和用户id
	 * 
	 * @param code
	 * @return
	 */
	public static final JSONObject getSinaTokenAndUid(String code, String host) {
		JSONObject json = null;
		try {
			// 获取令牌
			String tokenUrl = Global.getPropertiesConfig("accessTokenURL_sina");
			Map<String,Object> map = new HashMap<String, Object>();
			map.put("client_id",Global.getPropertiesConfig("app_id_sina"));
			map.put("client_secret",Global.getPropertiesConfig("app_key_sina"));
//			map.put("grant_type",Global.getPropertiesConfig("authorization_code"));
			map.put("grant_type","authorization_code");
			map.put("redirect_uri","http://" + host + Global.getPropertiesConfig("redirect_url_sina"));
			map.put("code",code);
			String tokenRes = HttpUtil.post(tokenUrl, map);
			// String tokenRes = httpClient(tokenUrl);
			// {"access_token":"2.00AvYzKGWraycB344b3eb242NUbiQB","remind_in":"157679999","expires_in":157679999,"uid":"5659232590"}
			if (tokenRes != null && tokenRes.indexOf("access_token") > -1) {
				json = JSONObject.parseObject(tokenRes);
			} else {
				throw new IllegalArgumentException("THIRDPARTY.LOGIN.NOTOKEN sina");
			}
		} catch (Exception e) {
			logger.error("getSinaTokenAndUid",e);
		}
		return json;
	}
 
Example #24
Source File: SystemStoreController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@PostMapping(value = "/getL")
@Log("获取经纬度")
@ApiOperation("获取经纬度")
@PreAuthorize("@el.check('yxSystemStore:getl')")
public ResponseEntity<Object> create(@Validated @RequestBody String jsonStr){
    String key = RedisUtil.get(ShopKeyUtils.getTengXunMapKey());
    if(StrUtil.isBlank(key)) throw  new BadRequestException("请先配置腾讯地图key");
    JSONObject jsonObject = JSON.parseObject(jsonStr);
    String addr = jsonObject.getString("addr");
    String url = StrUtil.format("?address={}&key={}",addr,key);
    String json = HttpUtil.get(ShopConstants.QQ_MAP_URL+url);
    return new ResponseEntity<>(json,HttpStatus.CREATED);
}
 
Example #25
Source File: PictureServiceImpl.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteAll(Long[] ids) {
    for (Long id : ids) {
        Picture picture = findById(id);
        try {
            HttpUtil.get(picture.getDeleteUrl());
            this.removeById(id);
        } catch(Exception e){
            this.removeById(id);
        }
    }
}
 
Example #26
Source File: AdminRootController.java    From Tbed with GNU Affero General Public License v3.0 5 votes vote down vote up
@PostMapping("/sysupdate")
@ResponseBody
public Integer sysupdate(String  dates) {
    HashMap<String, Object> paramMap = new HashMap<>();
    String urls ="http://tc.hellohao.cn/systemupdate";
    paramMap.put("dates",dates);
    String result= HttpUtil.post(urls, paramMap);
    return Integer.parseInt( result );
}
 
Example #27
Source File: CityParser.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
/**
     * 乡镇级数据
     *
     * @param url
     * @return
     */
    public List<Area> parseTowntr(String fullName, String url) {
        String htmlStr = HttpUtil.get(url, CHARSET);
        Document document = Jsoup.parse(htmlStr);
        Elements trs = document.getElementsByClass("towntr");

        List<Area> counties = new LinkedList<Area>();
        int sort = 1;
        for (Element tr : trs) {
            Elements links = tr.getElementsByTag("a");
            if (links == null || links.size() != 2) {
                continue;
            }
            String href = links.get(0).attr("href");
            String towntrCode = links.get(0).text();
//            String towntrCode = links.get(0).text().substring(0, 6);
            String towntrName = links.get(1).text();

            Area towntrArea = Area.builder()
                    .label(towntrName).code(towntrCode).source(url)
                    .fullName(fullName + towntrName)
                    .level(new RemoteData<>("TOWNTR"))
                    .sortValue(sort++)
//                    .nodes(parseVillagetr(fullName + towntrName, COMMON_URL + href.subSequence(2, 5).toString() + "/" + href.substring(5, 7) + "/" + href))
                    .build();

            StaticLog.info("			乡镇级数据:  {}  ", towntrArea);

            counties.add(towntrArea);
        }
        return counties;
    }
 
Example #28
Source File: ClientController.java    From Tbed with GNU Affero General Public License v3.0 5 votes vote down vote up
@GetMapping("/getNotice")
@ResponseBody
public Msg getNotice() {
    Msg msg = new Msg();
    String url = "http://tc.hellohao.cn/getNoticeText";
    if(TestUrl.testUrlWithTimeOut(url,2000)){
        String urls =url;
        msg.setData(HttpUtil.get(urls));
    }else{
        msg.setData("暂无公告");
    }
    return msg;
}
 
Example #29
Source File: ManualOperateController.java    From spring-boot-demo with MIT License 5 votes vote down vote up
/**
 * 任务组列表,xxl-job叫做触发器列表
 */
@GetMapping("/group")
public String xxlJobGroup() {
    HttpResponse execute = HttpUtil.createGet(baseUri + JOB_GROUP_URI + "/list").execute();
    log.info("【execute】= {}", execute);
    return execute.body();
}
 
Example #30
Source File: CityStats.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
public static void parseTowntr(String url, Area countyArea) {
    String htmlStr = HttpUtil.get(url, CHARSET);
    Document document = Jsoup.parse(htmlStr);
    Elements trs = document.getElementsByClass("towntr");

    List<Area> counties = new LinkedList<Area>();
    int sort = 1;
    for (Element tr : trs) {
        Elements links = tr.getElementsByTag("a");
        if (links == null || links.size() != 2) {
            continue;
        }
        String href = links.get(0).attr("href");
        String towntrCode = links.get(0).text().substring(0, 9);
        String towntrName = links.get(1).text();

        Area towntrArea = Area.builder().label(towntrName).code(towntrCode).source(url)
                .sortValue(sort++).level(new RemoteData<>("TOWNTR")).fullName(countyArea.getFullName() + towntrName)
                .build();

        StaticLog.info("		乡镇级数据:  {}  ", towntrArea);

        parseVillagetr(COMMON_URL + href.subSequence(2, 5).toString() + "/" + href.substring(5, 7) + "/" + href,
                countyArea);

        counties.add(towntrArea);
    }
    countyArea.setChildren(counties);
}