修复SQLITE创建表失败问题
This commit is contained in:
parent
2bdda9250c
commit
18cb4236eb
4
pom.xml
4
pom.xml
@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.yutou</groupId>
|
<groupId>com.yutou</groupId>
|
||||||
<artifactId>tools</artifactId>
|
<artifactId>tools</artifactId>
|
||||||
<version>1.0.10.1</version>
|
<version>1.0.10.3</version>
|
||||||
<name>tools</name>
|
<name>tools</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
@ -109,7 +109,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.mamoe</groupId>
|
<groupId>net.mamoe</groupId>
|
||||||
<artifactId>mirai-core-qqandroid</artifactId>
|
<artifactId>mirai-core-qqandroid</artifactId>
|
||||||
<version>1.3.2</version> <!-- 替换版本为最新版本 -->
|
<version>1.3.1</version> <!-- 替换版本为最新版本 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.yutou.tools;
|
package com.yutou.tools;
|
||||||
|
|
||||||
import com.yutou.tools.home.nas.MusicController;
|
import com.yutou.tools.home.nas.MusicController;
|
||||||
import com.yutou.tools.utils.APIFilter;
|
import com.yutou.tools.utils.*;
|
||||||
import com.yutou.tools.utils.MusicTools;
|
|
||||||
import com.yutou.tools.utils.QQBotManager;
|
|
||||||
import com.yutou.tools.utils.RedisTools;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
@ -15,10 +12,10 @@ import java.io.IOException;
|
|||||||
public class ToolsApplication {
|
public class ToolsApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("当前版本号:1.0.10.1");
|
System.out.println("当前版本号:1.0.10.3");
|
||||||
SpringApplication.run(ToolsApplication.class, args);
|
SpringApplication.run(ToolsApplication.class, args);
|
||||||
RedisTools.initRedisPoolSub();
|
RedisTools.initRedisPoolSub();
|
||||||
if (APIFilter.isDebug) {
|
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) {
|
||||||
MusicController.defaultMusicPath = "C:\\Users\\admin\\Music\\";
|
MusicController.defaultMusicPath = "C:\\Users\\admin\\Music\\";
|
||||||
MusicTools.getInstance().setMusicPath("C:\\Users\\admin\\Music\\");
|
MusicTools.getInstance().setMusicPath("C:\\Users\\admin\\Music\\");
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.yutou.tools.home.nas.Data.MusicData;
|
import com.yutou.tools.home.nas.Data.MusicData;
|
||||||
import com.yutou.tools.nas.UpdateIp;
|
import com.yutou.tools.nas.UpdateIp;
|
||||||
import com.yutou.tools.utils.APIFilter;
|
import com.yutou.tools.utils.APIFilter;
|
||||||
|
import com.yutou.tools.utils.ConfigTools;
|
||||||
import com.yutou.tools.utils.MusicTools;
|
import com.yutou.tools.utils.MusicTools;
|
||||||
import com.yutou.tools.utils.Tools;
|
import com.yutou.tools.utils.Tools;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
@ -88,7 +89,7 @@ public class MusicController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getLocalHost(){
|
public String getLocalHost(){
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json=new JSONObject();
|
||||||
if(APIFilter.isDebug){
|
if(ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")){
|
||||||
json.put("data","");
|
json.put("data","");
|
||||||
}else{
|
}else{
|
||||||
json.put("data", "http://"+UpdateIp.nas_ip);
|
json.put("data", "http://"+UpdateIp.nas_ip);
|
||||||
|
@ -34,7 +34,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
String sql = "insert into `app_ad` (`appId`,`adSrc`,`adAppId`,`adAppKey`,`adOpenKey`,`adInterKey`,`adBannerKey`,`adVideoKey`,`adNativeKey`,`show`) values " +
|
String sql = "insert into `app_ad` (`appId`,`adSrc`,`adAppId`,`adAppKey`,`adOpenKey`,`adInterKey`,`adBannerKey`,`adVideoKey`,`adNativeKey`,`show`) values " +
|
||||||
"('" + appId + "','" + adSrc + "','" + adAppId + "','" + adAppKey + "','" + adOpenKey + "','" + adInterKey + "','" + adBannerKey + "','" + adVideoKey + "','" + adNativeKey + "',1);";
|
"('" + appId + "','" + adSrc + "','" + adAppId + "','" + adAppKey + "','" + adOpenKey + "','" + adInterKey + "','" + adBannerKey + "','" + adVideoKey + "','" + adNativeKey + "',1);";
|
||||||
boolean flag = statement.execute(sql);
|
boolean flag = statement.execute(sql);
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return flag;
|
return flag;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -48,7 +48,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
String sql = "insert into `ad_log` (`appId`,`adSrc`,`adType`,`model`,`subtime`) values ('" + appId + "','" + src + "','" + type
|
String sql = "insert into `ad_log` (`appId`,`adSrc`,`adType`,`model`,`subtime`) values ('" + appId + "','" + src + "','" + type
|
||||||
+ "','" + model + "','" + System.currentTimeMillis() + "'); ";
|
+ "','" + model + "','" + System.currentTimeMillis() + "'); ";
|
||||||
boolean flag = statement.execute(sql);
|
boolean flag = statement.execute(sql);
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return flag;
|
return flag;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -65,7 +65,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
String appId = UUID.randomUUID().toString();
|
String appId = UUID.randomUUID().toString();
|
||||||
String sql = "insert into `app`(`appName`,`packageName`,`appId`) values ('" + appName + "','" + packageName + "','" + appId + "')";
|
String sql = "insert into `app`(`appName`,`packageName`,`appId`) values ('" + appName + "','" + packageName + "','" + appId + "')";
|
||||||
statement.execute(sql);
|
statement.execute(sql);
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return appId;
|
return appId;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -123,7 +123,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
array.add(item);
|
array.add(item);
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return array;
|
return array;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -157,7 +157,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
Statement statement=conn.createStatement();
|
Statement statement=conn.createStatement();
|
||||||
String sql="select * from `app` where `appName`='"+appName+"';";
|
String sql="select * from `app` where `appName`='"+appName+"';";
|
||||||
json=getApp(statement, sql);
|
json=getApp(statement, sql);
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return json;
|
return json;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -170,7 +170,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
Statement statement=conn.createStatement();
|
Statement statement=conn.createStatement();
|
||||||
String sql="select * from `app` where `packageName`='"+packageName+"';";
|
String sql="select * from `app` where `packageName`='"+packageName+"';";
|
||||||
json=getApp(statement, sql);
|
json=getApp(statement, sql);
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return json;
|
return json;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -208,7 +208,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
|||||||
json.put("packageName",set.getString("packageName"));
|
json.put("packageName",set.getString("packageName"));
|
||||||
}
|
}
|
||||||
set.close();
|
set.close();
|
||||||
statement.close();
|
statement.closeOnCompletion();
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,18 +44,25 @@ public class SQLiteManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
private void createSql(JSONObject json){
|
private void createSql(JSONObject json){
|
||||||
|
try {
|
||||||
|
sql.mkdirs();
|
||||||
|
sql.delete();
|
||||||
|
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
startBatch();
|
||||||
JSONArray array=json.getJSONArray("table");
|
JSONArray array=json.getJSONArray("table");
|
||||||
for (Object o : array) {
|
for (Object o : array) {
|
||||||
|
System.out.println("创建表:"+((JSONObject)o).getString("name"));
|
||||||
createSqlOfTable((JSONObject) o);
|
createSqlOfTable((JSONObject) o);
|
||||||
}
|
}
|
||||||
|
closeBatch();
|
||||||
ConfigTools.save(ConfigTools.SQLITE, json.getString("file"), json);
|
ConfigTools.save(ConfigTools.SQLITE, json.getString("file"), json);
|
||||||
}
|
}
|
||||||
private void createSqlOfTable(JSONObject table) {
|
private void createSqlOfTable(JSONObject table) {
|
||||||
String tableName = table.getString("name");
|
String tableName = table.getString("name");
|
||||||
try {
|
try {
|
||||||
sql.mkdirs();
|
|
||||||
sql.delete();
|
|
||||||
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
|
||||||
Statement statement = conn.createStatement();
|
Statement statement = conn.createStatement();
|
||||||
JSONArray items = table.getJSONArray("item");
|
JSONArray items = table.getJSONArray("item");
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
@ -88,7 +95,7 @@ public class SQLiteManager {
|
|||||||
}
|
}
|
||||||
sql.append(");");
|
sql.append(");");
|
||||||
statement.execute(sql.toString().replace(",);", ");"));
|
statement.execute(sql.toString().replace(",);", ");"));
|
||||||
|
statement.closeOnCompletion();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class APIFilter implements Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||||
if(isDebug){
|
if(ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")){
|
||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user