7
7
"time"
8
8
9
9
"github.com/360EntSecGroup-Skylar/excelize"
10
- "github.com/zzc-tongji/vocabulary4mydictionary"
11
10
)
12
11
13
12
// collection
@@ -20,7 +19,7 @@ type collectionStruct struct {
20
19
xlsx * excelize.File
21
20
sheetName string
22
21
columnIndex map [string ]int
23
- content []vocabulary4mydictionary. VocabularyAnswerStruct
22
+ content []VocabularyAnswerStruct
24
23
}
25
24
26
25
// open and check .xlsx file
@@ -169,7 +168,7 @@ RECHECK:
169
168
func (collection * collectionStruct ) read (filePath string ) (err error ) {
170
169
var (
171
170
str string
172
- vocabularyAnswer vocabulary4mydictionary. VocabularyAnswerStruct
171
+ vocabularyAnswer VocabularyAnswerStruct
173
172
)
174
173
if collection .readable {
175
174
// check
@@ -178,7 +177,7 @@ func (collection *collectionStruct) read(filePath string) (err error) {
178
177
return
179
178
}
180
179
// get space of content
181
- collection .content = make ([]vocabulary4mydictionary. VocabularyAnswerStruct , 0 )
180
+ collection .content = make ([]VocabularyAnswerStruct , 0 )
182
181
// ram image -> content
183
182
for i := 2 ; ; i ++ {
184
183
// `xlsx:wd` -> .Word
@@ -219,7 +218,7 @@ func (collection *collectionStruct) read(filePath string) (err error) {
219
218
}
220
219
// others
221
220
vocabularyAnswer .SourceName = collection .name
222
- vocabularyAnswer .Location .TableType = vocabulary4mydictionary . Collection
221
+ vocabularyAnswer .Location .TableType = Collection
223
222
vocabularyAnswer .Status = ""
224
223
// add to collection
225
224
collection .content = append (collection .content , vocabularyAnswer )
@@ -263,9 +262,9 @@ func (collection *collectionStruct) write() (information string, err error) {
263
262
}
264
263
265
264
// query and update
266
- func (collection * collectionStruct ) queryAndUpdate (vocabularyAsk vocabulary4mydictionary. VocabularyAskStruct ) (vocabularyAnswerList []vocabulary4mydictionary. VocabularyAnswerStruct ) {
265
+ func (collection * collectionStruct ) queryAndUpdate (vocabularyAsk VocabularyAskStruct ) (vocabularyAnswerList []VocabularyAnswerStruct ) {
267
266
var (
268
- vocabularyAnswer vocabulary4mydictionary. VocabularyAnswerStruct
267
+ vocabularyAnswer VocabularyAnswerStruct
269
268
tm time.Time
270
269
)
271
270
if collection .readable {
@@ -283,7 +282,7 @@ func (collection *collectionStruct) queryAndUpdate(vocabularyAsk vocabulary4mydi
283
282
}
284
283
}
285
284
vocabularyAnswer = collection .content [i ]
286
- vocabularyAnswer .Status = vocabulary4mydictionary . Basic
285
+ vocabularyAnswer .Status = Basic
287
286
vocabularyAnswerList = append (vocabularyAnswerList , vocabularyAnswer )
288
287
if vocabularyAsk .Advance {
289
288
continue
@@ -295,22 +294,22 @@ func (collection *collectionStruct) queryAndUpdate(vocabularyAsk vocabulary4mydi
295
294
// advance
296
295
if strings .Contains (collection .content [i ].Word , vocabularyAsk .Word ) {
297
296
vocabularyAnswer = collection .content [i ]
298
- vocabularyAnswer .Status = vocabulary4mydictionary . Advance
297
+ vocabularyAnswer .Status = Advance
299
298
vocabularyAnswerList = append (vocabularyAnswerList , vocabularyAnswer )
300
299
goto ADVANCE_END
301
300
}
302
301
for j := 0 ; j < len (collection .content [i ].Definition ); j ++ {
303
302
if strings .Contains (collection .content [i ].Definition [j ], vocabularyAsk .Word ) {
304
303
vocabularyAnswer = collection .content [i ]
305
- vocabularyAnswer .Status = vocabulary4mydictionary . Advance
304
+ vocabularyAnswer .Status = Advance
306
305
vocabularyAnswerList = append (vocabularyAnswerList , vocabularyAnswer )
307
306
goto ADVANCE_END
308
307
}
309
308
}
310
309
for j := 0 ; j < len (collection .content [i ].Note ); j ++ {
311
310
if strings .Contains (collection .content [i ].Note [j ], vocabularyAsk .Word ) {
312
311
vocabularyAnswer = collection .content [i ]
313
- vocabularyAnswer .Status = vocabulary4mydictionary . Advance
312
+ vocabularyAnswer .Status = Advance
314
313
vocabularyAnswerList = append (vocabularyAnswerList , vocabularyAnswer )
315
314
goto ADVANCE_END
316
315
}
@@ -323,21 +322,21 @@ func (collection *collectionStruct) queryAndUpdate(vocabularyAsk vocabulary4mydi
323
322
}
324
323
325
324
// add vocabulary to collection
326
- func (collection * collectionStruct ) add (vocabularyAnswerList []vocabulary4mydictionary. VocabularyAnswerStruct ) {
325
+ func (collection * collectionStruct ) add (vocabularyAnswerList []VocabularyAnswerStruct ) {
327
326
var (
328
327
existent bool
329
328
index int
330
- vocabularyAnswer vocabulary4mydictionary. VocabularyAnswerStruct
329
+ vocabularyAnswer VocabularyAnswerStruct
331
330
tm time.Time
332
331
)
333
332
if collection .readable && collection .writable {
334
333
// only available for collection which is readable and writable
335
334
existent = false
336
335
index = - 1
337
336
for i := 0 ; i < len (vocabularyAnswerList ); i ++ {
338
- if strings .Compare (vocabularyAnswerList [i ].Status , vocabulary4mydictionary . Basic ) == 0 {
337
+ if strings .Compare (vocabularyAnswerList [i ].Status , Basic ) == 0 {
339
338
// only for vocabulary with define from basic query
340
- if vocabularyAnswerList [i ].Location .TableType == vocabulary4mydictionary . Online {
339
+ if vocabularyAnswerList [i ].Location .TableType == Online {
341
340
// from online: check whether online source index match or not
342
341
if strings .Compare (vocabularyAnswerList [i ].SourceName , collection .onlineSource ) == 0 {
343
342
index = i
@@ -357,7 +356,7 @@ func (collection *collectionStruct) add(vocabularyAnswerList []vocabulary4mydict
357
356
vocabularyAnswer .QueryCounter = 1
358
357
vocabularyAnswer .QueryTime = fmt .Sprintf ("%04d-%02d-%02d %02d:%02d:%02d" , tm .Year (), tm .Month (), tm .Day (), tm .Hour (), tm .Minute (), tm .Second ())
359
358
vocabularyAnswer .SourceName = collection .name
360
- vocabularyAnswer .Location .TableType = vocabulary4mydictionary . Collection
359
+ vocabularyAnswer .Location .TableType = Collection
361
360
vocabularyAnswer .Status = ""
362
361
// add
363
362
collection .content = append (collection .content , vocabularyAnswer )
0 commit comments