@@ -0,0 +1,51 @@ | |||
package hdl | |||
import ( | |||
"applet/app/svc" | |||
"github.com/gin-gonic/gin" | |||
) | |||
// AppletApplicationMediumList | |||
// @Summary 媒体列表 | |||
// @Tags 媒体中心------嘉俊 | |||
// @Description 媒体中心-媒体列表 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.AppletApplicationMediumListReq true "请求参数" | |||
// @Success 200 {object} md.AppletApplicationMediumListRes "具体看返回内容---这是data里面的数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/medium/applet/application/medium/list [POST] | |||
func AppletApplicationMediumList(c *gin.Context) { | |||
svc.AppletApplicationMediumList(c) | |||
} | |||
// AppletApplicationList | |||
// @Summary 应用列表 | |||
// @Tags 媒体中心------嘉俊 | |||
// @Description 小程序应用-列表数据 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.AppletApplicationListReq true "请求参数" | |||
// @Success 200 {object} md.AppletApplicationListRes "具体看返回内容---这是data里面的数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/medium/applet/application/list [POST] | |||
func AppletApplicationList(c *gin.Context) { | |||
svc.AppletApplicationList(c) | |||
} | |||
// AppletApplicationAudit | |||
// @Summary 审核 | |||
// @Tags 媒体中心------嘉俊 | |||
// @Description 小程序应用-审核 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.AppletApplicationSaveReq true "请求参数" | |||
// @Success 200 {string} "具体看返回内容" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/medium/applet/application/audit [POST] | |||
func AppletApplicationAudit(c *gin.Context) { | |||
svc.AppletApplicationAudit(c) | |||
} |
@@ -0,0 +1,51 @@ | |||
package hdl | |||
import ( | |||
"applet/app/svc" | |||
"github.com/gin-gonic/gin" | |||
) | |||
// AppletApplicationAdSpaceMediumList | |||
// @Summary 媒体列表 | |||
// @Tags 媒体中心------嘉俊 | |||
// @Description 媒体中心-媒体列表 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.AppletApplicationAdSpaceMediumListReq true "请求参数" | |||
// @Success 200 {object} md.AppletApplicationAdSpaceMediumListRes "具体看返回内容---这是data里面的数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/medium/applet/application/ad/space/list [POST] | |||
func AppletApplicationAdSpaceMediumList(c *gin.Context) { | |||
svc.AppletApplicationAdSpaceMediumList(c) | |||
} | |||
// AppletApplicationAdSpaceList | |||
// @Summary 广告位列表 | |||
// @Tags 媒体中心------嘉俊 | |||
// @Description 小程序应用-广告位列表 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.AppletApplicationAdSpaceListReq true "请求参数" | |||
// @Success 200 {object} md.AppletApplicationAdSpaceListRes "具体看返回内容---这是data里面的数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/medium/applet/application/ad/space/save [POST] | |||
func AppletApplicationAdSpaceList(c *gin.Context) { | |||
svc.AppletApplicationAdSpaceList(c) | |||
} | |||
// AppletApplicationAdSpaceAudit | |||
// @Summary 广告位审核 | |||
// @Tags 媒体中心------嘉俊 | |||
// @Description 小程序应用-广告位审核 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.AppletApplicationAdSpaceSaveReq true "请求参数" | |||
// @Success 200 {string} "具体看返回内容" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/medium/applet/application/ad/space/audit [POST] | |||
func AppletApplicationAdSpaceAudit(c *gin.Context) { | |||
svc.AppletApplicationAdSpaceAudit(c) | |||
} |
@@ -462,3 +462,57 @@ func ShareIndex(c *gin.Context) { | |||
}, nil) | |||
return | |||
} | |||
// SetMob | |||
// @Summary mob设置 | |||
// @Tags 设置中心-基础设置 | |||
// @Description 基础设置-mob设置 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Param args body md.SetMobReq true "请求参数" | |||
// @Success 200 {string} "success" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/setCenter/basic/setOss [POST] | |||
func SetMob(c *gin.Context) { | |||
var req md.SetMobReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
masterId := svc.GetMasterId(c) | |||
engine := db.DBs[masterId] | |||
sysCfgDb := implement2.NewSysCfgDb(engine, masterId) | |||
sysCfgDb.SysCfgUpdate("mob_app_key", req.MobAppKey) | |||
sysCfgDb.SysCfgUpdate("mob_app_secret", req.MobAppSecret) | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
// GetMob | |||
// @Summary mob获取 | |||
// @Tags 设置中心-基础设置 | |||
// @Description 基础设置-mob获取 | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Accept json | |||
// @Produce json | |||
// @Success 200 {object} md.SetOssResp | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/setCenter/basic/getOss [GET] | |||
func GetMob(c *gin.Context) { | |||
masterId := svc.GetMasterId(c) | |||
engine := db.DBs[masterId] | |||
sysCfgDb := implement2.NewSysCfgDb(engine, masterId) | |||
res := sysCfgDb.SysCfgFindWithDb("mob_app_key", "mob_app_secret") | |||
e.OutSuc(c, md.SetMobResp{ | |||
Data: md.SetMobReq{ | |||
MobAppSecret: res["mob_app_secret"], | |||
MobAppKey: res["mob_app_key"], | |||
}, | |||
}, nil) | |||
return | |||
} |
@@ -0,0 +1,52 @@ | |||
package md | |||
type AppletApplicationMediumListReq struct { | |||
Limit string `json:"limit"` | |||
Page string `json:"page" ` | |||
Name string `json:"name" example:"媒体名称"` | |||
Account string `json:"account" example:"媒体账号"` | |||
} | |||
type AppletApplicationMediumListRes struct { | |||
List []AppletApplicationMediumListData `json:"list"` | |||
Total int64 `json:"total"` | |||
} | |||
type AppletApplicationMediumListData struct { | |||
Id string `json:"id" example:"id"` | |||
MediumId string `json:"medium_id" example:"媒体id"` | |||
Name string `json:"name" example:"名称"` | |||
Account string `json:"account" example:"账号"` | |||
ContactName string `json:"contact_name" example:"联系人"` | |||
Phone string `json:"phone" example:"联系电话"` | |||
Count string `json:"count" example:"应用数量"` | |||
} | |||
type AppletApplicationListReq struct { | |||
Limit string `json:"limit"` | |||
Page string `json:"page" ` | |||
Name string `json:"name"` | |||
MediumId string `json:"medium_id" example:"媒体id"` | |||
CooperateState string `json:"cooperate_state" example:"合作状态"` | |||
Platform string `json:"platform"` | |||
} | |||
type AppletApplicationListRes struct { | |||
List []AppletApplicationListData `json:"list"` | |||
Total int64 `json:"total"` | |||
State []SelectData `json:"state"` | |||
CooperateState []SelectData `json:"cooperate_state"` | |||
Platform []SelectData `json:"platform"` | |||
} | |||
type AppletApplicationListData struct { | |||
Id string `json:"id" example:"id"` | |||
Name string `json:"name" example:"应用名称"` | |||
Platform string `json:"platform" example:"平台"` | |||
Memo string `json:"memo" example:"备注"` | |||
Logo string `json:"logo" example:"logo"` | |||
AppId string `json:"app_id" example:"小程序appid"` | |||
OriginalId string `json:"original_id" example:"小程序id"` | |||
State string `json:"state" example:"应用状态 state=3 才能再次编辑"` | |||
CooperateState string `json:"cooperate_state" example:"合作状态"` | |||
} | |||
type AppletApplicationSaveReq struct { | |||
Id string `json:"id" example:"id 多个逗号隔开"` | |||
State string `json:"state" example:"审核状态"` | |||
Memo string `json:"memo" example:"备注"` | |||
} |
@@ -0,0 +1,54 @@ | |||
package md | |||
type AppletApplicationAdSpaceMediumListReq struct { | |||
Limit string `json:"limit"` | |||
Page string `json:"page" ` | |||
Name string `json:"name" example:"媒体名称"` | |||
Account string `json:"account" example:"媒体账号"` | |||
} | |||
type AppletApplicationAdSpaceMediumListRes struct { | |||
List []AppletApplicationAdSpaceMediumListData `json:"list"` | |||
Total int64 `json:"total"` | |||
} | |||
type AppletApplicationAdSpaceMediumListData struct { | |||
Id string `json:"id" example:"id"` | |||
MediumId string `json:"medium_id" example:"媒体id"` | |||
Name string `json:"name" example:"名称"` | |||
Account string `json:"account" example:"账号"` | |||
ContactName string `json:"contact_name" example:"联系人"` | |||
Phone string `json:"phone" example:"联系电话"` | |||
Count string `json:"count" example:"广告位数量"` | |||
} | |||
type AppletApplicationAdSpaceListReq struct { | |||
MediumId string `json:"medium_id" example:"媒体id"` | |||
Limit string `json:"limit"` | |||
Page string `json:"page" ` | |||
Name string `json:"name"` | |||
CooperateState string `json:"cooperate_state" example:"合作状态"` | |||
Platform string `json:"platform"` | |||
} | |||
type AppletApplicationAdSpaceListRes struct { | |||
List []AppletApplicationAdSpaceListData `json:"list"` | |||
Total int64 `json:"total"` | |||
State []SelectData `json:"state"` | |||
CooperateState []SelectData `json:"cooperate_state"` | |||
Platform []SelectData `json:"platform"` | |||
AdType []SelectData `json:"ad_type"` | |||
} | |||
type AppletApplicationAdSpaceListData struct { | |||
Id string `json:"id" example:"id"` | |||
Name string `json:"name" example:"应用名称"` | |||
Platform string `json:"platform" example:"平台"` | |||
Kind string `json:"kind" example:"广告位类型"` | |||
Memo string `json:"memo" example:"备注"` | |||
Logo string `json:"logo" example:"logo"` | |||
AppId string `json:"app_id" example:"小程序appid"` | |||
AdId string `json:"ad_id" example:"广告位id"` | |||
State string `json:"state" example:"应用状态 state=2 才能再次编辑"` | |||
CooperateState string `json:"cooperate_state" example:"合作状态"` | |||
} | |||
type AppletApplicationAdSpaceSaveReq struct { | |||
Id string `json:"id" example:"id 多个逗号隔开"` | |||
State string `json:"state" example:"审核状态"` | |||
Memo string `json:"memo" example:"备注"` | |||
} |
@@ -47,3 +47,11 @@ type ShareIndexResp struct { | |||
AgentDomain string `json:"agent_domain" example:"代理分享地址"` | |||
MediumDomain string `json:"medium_domain" example:"媒体分享地址"` | |||
} | |||
type SetMobReq struct { | |||
MobAppKey string `json:"mob_app_key"` | |||
MobAppSecret string `json:"mob_app_secret"` | |||
} | |||
type SetMobResp struct { | |||
Data SetMobReq `json:"data"` //数据内容 | |||
} |
@@ -0,0 +1,7 @@ | |||
package md | |||
type ImgReqUpload struct { | |||
Dir string `json:"dir"` | |||
FileName string `json:"file_name"` | |||
FileSize int64 `json:"file_size"` // 文件大小, 单位byte | |||
} |
@@ -0,0 +1,6 @@ | |||
package md | |||
type SmsReq struct { | |||
Username string `json:"username"` | |||
Type string `json:"type" example:"手机号登陆:fast_login 注册:register"` | |||
} |
@@ -66,6 +66,7 @@ func route(r *gin.RouterGroup) { | |||
rAgentQualification(r.Group("/agentQualification")) //渠道-资质 | |||
rMediumQualification(r.Group("/mediumQualification")) //媒体-资质 | |||
rSetCenter(r.Group("/setCenter")) //设置中心 | |||
rMedium(r.Group("/medium")) //媒体中心 | |||
} | |||
func rRole(r *gin.RouterGroup) { | |||
@@ -107,6 +108,8 @@ func rSetCenter(r *gin.RouterGroup) { | |||
rBasicSetCenter.GET("/getOss", hdl.GetOss) | |||
rBasicSetCenter.POST("/wxOpenSet", hdl.WxOpenSet) | |||
rBasicSetCenter.GET("/wxOpenGet", hdl.WxOpenGet) | |||
rBasicSetCenter.POST("/setMob", hdl.SetMob) | |||
rBasicSetCenter.GET("/getMob", hdl.GetMob) | |||
} | |||
rAppletSetCenter := r.Group("/applet") | |||
{ | |||
@@ -123,3 +126,12 @@ func rSetCenter(r *gin.RouterGroup) { | |||
} | |||
} | |||
func rMedium(r *gin.RouterGroup) { | |||
r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) //应用管理-媒体列表 | |||
r.POST("/applet/application/list", hdl.AppletApplicationList) //小程序应用-列表数据 | |||
r.POST("/applet/application/audit", hdl.AppletApplicationAudit) //小程序应用-审核 | |||
r.POST("/applet/application/ad/space/medium/list", hdl.AppletApplicationAdSpaceMediumList) //广告管理-媒体列表 | |||
r.POST("/applet/application/ad/space/list", hdl.AppletApplicationAdSpaceList) //小程序应用-广告位列表数据 | |||
r.POST("/applet/application/ad/space/audit", hdl.AppletApplicationAdSpaceAudit) //小程序应用-广告位审核 | |||
} |
@@ -0,0 +1,231 @@ | |||
package svc | |||
import ( | |||
"applet/app/e" | |||
"applet/app/lib/validate" | |||
"applet/app/lib/wechat" | |||
"applet/app/lib/wechat/enum" | |||
"applet/app/md" | |||
"applet/app/utils" | |||
db "code.fnuoos.com/zhimeng/model.git/src" | |||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement" | |||
"github.com/gin-gonic/gin" | |||
"github.com/jinzhu/copier" | |||
"strings" | |||
) | |||
func AppletApplicationMediumList(c *gin.Context) { | |||
var req md.AppletApplicationMediumListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
engine := MasterDb(c) | |||
NewMediumDb := implement.NewMediumDb(engine) | |||
list, total, _ := NewMediumDb.FindSuperAdmin(req.Account, req.Name, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
data := make([]md.AppletApplicationMediumListData, 0) | |||
if len(list) > 0 { | |||
for _, v := range list { | |||
var tmp = md.AppletApplicationMediumListData{ | |||
Id: utils.IntToStr(v.Id), | |||
MediumId: utils.IntToStr(v.MediumId), | |||
Name: v.Memo, | |||
Account: v.Username, | |||
ContactName: "", | |||
Phone: "", | |||
Count: "", | |||
} | |||
NewMediumContactInfoDb := implement2.NewMediumContactInfoDb(db.Db) | |||
infoList, _ := NewMediumContactInfoDb.GetMediumContactInfoList(v.MediumId) | |||
if infoList != nil { | |||
tmp.ContactName = infoList.Name | |||
tmp.Phone = infoList.Phone | |||
} | |||
count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplication{}) | |||
tmp.Count = utils.Int64ToStr(count) | |||
data = append(data, tmp) | |||
} | |||
} | |||
res := md.AppletApplicationMediumListRes{ | |||
List: data, | |||
Total: total, | |||
} | |||
e.OutSuc(c, res, nil) | |||
return | |||
} | |||
func AppletApplicationList(c *gin.Context) { | |||
var req md.AppletApplicationListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
engine := MasterDb(c) | |||
NewAppletApplicationDb := implement.NewAppletApplicationDb(engine) | |||
state := make([]string, 0) | |||
if req.CooperateState != "" { | |||
if req.CooperateState == "0" { | |||
state = []string{"0", "1"} | |||
} else { | |||
state = []string{req.CooperateState} | |||
} | |||
} | |||
appletApplicationList, total, _ := NewAppletApplicationDb.FindAppletApplicationList(req.Name, req.Platform, state, utils.StrToInt(req.MediumId), utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
data := make([]md.AppletApplicationListData, 0) | |||
if len(appletApplicationList) > 0 { | |||
for _, v := range appletApplicationList { | |||
var tmp md.AppletApplicationListData | |||
copier.Copy(&tmp, &v) | |||
tmp.Id = utils.IntToStr(v.Id) | |||
tmp.State = utils.IntToStr(v.State) | |||
if v.State == 1 { | |||
v.State = 0 | |||
} | |||
tmp.CooperateState = utils.IntToStr(v.State) | |||
data = append(data, tmp) | |||
} | |||
} | |||
res := md.AppletApplicationListRes{ | |||
List: data, | |||
Total: total, | |||
Platform: []md.SelectData{ | |||
{ | |||
Name: "微信小程序", | |||
Value: "wx_applet", | |||
}, | |||
}, | |||
State: []md.SelectData{ | |||
{ | |||
Name: "待审核", | |||
Value: "0", | |||
}, | |||
{ | |||
Name: "审核中", | |||
Value: "1", | |||
}, | |||
{ | |||
Name: "审核通过", | |||
Value: "2", | |||
}, | |||
{ | |||
Name: "审核拒绝", | |||
Value: "3", | |||
}, | |||
{ | |||
Name: "封禁中", | |||
Value: "4", | |||
}, | |||
}, | |||
CooperateState: []md.SelectData{ | |||
{ | |||
Name: "未运行", | |||
Value: "0", | |||
}, | |||
{ | |||
Name: "运行中", | |||
Value: "2", | |||
}, | |||
{ | |||
Name: "审核拒绝", | |||
Value: "3", | |||
}, | |||
{ | |||
Name: "封禁中", | |||
Value: "4", | |||
}, | |||
}, | |||
} | |||
e.OutSuc(c, res, nil) | |||
return | |||
} | |||
func AppletApplicationAudit(c *gin.Context) { | |||
var req md.AppletApplicationSaveReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c)) | |||
list, _ := NewAppletApplicationDb.FindAppletApplicationListByIds(strings.Split(req.Id, ",")) | |||
if list != nil { | |||
masterId := GetMasterId(c) | |||
wxOpenThirdPartyAppListDb := implement2.NewWxOpenThirdPartyAppListDb(db.Db) | |||
wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
if wxOpenThirdPartyAppList == nil { | |||
e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") | |||
return | |||
} | |||
wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
userWxAppletListDb := implement2.NewUserWxAppletListDb(db.Db) | |||
userWxAppletList, _ := userWxAppletListDb.GetUserWxAppletList(c.GetString("mid")) | |||
appId := "" | |||
if userWxAppletList != nil { | |||
appId = userWxAppletList.Appid | |||
} | |||
for _, v := range *list { | |||
v.State = utils.StrToInt(req.State) | |||
v.Memo = req.Memo | |||
err := changeWx(c, wxApiService, appId, v.State, v.MediumId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
MasterDb(c).Where("id=?", v.Id).Cols("state,memo").Update(&v) | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func changeWx(c *gin.Context, wxApiService wechat.WxApiService, appId string, state, mediumId int) error { | |||
if state != 2 && state != 4 { | |||
return nil | |||
} | |||
NewAppletApplicationAdSpaceListDb := implement.NewAppletApplicationAdSpaceListDb(MasterDb(c)) | |||
list, _ := NewAppletApplicationAdSpaceListDb.FindAppletApplicationAdSpaceListByMediumId(mediumId) | |||
if list != nil { | |||
for _, v := range *list { //全部恢复 全部封禁 | |||
if v.State != 2 && v.State != 4 { | |||
continue | |||
} | |||
if v.AppId != "" { | |||
onOff := "" | |||
if state == 4 { //禁用 | |||
onOff = enum.AdunitStatusForOff | |||
v.UseState = 2 | |||
v.State = 3 | |||
} | |||
if state == 2 { //恢复 | |||
onOff = enum.AdunitStatusForOn | |||
v.UseState = 1 | |||
v.State = 1 | |||
} | |||
if onOff != "" && v.AdId != "" && appId != "" { | |||
err := wxApiService.AgencyUpdateAdunit(appId, v.AdId, v.Name, enum.AdunitType(v.Kind), enum.AdunitStatus(onOff)) | |||
if err != nil { | |||
return err | |||
} | |||
} | |||
MasterDb(c).Where("id=?", v.Id).Cols("state,use_state").Update(&v) | |||
} | |||
} | |||
} | |||
return nil | |||
} |
@@ -0,0 +1,217 @@ | |||
package svc | |||
import ( | |||
"applet/app/e" | |||
"applet/app/lib/validate" | |||
"applet/app/lib/wechat" | |||
"applet/app/lib/wechat/enum" | |||
"applet/app/md" | |||
"applet/app/utils" | |||
db "code.fnuoos.com/zhimeng/model.git/src" | |||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||
"code.fnuoos.com/zhimeng/model.git/src/model" | |||
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement" | |||
"github.com/gin-gonic/gin" | |||
"strings" | |||
) | |||
func AppletApplicationAdSpaceMediumList(c *gin.Context) { | |||
var req md.AppletApplicationAdSpaceMediumListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
engine := MasterDb(c) | |||
NewMediumDb := implement.NewMediumDb(engine) | |||
list, total, _ := NewMediumDb.FindSuperAdmin(req.Account, req.Name, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
data := make([]md.AppletApplicationAdSpaceMediumListData, 0) | |||
if len(list) > 0 { | |||
for _, v := range list { | |||
var tmp = md.AppletApplicationAdSpaceMediumListData{ | |||
Id: utils.IntToStr(v.Id), | |||
MediumId: utils.IntToStr(v.MediumId), | |||
Name: v.Memo, | |||
Account: v.Username, | |||
ContactName: "", | |||
Phone: "", | |||
Count: "", | |||
} | |||
NewMediumContactInfoDb := implement2.NewMediumContactInfoDb(engine) | |||
infoList, _ := NewMediumContactInfoDb.GetMediumContactInfoList(v.MediumId) | |||
if infoList != nil { | |||
tmp.ContactName = infoList.Name | |||
tmp.Phone = infoList.Phone | |||
} | |||
count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplicationAdSpaceList{}) | |||
tmp.Count = utils.Int64ToStr(count) | |||
data = append(data, tmp) | |||
} | |||
} | |||
res := md.AppletApplicationAdSpaceMediumListRes{ | |||
List: data, | |||
Total: total, | |||
} | |||
e.OutSuc(c, res, nil) | |||
return | |||
} | |||
func AppletApplicationAdSpaceList(c *gin.Context) { | |||
var req md.AppletApplicationAdSpaceListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
engine := MasterDb(c) | |||
NewAppletApplicationDb := implement.NewAppletApplicationAdSpaceListDb(engine) | |||
appletApplicationList, total, _ := NewAppletApplicationDb.FindAppletApplicationAdSpaceList(req.Name, req.Platform, req.CooperateState, utils.StrToInt(req.MediumId), utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
data := make([]md.AppletApplicationAdSpaceListData, 0) | |||
if len(appletApplicationList) > 0 { | |||
for _, v := range appletApplicationList { | |||
var tmp = md.AppletApplicationAdSpaceListData{ | |||
Id: utils.IntToStr(v.AppletApplicationAdSpaceList.Id), | |||
Name: v.AppletApplicationAdSpaceList.Name, | |||
Platform: v.Platform, | |||
Kind: v.Kind, | |||
Memo: v.AppletApplicationAdSpaceList.Memo, | |||
Logo: v.Logo, | |||
AppId: v.AppletApplicationAdSpaceList.AppId, | |||
AdId: v.AppletApplicationAdSpaceList.AdId, | |||
State: utils.IntToStr(v.AppletApplicationAdSpaceList.State), | |||
CooperateState: utils.IntToStr(v.AppletApplicationAdSpaceList.State), | |||
} | |||
data = append(data, tmp) | |||
} | |||
} | |||
res := md.AppletApplicationAdSpaceListRes{ | |||
List: data, | |||
Total: total, | |||
AdType: []md.SelectData{ | |||
{Name: "banner", Value: enum.AdunitTypeForBanner}, | |||
{Name: "激励视频", Value: enum.AdunitTypeForRewardVideo}, | |||
{Name: "插屏广告", Value: enum.AdunitTypeForInterstitial}, | |||
{Name: "视频广告", Value: enum.AdunitTypeForVideoFeeds}, | |||
//{Name: "视频贴片广告", Value: "5"}, | |||
}, | |||
Platform: []md.SelectData{ | |||
{ | |||
Name: "微信小程序", | |||
Value: "wx_applet", | |||
}, | |||
}, | |||
State: []md.SelectData{ | |||
{ | |||
Name: "待审核", | |||
Value: "0", | |||
}, | |||
{ | |||
Name: "审核通过", | |||
Value: "1", | |||
}, | |||
{ | |||
Name: "审核拒绝", | |||
Value: "2", | |||
}, | |||
{ | |||
Name: "封禁中", | |||
Value: "3", | |||
}, | |||
}, | |||
CooperateState: []md.SelectData{ | |||
{ | |||
Name: "未运行", | |||
Value: "0", | |||
}, | |||
{ | |||
Name: "运行中", | |||
Value: "1", | |||
}, | |||
{ | |||
Name: "审核拒绝", | |||
Value: "2", | |||
}, | |||
{ | |||
Name: "封禁中", | |||
Value: "3", | |||
}, | |||
}, | |||
} | |||
e.OutSuc(c, res, nil) | |||
return | |||
} | |||
func AppletApplicationAdSpaceAudit(c *gin.Context) { | |||
var req md.AppletApplicationAdSpaceSaveReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
masterId := GetMasterId(c) | |||
wxOpenThirdPartyAppListDb := implement2.NewWxOpenThirdPartyAppListDb(db.Db) | |||
wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
if wxOpenThirdPartyAppList == nil { | |||
e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") | |||
return | |||
} | |||
wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
userWxAppletListDb := implement2.NewUserWxAppletListDb(db.Db) | |||
userWxAppletList, _ := userWxAppletListDb.GetUserWxAppletList(c.GetString("mid")) | |||
appId := "" | |||
if userWxAppletList != nil { | |||
appId = userWxAppletList.Appid | |||
} | |||
NewAppletApplicationAdSpaceListDb := implement.NewAppletApplicationAdSpaceListDb(MasterDb(c)) | |||
list, _ := NewAppletApplicationAdSpaceListDb.FindAppletApplicationAdSpaceListByIds(strings.Split(req.Id, ",")) | |||
if list != nil { | |||
for _, v := range *list { | |||
v.State = utils.StrToInt(req.State) | |||
v.Memo = req.Memo | |||
if v.AdId == "" && v.State == 1 && appId != "" { | |||
err, v.AdId = wxApiService.AgencyCreateAdunit(appId, v.Name, enum.AdunitType(v.Kind)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
v.UseState = 1 | |||
} | |||
if v.AppId != "" { | |||
onOff := "" | |||
if v.State == 3 && v.UseState != 2 { //禁用 | |||
onOff = enum.AdunitStatusForOff | |||
v.UseState = 2 | |||
} | |||
if v.State == 1 && v.UseState == 2 { //恢复 | |||
onOff = enum.AdunitStatusForOn | |||
v.UseState = 1 | |||
} | |||
if onOff != "" && v.AdId != "" && appId != "" { | |||
err = wxApiService.AgencyUpdateAdunit(appId, v.AdId, v.Name, enum.AdunitType(v.Kind), enum.AdunitStatus(onOff)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
} | |||
MasterDb(c).Where("id=?", v.Id).Cols("state,memo,ad_id,use_state").Update(&v) | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -15,7 +15,7 @@ func MediumQualificationEnterprise(c *gin.Context, req md.MediumQualificationEnt | |||
engine := db.Db | |||
MediumListDb := implement.NewMediumListDb(engine) | |||
MediumList, total, _ := MediumListDb.FindMediumList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
MediumList, total, _ := MediumListDb.FindMediumList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
data := make([]md.MediumQualificationEnterpriseData, 0) | |||
if len(MediumList) > 0 { | |||
for _, v := range MediumList { | |||
@@ -86,7 +86,7 @@ func MediumQualificationEnterpriseAudit(c *gin.Context, req md.MediumQualificati | |||
func MediumQualificationBank(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationBankRes { | |||
engine := db.Db | |||
MediumListDb := implement.NewMediumBankInfoDb(engine) | |||
MediumList, total, _ := MediumListDb.FindMediumBankInfoList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
MediumList, total, _ := MediumListDb.FindMediumBankInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
list := make([]md.MediumQualificationBankData, 0) | |||
if MediumList != nil { | |||
@@ -163,7 +163,7 @@ func MediumQualificationContactInfo(c *gin.Context, req md.MediumQualificationEn | |||
engine := db.Db | |||
MediumListDb := implement.NewMediumContactInfoDb(engine) | |||
MediumList, total, _ := MediumListDb.FindMediumContactInfoList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
MediumList, total, _ := MediumListDb.FindMediumContactInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||
list := make([]md.MediumQualificationContactData, 0) | |||
if MediumList != nil { | |||
@@ -1,78 +0,0 @@ | |||
package svc | |||
import ( | |||
"applet/app/db/implement" | |||
db "code.fnuoos.com/zhimeng/model.git/src" | |||
"github.com/gin-gonic/gin" | |||
"xorm.io/xorm" | |||
"applet/app/md" | |||
"applet/app/utils/cache" | |||
) | |||
// 单挑记录获取 | |||
func SysCfgGet(c *gin.Context, key string) string { | |||
masterId := GetMasterId(c) | |||
eg := db.DBs[masterId] | |||
sysCfgDb := implement.NewSysCfgDb(eg, masterId) | |||
return sysCfgDb.SysCfgGetWithDb(key) | |||
} | |||
// 多条记录获取 | |||
func SysCfgFind(c *gin.Context, keys ...string) map[string]string { | |||
var masterId string | |||
if c == nil { | |||
masterId = "" | |||
} else { | |||
masterId = GetMasterId(c) | |||
} | |||
tmp := SysCfgFindComm(masterId, keys...) | |||
return tmp | |||
} | |||
func SysCfgFindComm(masterId string, keys ...string) map[string]string { | |||
var eg *xorm.Engine | |||
if masterId == "" { | |||
eg = db.Db | |||
} else { | |||
eg = db.DBs[masterId] | |||
} | |||
res := map[string]string{} | |||
//TODO::判断keys长度(大于10个直接查数据库) | |||
sysCfgDb := implement.NewSysCfgDb(eg, masterId) | |||
if len(keys) > 10 { | |||
cfgList, _ := sysCfgDb.SysCfgGetAll() | |||
if cfgList == nil { | |||
return nil | |||
} | |||
for _, v := range *cfgList { | |||
res[v.K] = v.V | |||
} | |||
} else { | |||
for _, key := range keys { | |||
res[key] = sysCfgDb.SysCfgGetWithDb(key) | |||
} | |||
} | |||
return res | |||
} | |||
// 清理系统配置信息 | |||
func SysCfgCleanCache() { | |||
cache.Del(md.KEY_SYS_CFG_CACHE) | |||
} | |||
// 写入系统设置 | |||
func SysCfgSet(c *gin.Context, key, val, memo string) bool { | |||
masterId := GetMasterId(c) | |||
eg := db.DBs[masterId] | |||
sysCfgDb := implement.NewSysCfgDb(eg, masterId) | |||
cfg, err := sysCfgDb.SysCfgGetOne(key) | |||
if err != nil || cfg == nil { | |||
return sysCfgDb.SysCfgInsert(key, val, memo) | |||
} | |||
if memo != "" && cfg.Memo != memo { | |||
cfg.Memo = memo | |||
} | |||
SysCfgCleanCache() | |||
return sysCfgDb.SysCfgUpdate(key, val) | |||
} |
@@ -5,7 +5,7 @@ go 1.18 | |||
//replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models | |||
require ( | |||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240822030431-bf682f937fb0 | |||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240822095043-f18aa08f09b1 | |||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 | |||
github.com/boombuler/barcode v1.0.1 | |||
github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 | |||