mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-23 12:00:35 +08:00
implement GenerateFile
This commit is contained in:
@@ -81,6 +81,7 @@ func (f *FileDatabase) DelQuestion(id int64, istemp bool) error {
|
||||
type Question struct {
|
||||
ID int64 // ID is the first 8 bytes of the Plain's md5
|
||||
FileID int64 // FileID is fk to File(ID)
|
||||
Major string // Major is sub's major name
|
||||
Path string // Path is the question's docx position
|
||||
Plain string // Plain is the plain text of the question (like markdown format)
|
||||
Images []byte // Images is json of the image dhash in XML, ex. ['rId1': '1234567890abcdef', ...]
|
||||
@@ -110,6 +111,21 @@ func (f *FileDatabase) GetQuestionHex(hexid string, istemp bool) (q Question, er
|
||||
return f.GetQuestion(int64(binary.LittleEndian.Uint64(idb)), istemp)
|
||||
}
|
||||
|
||||
// GetMajors ...
|
||||
func (f *FileDatabase) GetMajors() (majors []string) {
|
||||
type majorq struct {
|
||||
Major string
|
||||
}
|
||||
var maj majorq
|
||||
f.mu.RLock()
|
||||
defer f.mu.RUnlock()
|
||||
f.db.QueryFor("SELECT DISTINCT Major FROM question;", &maj, func() error {
|
||||
majors = append(majors, maj.Major)
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// MaxDuplicateRate parse q.Dup and get the max rate
|
||||
func (q *Question) MaxDuplicateRate() float64 {
|
||||
dupmap := make(map[string]float64, 64)
|
||||
|
||||
Reference in New Issue
Block a user