mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-22 19:40:36 +08:00
初步完成step1前端设计
This commit is contained in:
@@ -235,7 +235,7 @@ func (f *FileDatabase) AddFile(lstid int, reg *Regex, istemp bool, progress func
|
||||
m := md5.Sum(sb.Bytes())
|
||||
que := &Question{
|
||||
ID: int64(binary.LittleEndian.Uint64(m[:8])),
|
||||
FileID: file.ID,
|
||||
ListID: *lst.ID,
|
||||
Major: majorq.Name,
|
||||
Plain: base14.BytesToString(sb.Bytes()),
|
||||
Images: func() []byte {
|
||||
|
||||
@@ -2,6 +2,7 @@ package global
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
@@ -77,7 +78,26 @@ func (f *FileDatabase) GenerateFile(config *GenerateConfig) (*docx.Docx, error)
|
||||
if rate > config.RateLimit {
|
||||
return nil, ErrRateLimitExceeded
|
||||
}
|
||||
// TODO: 写入question到docf
|
||||
for i, q := range ques {
|
||||
lst, err := sql.Find[List](&f.db, FileTableFile, "WHERE ID="+strconv.Itoa(q.ListID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
quesfile, err := os.Open(q.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stat, err := quesfile.Stat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
docq, err := docx.Parse(quesfile, stat.Size())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
docf.AddParagraph().AddText(strconv.Itoa(i+1) + ". (" + lst.Desc + ")")
|
||||
docf.AppendFile(docq)
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
return docf, nil
|
||||
}
|
||||
|
||||
@@ -80,7 +80,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)
|
||||
ListID int // ListID is fk to List(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)
|
||||
|
||||
Reference in New Issue
Block a user