pali_text.go 985 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 PaliTextPath struct {
  9. Title string `json:"title" `
  10. Book int `json:"book" `
  11. Paragraph int `json:"paragraph" `
  12. }
  13. type PaliText struct {
  14. Id int `form:"id" json:"id" `
  15. BookId int
  16. Paragraph int
  17. Level int
  18. Class string
  19. Text string
  20. Html string
  21. Toc string
  22. StrLength int
  23. ChapterLen int
  24. NextChapter int
  25. PrevChapter int
  26. Parent int
  27. ChapterStrlen int
  28. Path []PaliTextPath
  29. Version int
  30. CreatedAt time.Time
  31. UpdatedAt time.Time
  32. }
  33. //display a list of all palitexts
  34. func PaliTextsIndex(db *pg.DB) gin.HandlerFunc {
  35. return func(c *gin.Context) {
  36. book := c.Query("book")
  37. // TODO 补充业务逻辑
  38. var palitexts []PaliText
  39. err := db.Model(&palitexts).Where("book = ?", book).Select()
  40. if err != nil {
  41. panic(err)
  42. }
  43. c.JSON(http.StatusOK, gin.H{
  44. "status": "sucess",
  45. "data": palitexts,
  46. })
  47. }
  48. }