This commit is contained in:
yutou 2023-12-27 10:43:20 +08:00
parent 6c4fbc47ab
commit 2183444676
12 changed files with 446 additions and 568 deletions

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ToolsApplication {
public static final String version="1.4.7";
public static final String version="1.4.9";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);

View File

@ -301,7 +301,20 @@ public class tools {
json.put("msg", "ok~");
return json;
}
@ResponseBody
@RequestMapping("/public/tools/setu.do")
public ResponseEntity<FileSystemResource> getSetu(String model){
String url="https://api.lolicon.app/setu/v2?r18=0&size=regular";
String body=HttpTools.get(url);
JSONObject json=JSONObject.parseObject(body);
if (json.getJSONArray("data").isEmpty()) {
return Tools.getFile(new File("def_setu.png"));
}
JSONObject item = json.getJSONArray("data").getJSONObject(0);
File file = HttpTools.syncDownload(item.getJSONObject("urls").getString("regular"),
System.currentTimeMillis() + "_setu.jpg");
return Tools.getFile(file);
}
public int getUid(HttpServletRequest request) {
String token = request.getParameter("token");
if (StringUtils.isEmpty(token)) {

View File

@ -1,9 +1,12 @@
package com.yutou.tools.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
@ -14,9 +17,12 @@ import java.util.TimerTask;
*/
@Component
public class ApplicationInit implements ApplicationRunner {
@Resource
private Environment environment;
@Override
public void run(ApplicationArguments args) throws Exception {
RedisTools.initConfig(environment.getProperty("redis.port",Integer.class,6379),
environment.getProperty("redis.auth"));
new Timer().schedule(new TimerTask() {
@Override
public void run() {

View File

@ -9,6 +9,8 @@ import java.util.Properties;
import java.util.Set;
import com.alibaba.fastjson2.JSONObject;
import org.apache.ibatis.mapping.Environment;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
@ -19,6 +21,7 @@ public class RedisTools {
private static boolean isNotInstallRedis = false;
private static String host;
private static int port;
private static String auth;
public static int TOKEN_TIMEOUT_DEFAULT = 360;
private RedisTools() {
@ -26,12 +29,11 @@ public class RedisTools {
}
// 写成静态代码块形式只加载一次节省资源
static {
//Properties properties = PropertyUtil.loadProperties("jedis.properties");
//host = properties.getProperty("redis.host");
//port = Integer.valueOf(properties.getProperty("redis.port"));
public static void initConfig(int port, String auth) {
host = "127.0.0.1";
port = 6379;
RedisTools.port = port;
RedisTools.auth = auth;
}
@ -135,6 +137,7 @@ public class RedisTools {
jedis.close();
return flag;
}
public static boolean exists(String key) {
if (isNotInstallRedis) {
return false;
@ -146,7 +149,9 @@ public class RedisTools {
}
public static Jedis getRedis() {
return new Jedis(host, port);
Jedis jedis = new Jedis(host, port);
jedis.auth(auth);
return jedis;
}
public static boolean remove(String key, int index) {
@ -195,6 +200,7 @@ public class RedisTools {
return flag;
}
private static class PropertyUtil {
// 加载property文件到io流里面

View File

@ -8,3 +8,5 @@ mybatis.type-aliases-package=com.yutou.tools.mybatis
#<23><>ӡmybatis<69><73>־
#logging.level.com.yutou.tools=debug
#server.servlet.session.timeout=10s
redis.auth=ADVbdzPbF1jwThtb
redis.port=21120

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long