Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 96bff56

Browse files
committed
update
1 parent ff84d00 commit 96bff56

File tree

2 files changed

+127
-45
lines changed

2 files changed

+127
-45
lines changed

src/main/java/top/mryan2005/managesysteminjava/BasicClass/Entry.java

Lines changed: 98 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22

33
import org.apache.commons.codec.binary.Base64;
44
import org.apache.commons.codec.digest.DigestUtils;
5+
import top.mryan2005.managesysteminjava.SQLs.SQLLinker;
6+
57
import javax.swing.*;
68
import javax.swing.table.TableColumn;
79
import java.awt.*;
810
import java.awt.event.ActionEvent;
911
import java.awt.event.ActionListener;
1012
import java.io.UnsupportedEncodingException;
13+
import java.sql.Connection;
14+
import java.sql.ResultSet;
15+
import java.sql.SQLException;
1116
import java.util.ArrayList;
1217

1318
public class Entry {
19+
public SQLLinker sql; // 数据库连接
1420
public String currentHash; // 当前哈希
21+
public int charId; // 字符ID
1522
public String simplified_Chinese_character; // 简体中文字符
1623
public String traditional_Chinese_character; // 繁体中文字符
1724
public String Pronunciation_of_Wuzhou; // 梧州话发音
@@ -68,26 +75,65 @@ public String generateCurrentHash() throws UnsupportedEncodingException {
6875
return currentHash;
6976
}
7077

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);
8985
entry.viewEntry(entry);
9086
}
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() {}
91137

92138
public void viewEntry(Entry entry) throws UnsupportedEncodingException {
93139
JFrame jDialog = new JFrame();
@@ -104,7 +150,7 @@ public void viewEntry(Entry entry) throws UnsupportedEncodingException {
104150
jButton.addActionListener(new ActionListener() {
105151
@Override
106152
public void actionPerformed(ActionEvent e) {
107-
editEntry(jDialog);
153+
editEntry(jDialog, 1);
108154
dispHtml = entry.generateHTML();
109155
try {
110156
entry.generateCurrentHash();
@@ -178,7 +224,7 @@ public void actionPerformed(ActionEvent e) {
178224
jDialog.setVisible(true);
179225
}
180226

181-
public void editEntry(JFrame parentJFrame) {
227+
public void editEntry(JFrame parentJFrame, int operatorId) {
182228
JDialog jDialog = new JDialog(parentJFrame);
183229
jDialog.setSize(800, 600);
184230
jDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
@@ -304,6 +350,7 @@ public void editEntry(JFrame parentJFrame) {
304350
jButton.addActionListener(new ActionListener() {
305351
@Override
306352
public void actionPerformed(ActionEvent e) {
353+
307354
simplified_Chinese_character = jTextFieldSimplifiedChineseCharacter.getText();
308355
traditional_Chinese_character = jTextFieldTraditionalChineseCharacter.getText();
309356
Pronunciation_of_Wuzhou = jTextFieldPoWuzhou.getText();
@@ -316,6 +363,37 @@ public void actionPerformed(ActionEvent e) {
316363
total_number_of_radical_strokes_traditional = Integer.parseInt(jTextFieldTotalNumberOfRadicalStrokesTraditional.getText());
317364
total_number_of_strokes_simplified = Integer.parseInt(jTextFieldTotalNumberOfStrokesSimplified.getText());
318365
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+
}
319397
jDialog.dispose();
320398
}
321399
});

src/main/java/top/mryan2005/managesysteminjava/Core.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -626,59 +626,63 @@ public void actionPerformed(ActionEvent e) {
626626
String place = null;
627627
if(types[1].matches("梧州")) {
628628
place = "Wuzhou";
629+
} else if(types[1].matches("苍梧石桥")) {
630+
place = "Cangwu_Shiqiao";
631+
} else if(types[1].matches("蒙山")) {
632+
place = "Mengshan";
629633
}
630634
if(types[0].matches("A"))
631635
res = sql.runSQL("SELECT * FROM entry.main WHERE Pronunciation_of_"+place+" LIKE 'a%' ORDER BY id");
632636
else if(types[0].matches("B"))
633-
res = sql.runSQL("SELECT * FROM entry.bPart ORDER BY id");
637+
res = sql.runSQL("SELECT * FROM entry[main] WHERE Pronunciation_of_"+place+" LIKE 'b%' ORDER BY id");
634638
else if(types[0].matches("C"))
635-
res = sql.runSQL("SELECT * FROM entry.cPart ORDER BY id");
639+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'c%' ORDER BY id");
636640
else if(types[0].matches("D"))
637-
res = sql.runSQL("SELECT * FROM entry.dPart ORDER BY id");
641+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'd%' ORDER BY id");
638642
else if(types[0].matches("E"))
639-
res = sql.runSQL("SELECT * FROM entry.ePart ORDER BY id");
643+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'e%' ORDER BY id");
640644
else if(types[0].matches("F"))
641-
res = sql.runSQL("SELECT * FROM entry.fPart ORDER BY id");
645+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'f%' ORDER BY id");
642646
else if(types[0].matches("G"))
643-
res = sql.runSQL("SELECT * FROM entry.gPart ORDER BY id");
647+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'g%' ORDER BY id");
644648
else if(types[0].matches("H"))
645-
res = sql.runSQL("SELECT * FROM entry.hPart ORDER BY id");
649+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'h%' ORDER BY id");
646650
else if(types[0].matches("I"))
647-
res = sql.runSQL("SELECT * FROM entry.iPart ORDER BY id");
651+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'i%' ORDER BY id");
648652
else if(types[0].matches("J"))
649-
res = sql.runSQL("SELECT * FROM entry.jPart ORDER BY id");
653+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'j%' ORDER BY id");
650654
else if(types[0].matches("K"))
651-
res = sql.runSQL("SELECT * FROM entry.kPart ORDER BY id");
655+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'k%' ORDER BY id");
652656
else if(types[0].matches("L"))
653-
res = sql.runSQL("SELECT * FROM entry.lPart ORDER BY id");
657+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'l%' ORDER BY id");
654658
else if(types[0].matches("M"))
655-
res = sql.runSQL("SELECT * FROM entry.mPart ORDER BY id");
659+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'm%' ORDER BY id");
656660
else if(types[0].matches("N"))
657-
res = sql.runSQL("SELECT * FROM entry.nPart ORDER BY id");
661+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'n%' ORDER BY id");
658662
else if(types[0].matches("O"))
659-
res = sql.runSQL("SELECT * FROM entry.oPart ORDER BY id");
663+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'o%' ORDER BY id");
660664
else if(types[0].matches("P"))
661-
res = sql.runSQL("SELECT * FROM entry.pPart ORDER BY id");
665+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'p%' ORDER BY id");
662666
else if(types[0].matches("Q"))
663-
res = sql.runSQL("SELECT * FROM entry.qPart ORDER BY id");
667+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'q%' ORDER BY id");
664668
else if(types[0].matches("R"))
665-
res = sql.runSQL("SELECT * FROM entry.rPart ORDER BY id");
669+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'r%' ORDER BY id");
666670
else if(types[0].matches("S"))
667-
res = sql.runSQL("SELECT * FROM entry.sPart ORDER BY id");
671+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 's%' ORDER BY id");
668672
else if(types[0].matches("T"))
669-
res = sql.runSQL("SELECT * FROM entry.tPart ORDER BY id");
673+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 't%' ORDER BY id");
670674
else if(types[0].matches("U"))
671-
res = sql.runSQL("SELECT * FROM entry.uPart ORDER BY id");
675+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'u%' ORDER BY id");
672676
else if(types[0].matches("V"))
673-
res = sql.runSQL("SELECT * FROM entry.vPart ORDER BY id");
677+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'v%' ORDER BY id");
674678
else if(types[0].matches("W"))
675-
res = sql.runSQL("SELECT * FROM entry.wPart ORDER BY id");
679+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'w%' ORDER BY id");
676680
else if(types[0].matches("X"))
677-
res = sql.runSQL("SELECT * FROM entry.xPart ORDER BY id");
681+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'x%' ORDER BY id");
678682
else if(types[0].matches("Y"))
679-
res = sql.runSQL("SELECT * FROM entry.yPart ORDER BY id");
683+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'y%' ORDER BY id");
680684
else if(types[0].matches("Z"))
681-
res = sql.runSQL("SELECT * FROM entry.zPart ORDER BY id");
685+
res = sql.runSQL("SELECT * FROM entry.[main] WHERE Pronunciation_of_"+place+" LIKE 'z%' ORDER BY id");
682686
else if(types[0].matches("All"))
683687
res = sql.runSQL("SELECT * FROM entry.viewAll ORDER BY id");
684688
else

0 commit comments

Comments
 (0)