package com.api.test;

import com.alibaba.fastjson.JSON;
import com.heyu.api.data.entity.vv.VvResourceEntity;
import org.apache.commons.lang3.text.StrSubstitutor;
import org.junit.Test;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class test2 {

    public static void main(String[] args)  throws Exception{

        // 读取文件内容到Stream流中，按行读取
        Stream<String> lines = Files.lines(Paths.get("/Users/quyixiao/gitb/eb-service-api/api-web/api-interface/src/main/resources/filebase64.txt"));



        String a = lines.collect(Collectors.joining());

        System.out.println(a);
    }


    @Test
    public void testxx(){

        Map valuesMap = new HashMap();
        valuesMap.put("yesterDay", "2025-10-18");
        String templateString = "\n" +
                "select x,name,y from (\n" +
                "select \n" +
                "date_format(create_time, '%Y-%m-%d') as x  ,description as name,count(*) as y  \n" +
                "from vv_request_log where DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT('${yesterDay}', '%Y-%m-%d')  group by description\n" +
                ") as all_data  order by y desc limit 100 \n" +
                "\n" +
                "\n" +
                "\n" +
                "\n";

        StrSubstitutor sub = new StrSubstitutor(valuesMap);
        String resolvedString = sub.replace(templateString);


        System.out.println(resolvedString);
    }

    @Test
    public void test1() throws Exception{
        VvResourceEntity vvResourceEntity = new VvResourceEntity();
        vvResourceEntity.setFileName("张三");
        vvResourceEntity.setParentId(0L);
        vvResourceEntity.setResourceUrl("https://www.baidu.com");
        vvResourceEntity.setType("image");



        VvResourceEntity vvResourceEntity2 = new VvResourceEntity();
        vvResourceEntity2.setFileName("张三");
        vvResourceEntity2.setParentId(0L);
        vvResourceEntity2.setResourceUrl("https://www.baidu.com");
        vvResourceEntity2.setType("image");


        List<VvResourceEntity> vvResourceEntityList = Arrays.asList(vvResourceEntity, vvResourceEntity2);
        System.out.println(JSON.toJSONString(vvResourceEntityList)  );

    }

}
