words.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package v1
  2. import (
  3. "github.com/gogf/gf/v2/frame/g"
  4. "github.com/gogf/gf/v2/os/gtime"
  5. )
  6. type ProficiencyLevel uint
  7. const (
  8. ProficiencyLevel1 ProficiencyLevel = iota + 1
  9. ProficiencyLevel2
  10. ProficiencyLevel3
  11. ProficiencyLevel4
  12. ProficiencyLevel5
  13. )
  14. type CreateReq struct {
  15. g.Meta `path:"words" method:"post" sm:"创建" tags:"单词"`
  16. Word string `json:"word" v:"required|length:1,100" dc:"单词"`
  17. Definition string `json:"definition" v:"required|length:1,300" dc:"单词定义"`
  18. ExampleSentence string `json:"example_sentence" v:"required|length:1,300" dc:"例句"`
  19. ChineseTranslation string `json:"chinese_translation" v:"required|length:1,300" dc:"中文翻译"`
  20. Pronunciation string `json:"pronunciation" v:"required|length:1,100" dc:"发音"`
  21. ProficiencyLevel ProficiencyLevel `json:"proficiency_level" v:"required|between:1,5" dc:"熟练度,1最低,5最高"`
  22. }
  23. type CreateRes struct {
  24. }
  25. type UpdateReq struct {
  26. g.Meta `path:"words/{id}" method:"put" sm:"更新" tags:"单词"`
  27. Id uint `json:"id" v:"required"`
  28. Word string `json:"word" v:"required|length:1,100" dc:"单词"`
  29. Definition string `json:"definition" v:"required|length:1,300" dc:"单词定义"`
  30. ExampleSentence string `json:"example_sentence" v:"required|length:1,300" dc:"例句"`
  31. ChineseTranslation string `json:"chinese_translation" v:"required|length:1,300" dc:"中文翻译"`
  32. Pronunciation string `json:"pronunciation" v:"required|length:1,100" dc:"发音"`
  33. ProficiencyLevel ProficiencyLevel `json:"proficiency_level" v:"required|between:1,5" dc:"熟练度,1最低,5最高"`
  34. }
  35. type UpdateRes struct {
  36. }
  37. type List struct {
  38. Id uint `json:"id"`
  39. Word string `json:"word"`
  40. Definition string `json:"definition"`
  41. ProficiencyLevel ProficiencyLevel `json:"proficiencyLevel"`
  42. }
  43. type ListReq struct {
  44. g.Meta `path:"words" method:"get" sm:"列表" tags:"单词"`
  45. Word string `json:"word" v:"length:1,100" dc:"模糊查询单词"`
  46. Page int `json:"page" v:"min:1" dc:"页码,默认1"`
  47. Size int `json:"size" v:"between:1,100" dc:"每页数量,默认10"`
  48. }
  49. type ListRes struct {
  50. List []List `json:"words"`
  51. Total uint `json:"total"`
  52. }
  53. type DetailReq struct {
  54. g.Meta `path:"words/{id}" method:"get" sm:"详情" tags:"单词"`
  55. Id uint `json:"id" v:"required"`
  56. }
  57. type DetailRes struct {
  58. Id uint `json:"id"`
  59. Word string `json:"word"`
  60. Definition string `json:"definition"`
  61. ExampleSentence string `json:"exampleSentence"`
  62. ChineseTranslation string `json:"chineseTranslation"`
  63. Pronunciation string `json:"pronunciation"`
  64. ProficiencyLevel ProficiencyLevel `json:"proficiencyLevel"`
  65. CreatedAt *gtime.Time `json:"createdAt"`
  66. UpdatedAt *gtime.Time `json:"updatedAt"`
  67. }
  68. type DeleteReq struct {
  69. g.Meta `path:"words/{id}" method:"delete" sm:"删除" tags:"单词"`
  70. Id uint `json:"id" v:"required"`
  71. }
  72. type DeleteRes struct {
  73. }