常用工具类

Time: 2025-04-11 Friday 16:00:00

常用工具类

Hutool的JSONUtil可以转换JSON字符串

1
JSONUtil.toJsonStr()

Arrays.asList可以将数组转换为集合

1
2
3
List<String> tagList = Arrays.asList("热门", "搞笑", "生活", "高清", "艺术", "校园", "背景", "简历", "创意");

List<String> categoryList = Arrays.asList("模板", "电商", "表情包", "素材", "海报");

Hutool的IdUtil生成随机ID

1
IdUtil.getSnowflakeNextId()

下载url文件

1
HttpUtil.downloadFile

创建文件

1
tempFile = File.createTempFile("temp", null);

获取图片接口地址

1
https://cn.bing.com/images/async?q=%E9%A3%8E%E6%99%AF&mmasync=1

curl调试接口速度

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
curl 'http://127.0.0.1:5173/cloud-picture/picture/list/page/vo' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-b 'SESSION=ZWM5ZDRmYzktZjE3ZC00NTI5LWI1ZTEtZGI3MDBjNDg5ZTI0' \
-H 'Origin: http://127.0.0.1:5173' \
-H 'Pragma: no-cache' \
-H 'Referer: http://127.0.0.1:5173/home' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"pageNumber":1,"pageSize":12,"sortField":"createTime","sortOrder":"desc","searchText":"","category":"","tags":[]}' \
-o /dev/null -s -w "\n总耗时: %{time_total}秒\n连接耗时: %{time_connect}秒\n服务器处理耗时: %{time_starttransfer}秒\n数据传输耗时: %{time_total}-%{time_starttransfer}秒\n"

常用工具类
http://example.com/2025/04/28/常用工具类/
作者
Jack Asher
发布于
2025年4月28日
许可协议