蛋蛋星球 后台端
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

svc_function.go 2.3 KiB

há 1 semana
há 3 semanas
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package advertising
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/utils"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  9. "github.com/gin-gonic/gin"
  10. )
  11. func FunctionList(c *gin.Context) {
  12. var req *md.AdvertisingFunctionListReq
  13. if err := c.ShouldBindJSON(&req); err != nil {
  14. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  15. return
  16. }
  17. var resp md.AdvertisingFunctionListResp
  18. noticeList := make([]md.AdvertisingFunctionList, 0)
  19. resp.SelectData = md.AdvertisingType
  20. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(db.Db)
  21. adv, _, _ := NewAdvertisingSpaceDb.FindUserFeedbackCateAndTotal("1", "1000", "", "")
  22. advList := make([]map[string]string, 0)
  23. if adv != nil {
  24. for _, v := range *adv {
  25. tmp := map[string]string{
  26. "name": v.Name,
  27. "value": utils.IntToStr(v.Id),
  28. }
  29. advList = append(advList, tmp)
  30. }
  31. }
  32. resp.AdvData = advList
  33. NewJpushNoticeDb := implement.NewAdvertisingFunctionDb(db.Db)
  34. notice, total, _ := NewJpushNoticeDb.FindUserFeedbackFunctionAndTotal(req.Page, req.Limit)
  35. resp.Total = total
  36. if notice != nil {
  37. for _, v := range *notice {
  38. tmp := md.AdvertisingFunctionList{
  39. Id: utils.Int64ToStr(v.Id),
  40. AdId: utils.IntToStr(v.AdId),
  41. Type: v.Type,
  42. }
  43. noticeList = append(noticeList, tmp)
  44. }
  45. }
  46. resp.List = noticeList
  47. e.OutSuc(c, resp, nil)
  48. return
  49. }
  50. func FunctionDel(c *gin.Context) {
  51. var req *md.ArticleCateDelReq
  52. if err := c.ShouldBindJSON(&req); err != nil {
  53. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  54. return
  55. }
  56. db.Db.In("id", req.Id).Delete(&model.AdvertisingFunction{})
  57. e.OutSuc(c, "success", nil)
  58. return
  59. }
  60. func FunctionSave(c *gin.Context) {
  61. var req *md.AdvertisingFunctionList
  62. if err := c.ShouldBindJSON(&req); err != nil {
  63. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  64. return
  65. }
  66. var data = new(model.AdvertisingFunction)
  67. if utils.StrToInt(req.Id) > 0 {
  68. NewAdvertisingSpaceDb := implement.NewAdvertisingFunctionDb(db.Db)
  69. space, _ := NewAdvertisingSpaceDb.GetAdvertisingFunction(req.Id)
  70. if space == nil {
  71. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  72. return
  73. }
  74. data = space
  75. } else {
  76. db.Db.Insert(data)
  77. }
  78. data.Type = req.Type
  79. data.AdId = utils.StrToInt(req.AdId)
  80. db.Db.Where("id=?", data.Id).Update(data)
  81. e.OutSuc(c, "success", nil)
  82. return
  83. }