|
- package advertising
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "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 List(c *gin.Context) {
- var req *md.AdvertisingListReq
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- var resp md.AdvertisingListResp
- noticeList := make([]md.AdvertisingList, 0)
- resp.AdvData = []map[string]string{
- {"name": "开屏广告", "value": "1"},
- {"name": "插屏广告", "value": "2"},
- {"name": "激励视频", "value": "3"},
- {"name": "信息流广告", "value": "4"},
- {"name": "全屏视频", "value": "5"},
- {"name": "短视频", "value": "6"},
- {"name": "短剧", "value": "7"},
- }
- resp.SelectData = md.AdvertisingPlatform
- NewJpushNoticeDb := implement.NewAdvertisingSpaceDb(db.Db)
- notice, total, _ := NewJpushNoticeDb.FindUserFeedbackCateAndTotal(req.Page, req.Limit, req.Name, req.Kind)
- resp.Total = total
- if notice != nil {
- for _, v := range *notice {
- tmp := md.AdvertisingList{
- Id: utils.IntToStr(v.Id),
- CountingDown: utils.IntToStr(v.CountingDown),
- Kind: utils.IntToStr(v.Kind),
- Info: v.Info,
- Name: v.Name,
- }
- noticeList = append(noticeList, tmp)
- }
- }
- resp.List = noticeList
- e.OutSuc(c, resp, nil)
- return
- }
- func Del(c *gin.Context) {
- var req *md.ArticleCateDelReq
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- db.Db.In("id", req.Id).Delete(&model.AdvertisingSpace{})
- e.OutSuc(c, "success", nil)
- return
- }
- func Save(c *gin.Context) {
- var req *md.AdvertisingSaveReq
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- var data = new(model.AdvertisingSpace)
- if utils.StrToInt(req.Id) > 0 {
- NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(db.Db)
- space, _ := NewAdvertisingSpaceDb.GetAdvertisingSpace(req.Id)
- if space == nil {
- e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
- return
- }
- data = space
- } else {
- db.Db.Insert(data)
- }
- data.Name = req.Name
- data.Info = req.Info
- data.Kind = utils.StrToInt(req.Kind)
- data.CountingDown = utils.StrToInt(req.CountingDown)
- db.Db.Where("id=?", data.Id).Update(data)
- e.OutSuc(c, "success", nil)
- return
- }
|