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
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 | 3 | import com.shunzhi.parent.AppContext; |
4 | 4 | |
5 | 5 | import org.greenrobot.greendao.annotation.Entity; |
6 | +import org.greenrobot.greendao.annotation.Generated; | |
6 | 7 | import org.greenrobot.greendao.annotation.Id; |
7 | 8 | import org.greenrobot.greendao.annotation.Keep; |
8 | 9 | import org.greenrobot.greendao.annotation.NotNull; |
9 | 10 | |
10 | 11 | import java.util.Collection; |
11 | -import java.util.Collections; | |
12 | 12 | import java.util.Date; |
13 | -import java.util.List; | |
14 | - | |
15 | -import org.greenrobot.greendao.annotation.Generated; | |
16 | 13 | |
17 | 14 | /** |
18 | 15 | * 内部变量可能存在值为null,使用时要注意 |
... | ... | @@ -37,8 +34,8 @@ public class PHMessage { |
37 | 34 | |
38 | 35 | @Generated(hash = 1935192071) |
39 | 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 | 39 | this.id = id; |
43 | 40 | this.date = date; |
44 | 41 | this.messageId = messageId; | ... | ... |
processor/src/main/java/org/shunzhi/processorlibs/AddColumn.java
processor/src/main/java/org/shunzhi/processorlibs/VersionProcessor.java
1 | 1 | package org.shunzhi.processorlibs; |
2 | 2 | |
3 | +import java.io.BufferedReader; | |
3 | 4 | import java.io.BufferedWriter; |
4 | 5 | import java.io.File; |
6 | +import java.io.FileReader; | |
5 | 7 | import java.io.FileWriter; |
6 | 8 | import java.io.IOException; |
7 | 9 | import java.io.OutputStreamWriter; |
... | ... | @@ -65,7 +67,7 @@ public class VersionProcessor extends AbstractProcessor { |
65 | 67 | sql = String.format(sql_insert, tableName, element.getSimpleName().toString(), "INTEGER"); |
66 | 68 | if (!isDebug) |
67 | 69 | set.add(sql); |
68 | - } else if (type.equalsIgnoreCase("boolean")){ | |
70 | + } else if (type.equalsIgnoreCase("boolean")) { | |
69 | 71 | sql = String.format(sql_insert, tableName, element.getSimpleName().toString(), "INTEGER"); |
70 | 72 | if (!isDebug) |
71 | 73 | set.add(sql); |
... | ... | @@ -90,20 +92,37 @@ public class VersionProcessor extends AbstractProcessor { |
90 | 92 | } |
91 | 93 | File tmp = new File("tmp"); |
92 | 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 | 96 | // File[] files = migrations.listFiles(); |
95 | 97 | // if (files != null) |
96 | 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 | 110 | for (Integer version : map.keySet()) { |
101 | 111 | try { |
102 | 112 | String path = "app\\src\\main\\assets\\migrations\\".replace("\\", File.separator) + version + ".sql"; |
103 | 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 | 123 | BufferedWriter bw = new BufferedWriter(new FileWriter(file)); |
105 | 124 | StringBuilder builder = new StringBuilder(); |
106 | - for (String str : map.get(version)) { | |
125 | + for (String str : set) { | |
107 | 126 | builder.append(str); |
108 | 127 | builder.append("\r\n"); |
109 | 128 | } | ... | ... |
sql.txt
... | ... | @@ -1 +0,0 @@ |
1 | -3 ALTER table test ADD COLUMN area INTEGER |