Created
March 7, 2019 07:13
-
-
Save Tapac/9621fe2de893dd61edf5e0d2988bb2df to your computer and use it in GitHub Desktop.
Patch file for https://github.com/tibbytang/blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/main/resources/application.conf | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/main/resources/application.conf (revision 0fa7ca32ce85a7888ff6df03cb01ae080bc4b74e) | |
+++ src/main/resources/application.conf (date 1551942564345) | |
@@ -1,7 +1,7 @@ | |
ktor { | |
deployment { | |
port = 8080 | |
- watch = [tibbytang] | |
+ watch = [me.tibbytang] | |
} | |
application { | |
modules = [ me.tibbytang.ApplicationKt.module ] | |
Index: src/main/kotlin/me/tibbytang/blog/entity/Blog.kt | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/main/kotlin/me/tibbytang/blog/entity/Blog.kt (revision 0fa7ca32ce85a7888ff6df03cb01ae080bc4b74e) | |
+++ src/main/kotlin/me/tibbytang/blog/entity/Blog.kt (date 1551942668501) | |
@@ -12,5 +12,5 @@ | |
val content: String, | |
val date: DateTime, | |
val title: String, | |
- val account: String | |
+ val account: String? | |
) | |
\ No newline at end of file | |
Index: src/main/kotlin/me/tibbytang/blog/db/DBFactoryUtils.kt | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/main/kotlin/me/tibbytang/blog/db/DBFactoryUtils.kt (revision 0fa7ca32ce85a7888ff6df03cb01ae080bc4b74e) | |
+++ src/main/kotlin/me/tibbytang/blog/db/DBFactoryUtils.kt (date 1551942668483) | |
@@ -13,12 +13,15 @@ | |
* Wechat:ITnan562980080 | |
*/ | |
object DBFactoryUtils { | |
- | |
- fun initDb() { | |
+ fun connect() { | |
Database.connect( | |
"jdbc:mysql://localhost:3306/tb_blog", | |
driver = "com.mysql.cj.jdbc.Driver") | |
+ } | |
+ fun initDb() { | |
+ connect() | |
transaction { | |
+ SchemaUtils.drop(Users, Blogs) | |
SchemaUtils.create(Users, Blogs) | |
} | |
} | |
Index: src/test/kotlin/ApplicationTest.kt | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/test/kotlin/ApplicationTest.kt (revision 0fa7ca32ce85a7888ff6df03cb01ae080bc4b74e) | |
+++ src/test/kotlin/ApplicationTest.kt (date 1551942668514) | |
@@ -1,8 +1,8 @@ | |
package test.kotlin | |
import kotlin.test.* | |
-import io.ktor.server.testing.* | |
import me.tibbytang.db.Blogs | |
+import me.tibbytang.db.DBFactoryUtils | |
import me.tibbytang.db.Users | |
import org.jetbrains.exposed.sql.* | |
import org.jetbrains.exposed.sql.transactions.transaction | |
@@ -12,14 +12,8 @@ | |
class ApplicationTest { | |
@Test | |
fun testUser() { | |
- Database.connect( | |
- "jdbc:mysql://localhost:3306/tb_blog", | |
- driver = "com.mysql.cj.jdbc.Driver", | |
- user = "root", | |
- password = "[]<>777857ghGH<>" | |
- ) | |
+ DBFactoryUtils.initDb() | |
transaction { | |
- SchemaUtils.create(Users) | |
val list = | |
Users.select({ Users.account eq "56298008088@qq.com" and Users.password.eq("777857gh") }).toList() | |
if (list != null) { | |
@@ -32,14 +26,8 @@ | |
@Test | |
fun testBlogInsert() { | |
- Database.connect( | |
- "jdbc:mysql://localhost:3306/tb_blog", | |
- driver = "com.mysql.cj.jdbc.Driver", | |
- user = "root", | |
- password = "[]<>777857ghGH<>" | |
- ) | |
+ DBFactoryUtils.initDb() | |
transaction { | |
- SchemaUtils.create(Blogs) | |
val id = Blogs.insert { | |
it[title] = "RecyclerView 的使用" | |
it[content] = | |
@@ -56,17 +44,4 @@ | |
val date = DateTime.now(DateTimeZone.UTC) | |
println(date) | |
} | |
- | |
- @Test | |
- fun testDropBlogs() { | |
- Database.connect( | |
- "jdbc:mysql://localhost:3306/tb_blog", | |
- driver = "com.mysql.cj.jdbc.Driver", | |
- user = "root", | |
- password = "[]<>777857ghGH<>" | |
- ) | |
- transaction { | |
- SchemaUtils.drop(Blogs) | |
- } | |
- } | |
} | |
Index: src/main/kotlin/me/tibbytang/blog/db/Blogs.kt | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/main/kotlin/me/tibbytang/blog/db/Blogs.kt (revision 0fa7ca32ce85a7888ff6df03cb01ae080bc4b74e) | |
+++ src/main/kotlin/me/tibbytang/blog/db/Blogs.kt (date 1551942668526) | |
@@ -1,7 +1,5 @@ | |
package me.tibbytang.db | |
-import me.tibbytang.db.Users.primaryKey | |
-import org.jetbrains.exposed.sql.Column | |
import org.jetbrains.exposed.sql.Table | |
/** | |
@@ -14,5 +12,5 @@ | |
val content = text("content") | |
val date = datetime("date") | |
val title = varchar("title", 255) | |
- val account = varchar("account", length = 50) | |
+ val account = varchar("account", length = 50).nullable() | |
} | |
\ No newline at end of file | |
Index: src/main/kotlin/me/tibbytang/blog/Application.kt | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/main/kotlin/me/tibbytang/blog/Application.kt (revision 0fa7ca32ce85a7888ff6df03cb01ae080bc4b74e) | |
+++ src/main/kotlin/me/tibbytang/blog/Application.kt (date 1551942668461) | |
@@ -7,7 +7,7 @@ | |
import io.ktor.http.* | |
import freemarker.cache.* | |
import io.ktor.freemarker.* | |
-import io.ktor.http.content.resources | |
+import io.ktor.http.content.files | |
import io.ktor.http.content.static | |
import me.tibbytang.db.DBFactoryUtils | |
@@ -18,7 +18,7 @@ | |
fun Application.module(testing: Boolean = false) { | |
DBFactoryUtils.initDb() | |
install(FreeMarker) { | |
- templateLoader = ClassTemplateLoader(this::class.java.classLoader, "main/resources/templates") | |
+ templateLoader = ClassTemplateLoader(this::class.java.classLoader, "templates") | |
} | |
intercept(ApplicationCallPipeline.Call) { | |
val uri = call.request.uri | |
@@ -92,8 +92,8 @@ | |
) | |
} | |
} | |
- static("main/resources/static") { | |
- resources("main/resources/static") | |
+ static("static") { | |
+ files("static") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment