emoji_package.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func listEmojiPacks(c *bm.Context) {
  7. packs, err := rpSvc.EmojiPackageList(c)
  8. if err != nil {
  9. c.JSON(nil, err)
  10. return
  11. }
  12. c.JSON(packs, nil)
  13. }
  14. func createEmojiPackage(c *bm.Context) {
  15. v := new(struct {
  16. Name string `form:"name" validate:"required"`
  17. URL string `form:"url" validate:"required"`
  18. Sort int32 `form:"sort" validate:"min=0"`
  19. Remark string `form:"remark" default:""`
  20. State int32 `form:"state" validate:"min=0"`
  21. })
  22. if err := c.Bind(v); err != nil {
  23. c.JSON(nil, ecode.RequestErr)
  24. return
  25. }
  26. id, err := rpSvc.CreateEmojiPackage(c, v.Name, v.URL, v.Sort, v.Remark, v.State)
  27. if err != nil {
  28. c.JSON(nil, err)
  29. return
  30. }
  31. c.JSON(id, nil)
  32. }
  33. func upEmojiPackageSort(c *bm.Context) {
  34. v := new(struct {
  35. IDs string `form:"ids" validate:"required"`
  36. })
  37. if err := c.Bind(v); err != nil {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. err := rpSvc.UpEmojiPackageSort(c, v.IDs)
  42. if err != nil {
  43. c.JSON(nil, err)
  44. return
  45. }
  46. c.JSON(nil, nil)
  47. }
  48. func editEmojiPack(c *bm.Context) {
  49. v := new(struct {
  50. ID int64 `form:"id" validate:"min=0"`
  51. Name string `form:"name" default:""`
  52. URL string `form:"url" default:""`
  53. Remark string `form:"remark" default:""`
  54. State int32 `form:"state" validate:"min=0"`
  55. })
  56. if err := c.Bind(v); err != nil {
  57. c.JSON(nil, ecode.RequestErr)
  58. return
  59. }
  60. id, err := rpSvc.UpEmojiPackage(c, v.Name, v.URL, v.Remark, v.State, v.ID)
  61. if err != nil {
  62. c.JSON(nil, err)
  63. return
  64. }
  65. c.JSON(id, nil)
  66. }