|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package advertising
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "applet/app/svc"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
- "github.com/gin-gonic/gin"
- )
-
- func GetLimit(c *gin.Context) {
- NewAdvertisingBasicDb := implement.NewAdvertisingLimitDb(db.Db)
- data, _ := NewAdvertisingBasicDb.GetAdvertisingLimit()
- if data == nil {
- data = &model.AdvertisingLimit{}
- db.Db.Insert(data)
- }
- AdvertisingBase := md.AdvertisingLimit{
- Minute: utils.IntToStr(data.Minute),
- ImeiNum: utils.IntToStr(data.ImeiNum),
- Tip: data.Tip,
- PublicImg: data.PublicImg,
- PublicImgUrl: svc.GetOssUrl(data.PublicImg),
- PublicStr: data.PublicStr,
- WithdrawImg: data.WithdrawImg,
- WithdrawImgUrl: svc.GetOssUrl(data.WithdrawImg),
- WithdrawStr: data.WithdrawStr,
- }
- e.OutSuc(c, AdvertisingBase, nil)
- return
- }
- func SetLimit(c *gin.Context) {
- var req *md.AdvertisingLimit
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- NewAdvertisingBasicDb := implement.NewAdvertisingLimitDb(db.Db)
- data, _ := NewAdvertisingBasicDb.GetAdvertisingLimit()
- data.Minute = utils.StrToInt(req.Minute)
- data.ImeiNum = utils.StrToInt(req.ImeiNum)
- data.Tip = req.Tip
- data.PublicImg = req.PublicImg
- data.PublicStr = req.PublicStr
- data.WithdrawImg = req.WithdrawImg
- data.WithdrawStr = req.WithdrawStr
- db.Db.Where("id=?", data.Id).Update(data)
- e.OutSuc(c, "success", nil)
- return
- }
|