master
parent
73d66e8324
commit
e11082cea9
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@ |
||||
package com.hfkj.common.utils; |
||||
|
||||
import java.util.Random; |
||||
|
||||
/** |
||||
* @ClassName RandomStringGeneratorUtil |
||||
* @Author Sum1Dream |
||||
* @Description 生成随机数 |
||||
* @Date 2024/8/27 上午11:33 |
||||
**/ |
||||
public class RandomStringGeneratorUtil { |
||||
|
||||
public static String generateRandomString(int stringLength) { |
||||
char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".toCharArray(); |
||||
StringBuilder sb = new StringBuilder(); |
||||
Random random = new Random(); |
||||
for (int i = 0; i < stringLength; i++) { |
||||
char c = chars[random.nextInt(chars.length)]; |
||||
sb.append(c); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,74 @@ |
||||
package com.hfkj.meituan; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.config.CommonSysConst; |
||||
|
||||
import com.meituan.sqt.utils.EncryptUtil; |
||||
import com.meituan.sqt.utils.JsonUtil; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName MeiTuanService |
||||
* @Author Sum1Dream |
||||
* @Description 美团接口 |
||||
* @Date 2024/8/26 下午4:52 |
||||
**/ |
||||
public class MeiTuanService { |
||||
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(MeiTuanService.class); |
||||
|
||||
|
||||
/** |
||||
* @MethodName loginFree |
||||
* @Description: H5免登接口 |
||||
* @param map |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/8/27 上午11:16 |
||||
*/ |
||||
public static JSONObject loginFree(Map<String , Object> map) throws Exception { |
||||
|
||||
JSONObject object = request("" , map); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 请求 |
||||
* @param postUrl 接口请求地址 |
||||
* @param param 参数 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject request(String postUrl, Map<String,Object> param) throws Exception { |
||||
|
||||
|
||||
|
||||
log.info("============ 千猪请求-START ============="); |
||||
param.put("accessKey", CommonSysConst.getSysConfig().getMtAccessKey()); |
||||
param.put("content", EncryptUtil.aesEncrypt(JsonUtil.object2Json(param), CommonSysConst.getSysConfig().getMtSecretKey())); |
||||
|
||||
log.info("请求接口:" + postUrl); |
||||
log.info("请求参数:" + JSONObject.toJSONString(param)); |
||||
|
||||
JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getMtPostUrl() + postUrl, JSONObject.toJSONString(param)); |
||||
|
||||
log.info("响应参数:" + response.toJSONString()); |
||||
log.info("============ 千猪请求-END =============="); |
||||
return response; |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue