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 @SpringBootApplication
public class ToolsApplication { 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) { public static void main(String[] args) {
System.out.println("当前版本号:" + version); System.out.println("当前版本号:" + version);

View File

@ -301,7 +301,20 @@ public class tools {
json.put("msg", "ok~"); json.put("msg", "ok~");
return json; 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) { public int getUid(HttpServletRequest request) {
String token = request.getParameter("token"); String token = request.getParameter("token");
if (StringUtils.isEmpty(token)) { if (StringUtils.isEmpty(token)) {

View File

@ -1,9 +1,12 @@
package com.yutou.tools.utils; package com.yutou.tools.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Timer; import java.util.Timer;
@ -14,9 +17,12 @@ import java.util.TimerTask;
*/ */
@Component @Component
public class ApplicationInit implements ApplicationRunner { public class ApplicationInit implements ApplicationRunner {
@Resource
private Environment environment;
@Override @Override
public void run(ApplicationArguments args) throws Exception { 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() { new Timer().schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {

View File

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

View File

@ -8,3 +8,5 @@ mybatis.type-aliases-package=com.yutou.tools.mybatis
#<23><>ӡmybatis<69><73>־ #<23><>ӡmybatis<69><73>־
#logging.level.com.yutou.tools=debug #logging.level.com.yutou.tools=debug
#server.servlet.session.timeout=10s #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