package com.yfd.platform;

import cn.hutool.jwt.JWTUtil;
import org.junit.jupiter.api.Test;

import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

class PlatformApplicationTests {

    @Test
    void contextLoads() {
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        Timestamp timestamp1 = new Timestamp(System.currentTimeMillis());
        long time = timestamp.getTime();
        long time1 = timestamp1.getTime();
        System.out.println(time1 - time);
        String path = System.getProperty("user.dir");
        System.out.println(path);
        int max = 101;
        DecimalFormat df = new DecimalFormat("0000");
        String code = df.format(max + 1);
        int i = Integer.parseInt("0030");
        System.out.println(i);
    }

    @Test
    void myTest() throws InterruptedException {
        Map<String, Object> map = new HashMap<String, Object>() {
            private static final long serialVersionUID = 1L;

            {
                put("userid", Integer.parseInt("123232323"));
                put("expire_time", System.currentTimeMillis() + 5 * 1000);
            }
        };
        String token = JWTUtil.createToken(map, "1234".getBytes());
        System.out.println(token);
        Thread.sleep(10 * 1000);

        //解析token
        boolean isok = JWTUtil.verify(token, "1234".getBytes());
        String userid = "";

    }

}
