From 173799abb916cc81fe6d919e6c301701dba37541 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 8 Oct 2024 18:11:23 +0800 Subject: [PATCH] 1 --- app/router/router.go | 4 +- app/svc/svc_data_center_original_data.go | 77 ++++++++++++------------ app/svc/svc_db.go | 5 +- app/svc/svc_medium_agent.go | 6 +- etc/cfg.yml | 2 +- 5 files changed, 46 insertions(+), 48 deletions(-) diff --git a/app/router/router.go b/app/router/router.go index c77d630..a3119b7 100644 --- a/app/router/router.go +++ b/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")) // 短信中心 diff --git a/app/svc/svc_data_center_original_data.go b/app/svc/svc_data_center_original_data.go index aa6ef2d..1378657 100644 --- a/app/svc/svc_data_center_original_data.go +++ b/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 } diff --git a/app/svc/svc_db.go b/app/svc/svc_db.go index 77c2143..9652b52 100644 --- a/app/svc/svc_db.go +++ b/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] } diff --git a/app/svc/svc_medium_agent.go b/app/svc/svc_medium_agent.go index 7bbe358..4bfd9ba 100644 --- a/app/svc/svc_medium_agent.go +++ b/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 diff --git a/etc/cfg.yml b/etc/cfg.yml index 841ed21..88f1c10 100644 --- a/etc/cfg.yml +++ b/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: