Commit ef29e61f238f47d0b017e7ad3af1ff0c0aa3e11b
1 parent
42f883a1
Exists in
yxb_dev
and in
2 other branches
no message
Showing
7 changed files
with
28 additions
and
15 deletions
Show diff stats
app/build.gradle
@@ -65,6 +65,5 @@ dependencies { | @@ -65,6 +65,5 @@ dependencies { | ||
65 | // add library | 65 | // add library |
66 | compile 'me.leolin:ShortcutBadger:1.1.19@aar' | 66 | compile 'me.leolin:ShortcutBadger:1.1.19@aar' |
67 | annotationProcessor 'com.google.dagger:dagger-compiler:2.12' | 67 | annotationProcessor 'com.google.dagger:dagger-compiler:2.12' |
68 | - //implementation project(':processor') | ||
69 | compile files('libs/processor.jar') | 68 | compile files('libs/processor.jar') |
70 | } | 69 | } |
app/libs/processor.jar
No preview for this file type
app/src/main/assets/migrations/1.sql
app/src/main/java/com/shunzhi/parent/bean/message/PHMessage.java
@@ -3,16 +3,13 @@ package com.shunzhi.parent.bean.message; | @@ -3,16 +3,13 @@ package com.shunzhi.parent.bean.message; | ||
3 | import com.shunzhi.parent.AppContext; | 3 | import com.shunzhi.parent.AppContext; |
4 | 4 | ||
5 | import org.greenrobot.greendao.annotation.Entity; | 5 | import org.greenrobot.greendao.annotation.Entity; |
6 | +import org.greenrobot.greendao.annotation.Generated; | ||
6 | import org.greenrobot.greendao.annotation.Id; | 7 | import org.greenrobot.greendao.annotation.Id; |
7 | import org.greenrobot.greendao.annotation.Keep; | 8 | import org.greenrobot.greendao.annotation.Keep; |
8 | import org.greenrobot.greendao.annotation.NotNull; | 9 | import org.greenrobot.greendao.annotation.NotNull; |
9 | 10 | ||
10 | import java.util.Collection; | 11 | import java.util.Collection; |
11 | -import java.util.Collections; | ||
12 | import java.util.Date; | 12 | import java.util.Date; |
13 | -import java.util.List; | ||
14 | - | ||
15 | -import org.greenrobot.greendao.annotation.Generated; | ||
16 | 13 | ||
17 | /** | 14 | /** |
18 | * 内部变量可能存在值为null,使用时要注意 | 15 | * 内部变量可能存在值为null,使用时要注意 |
@@ -37,8 +34,8 @@ public class PHMessage { | @@ -37,8 +34,8 @@ public class PHMessage { | ||
37 | 34 | ||
38 | @Generated(hash = 1935192071) | 35 | @Generated(hash = 1935192071) |
39 | public PHMessage(Long id, Date date, String messageId, String sessionId, | 36 | public PHMessage(Long id, Date date, String messageId, String sessionId, |
40 | - @NotNull String messageText, String exValue, String filePath, String fileUrl, | ||
41 | - String messageType, Integer sendState, Integer sessionType) { | 37 | + @NotNull String messageText, String exValue, String filePath, String fileUrl, |
38 | + String messageType, Integer sendState, Integer sessionType) { | ||
42 | this.id = id; | 39 | this.id = id; |
43 | this.date = date; | 40 | this.date = date; |
44 | this.messageId = messageId; | 41 | this.messageId = messageId; |
processor/src/main/java/org/shunzhi/processorlibs/AddColumn.java
@@ -15,7 +15,7 @@ public @interface AddColumn { | @@ -15,7 +15,7 @@ public @interface AddColumn { | ||
15 | 15 | ||
16 | String type(); | 16 | String type(); |
17 | 17 | ||
18 | - boolean isDebug() default true; | 18 | + boolean isDebug() default false; |
19 | 19 | ||
20 | String type_string = "string"; | 20 | String type_string = "string"; |
21 | String type_boolean = "boolean"; | 21 | String type_boolean = "boolean"; |
processor/src/main/java/org/shunzhi/processorlibs/VersionProcessor.java
1 | package org.shunzhi.processorlibs; | 1 | package org.shunzhi.processorlibs; |
2 | 2 | ||
3 | +import java.io.BufferedReader; | ||
3 | import java.io.BufferedWriter; | 4 | import java.io.BufferedWriter; |
4 | import java.io.File; | 5 | import java.io.File; |
6 | +import java.io.FileReader; | ||
5 | import java.io.FileWriter; | 7 | import java.io.FileWriter; |
6 | import java.io.IOException; | 8 | import java.io.IOException; |
7 | import java.io.OutputStreamWriter; | 9 | import java.io.OutputStreamWriter; |
@@ -65,7 +67,7 @@ public class VersionProcessor extends AbstractProcessor { | @@ -65,7 +67,7 @@ public class VersionProcessor extends AbstractProcessor { | ||
65 | sql = String.format(sql_insert, tableName, element.getSimpleName().toString(), "INTEGER"); | 67 | sql = String.format(sql_insert, tableName, element.getSimpleName().toString(), "INTEGER"); |
66 | if (!isDebug) | 68 | if (!isDebug) |
67 | set.add(sql); | 69 | set.add(sql); |
68 | - } else if (type.equalsIgnoreCase("boolean")){ | 70 | + } else if (type.equalsIgnoreCase("boolean")) { |
69 | sql = String.format(sql_insert, tableName, element.getSimpleName().toString(), "INTEGER"); | 71 | sql = String.format(sql_insert, tableName, element.getSimpleName().toString(), "INTEGER"); |
70 | if (!isDebug) | 72 | if (!isDebug) |
71 | set.add(sql); | 73 | set.add(sql); |
@@ -90,20 +92,37 @@ public class VersionProcessor extends AbstractProcessor { | @@ -90,20 +92,37 @@ public class VersionProcessor extends AbstractProcessor { | ||
90 | } | 92 | } |
91 | File tmp = new File("tmp"); | 93 | File tmp = new File("tmp"); |
92 | // File migrations = new File(tmp.getParentFile(), "app\\src\\main\\assets\\migrations\\".replace("\\", File.separator)); | 94 | // File migrations = new File(tmp.getParentFile(), "app\\src\\main\\assets\\migrations\\".replace("\\", File.separator)); |
93 | -// if (migrations.exists() || migrations.mkdirs()) { | 95 | +// if (migrations.exists()) { |
94 | // File[] files = migrations.listFiles(); | 96 | // File[] files = migrations.listFiles(); |
95 | // if (files != null) | 97 | // if (files != null) |
96 | // for (File f : files) { | 98 | // for (File f : files) { |
97 | -// if (!f.getName().equals("1.sql") && f.getName().endsWith(".sql")) f.delete(); | 99 | +// try { |
100 | +// Integer existVersion = Integer.parseInt(f.getName().replace(".sql", "")); | ||
101 | +// if (existVersion < 2) continue; | ||
102 | +// if (!map.containsKey(existVersion)) { | ||
103 | +// f.delete(); | ||
104 | +// } | ||
105 | +// } catch (NumberFormatException e) { | ||
106 | +// e.printStackTrace(); | ||
107 | +// } | ||
98 | // } | 108 | // } |
99 | // } | 109 | // } |
100 | for (Integer version : map.keySet()) { | 110 | for (Integer version : map.keySet()) { |
101 | try { | 111 | try { |
102 | String path = "app\\src\\main\\assets\\migrations\\".replace("\\", File.separator) + version + ".sql"; | 112 | String path = "app\\src\\main\\assets\\migrations\\".replace("\\", File.separator) + version + ".sql"; |
103 | File file = new File(tmp.getParentFile(), path); | 113 | File file = new File(tmp.getParentFile(), path); |
114 | + Set<String> set = map.get(version); | ||
115 | + if (file.exists()) { | ||
116 | + BufferedReader br = new BufferedReader(new FileReader(file)); | ||
117 | + String buffer; | ||
118 | + for (; (buffer = br.readLine()) != null; ) { | ||
119 | + set.add(buffer); | ||
120 | + } | ||
121 | + br.close(); | ||
122 | + } | ||
104 | BufferedWriter bw = new BufferedWriter(new FileWriter(file)); | 123 | BufferedWriter bw = new BufferedWriter(new FileWriter(file)); |
105 | StringBuilder builder = new StringBuilder(); | 124 | StringBuilder builder = new StringBuilder(); |
106 | - for (String str : map.get(version)) { | 125 | + for (String str : set) { |
107 | builder.append(str); | 126 | builder.append(str); |
108 | builder.append("\r\n"); | 127 | builder.append("\r\n"); |
109 | } | 128 | } |
sql.txt
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -3 ALTER table test ADD COLUMN area INTEGER |