pali_word.go 875 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 PaliWord struct {
  9. Id int `json:"id" `
  10. BookId int `json:"book_id" `
  11. Paragraph int `json:"paragraph" `
  12. PaliWordIndexId int `json:"pali_word_index_id" `
  13. IsBase bool `json:"is_base" `
  14. Weight string `json:"weight" `
  15. CreatedAt time.Time
  16. }
  17. //display a list of all palitexts
  18. func PaliWordsIndex(db *pg.DB) gin.HandlerFunc {
  19. return func(c *gin.Context) {
  20. book := c.Query("book")
  21. paragraph := c.Query("paragraph")
  22. // TODO 补充业务逻辑
  23. var pali_words []PaliWord
  24. err := db.Model(&pali_words).Where("book_id = ?", book).Where("paragraph = ?", paragraph).Select()
  25. if err != nil {
  26. panic(err)
  27. }
  28. c.JSON(http.StatusOK, gin.H{
  29. "status": "sucess",
  30. "data": pali_words,
  31. })
  32. }
  33. }