bolds.go 735 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package mint
  2. import (
  3. "net/http"
  4. "time"
  5. "github.com/gin-gonic/gin"
  6. "github.com/go-pg/pg/v10"
  7. )
  8. type Bolds struct {
  9. Id int `json:"id" `
  10. BookId int `json:"book_id" `
  11. Paragraph int `json:"paragraph" `
  12. WordSpell string `json:"word_spell" `
  13. WordReal string `json:"word_real" `
  14. WordEn string `json:"word_en" `
  15. CreatedAt time.Time
  16. }
  17. //display a list of all palitexts
  18. func BoldsIndex(db *pg.DB) gin.HandlerFunc {
  19. return func(c *gin.Context) {
  20. word := c.Query("word")
  21. // TODO 补充业务逻辑
  22. var bolds []Bolds
  23. err := db.Model(&bolds).Where("word_real = ?", word).Select()
  24. if err != nil {
  25. panic(err)
  26. }
  27. c.JSON(http.StatusOK, gin.H{
  28. "status": "sucess",
  29. "data": bolds,
  30. })
  31. }
  32. }