|
|
@@ -10,6 +10,25 @@ function normalizeIdList(value) {
|
|
10
|
10
|
return ids.length > 0 ? ids.join(',') : '0';
|
|
11
|
11
|
}
|
|
12
|
12
|
|
|
|
13
|
+function normalizeEnglishWordList(value) {
|
|
|
14
|
+ const list = Array.isArray(value) ? value : String(value || '').split(',');
|
|
|
15
|
+ return list
|
|
|
16
|
+ .map(item => String(item).trim().replace(/^(["'])(.*)\1$/, '$2'))
|
|
|
17
|
+ .filter(Boolean);
|
|
|
18
|
+}
|
|
|
19
|
+
|
|
|
20
|
+export function buildTextbookWordsQuery(value) {
|
|
|
21
|
+ const words = normalizeEnglishWordList(value);
|
|
|
22
|
+ if (words.length === 0)
|
|
|
23
|
+ return null;
|
|
|
24
|
+
|
|
|
25
|
+ const placeholders = words.map(() => '?').join(',');
|
|
|
26
|
+ return {
|
|
|
27
|
+ sql: `Select * from Words where BookID in (151,152,153,161,162,163,164,165,166,167,168,141,142,143,144,145,146) and Word in (${placeholders}) order by Word,BookID,ID`,
|
|
|
28
|
+ params: words,
|
|
|
29
|
+ };
|
|
|
30
|
+}
|
|
|
31
|
+
|
|
13
|
32
|
function normalizeOrderType(orderType, fallback = 'ac.UpdateTime desc') {
|
|
14
|
33
|
const allowList = new Set([
|
|
15
|
34
|
'ac.UpdateTime desc',
|
|
|
@@ -800,11 +819,17 @@ class Miaoguo {
|
|
800
|
819
|
}
|
|
801
|
820
|
|
|
802
|
821
|
static async GetTestEnglishWords(obj) {
|
|
803
|
|
- let sql = "select wf.ID,wf.SentenceID,ml.JSONString from WordFrequency wf inner join MiaoguoLiteracy ml on wf.Word=ml.Word where (ml.SearchType is null or ml.SearchType='ENG') and wf.Word in(" + obj.Words + ");";
|
|
804
|
|
- if (obj.Words.substr(0, 12) == "\"A\",\"B\",\"C\",")
|
|
805
|
|
- sql = "select ID,Word,JSONString from MiaoguoLiteracy where Word in(" + obj.Words + ");";
|
|
806
|
|
- if (obj.Type == "textbook")
|
|
807
|
|
- sql = "Select * from Words where BookID in (151,152,153,161,162,163,164,165,166,167,168,141,142,143,144,145,146) and Word in (" + obj.Words + ") order by Word,BookID,ID";
|
|
|
822
|
+ if (obj.Type == "textbook") {
|
|
|
823
|
+ const textbookQuery = buildTextbookWordsQuery(obj.Words);
|
|
|
824
|
+ if (!textbookQuery)
|
|
|
825
|
+ return [];
|
|
|
826
|
+ return await query(textbookQuery.sql, textbookQuery.params);
|
|
|
827
|
+ }
|
|
|
828
|
+
|
|
|
829
|
+ const words = String(obj.Words || '');
|
|
|
830
|
+ let sql = "select wf.ID,wf.SentenceID,ml.JSONString from WordFrequency wf inner join MiaoguoLiteracy ml on wf.Word=ml.Word where (ml.SearchType is null or ml.SearchType='ENG') and wf.Word in(" + words + ");";
|
|
|
831
|
+ if (words.substr(0, 12) == "\"A\",\"B\",\"C\",")
|
|
|
832
|
+ sql = "select ID,Word,JSONString from MiaoguoLiteracy where Word in(" + words + ");";
|
|
808
|
833
|
if (obj.Type == "GaoKao")
|
|
809
|
834
|
sql = "SELECT w.ID,w.Word,w.ExampleSentence,w.Translate,l.JSONString FROM kylx365_db.Words w left join MiaoguoLiteracy l on w.WordRemark=l.Word where w.BookID=" + obj.BookID + " and w.LessonID=" + obj.LessonID + " Group By w.ID;";
|
|
810
|
835
|
else if (obj.Type == "GET4" || obj.Type == "GET6")
|