package com.micer.easyball;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.micer.easyball.mapper.*;
import com.micer.easyball.pojo.Club;
import com.micer.easyball.pojo.GameImage;
import com.micer.easyball.pojo.User;
import com.micer.easyball.utils.JwtUtil;
import io.jsonwebtoken.Jwt;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@SpringBootTest
class EasyballApplicationTests {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ClubMapper clubMapper;

    @Autowired
    private ClubPlayerMapper clubPlayerMapper;

    @Autowired
    private GameImageMapper gameImageMapper;

    @Test
    public void TestBCryptPasswordEncoder() {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String encode = passwordEncoder.encode("15013153445");
        System.out.println(encode);
    }


    @Test
    void contextLoads() {

    }

    @Test
    public void testApplicationHome()
    {
        ApplicationHome applicationHome = new ApplicationHome(this.getClass());
        System.out.println(applicationHome.getDir());
    }


    @Test
    public void testSelectAllClubByUserId()
    {
        List<Club> clubs = clubPlayerMapper.selectAllClubByUserId("1760191788309561344");
        System.out.println(clubs);
    }

    @Test
    public void testString()
    {
        String projects = "[\"java\",\"pyhton\",\"C++\"]";
        JSONArray jsonArray = JSONArray.parseArray(projects);
        System.out.println(jsonArray);

    }

    @Test
    public void testUserMapper()
    {
        List<User> users = userMapper.selectList(new QueryWrapper<>());
        System.out.println(users);
    }

    @Test
    public void testClubMapper()
    {
        List<Club> clubs = clubMapper.selectList(new QueryWrapper<>());
        System.out.println(clubs);
    }

    @Test
    public void testUUID()
    {
        System.out.println(JwtUtil.getUUID());
    }


}
