package com.miaxis.test;

import com.alibaba.fastjson.JSONObject;
import com.miaxis.ZzjsApplication;
import com.miaxis.common.sms.MD5Utils;
import com.miaxis.feign.dto.fulu.FuluDTO;
import com.miaxis.feign.service.IFuluService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

@SpringBootTest(classes = ZzjsApplication.class)
@RunWith(SpringRunner.class)
public class FuluTest {
    @Autowired
    private IFuluService fuluService;

    String AppSecret = "0a091b3aa4324435aab703142518a8f7";


    @Test
    public void test1()  {
        FuluDTO fuluDTO = new FuluDTO();
        fuluDTO.setApp_key("i4esv1l+76l/7NQCL3QudG90Fq+YgVfFGJAWgT+7qO1Bm9o/adG/1iwO2qXsAXNB");
        fuluDTO.setMethod("fulu.goods.list.get");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        fuluDTO.setTimestamp(simpleDateFormat.format(new Date()));
        fuluDTO.setVersion("2.0");
        fuluDTO.setFormat("json");
        fuluDTO.setCharset("utf-8");
        fuluDTO.setSign_type("md5");
        fuluDTO.setApp_auth_token("");
        fuluDTO.setBiz_content("{}");
        String str = JSONObject.toJSONString(fuluDTO);
        System.out.println("json字符串"+str);
        char[] s = str.toCharArray();
        Arrays.sort(s);
        String outputSignOriginalStr = new String(s) + AppSecret;
        String sign = MD5Utils.MD5Encode(outputSignOriginalStr);
        fuluDTO.setSign(sign);
        fuluService.fuluCommonApi(fuluDTO);

    }








}
