Pārlūkot izejas kodu

应用审核

广告位审核
master
huangjiajun pirms 3 mēnešiem
vecāks
revīzija
2e1929f46c
20 mainītis faili ar 930 papildinājumiem un 92 dzēšanām
  1. +64
    -0
      app/enum/adunit_enum.go
  2. +36
    -0
      app/hdl/hdl_applet_application.go
  3. +36
    -0
      app/hdl/hdl_applet_application_ad_space_list.go
  4. +154
    -0
      app/hdl/hdl_login.go
  5. +112
    -0
      app/hdl/hdl_qiniuyun.go
  6. +75
    -0
      app/hdl/hdl_sms.go
  7. +6
    -0
      app/md/comm.go
  8. +35
    -0
      app/md/md__applet_application.go
  9. +35
    -0
      app/md/md__applet_application_ad_space_list.go
  10. +10
    -0
      app/md/md_login.go
  11. +7
    -0
      app/md/qiniuyun.go
  12. +6
    -0
      app/md/sms.go
  13. +15
    -4
      app/router/router.go
  14. +159
    -0
      app/svc/svc_applet_application.go
  15. +123
    -0
      app/svc/svc_applet_application_ad_space.go
  16. +1
    -1
      app/svc/svc_master.go
  17. +19
    -0
      app/svc/svc_sms.go
  18. +0
    -78
      app/svc/svc_sys_cfg_get.go
  19. +27
    -0
      app/utils/rand.go
  20. +10
    -9
      go.mod

+ 64
- 0
app/enum/adunit_enum.go Parādīt failu

@@ -0,0 +1,64 @@
package enum

type AdunitType string //广告单元类型

const (
AdunitTypeForBanner = "SLOT_ID_WEAPP_BANNER"
AdunitTypeForRewardVideo = "SLOT_ID_WEAPP_REWARD_VIDEO"
AdunitTypeForInterstitial = "SLOT_ID_WEAPP_INTERSTITIAL"
AdunitTypeForVideoFeeds = "SLOT_ID_WEAPP_VIDEO_FEEDS"
AdunitTypeForVideoBegin = "SLOT_ID_WEAPP_VIDEO_BEGIN"
)

func (gt AdunitType) String() string {
switch gt {
case AdunitTypeForBanner:
return "小程序banner"
case AdunitTypeForRewardVideo:
return "小程序激励视频"
case AdunitTypeForInterstitial:
return "小程序插屏广告"
case AdunitTypeForVideoFeeds:
return "小程序视频广告"
case AdunitTypeForVideoBegin:
return "小程序视频贴片广告"
default:
return "未知"
}
}

type AdunitStatus string //广告单元开关状态

const (
AdunitStatusForOn = "AD_UNIT_STATUS_ON"
AdunitStatusForOff = "AD_UNIT_STATUS_OFF"
)

func (gt AdunitStatus) String() string {
switch gt {
case AdunitStatusForOn:
return "开通"
case AdunitStatusForOff:
return "关闭"
default:
return "未知"
}
}

type SetCoverAdposStatus int32 //广告单元开关状态

const (
SetCoverAdposStatusForOn = 1
SetCoverAdposStatusForOff = 4
)

func (gt SetCoverAdposStatus) String() string {
switch gt {
case SetCoverAdposStatusForOn:
return "开通"
case SetCoverAdposStatusForOff:
return "关闭"
default:
return "未知"
}
}

+ 36
- 0
app/hdl/hdl_applet_application.go Parādīt failu

@@ -0,0 +1,36 @@
package hdl

import (
"applet/app/svc"
"github.com/gin-gonic/gin"
)

// 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/application/applet/list [POST]
func AppletApplicationList(c *gin.Context) {
svc.AppletApplicationList(c)
}

// AppletApplicationSave
// @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/application/applet/save [POST]
func AppletApplicationSave(c *gin.Context) {
svc.AppletApplicationSave(c)
}

+ 36
- 0
app/hdl/hdl_applet_application_ad_space_list.go Parādīt failu

@@ -0,0 +1,36 @@
package hdl

import (
"applet/app/svc"
"github.com/gin-gonic/gin"
)

// 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/applet/application/ad/space/save [POST]
func AppletApplicationAdSpaceList(c *gin.Context) {
svc.AppletApplicationAdSpaceList(c)
}

// AppletApplicationAdSpaceSave
// @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/applet/application/ad/space/save [POST]
func AppletApplicationAdSpaceSave(c *gin.Context) {
svc.AppletApplicationAdSpaceSave(c)
}

+ 154
- 0
app/hdl/hdl_login.go Parādīt failu

@@ -8,8 +8,12 @@ import (
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
"code.fnuoos.com/zhimeng/model.git/src/implement"
model2 "code.fnuoos.com/zhimeng/model.git/src/model"
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement"
"code.fnuoos.com/zhimeng/model.git/src/super/model"
"fmt"
"github.com/gin-gonic/gin"
"time"
)

// Login 登陆
@@ -58,3 +62,153 @@ func Login(c *gin.Context) {
}, nil)
return
}

// LoginPhone 手机号登陆
// @Summary 手机号登陆
// @Tags ADMIN
// @Description 手机号登入
// @Accept json
// @Produce json
// @Param req body md.LoginPhoneReq true "用户名、验证码"
// @Success 200 {object} md.LoginResponse "token"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/login [post]
func LoginPhone(c *gin.Context) {
var req md.LoginPhoneReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := db.DBs[svc.GetMasterId(c)]
check, err := svc.SmsCheck(c, req.UserName, req.Captcha)
if check == false {
e.OutErr(c, 400, e.NewErr(400, err.Error()))
return
}
adminDb := implement.NewMediumDb(engine)
admin, err := adminDb.GetMediumByUsername(req.UserName)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
return
}
if admin == nil {
e.OutErr(c, e.ERR_NO_DATA, "账号不存在!")
return
}
ip := utils.GetIP(c.Request)
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(admin.Id))
token, err := svc.HandleLoginToken(key, admin)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
e.OutSuc(c, md.LoginResponse{
Token: token,
}, nil)
return
}

// Register 手机号注册
// @Summary 手机号注册
// @Tags ADMIN
// @Description 手机号注册
// @Accept json
// @Produce json
// @Param req body md.LoginReq true "用户名、验证码"
// @Success 200 {object} md.LoginResponse "token"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/login [post]
func Register(c *gin.Context) {
var req md.RegisterReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := db.DBs[svc.GetMasterId(c)]
check, err := svc.SmsCheck(c, req.UserName, req.Captcha)
if check == false {
e.OutErr(c, 400, e.NewErr(400, err.Error()))
return
}
now := time.Now()
//1、判断当前账号是否已存在
mediumDb := implement.NewMediumDb(engine)
medium, err := mediumDb.GetMediumByUsername(req.UserName)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
return
}
if medium != nil {
e.OutErr(c, e.ERR_NO_DATA, "账号已存在!")
return
}
//2、生成 medium_list 记录
mediumListDb := implement2.NewMediumListDb(db.Db)
mediumId := utils.GenerateUniqueRandomNumbers(8)
mediumList := model.MediumList{
Uuid: utils.StrToInt(c.GetString("mid")),
MediumId: utils.StrToInt(mediumId),
Kind: 1,
CompanyName: "",
CompanyAbbreviation: "",
UnifiedSocialCreditCode: "",
BusinessLicenseImgUrl: "",
LegalRepresentative: "",
CountryRegionId: 1,
CountryRegion: "",
RegisteredAddressProvinceId: 0,
RegisteredAddressCityId: 0,
RegisteredAddressCountyId: 0,
RegisteredAddress: "",
BusinessLicenseAddress: "",
CertificateValidity: "",
State: 0,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
insertAffected, err := mediumListDb.MediumListInsert(&mediumList)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if insertAffected <= 0 {
e.OutErr(c, e.ERR_DB_ORM, "生成 medium_list 记录失败")
return
}
//3、新增 medium 记录
mediumModel := model2.Medium{
MediumId: utils.StrToInt(mediumId),
Username: req.UserName,
Password: utils.Md5(req.PassWord),
State: 1,
IsSuperAdministrator: 1,
Memo: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
insertAffected, err = mediumDb.MediumInsert(&mediumModel)
if err != nil {
return
}
if insertAffected <= 0 {
e.OutErr(c, e.ERR_DB_ORM, "新增 medium 记录失败")
return
}
ip := utils.GetIP(c.Request)
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(mediumModel.Id))
token, err := svc.HandleLoginToken(key, &mediumModel)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
e.OutSuc(c, md.LoginResponse{
Token: token,
}, nil)
return
}

+ 112
- 0
app/hdl/hdl_qiniuyun.go Parādīt failu

@@ -0,0 +1,112 @@
package hdl

import (
"applet/app/db/implement"
"applet/app/e"
"applet/app/lib/validate"
"applet/app/md"
"applet/app/svc"
"applet/app/utils"
"applet/app/utils/logx"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
qiniu "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/qiniuyun"
"fmt"
"github.com/gin-gonic/gin"
)

// ImgReqUpload
// @Summary 七牛云上传
// @Tags 七牛云
// @Description 七牛云-七牛云上传
// @param Authorization header string false "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.ImgReqUpload true "请求参数"
// @Success 200 {string} "success"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/qiniuyun/upload [POST]
func ImgReqUpload(c *gin.Context) {
var args md.ImgReqUpload
err := c.ShouldBindJSON(&args)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
// 文件名名称

if args.FileSize < 1 || args.FileName == "" {
logx.Warn(err)
e.OutErr(c, e.ERR_INVALID_ARGS)
return
}
scheme := "http"
if c.Request.TLS != nil {
scheme = "https"
}
// 拼装回调地址
callbackUrl := scheme + "://" + c.Request.Host + "/api/qiniuyun/callback?master_id=" + c.GetString("mid")
NewSysCfgDb := implement.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid"))
stgInfo := NewSysCfgDb.SysCfgFindWithDb(
md2.KEY_CFG_FILE_BUCKET,
md2.KEY_CFG_FILE_HOST,
md2.KEY_CFG_FILE_AK,
md2.KEY_CFG_FILE_SK,
md2.KEY_CFG_FILE_PVD,
md2.KEY_CFG_FILE_REGION,
md2.KEY_CFG_FILE_MAX_SIZE,
md2.KEY_CFG_FILE_EXT,
md2.KEY_CFG_FILE_SCHEME,
md2.KEY_CFG_FILE_AVATAR_THUMBNAIL,
)
if stgInfo == nil {
e.OutErr(c, 400, e.NewErr(400, "配置未设置"))
return
}
res, err := qiniu.ImgReqUpload(stgInfo, "", args.Dir, args.FileName, callbackUrl, args.FileSize)
if err != nil {
e.OutErr(c, 400, err.Error())
return
}
my := utils.SerializeStr(res)
var my1 map[string]interface{}
utils.Unserialize([]byte(my), &my1)
e.OutSuc(c, my1, nil)
return
}
func FileImgCallback(c *gin.Context) {
masterID := c.Query("master_id")
c.Set("mid", masterID)
var args md2.FileCallback
err := c.ShouldBindJSON(&args)

if err != nil {
fmt.Println("七牛云上传回调参数错误:>>>>>>>>>>", err)
e.OutErr(c, 200, e.ERR_INVALID_ARGS)
return
}
res := map[string]interface{}{
"name": args.FileName,
"fname": getFileNameURL(c, args.FileName),
"fsize": args.FileSize,
"provider": args.Provider,
"uid": args.Uid,
"dir_id": args.DirId,
"w": args.Width,
"h": args.Height,
}
e.OutSuc(c, &res, nil)
}

func getFileNameURL(c *gin.Context, filename string) string {
NewSysCfgDb := implement.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid"))

protocol := NewSysCfgDb.SysCfgGetWithDb("file_bucket_scheme")
domain := NewSysCfgDb.SysCfgGetWithDb("file_bucket_host")
imgformat := NewSysCfgDb.SysCfgGetWithDb("file_avatar_thumbnail")
if protocol != "" && domain != "" && imgformat != "" {
return protocol + "://" + domain + "/" + filename
}
return filename
}

+ 75
- 0
app/hdl/hdl_sms.go Parādīt failu

@@ -0,0 +1,75 @@
package hdl

import (
implement2 "applet/app/db/implement"
"applet/app/e"
"applet/app/lib/validate"
"applet/app/md"
"applet/app/svc"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/sms"
"code.fnuoos.com/zhimeng/model.git/src/implement"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
)

// Sms
// @Summary 短信发送
// @Tags 短信
// @Description 短信-短信发送
// @param Authorization header string false "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.SmsReq true "请求参数"
// @Success 200 {string} "success"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/sms [POST]
func Sms(c *gin.Context) {
var args md.SmsReq
err := c.ShouldBindJSON(&args)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
if args.Type == "fast_login" {
NewAdminDb := implement.NewAdminDb(svc.MasterDb(c))
admin, _ := NewAdminDb.GetAdminByUserName(args.Phone)
if admin == nil {
e.OutErr(c, 400, e.NewErr(400, "账号未注册"))
return
}
}
NewSysCfgDb := implement2.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid"))
key := NewSysCfgDb.SysCfgGetWithDb("mob_app_key")
if key == "" {
e.OutErr(c, 400, e.NewErr(400, "appkey不存在"))
return
}
where := map[string]interface{}{
"appkey": key,
"zone": "86",
"phone": args.Phone,
}
send, err := sms.SmsMobApiSend(where)
if err != nil {
e.OutErr(c, 400, err.Error())
return
}
status := gjson.Get(send, "status").Int()
msg := gjson.Get(send, "error").String()
if status == 471 {
e.OutErr(c, 400, e.NewErr(400, "发送的ip不在白名单中"))
return
}
if status == 406 {
e.OutErr(c, 400, e.NewErr(400, "appkey不存在"))
return
}
if status != 200 {
e.OutErr(c, 400, e.NewErr(400, msg))
return
}
e.OutSuc(c, "success", nil)
return
}

+ 6
- 0
app/md/comm.go Parādīt failu

@@ -0,0 +1,6 @@
package md

type SelectData struct {
Name string `json:"name" example:"名称"`
Value string `json:"value" example:"值"`
}

+ 35
- 0
app/md/md__applet_application.go Parādīt failu

@@ -0,0 +1,35 @@
package md

type AppletApplicationListReq struct {
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name"`
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"`
Name string `json:"name" example:"应用名称"`
Platform string `json:"platform" example:"平台 微信小程序:wx_applet"`
Logo string `json:"logo" example:"logo"`
AppId string `json:"app_id" example:"小程序appid"`
OriginalId string `json:"original_id" example:"小程序id"`
}

+ 35
- 0
app/md/md__applet_application_ad_space_list.go Parādīt failu

@@ -0,0 +1,35 @@
package md

type AppletApplicationAdSpaceListReq struct {
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"`
Application []map[string]string `json:"application"`
}
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 {
Name string `json:"name" example:"应用名称"`
AppId string `json:"app_id" example:"小程序appid"`
Kind string `json:"kind" example:"广告类型"`
}

+ 10
- 0
app/md/md_login.go Parādīt failu

@@ -9,3 +9,13 @@ type LoginReq struct {
type LoginResponse struct {
Token string `json:"token"`
}

type LoginPhoneReq struct {
UserName string `json:"username" binding:"required" example:"登录账号"`
Captcha string `json:"captcha" binding:"required" example:"验证码"`
}
type RegisterReq struct {
UserName string `json:"username" binding:"required" example:"登录账号"`
Captcha string `json:"captcha" binding:"required" example:"验证码"`
PassWord string `json:"password" binding:"required" example:"登录密码"`
}

+ 7
- 0
app/md/qiniuyun.go Parādīt failu

@@ -0,0 +1,7 @@
package md

type ImgReqUpload struct {
Dir string `json:"dir"`
FileName string `json:"file_name"`
FileSize int64 `json:"file_size"` // 文件大小, 单位byte
}

+ 6
- 0
app/md/sms.go Parādīt failu

@@ -0,0 +1,6 @@
package md

type SmsReq struct {
Phone string `json:"phone"`
Type string `json:"type" example:"手机号登陆:fast_login 注册:register"`
}

+ 15
- 4
app/router/router.go Parādīt failu

@@ -51,18 +51,23 @@ func Init() *gin.Engine {

func route(r *gin.RouterGroup) {
r.GET("/test", hdl.Demo)
r.Use(mw.DB) // 以下接口需要用到数据库
r.POST("/qiniuyun/callback", hdl.FileImgCallback) //七牛云回调
r.Use(mw.DB) // 以下接口需要用到数据库
{
r.POST("/login", hdl.Login)
r.POST("/login/phone", hdl.LoginPhone)
r.POST("/register", hdl.Register)
}
r.Use(mw.CheckBody) //body参数转换
r.Use(mw.CheckSign) //签名校验

{
r.POST("/qiniuyun/upload", hdl.ImgReqUpload) //七牛云上传
r.POST("/sms", hdl.Sms) //短信发送
}
r.Use(mw.Auth) // 以下接口需要JWT验证
rRole(r.Group("/role")) //权限管理
rQualification(r.Group("/qualification")) //资质
rApplication(r.Group("/application")) //应用管理
}

func rRole(r *gin.RouterGroup) {
@@ -88,3 +93,9 @@ func rQualification(r *gin.RouterGroup) {
r.POST("/bank/save", hdl.QualificationBankSave) //资质认证-银行资质保存
r.POST("/contact/save", hdl.QualificationContactSave) //资质认证-联系方式保存
}
func rApplication(r *gin.RouterGroup) {
r.POST("/applet/list", hdl.AppletApplicationList) //小程序应用-列表数据
r.POST("/applet/save", hdl.AppletApplicationSave) //小程序应用-新增或保存
r.POST("/applet/ad/space/list", hdl.AppletApplicationAdSpaceList) //小程序应用-广告位列表数据
r.POST("/applet/ad/space/save", hdl.AppletApplicationAdSpaceSave) //小程序应用-广告位新增
}

+ 159
- 0
app/svc/svc_applet_application.go Parādīt failu

@@ -0,0 +1,159 @@
package svc

import (
"applet/app/e"
"applet/app/lib/validate"
"applet/app/md"
"applet/app/utils"
"code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/model"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"time"
)

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}
}
}
user := GetUser(c)
appletApplicationList, total, _ := NewAppletApplicationDb.FindAppletApplicationList(req.Name, req.Platform, state, user.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 AppletApplicationSave(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
}
if req.AppId == "" {
e.OutErr(c, 400, e.NewErr(400, "请填写小程序appid"))
return
}
user := GetUser(c)
engine := MasterDb(c)
NewAppletApplicationDb := implement.NewAppletApplicationDb(engine)
var data *model.AppletApplication
if utils.StrToInt(req.Id) > 0 {
data, _ = NewAppletApplicationDb.GetAppletApplicationList(utils.StrToInt(req.Id))
if data == nil {
e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
return
}
if data.State != 3 {
e.OutErr(c, 400, e.NewErr(400, "您已提交审核,不能再次修改!"))
return
}
tmp, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(req.AppId)
if tmp != nil && tmp.Id != data.Id {
e.OutErr(c, 400, e.NewErr(400, "该小程序已提交过"))
return
}
} else {
tmp, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(req.AppId)
if tmp != nil {
e.OutErr(c, 400, e.NewErr(400, "该小程序已提交过"))
return
}
data = &model.AppletApplication{
Platform: req.Platform,
State: 0,
MediumId: user.MediumId,
AppId: req.AppId,
CreateAt: time.Now(),
}
engine.Insert(data)
}
data.UpdateAt = time.Now()
data.State = 0
data.Name = req.Name
data.Logo = req.Logo
data.AppId = req.AppId
data.OriginalId = req.OriginalId
engine.Where("id=?", data.Id).Update(data)
e.OutSuc(c, "success", nil)
return
}

+ 123
- 0
app/svc/svc_applet_application_ad_space.go Parādīt failu

@@ -0,0 +1,123 @@
package svc

import (
"applet/app/e"
"applet/app/enum"
"applet/app/lib/validate"
"applet/app/md"
"applet/app/utils"
"code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/model"
"github.com/gin-gonic/gin"
"time"
)

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
}
user := GetUser(c)
engine := MasterDb(c)

NewAppletApplicationDb := implement.NewAppletApplicationAdSpaceListDb(engine)
appletApplicationList, total, _ := NewAppletApplicationDb.FindAppletApplicationAdSpaceList(req.Name, req.Platform, req.CooperateState, user.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.AdId,
State: utils.IntToStr(v.AppletApplicationAdSpaceList.State),
CooperateState: utils.IntToStr(v.AppletApplicationAdSpaceList.State),
}
data = append(data, tmp)
}
}
applicationDb := implement.NewAppletApplicationDb(engine)
list, _, _ := applicationDb.FindAppletApplicationList("", req.Platform, []string{"2"}, user.MediumId, 0, 0)
var application = make([]map[string]string, 0)
for _, v := range list {
tmp := map[string]string{
"app_id": v.AppId,
"logo": v.Logo,
"name": v.Name,
"state_str": "运行中",
}
application = append(application, tmp)
}
res := md.AppletApplicationAdSpaceListRes{
List: data,
Total: total,
Application: application,
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 AppletApplicationAdSpaceSave(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
}
if req.AppId == "" {
e.OutErr(c, 400, e.NewErr(400, "请填写小程序appid"))
return
}
NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
app, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(req.AppId)
if app == nil {
e.OutErr(c, 400, e.NewErr(400, "应用不存在"))
return
}

user := GetUser(c)
engine := MasterDb(c)
data := &model.AppletApplicationAdSpaceList{
Name: req.Name,
AppId: req.AppId,
Kind: req.Kind,
State: 0,
MediumId: user.MediumId,
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
engine.Insert(data)
e.OutSuc(c, "success", nil)
return
}

+ 1
- 1
app/svc/svc_master.go Parādīt failu

@@ -21,7 +21,7 @@ func GetMasterId(c *gin.Context) (masterId string) {
//TODO::通过域名查找masterId
host := c.Request.Host
userAppDomainDb := implement.NewUserAppDomainDb(db.Db)
userAppDomain, err := userAppDomainDb.GetMediumAppDomainByHost(host)
userAppDomain, err := userAppDomainDb.GetAppDomainByHost(host)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
return


+ 19
- 0
app/svc/svc_sms.go Parādīt failu

@@ -0,0 +1,19 @@
package svc

import (
"applet/app/db/implement"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/sms"
"github.com/gin-gonic/gin"
)

func SmsCheck(c *gin.Context, phone, captcha string) (bool, error) {
send := map[string]interface{}{
"phone": phone,
"zone": "86",
"code": captcha,
}
NewSysCfgDb := implement.NewSysCfgDb(MasterDb(c), c.GetString("mid"))
key := NewSysCfgDb.SysCfgGetWithDb("mob_app_key")
send["appkey"] = key
return sms.SMSMobCheck(send)
}

+ 0
- 78
app/svc/svc_sys_cfg_get.go Parādīt failu

@@ -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)
}

+ 27
- 0
app/utils/rand.go Parādīt failu

@@ -5,6 +5,7 @@ import (
"fmt"
"math/big"
"math/rand"
"strconv"
"time"
)

@@ -29,3 +30,29 @@ func RandNum() string {
seed := time.Now().UnixNano() + rand.Int63()
return fmt.Sprintf("%05v", rand.New(rand.NewSource(seed)).Int31n(1000000))
}
func GenerateUniqueRandomNumbers(n int) string {
rand.Seed(time.Now().UnixNano()) // 初始化随机种子
numbers := make([]int, n) // 创建一个切片来保存随机数
for i := range numbers {
j := 0
for {
b := rand.Intn(10) // 生成0-9之间的随机数
numbers[i] = b
for _, num := range numbers[:i] {
if num == b {
j++
break
}
}
if j == 0 {
break
}
}
}

var numbersStr string
for _, v := range numbers {
numbersStr += strconv.Itoa(v)
}
return numbersStr
}

+ 10
- 9
go.mod Parādīt failu

@@ -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.20240821082038-bfd73b32452e
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
@@ -28,14 +28,17 @@ require (
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.8.12
github.com/syyongx/php2go v0.9.8
github.com/tidwall/gjson v1.7.4
github.com/tidwall/gjson v1.14.1
go.uber.org/zap v1.16.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v2 v2.4.0
xorm.io/xorm v1.3.1
xorm.io/xorm v1.3.2
)

require github.com/jinzhu/copier v0.4.0
require (
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240821062104-50d608c7fd6a
github.com/jinzhu/copier v0.4.0
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
@@ -58,7 +61,7 @@ require (
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gookit/color v1.3.8 // indirect
github.com/gorilla/context v1.1.1 // indirect
@@ -73,15 +76,13 @@ require (
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/onsi/ginkgo v1.15.0 // indirect
github.com/onsi/gomega v1.10.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
github.com/tidwall/match v1.0.3 // indirect
github.com/tidwall/pretty v1.1.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
go.uber.org/atomic v1.7.0 // indirect


Notiek ielāde…
Atcelt
Saglabāt