123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package fcb.project.manager.base.utils;
- import com.alibaba.fastjson.JSON;
- import fdage.back.sdk.base.entity.Result;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * 2 * @Author: Abner
- * 3 * @Date: 2021/1/18 9:11
- * 4
- */
- public class FcbUtils {
- public static Result<Object> getFcbSign(Map<String , Object> params , String fcbClientSecret){
- if(CollectionUtils.isEmpty(params)){
- return Result.failure("入参不能为空");
- }
- for (Map.Entry entry : params.entrySet()) {
- //1、先剔除value值为null的键值对
- if(null == entry.getValue()){
- params.remove(entry.getKey());
- }
- }
- //2、新增房车宝的client_secret作为噪点
- params.put("client_secret" , fcbClientSecret);
- params = DataUtils.sortMapByKey(params);
- //3、生成MD5密文,然后转成小写字母
- String md5EncryptionStr = DataUtils.md5Encryption(JSON.toJSONString(params));
- Map<String , Object> resultMap = new HashMap<>();
- resultMap.put("authcode" , md5EncryptionStr);
- resultMap.put("timeStamp" , System.currentTimeMillis());
- return Result.success(resultMap);
- }
- }
|