蛋蛋星球 后台端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

54 righe
1.5 KiB

  1. package advertising
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  9. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func GetLimit(c *gin.Context) {
  13. NewAdvertisingBasicDb := implement.NewAdvertisingLimitDb(db.Db)
  14. data, _ := NewAdvertisingBasicDb.GetAdvertisingLimit()
  15. if data == nil {
  16. data = &model.AdvertisingLimit{}
  17. db.Db.Insert(data)
  18. }
  19. AdvertisingBase := md.AdvertisingLimit{
  20. Minute: utils.IntToStr(data.Minute),
  21. ImeiNum: utils.IntToStr(data.ImeiNum),
  22. Tip: data.Tip,
  23. PublicImg: data.PublicImg,
  24. PublicImgUrl: svc.GetOssUrl(data.PublicImg),
  25. PublicStr: data.PublicStr,
  26. WithdrawImg: data.WithdrawImg,
  27. WithdrawImgUrl: svc.GetOssUrl(data.WithdrawImg),
  28. WithdrawStr: data.WithdrawStr,
  29. }
  30. e.OutSuc(c, AdvertisingBase, nil)
  31. return
  32. }
  33. func SetLimit(c *gin.Context) {
  34. var req *md.AdvertisingLimit
  35. if err := c.ShouldBindJSON(&req); err != nil {
  36. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  37. return
  38. }
  39. NewAdvertisingBasicDb := implement.NewAdvertisingLimitDb(db.Db)
  40. data, _ := NewAdvertisingBasicDb.GetAdvertisingLimit()
  41. data.Minute = utils.StrToInt(req.Minute)
  42. data.ImeiNum = utils.StrToInt(req.ImeiNum)
  43. data.Tip = req.Tip
  44. data.PublicImg = req.PublicImg
  45. data.PublicStr = req.PublicStr
  46. data.WithdrawImg = req.WithdrawImg
  47. data.WithdrawStr = req.WithdrawStr
  48. db.Db.Where("id=?", data.Id).Update(data)
  49. e.OutSuc(c, "success", nil)
  50. return
  51. }