|
- package svc
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "encoding/json"
- "github.com/gin-gonic/gin"
- )
-
- func Advertising(c *gin.Context) {
- eg := db.Db
-
- var res = md.AdvertisingResp{}
- NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(eg)
- NewAdvertisingBasic, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb()
- if NewAdvertisingBasic != nil {
- var info = make(map[string]interface{})
- json.Unmarshal([]byte(NewAdvertisingBasic.Info), &info)
- res.Basic = md.AdvertisingBasic{
- Info: info,
- AndroidAdIsOpen: utils.IntToStr(NewAdvertisingBasic.AndroidOpenAdIsOpen),
- IosAdIsOpen: utils.IntToStr(NewAdvertisingBasic.IosAdIsOpen),
- AndroidOpenAdIsOpen: utils.IntToStr(NewAdvertisingBasic.AndroidOpenAdIsOpen),
- IosOpenAdIsOpen: utils.IntToStr(NewAdvertisingBasic.IosOpenAdIsOpen),
- Voice: GetOssUrl(NewAdvertisingBasic.Voice),
- }
- }
- NewAdvertisingLimitDb := implement.NewAdvertisingLimitDb(eg)
- NewAdvertisingLimit, _ := NewAdvertisingLimitDb.GetAdvertisingLimit()
- if NewAdvertisingLimit != nil {
- res.Pop = md.AdvertisingLimit{
- PublicImg: GetOssUrl(NewAdvertisingLimit.PublicImg),
- PublicStr: NewAdvertisingLimit.PublicStr,
- WithdrawImg: GetOssUrl(NewAdvertisingLimit.WithdrawImg),
- WithdrawStr: NewAdvertisingLimit.WithdrawStr,
- }
- }
- NewAdvertisingFunctionDb := implement.NewAdvertisingFunctionDb(eg)
- NewAdvertisingFunction, _ := NewAdvertisingFunctionDb.AdvertisingFunctionAll()
- AdvertisingFunctionTmp := make([]md.AdvertisingFunction, 0)
- if NewAdvertisingFunction != nil {
- for _, v := range *NewAdvertisingFunction {
- tmp := md.AdvertisingFunction{
- Name: v.Name,
- Type: v.Type,
- AdId: utils.IntToStr(v.AdId),
- }
- AdvertisingFunctionTmp = append(AdvertisingFunctionTmp, tmp)
- }
- }
- res.Function = AdvertisingFunctionTmp
- NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(eg)
- NewAdvertisingSpace, _ := NewAdvertisingSpaceDb.AdvertisingSpaceAll()
- NewAdvertisingSpaceTmp := make([]md.AdvertisingSpace, 0)
- if NewAdvertisingSpace != nil {
- for _, v := range *NewAdvertisingSpace {
- var info = make(map[string]interface{})
- json.Unmarshal([]byte(v.Info), &info)
- tmp := md.AdvertisingSpace{
- Id: utils.IntToStr(v.Id),
- Name: v.Name,
- Kind: utils.IntToStr(v.Kind),
- Info: info,
- CountingDown: utils.IntToStr(v.CountingDown),
- }
- NewAdvertisingSpaceTmp = append(NewAdvertisingSpaceTmp, tmp)
- }
- }
- res.Space = NewAdvertisingSpaceTmp
- e.OutSuc(c, res, nil)
- return
- }
- func AdvertisingDetail(c *gin.Context) {
- eg := db.Db
- var req md.AdvertisingReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- var res = md.AdvertisingSpace{}
- NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(eg)
- NewAdvertisingSpace, _ := NewAdvertisingSpaceDb.GetAdvertisingSpace(req.Id)
- if NewAdvertisingSpace != nil {
- var info = make(map[string]interface{})
- json.Unmarshal([]byte(NewAdvertisingSpace.Info), &info)
- tmp := md.AdvertisingSpace{
- Id: utils.IntToStr(NewAdvertisingSpace.Id),
- Name: NewAdvertisingSpace.Name,
- Kind: utils.IntToStr(NewAdvertisingSpace.Kind),
- Info: info,
- CountingDown: utils.IntToStr(NewAdvertisingSpace.CountingDown),
- }
- res = tmp
- }
- e.OutSuc(c, res, nil)
- return
- }
|