pali_word_index.go 953 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 PaliWordIndex struct {
  9. Id int `json:"id" `
  10. Word int `json:"word" `
  11. BookId int `json:"book_id" `
  12. WordEn int `json:"word_en" `
  13. Count string `json:"count" `
  14. Normal string `json:"normal" `
  15. Bold string `json:"bold" `
  16. IsBase bool `json:"is_base" `
  17. StrLen string `json:"str_len" `
  18. CreatedAt time.Time
  19. }
  20. //display a list of all palitexts
  21. func PaliWordIndexsIndex(db *pg.DB) gin.HandlerFunc {
  22. return func(c *gin.Context) {
  23. book := c.Query("book")
  24. paragraph := c.Query("paragraph")
  25. // TODO 补充业务逻辑
  26. var pali_word_indexs []PaliWordIndex
  27. err := db.Model(&pali_word_indexs).Where("book_id = ?", book).Where("paragraph = ?", paragraph).Select()
  28. if err != nil {
  29. panic(err)
  30. }
  31. c.JSON(http.StatusOK, gin.H{
  32. "status": "sucess",
  33. "data": pali_word_indexs,
  34. })
  35. }
  36. }