dengbiao 2 月之前
父節點
當前提交
173799abb9
共有 5 個文件被更改,包括 46 次插入48 次删除
  1. +2
    -2
      app/router/router.go
  2. +37
    -40
      app/svc/svc_data_center_original_data.go
  3. +2
    -3
      app/svc/svc_db.go
  4. +4
    -2
      app/svc/svc_medium_agent.go
  5. +1
    -1
      etc/cfg.yml

+ 2
- 2
app/router/router.go 查看文件

@@ -63,12 +63,12 @@ func route(r *gin.RouterGroup) {
r.Use(mw.DB) // 以下接口需要用到数据库
{
r.POST("/login", hdl.Login)
r.POST("/loginInfo", hdl.LoginInfo)
}
r.Use(mw.CheckBody) // body参数转换
r.Use(mw.CheckSign) // 签名校验

r.Use(mw.Auth) // 以下接口需要JWT验证
r.Use(mw.Auth) // 以下接口需要JWT验证
r.GET("/loginInfo", hdl.LoginInfo)
rRole(r.Group("/role")) // 权限管理
rDataCenter(r.Group("/dataCenter")) // 数据中心
rSmsCenter(r.Group("/smsCenter")) // 短信中心


+ 37
- 40
app/svc/svc_data_center_original_data.go 查看文件

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

func DataCenterOriginalDataList(c *gin.Context, req md.DataCenterOriginalDataReq) md.DataCenterOriginalDataRes {
@@ -61,37 +58,37 @@ func DataCenterOriginalDataList(c *gin.Context, req md.DataCenterOriginalDataReq
// 应用
func GetAppletId(c *gin.Context, name, platform string) string {
mediumId := ""
sess := MasterDb(c).Where("1=1")
if name != "" || platform != "" {
ids := []string{"-1"}
var tmp []model2.AppletApplication
if name != "" {
sess.And("name like ? ", "%"+name+"%")
}
if platform != "" {
sess.And("platform = ? ", platform)
}
sess.Find(&tmp)
for _, v := range tmp {
ids = append(ids, utils.IntToStr(v.MediumId))
}
mediumId = strings.Join(ids, ",")
}
// sess := MasterDb(c).Where("1=1")
// if name != "" || platform != "" {
// ids := []string{"-1"}
// var tmp []model2.AppletApplication
// if name != "" {
// sess.And("name like ? ", "%"+name+"%")
// }
// if platform != "" {
// sess.And("platform = ? ", platform)
// }
// sess.Find(&tmp)
// for _, v := range tmp {
// ids = append(ids, utils.IntToStr(v.MediumId))
// }
// mediumId = strings.Join(ids, ",")
// }
return mediumId
}

// 广告位
func GetSlotId(c *gin.Context, state string) string {
mediumId := ""
if state != "" {
ids := []string{"-1"}
var tmp []model2.AppletApplicationAdSpaceList
MasterDb(c).Where("state=?", state).Find(&tmp)
for _, v := range tmp {
ids = append(ids, utils.IntToStr(v.MediumId))
}
mediumId = strings.Join(ids, ",")
}
// if state != "" {
// ids := []string{"-1"}
// var tmp []model2.AppletApplicationAdSpaceList
// MasterDb(c).Where("state=?", state).Find(&tmp)
// for _, v := range tmp {
// ids = append(ids, utils.IntToStr(v.MediumId))
// }
// mediumId = strings.Join(ids, ",")
// }
return mediumId
}

@@ -101,12 +98,12 @@ func GetAppletInfo(c *gin.Context, id string) map[string]string {
"platform": "",
"name": "",
}
NewAppletApplicationDb := implement2.NewAppletApplicationDb(MasterDb(c))
data, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(id)
if data != nil {
res["platform"] = data.Platform
res["name"] = data.Name
}
// NewAppletApplicationDb := implement2.NewAppletApplicationDb(MasterDb(c))
// data, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(id)
// if data != nil {
// res["platform"] = data.Platform
// res["name"] = data.Name
// }
return res
}

@@ -116,11 +113,11 @@ func GetSlotInfo(c *gin.Context, id string) map[string]string {
"state": "",
"name": "",
}
NewAppletApplicationAdSpaceListDb := implement2.NewAppletApplicationAdSpaceListDb(MasterDb(c))
data, _ := NewAppletApplicationAdSpaceListDb.GetAppletApplicationAdSpaceListByAdId(id)
if data != nil {
res["name"] = data.Name
res["state"] = utils.IntToStr(data.State)
}
// NewAppletApplicationAdSpaceListDb := implement2.NewAppletApplicationAdSpaceListDb(MasterDb(c))
// data, _ := NewAppletApplicationAdSpaceListDb.GetAppletApplicationAdSpaceListByAdId(id)
// if data != nil {
// res["name"] = data.Name
// res["state"] = utils.IntToStr(data.State)
// }
return res
}

+ 2
- 3
app/svc/svc_db.go 查看文件

@@ -2,10 +2,9 @@ package svc

import (
db "code.fnuoos.com/zhimeng/model.git/src"
"github.com/gin-gonic/gin"
"xorm.io/xorm"
)

func MasterDb(c *gin.Context) *xorm.Engine {
return db.DBs[c.GetString("mid")]
func MasterDb(mid string) *xorm.Engine {
return db.DBs[mid]
}

+ 4
- 2
app/svc/svc_medium_agent.go 查看文件

@@ -1,6 +1,7 @@
package svc

import (
db "code.fnuoos.com/zhimeng/model.git/src"
implement2 "code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin"
@@ -11,8 +12,9 @@ func GetAgentInfo(c *gin.Context, mediumId int) map[string]string {
"account": "",
"name": "",
}
NewAgentDb := implement2.NewAgentDb(MasterDb(c))
NewAgentListDb := implement.NewAgentListDb(MasterDb(c))

NewAgentDb := implement2.NewAgentDb(db.Db)
NewAgentListDb := implement.NewAgentListDb(db.Db)
medium := NewAgentDb.GetSuperAdmin(mediumId)
if medium != nil {
res["account"] = medium.Username


+ 1
- 1
etc/cfg.yml 查看文件

@@ -6,7 +6,7 @@ local: true
# 服务器参数
srv_addr: ':1000'
# 缓存
redis_addr: '120.24.28.6:32572'
redis_addr: '127.0.0.1:6379'

# 连接官网数据库获取db mapping
db:


Loading…
取消
儲存