Spaces:
Sleeping
Sleeping
we
commited on
Commit
·
ac8bb87
1
Parent(s):
00d8ed3
test bw
Browse files- pom.xml +19 -19
- src/main/java/com/example/demo/DemoApplication.java +35 -1
- src/main/java/com/example/demo/Test.java +0 -1
- src/main/java/com/example/demo/entity/User.java +0 -44
- src/main/java/com/example/demo/repository/UserRepository.java +0 -9
- src/main/java/com/sqlite/config/DBConfig.java +1 -1
- src/main/java/com/sqlite/config/DBInitializeConfig.java +1 -1
- src/main/java/com/sqlite/config/SQLiteDialect.java +0 -155
- src/main/resources/application.properties +5 -5
pom.xml
CHANGED
@@ -45,25 +45,25 @@
|
|
45 |
<groupId>org.springframework.boot</groupId>
|
46 |
<artifactId>spring-boot-starter-web</artifactId>
|
47 |
</dependency>
|
48 |
-
<dependency
|
49 |
-
<groupId>org.springframework.boot</groupId
|
50 |
-
<artifactId>spring-boot-starter-data-jpa</artifactId
|
51 |
-
</dependency
|
52 |
-
<dependency
|
53 |
-
<groupId>org.postgresql</groupId
|
54 |
-
<artifactId>postgresql</artifactId
|
55 |
-
<scope>runtime</scope
|
56 |
-
</dependency
|
57 |
-
<dependency
|
58 |
-
<groupId>org.xerial</groupId
|
59 |
-
<artifactId>sqlite-jdbc</artifactId
|
60 |
-
<version>3.7.2</version
|
61 |
-
</dependency
|
62 |
-
<dependency
|
63 |
-
<groupId>com.h2database</groupId
|
64 |
-
<artifactId>h2</artifactId
|
65 |
-
<scope>compile</scope
|
66 |
-
</dependency
|
67 |
<dependency>
|
68 |
<groupId>org.springframework.boot</groupId>
|
69 |
<artifactId>spring-boot-starter-test</artifactId>
|
|
|
45 |
<groupId>org.springframework.boot</groupId>
|
46 |
<artifactId>spring-boot-starter-web</artifactId>
|
47 |
</dependency>
|
48 |
+
<!-- <dependency>-->
|
49 |
+
<!-- <groupId>org.springframework.boot</groupId>-->
|
50 |
+
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
|
51 |
+
<!-- </dependency>-->
|
52 |
+
<!-- <dependency>-->
|
53 |
+
<!-- <groupId>org.postgresql</groupId>-->
|
54 |
+
<!-- <artifactId>postgresql</artifactId>-->
|
55 |
+
<!-- <scope>runtime</scope>-->
|
56 |
+
<!-- </dependency>-->
|
57 |
+
<!-- <dependency>-->
|
58 |
+
<!-- <groupId>org.xerial</groupId>-->
|
59 |
+
<!-- <artifactId>sqlite-jdbc</artifactId>-->
|
60 |
+
<!-- <version>3.7.2</version>-->
|
61 |
+
<!-- </dependency>-->
|
62 |
+
<!-- <dependency>-->
|
63 |
+
<!-- <groupId>com.h2database</groupId>-->
|
64 |
+
<!-- <artifactId>h2</artifactId>-->
|
65 |
+
<!-- <scope>compile</scope>-->
|
66 |
+
<!-- </dependency>-->
|
67 |
<dependency>
|
68 |
<groupId>org.springframework.boot</groupId>
|
69 |
<artifactId>spring-boot-starter-test</artifactId>
|
src/main/java/com/example/demo/DemoApplication.java
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
package com.example.demo;
|
2 |
|
3 |
import com.example.demo.entity.User_test;
|
4 |
-
import com.example.demo.repository.UserRepository;
|
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
6 |
import org.springframework.boot.SpringApplication;
|
7 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
@@ -50,6 +49,8 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|
50 |
import org.apache.http.util.EntityUtils;
|
51 |
import tqtk.Utils.Doc_file_kieu_txt;
|
52 |
|
|
|
|
|
53 |
@SpringBootApplication
|
54 |
@RestController
|
55 |
public class DemoApplication {
|
@@ -64,6 +65,39 @@ public class DemoApplication {
|
|
64 |
context = SpringApplication.run(DemoApplication.class, args);
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
@GetMapping("start_spam")
|
68 |
public String startSpam() throws IOException {
|
69 |
LocalTime now = LocalTime.now();
|
|
|
1 |
package com.example.demo;
|
2 |
|
3 |
import com.example.demo.entity.User_test;
|
|
|
4 |
import org.springframework.beans.factory.annotation.Autowired;
|
5 |
import org.springframework.boot.SpringApplication;
|
6 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
49 |
import org.apache.http.util.EntityUtils;
|
50 |
import tqtk.Utils.Doc_file_kieu_txt;
|
51 |
|
52 |
+
import javax.servlet.http.HttpServletResponse;
|
53 |
+
|
54 |
@SpringBootApplication
|
55 |
@RestController
|
56 |
public class DemoApplication {
|
|
|
65 |
context = SpringApplication.run(DemoApplication.class, args);
|
66 |
}
|
67 |
|
68 |
+
public static int index = 0;
|
69 |
+
|
70 |
+
@GetMapping("getFile")
|
71 |
+
public void getFile(HttpServletResponse response) throws IOException {
|
72 |
+
|
73 |
+
List<String> lists = Doc_file_kieu_txt.readFile("urls.txt");
|
74 |
+
|
75 |
+
index = ++index % lists.size();
|
76 |
+
|
77 |
+
response.setHeader("Pragma", "no-cache");
|
78 |
+
response.setHeader("Cache-Control", "no-cache");
|
79 |
+
|
80 |
+
HttpClient httpClient = new DefaultHttpClient();
|
81 |
+
try {
|
82 |
+
HttpPost get = new HttpPost(lists.get(index));
|
83 |
+
|
84 |
+
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36");
|
85 |
+
|
86 |
+
get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
|
87 |
+
get.setHeader("Sec-Fetch-Dest", "empty");
|
88 |
+
get.setHeader("Sec-Fetch-Mode", "cors");
|
89 |
+
get.setHeader("Sec-Fetch-Site", "same-origin");
|
90 |
+
get.setHeader("X-Same-Domain", "1");
|
91 |
+
|
92 |
+
CloseableHttpResponse Cresponse = (CloseableHttpResponse) httpClient.execute(get);
|
93 |
+
int s = Cresponse.getStatusLine().getStatusCode();
|
94 |
+
Cresponse.getEntity().getContent().transferTo(response.getOutputStream());
|
95 |
+
} catch (IOException ex) {
|
96 |
+
ex.getMessage();
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
@GetMapping("start_spam")
|
102 |
public String startSpam() throws IOException {
|
103 |
LocalTime now = LocalTime.now();
|
src/main/java/com/example/demo/Test.java
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
package com.example.demo;
|
2 |
|
3 |
import com.example.demo.entity.User_test;
|
4 |
-
import com.example.demo.repository.UserRepository;
|
5 |
import com.fasterxml.jackson.databind.DeserializationFeature;
|
6 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
7 |
import java.io.BufferedInputStream;
|
|
|
1 |
package com.example.demo;
|
2 |
|
3 |
import com.example.demo.entity.User_test;
|
|
|
4 |
import com.fasterxml.jackson.databind.DeserializationFeature;
|
5 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
6 |
import java.io.BufferedInputStream;
|
src/main/java/com/example/demo/entity/User.java
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
package com.example.demo.entity;
|
2 |
-
|
3 |
-
import javax.persistence.*;
|
4 |
-
import java.io.Serializable;
|
5 |
-
|
6 |
-
@Entity
|
7 |
-
@Table(name = "users")
|
8 |
-
public class User implements Serializable {
|
9 |
-
|
10 |
-
@Id
|
11 |
-
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "sequence_name_user", allocationSize = 1, initialValue = 1)
|
12 |
-
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
|
13 |
-
private Long id;
|
14 |
-
|
15 |
-
@Column(name = "first_name", length = 50)
|
16 |
-
private String firstName;
|
17 |
-
|
18 |
-
@Column(name = "last_name", length = 50)
|
19 |
-
private String lastName;
|
20 |
-
|
21 |
-
public Long getId() {
|
22 |
-
return id;
|
23 |
-
}
|
24 |
-
|
25 |
-
public void setId(Long id) {
|
26 |
-
this.id = id;
|
27 |
-
}
|
28 |
-
|
29 |
-
public String getFirstName() {
|
30 |
-
return firstName;
|
31 |
-
}
|
32 |
-
|
33 |
-
public void setFirstName(String firstName) {
|
34 |
-
this.firstName = firstName;
|
35 |
-
}
|
36 |
-
|
37 |
-
public String getLastName() {
|
38 |
-
return lastName;
|
39 |
-
}
|
40 |
-
|
41 |
-
public void setLastName(String lastName) {
|
42 |
-
this.lastName = lastName;
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/main/java/com/example/demo/repository/UserRepository.java
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
package com.example.demo.repository;
|
2 |
-
|
3 |
-
import com.example.demo.entity.User;
|
4 |
-
import org.springframework.data.jpa.repository.JpaRepository;
|
5 |
-
import org.springframework.stereotype.Repository;
|
6 |
-
|
7 |
-
@Repository
|
8 |
-
public interface UserRepository extends JpaRepository<User, Long> {
|
9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/main/java/com/sqlite/config/DBConfig.java
CHANGED
@@ -6,7 +6,7 @@ import org.springframework.boot.jdbc.DataSourceBuilder;
|
|
6 |
import org.springframework.context.annotation.Bean;
|
7 |
import org.springframework.context.annotation.Configuration;
|
8 |
|
9 |
-
|
10 |
public class DBConfig {
|
11 |
@Bean
|
12 |
public DataSource dataSource() {
|
|
|
6 |
import org.springframework.context.annotation.Bean;
|
7 |
import org.springframework.context.annotation.Configuration;
|
8 |
|
9 |
+
//@Configuration
|
10 |
public class DBConfig {
|
11 |
@Bean
|
12 |
public DataSource dataSource() {
|
src/main/java/com/sqlite/config/DBInitializeConfig.java
CHANGED
@@ -10,7 +10,7 @@ import javax.sql.DataSource;
|
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.context.annotation.Configuration;
|
12 |
|
13 |
-
|
14 |
public class DBInitializeConfig {
|
15 |
|
16 |
@Autowired
|
|
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.context.annotation.Configuration;
|
12 |
|
13 |
+
//@Configuration
|
14 |
public class DBInitializeConfig {
|
15 |
|
16 |
@Autowired
|
src/main/java/com/sqlite/config/SQLiteDialect.java
DELETED
@@ -1,155 +0,0 @@
|
|
1 |
-
package com.sqlite.config;
|
2 |
-
|
3 |
-
import java.sql.Types;
|
4 |
-
|
5 |
-
import org.hibernate.dialect.Dialect;
|
6 |
-
import org.hibernate.dialect.function.SQLFunctionTemplate;
|
7 |
-
import org.hibernate.dialect.function.StandardSQLFunction;
|
8 |
-
import org.hibernate.dialect.function.VarArgsSQLFunction;
|
9 |
-
import org.hibernate.type.StringType;
|
10 |
-
|
11 |
-
public class SQLiteDialect extends Dialect {
|
12 |
-
public SQLiteDialect() {
|
13 |
-
registerColumnType(Types.BIT, "integer");
|
14 |
-
registerColumnType(Types.TINYINT, "tinyint");
|
15 |
-
registerColumnType(Types.SMALLINT, "smallint");
|
16 |
-
registerColumnType(Types.INTEGER, "integer");
|
17 |
-
registerColumnType(Types.BIGINT, "bigint");
|
18 |
-
registerColumnType(Types.FLOAT, "float");
|
19 |
-
registerColumnType(Types.REAL, "real");
|
20 |
-
registerColumnType(Types.DOUBLE, "double");
|
21 |
-
registerColumnType(Types.NUMERIC, "numeric");
|
22 |
-
registerColumnType(Types.DECIMAL, "decimal");
|
23 |
-
registerColumnType(Types.CHAR, "char");
|
24 |
-
registerColumnType(Types.VARCHAR, "varchar");
|
25 |
-
registerColumnType(Types.LONGVARCHAR, "longvarchar");
|
26 |
-
registerColumnType(Types.DATE, "date");
|
27 |
-
registerColumnType(Types.TIME, "time");
|
28 |
-
registerColumnType(Types.TIMESTAMP, "timestamp");
|
29 |
-
registerColumnType(Types.BINARY, "blob");
|
30 |
-
registerColumnType(Types.VARBINARY, "blob");
|
31 |
-
registerColumnType(Types.LONGVARBINARY, "blob");
|
32 |
-
// registerColumnType(Types.NULL, "null");
|
33 |
-
registerColumnType(Types.BLOB, "blob");
|
34 |
-
registerColumnType(Types.CLOB, "clob");
|
35 |
-
registerColumnType(Types.BOOLEAN, "integer");
|
36 |
-
|
37 |
-
registerFunction( "concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", "") );
|
38 |
-
registerFunction( "mod", new SQLFunctionTemplate( StringType.INSTANCE, "?1 % ?2" ) );
|
39 |
-
registerFunction( "substr", new StandardSQLFunction("substr", StringType.INSTANCE) );
|
40 |
-
registerFunction( "substring", new StandardSQLFunction( "substr", StringType.INSTANCE) );
|
41 |
-
}
|
42 |
-
|
43 |
-
public boolean supportsIdentityColumns() {
|
44 |
-
return true;
|
45 |
-
}
|
46 |
-
|
47 |
-
/*
|
48 |
-
public boolean supportsInsertSelectIdentity() {
|
49 |
-
return true; // As specify in NHibernate dialect
|
50 |
-
}
|
51 |
-
*/
|
52 |
-
|
53 |
-
public boolean hasDataTypeInIdentityColumn() {
|
54 |
-
return false; // As specify in NHibernate dialect
|
55 |
-
}
|
56 |
-
|
57 |
-
/*
|
58 |
-
public String appendIdentitySelectToInsert(String insertString) {
|
59 |
-
return new StringBuffer(insertString.length()+30). // As specify in NHibernate dialect
|
60 |
-
append(insertString).
|
61 |
-
append("; ").append(getIdentitySelectString()).
|
62 |
-
toString();
|
63 |
-
}
|
64 |
-
*/
|
65 |
-
|
66 |
-
public String getIdentityColumnString() {
|
67 |
-
// return "integer primary key autoincrement";
|
68 |
-
return "integer";
|
69 |
-
}
|
70 |
-
|
71 |
-
public String getIdentitySelectString() {
|
72 |
-
return "select last_insert_rowid()";
|
73 |
-
}
|
74 |
-
|
75 |
-
public boolean supportsLimit() {
|
76 |
-
return true;
|
77 |
-
}
|
78 |
-
|
79 |
-
protected String getLimitString(String query, boolean hasOffset) {
|
80 |
-
return new StringBuffer(query.length()+20).
|
81 |
-
append(query).
|
82 |
-
append(hasOffset ? " limit ? offset ?" : " limit ?").
|
83 |
-
toString();
|
84 |
-
}
|
85 |
-
|
86 |
-
public boolean supportsTemporaryTables() {
|
87 |
-
return true;
|
88 |
-
}
|
89 |
-
|
90 |
-
public String getCreateTemporaryTableString() {
|
91 |
-
return "create temporary table if not exists";
|
92 |
-
}
|
93 |
-
|
94 |
-
public boolean dropTemporaryTableAfterUse() {
|
95 |
-
return false;
|
96 |
-
}
|
97 |
-
|
98 |
-
public boolean supportsCurrentTimestampSelection() {
|
99 |
-
return true;
|
100 |
-
}
|
101 |
-
|
102 |
-
public boolean isCurrentTimestampSelectStringCallable() {
|
103 |
-
return false;
|
104 |
-
}
|
105 |
-
|
106 |
-
public String getCurrentTimestampSelectString() {
|
107 |
-
return "select current_timestamp";
|
108 |
-
}
|
109 |
-
|
110 |
-
public boolean supportsUnionAll() {
|
111 |
-
return true;
|
112 |
-
}
|
113 |
-
|
114 |
-
public boolean hasAlterTable() {
|
115 |
-
return false; // As specify in NHibernate dialect
|
116 |
-
}
|
117 |
-
|
118 |
-
public boolean dropConstraints() {
|
119 |
-
return false;
|
120 |
-
}
|
121 |
-
|
122 |
-
public String getAddColumnString() {
|
123 |
-
return "add column";
|
124 |
-
}
|
125 |
-
|
126 |
-
public String getForUpdateString() {
|
127 |
-
return "";
|
128 |
-
}
|
129 |
-
|
130 |
-
public boolean supportsOuterJoinForUpdate() {
|
131 |
-
return false;
|
132 |
-
}
|
133 |
-
|
134 |
-
public String getDropForeignKeyString() {
|
135 |
-
throw new UnsupportedOperationException("No drop foreign key syntax supported by SQLiteDialect");
|
136 |
-
}
|
137 |
-
|
138 |
-
public String getAddForeignKeyConstraintString(String constraintName,
|
139 |
-
String[] foreignKey, String referencedTable, String[] primaryKey,
|
140 |
-
boolean referencesPrimaryKey) {
|
141 |
-
throw new UnsupportedOperationException("No add foreign key syntax supported by SQLiteDialect");
|
142 |
-
}
|
143 |
-
|
144 |
-
public String getAddPrimaryKeyConstraintString(String constraintName) {
|
145 |
-
throw new UnsupportedOperationException("No add primary key syntax supported by SQLiteDialect");
|
146 |
-
}
|
147 |
-
|
148 |
-
public boolean supportsIfExistsBeforeTableName() {
|
149 |
-
return true;
|
150 |
-
}
|
151 |
-
|
152 |
-
public boolean supportsCascadeDelete() {
|
153 |
-
return false;
|
154 |
-
}
|
155 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/main/resources/application.properties
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
server.tomcat.accesslog.enabled=true
|
2 |
|
3 |
-
spring.profiles.active=dev
|
4 |
-
spring.jpa.database-platform=com.sqlite.config.SQLiteDialect
|
5 |
#spring.jpa.hibernate.ddl-auto=create-drop
|
6 |
-
spring.jpa.hibernate.ddl-auto=create
|
7 |
-
spring.jpa.show-sql=true
|
8 |
-
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
|
9 |
server.port=7860
|
|
|
1 |
server.tomcat.accesslog.enabled=true
|
2 |
|
3 |
+
#spring.profiles.active=dev
|
4 |
+
#spring.jpa.database-platform=com.sqlite.config.SQLiteDialect
|
5 |
#spring.jpa.hibernate.ddl-auto=create-drop
|
6 |
+
#spring.jpa.hibernate.ddl-auto=create
|
7 |
+
#spring.jpa.show-sql=true
|
8 |
+
#spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
|
9 |
server.port=7860
|