wbw_template.go 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 WbwTemplate struct {
  9. Id int `json:"id" `
  10. BookId int `json:"book_id" `
  11. Paragraph int `json:"paragraph" `
  12. WordSn int `json:"word_sn" `
  13. Word string `json:"word" `
  14. RealWord string `json:"real_word" `
  15. Type string `json:"type" `
  16. Grammar string `json:"grammar" `
  17. Factors string `json:"factors" `
  18. CreatedAt time.Time
  19. }
  20. //display a list of all palitexts
  21. func WbwTemplatesIndex(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 wbw_template []WbwTemplate
  27. err := db.Model(&wbw_template).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": wbw_template,
  34. })
  35. }
  36. }