word_in_book_index.go 824 B

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