2
2
3
3
import org .apache .commons .codec .binary .Base64 ;
4
4
import org .apache .commons .codec .digest .DigestUtils ;
5
+ import top .mryan2005 .managesysteminjava .SQLs .SQLLinker ;
6
+
5
7
import javax .swing .*;
6
8
import javax .swing .table .TableColumn ;
7
9
import java .awt .*;
8
10
import java .awt .event .ActionEvent ;
9
11
import java .awt .event .ActionListener ;
10
12
import java .io .UnsupportedEncodingException ;
13
+ import java .sql .Connection ;
14
+ import java .sql .ResultSet ;
15
+ import java .sql .SQLException ;
11
16
import java .util .ArrayList ;
12
17
13
18
public class Entry {
19
+ public SQLLinker sql ; // 数据库连接
14
20
public String currentHash ; // 当前哈希
21
+ public int charId ; // 字符ID
15
22
public String simplified_Chinese_character ; // 简体中文字符
16
23
public String traditional_Chinese_character ; // 繁体中文字符
17
24
public String Pronunciation_of_Wuzhou ; // 梧州话发音
@@ -68,26 +75,65 @@ public String generateCurrentHash() throws UnsupportedEncodingException {
68
75
return currentHash ;
69
76
}
70
77
71
- public static void main (String [] args ) throws UnsupportedEncodingException {
72
- Entry entry = new Entry ();
73
- entry .simplified_Chinese_character = "你" ;
74
- entry .traditional_Chinese_character = "你" ;
75
- entry .Pronunciation_of_Wuzhou = "ni" ;
76
- entry .Pronunciation_of_Cangwu_Shiqiao = "ni" ;
77
- entry .Pronunciation_of_Mengshan = "ni" ;
78
- entry .Heterozygous_Ancient_Texts_of_the_Same_Type = "你" ;
79
- entry .Radical_simplified = "人" ;
80
- entry .Radical_traditional = "人" ;
81
- entry .finalUpdateDate = "2024-11-08" ;
82
- entry .total_number_of_strokes_simplified = 7 ;
83
- entry .total_number_of_strokes_traditional = 7 ;
84
- entry .total_number_of_radical_strokes_simplified = 2 ;
85
- entry .total_number_of_radical_strokes_traditional = 2 ;
86
- entry .Contributors = new ArrayList <>();
87
- entry .Contributors .add ("mryan2005" );
88
- entry .Contributors .add ("gungbbogedding" );
78
+ public static void main (String [] args ) throws UnsupportedEncodingException , SQLException {
79
+ SQLLinker sql = new SQLLinker ("SQL Server" , "127.0.0.1" , "1433" , "sa" , "123456" , "testSQL" );
80
+ sql .runSQL ("INSERT INTO entry.[main] (id, simplified_Chinese_character, traditional_Chinese_character, Pronunciation_of_Wuzhou, Pronunciation_of_Cangwu_Shiqiao, Pronunciation_of_Mengshan, Heterozygous_Ancient_Texts_of_the_Same_Type, Radical_simplified, Radical_traditional, total_number_of_strokes_simplified, total_number_of_strokes_traditional, total_number_of_radical_strokes_simplified, total_number_of_radical_strokes_traditional) VALUES (1, '中', '中', 'zhong', 'zhong', 'zhong', 'zhong', 'zhong', 'zhong', 1, 1, 1, 1)" );
81
+ sql .runSQL ("INSERT INTO Users.[user] (id, username, password, level, role, name, avator) VALUES (1, 'admin', '123456', 0, 'admin', '管理员', 'default.jpg')" );
82
+ sql .runSQL ("INSERT INTO Users.[permission] (id, permissionName, description) VALUES (0, 'admin', 'admin')" );
83
+ sql .runSQL ("INSERT INTO entry.[history] (id, entryId, beforeChange, afterChange, operatorId, operationDate, hash) VALUES (1, 1, 'before', 'after', 1, GETDATE(), 'hash')" );
84
+ Entry entry = new Entry ("中" , sql );
89
85
entry .viewEntry (entry );
90
86
}
87
+
88
+ public Entry (String chara , SQLLinker SQL ) {
89
+ sql = SQL ;
90
+ if (chara == null ) {
91
+ return ;
92
+ }
93
+ try {
94
+ ResultSet res = sql .runSQL ("SELECT * " +
95
+ "FROM entry.[main] as main, entry.[history] as history " +
96
+ "WHERE main.id = history.entryId " +
97
+ "AND main.simplified_Chinese_character = '" + chara + "'" );
98
+ if (res == null ) {
99
+ return ;
100
+ }
101
+ while (res .next ()) {
102
+ charId = res .getInt ("id" );
103
+ simplified_Chinese_character = res .getString ("simplified_Chinese_character" );
104
+ traditional_Chinese_character = res .getString ("traditional_Chinese_character" );
105
+ Pronunciation_of_Wuzhou = res .getString ("Pronunciation_of_Wuzhou" );
106
+ Pronunciation_of_Cangwu_Shiqiao = res .getString ("Pronunciation_of_Cangwu_Shiqiao" );
107
+ Pronunciation_of_Mengshan = res .getString ("Pronunciation_of_Mengshan" );
108
+ Heterozygous_Ancient_Texts_of_the_Same_Type = res .getString ("Heterozygous_Ancient_Texts_of_the_Same_Type" );
109
+ Radical_simplified = res .getString ("Radical_simplified" );
110
+ Radical_traditional = res .getString ("Radical_traditional" );
111
+ finalUpdateDate = res .getString ("finalUpdateDate" );
112
+ total_number_of_strokes_simplified = res .getInt ("total_number_of_strokes_simplified" );
113
+ total_number_of_strokes_traditional = res .getInt ("total_number_of_strokes_traditional" );
114
+ total_number_of_radical_strokes_simplified = res .getInt ("total_number_of_radical_strokes_simplified" );
115
+ total_number_of_radical_strokes_traditional = res .getInt ("total_number_of_radical_strokes_traditional" );
116
+ Contributors = new ArrayList <>();
117
+ ResultSet res1 = sql .runSQL ("SELECT username" +
118
+ "FROM Users.[user] as user" +
119
+ "WHERE id IN (SELECT operatorId" +
120
+ "FROM entry.[history]" +
121
+ "WHERE entryId in (SELECT id" +
122
+ "FROM entry.[main]" +
123
+ "WHERE simplified_Chinese_character = '" + chara + "'))" );
124
+ if (res1 == null ) {
125
+ return ;
126
+ }
127
+ while (res1 .next ()) {
128
+ Contributors .add (res .getString ("username" ));
129
+ }
130
+ }
131
+ } catch (SQLException e ) {
132
+ throw new RuntimeException (e );
133
+ }
134
+ }
135
+
136
+ public Entry () {}
91
137
92
138
public void viewEntry (Entry entry ) throws UnsupportedEncodingException {
93
139
JFrame jDialog = new JFrame ();
@@ -104,7 +150,7 @@ public void viewEntry(Entry entry) throws UnsupportedEncodingException {
104
150
jButton .addActionListener (new ActionListener () {
105
151
@ Override
106
152
public void actionPerformed (ActionEvent e ) {
107
- editEntry (jDialog );
153
+ editEntry (jDialog , 1 );
108
154
dispHtml = entry .generateHTML ();
109
155
try {
110
156
entry .generateCurrentHash ();
@@ -178,7 +224,7 @@ public void actionPerformed(ActionEvent e) {
178
224
jDialog .setVisible (true );
179
225
}
180
226
181
- public void editEntry (JFrame parentJFrame ) {
227
+ public void editEntry (JFrame parentJFrame , int operatorId ) {
182
228
JDialog jDialog = new JDialog (parentJFrame );
183
229
jDialog .setSize (800 , 600 );
184
230
jDialog .setDefaultCloseOperation (JDialog .DISPOSE_ON_CLOSE );
@@ -304,6 +350,7 @@ public void editEntry(JFrame parentJFrame) {
304
350
jButton .addActionListener (new ActionListener () {
305
351
@ Override
306
352
public void actionPerformed (ActionEvent e ) {
353
+
307
354
simplified_Chinese_character = jTextFieldSimplifiedChineseCharacter .getText ();
308
355
traditional_Chinese_character = jTextFieldTraditionalChineseCharacter .getText ();
309
356
Pronunciation_of_Wuzhou = jTextFieldPoWuzhou .getText ();
@@ -316,6 +363,37 @@ public void actionPerformed(ActionEvent e) {
316
363
total_number_of_radical_strokes_traditional = Integer .parseInt (jTextFieldTotalNumberOfRadicalStrokesTraditional .getText ());
317
364
total_number_of_strokes_simplified = Integer .parseInt (jTextFieldTotalNumberOfStrokesSimplified .getText ());
318
365
total_number_of_strokes_traditional = Integer .parseInt (jTextFieldTotalNumberOfStrokesTraditional .getText ());
366
+ sql .runSQL ("UPDATE entry.[main]" +
367
+ "SET simplified_Chinese_character = '" + simplified_Chinese_character + "'," +
368
+ "traditional_Chinese_character = '" + traditional_Chinese_character + "'," +
369
+ "Pronunciation_of_Wuzhou = '" + Pronunciation_of_Wuzhou + "'," +
370
+ "Pronunciation_of_Cangwu_Shiqiao = '" + Pronunciation_of_Cangwu_Shiqiao + "'," +
371
+ "Pronunciation_of_Mengshan = '" + Pronunciation_of_Mengshan + "'," +
372
+ "Heterozygous_Ancient_Texts_of_the_Same_Type = '" + Heterozygous_Ancient_Texts_of_the_Same_Type + "'," +
373
+ "Radical_simplified = '" + Radical_simplified + "'," +
374
+ "Radical_traditional = '" + Radical_traditional + "'," +
375
+ "total_number_of_radical_strokes_simplified = " + total_number_of_radical_strokes_simplified + "," +
376
+ "total_number_of_radical_strokes_traditional = " + total_number_of_radical_strokes_traditional + "," +
377
+ "total_number_of_strokes_simplified = " + total_number_of_strokes_simplified + "," +
378
+ "total_number_of_strokes_traditional = " + total_number_of_strokes_traditional +
379
+ "WHERE id = " + charId );
380
+ ResultSet lastId = sql .runSQL ("SELECT MAX(id) FROM entry.[history]" );
381
+ int LastId ;
382
+ if (lastId == null ) {
383
+ LastId = 0 ;
384
+ } else {
385
+ try {
386
+ LastId = lastId .getInt (1 );
387
+ } catch (SQLException ex ) {
388
+ throw new RuntimeException (ex );
389
+ }
390
+ }
391
+ try {
392
+ sql .runSQL ("INSERT INTO entry.[history] (id, beforeChange, afterChange, operatorId, operationDate, hash)" +
393
+ "VALUES (" + (LastId + 1 ) + ", '" + html + "', '" + generateHTML () + "', " + operatorId + ", GETDATE(), '" + generateCurrentHash () + "')" );
394
+ } catch (UnsupportedEncodingException ex ) {
395
+ throw new RuntimeException (ex );
396
+ }
319
397
jDialog .dispose ();
320
398
}
321
399
});
0 commit comments