memos.go 445 B

123456789101112131415161718192021222324252627
  1. package model
  2. import (
  3. "time"
  4. "woord-core-service/global"
  5. "gorm.io/gorm"
  6. )
  7. // 复习记录
  8. type Memo struct {
  9. ID uint `gorm:"primarykey"`
  10. CreatedAt time.Time `gorm:"index"`
  11. UpdatedAt time.Time
  12. DeletedAt gorm.DeletedAt `gorm:"index"`
  13. // 所属单词 ID
  14. WordID uint
  15. }
  16. // 创建复习记录
  17. func CreateMemo(wordID uint) error {
  18. memo := &Memo{
  19. WordID: wordID,
  20. }
  21. return global.DB.Select("word_id").Create(memo).Error
  22. }