diff --git a/api/v1/game/notice.go b/api/v1/game/notice.go index 63d3b47..b344e72 100644 --- a/api/v1/game/notice.go +++ b/api/v1/game/notice.go @@ -67,6 +67,7 @@ type AddNoticeReq struct { NoticeType int `p:"noticeType"` SendTime int64 `p:"sendTime"` NoticeId int64 `p:"noticeId"` + IsShow int `p:"isShow"` Id int64 `p:"id"` } @@ -89,6 +90,15 @@ type DelNoticeListReq struct { type DelNoticeListRes struct { } +type NoticeShowReq struct { + g.Meta `path:"/notice/showOpen" tags:"公告" method:"post" summary:"公告列表删除"` + Id int64 `p:"id"` + IsShow int `p:"isShow"` +} + +type NoticeShowRes struct { +} + type GetNoticeReq struct { g.Meta `path:"/notice/get" tags:"公告" method:"get" summary:"维护公告"` Channel string `p:"channel"` @@ -135,10 +145,8 @@ type GetGameNoticeReq struct { } type GetGameNoticeRes struct { - g.Meta `mime:"application/json"` - Status int `json:"status"` - Content string `json:"content"` - TimeStamp int32 `json:"timeStamp"` + g.Meta `mime:"application/json"` + Notice } type GetGameNoticeListReq struct { @@ -151,6 +159,7 @@ type Notice struct { Status int `json:"status"` Content string `json:"content"` TimeStamp int32 `json:"timeStamp"` + IsShow int `json:"isShow"` NoticeType int32 `json:"noticeType"` } diff --git a/api/v1/game/serverConfig.go b/api/v1/game/serverConfig.go index 3f75c5f..96504ab 100644 --- a/api/v1/game/serverConfig.go +++ b/api/v1/game/serverConfig.go @@ -34,6 +34,8 @@ type AddServerConfigGeneralReq struct { RechargeWhiteListIps string `p:"rechargeWhiteListIps"` SdkAddress string `p:"sdkAddress"` UniqueAddress string `p:"uniqueAddress"` + ActivityDbUrl string `p:"activityDbUrl"` + ActivityDbName string `p:"activityDbName"` } type AddServerConfigGeneralRes struct { diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 2b4079e..db1fa95 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -6,6 +6,7 @@ import ( "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/goai" "github.com/gogf/gf/v2/os/gcmd" + "log" "tyj_admin/internal/consts" "tyj_admin/internal/router" ) @@ -22,8 +23,10 @@ var ( router.BindAnotherController(group) }) - s.BindHandler("/upload_file", func(r *ghttp.Request) { - r.Response.ServeFileDownload("./download/" + r.GetQuery("filename").String()) + s.BindHandler("/pub_upload/*", func(r *ghttp.Request) { + r.Response.Header().Set("Access-Control-Allow-Origin", "*") + log.Println("r.RequestURI: ", r.RequestURI) + r.Response.ServeFile("."+r.RequestURI, false) }) s.BindHandler("/download_file", func(r *ghttp.Request) { @@ -31,7 +34,6 @@ var ( r.Response.ServeFileDownload("./download/" + r.GetQuery("filename").String()) }) enhanceOpenAPIDoc(s) - //s.EnableHTTPS("server.crt", "server.key") s.Run() return nil }, diff --git a/internal/consts/consts.go b/internal/consts/consts.go index 39142bf..28ff328 100644 --- a/internal/consts/consts.go +++ b/internal/consts/consts.go @@ -45,6 +45,7 @@ const ( Notice_Type_Maintenance = 3 Notice_Type_Customer = 4 Notice_Type_Preview = 5 + Notice_Type_NewServer = 6 ) const ( diff --git a/internal/controller/game_notice.go b/internal/controller/game_notice.go index 3b7d7ad..7d33f06 100644 --- a/internal/controller/game_notice.go +++ b/internal/controller/game_notice.go @@ -61,3 +61,8 @@ func (c *noticeController) DelModel(ctx context.Context, req *game.DelNoticeMode res, err = serviceGame.GameNotice().DelNoticeModel(ctx, req) return } + +func (c *noticeController) NoticeShow(ctx context.Context, req *game.NoticeShowReq) (res *game.NoticeShowRes, err error) { + res, err = serviceGame.GameNotice().NoticeShow(ctx, req) + return +} diff --git a/internal/dao/internal/game_notice.go b/internal/dao/internal/game_notice.go index b387a6e..d5820d7 100644 --- a/internal/dao/internal/game_notice.go +++ b/internal/dao/internal/game_notice.go @@ -20,13 +20,14 @@ type GameNoticeDao struct { // GameNoticeColumns defines and stores column names for table game_notice. type GameNoticeColumns struct { - Id string // 索引ID - NoticeType string // 公告类型:1表示弹窗公告,2表示登录公告,3表示维护公告 + Id string // 维护公告1.正常,2.白名单,3.维护 + NoticeType string // 公告类型:1表示弹窗公告,2表示登录公告,3表示维护公告, 4客服界面, 5预览, 6新服公告, Channel string // 渠道号:第三方的登录渠道 Content string // - Status string // 1.正常,2.白名单,3.维护 + Status string // 维护公告:1.正常,2.白名单,3.维护 CDate string // 公告创建时间 ServerId string // + IsShow string // 公告类型6:0-不显示, 1-显示 } // gameNoticeColumns holds the columns for table game_notice. @@ -38,6 +39,7 @@ var gameNoticeColumns = GameNoticeColumns{ Status: "status", CDate: "c_date", ServerId: "serverId", + IsShow: "is_show", } // NewGameNoticeDao creates and returns a new DAO object for table data access. diff --git a/internal/dao/internal/game_notice_log.go b/internal/dao/internal/game_notice_log.go index 7072b17..398ad2e 100644 --- a/internal/dao/internal/game_notice_log.go +++ b/internal/dao/internal/game_notice_log.go @@ -31,6 +31,7 @@ type GameNoticeLogColumns struct { ServerId string // Uids string // PopType string // 1.强制退出,2.普通弹窗 + IsShow string // 公告类型6:0-不显示, 1-显示 } // gameNoticeLogColumns holds the columns for table game_notice_log. @@ -46,6 +47,7 @@ var gameNoticeLogColumns = GameNoticeLogColumns{ ServerId: "server_id", Uids: "uids", PopType: "pop_type", + IsShow: "is_show", } // NewGameNoticeLogDao creates and returns a new DAO object for table data access. diff --git a/internal/model/do/game_notice.go b/internal/model/do/game_notice.go index e17e941..62da337 100644 --- a/internal/model/do/game_notice.go +++ b/internal/model/do/game_notice.go @@ -11,11 +11,12 @@ import ( // GameNotice is the golang structure of table game_notice for DAO operations like Where/Data. type GameNotice struct { g.Meta `orm:"table:game_notice, do:true"` - Id interface{} // 索引ID - NoticeType interface{} // 公告类型:1表示弹窗公告,2表示登录公告,3表示维护公告 + Id interface{} // 维护公告1.正常,2.白名单,3.维护 + NoticeType interface{} // 公告类型:1表示弹窗公告,2表示登录公告,3表示维护公告, 4客服界面, 5预览, 6新服公告, Channel interface{} // 渠道号:第三方的登录渠道 Content interface{} // - Status interface{} // 1.正常,2.白名单,3.维护 + Status interface{} // 维护公告:1.正常,2.白名单,3.维护 CDate interface{} // 公告创建时间 ServerId interface{} // + IsShow interface{} // 公告类型6:0-不显示, 1-显示 } diff --git a/internal/model/do/game_notice_log.go b/internal/model/do/game_notice_log.go index b2f7657..f804654 100644 --- a/internal/model/do/game_notice_log.go +++ b/internal/model/do/game_notice_log.go @@ -23,4 +23,5 @@ type GameNoticeLog struct { ServerId interface{} // Uids interface{} // PopType interface{} // 1.强制退出,2.普通弹窗 + IsShow interface{} // 公告类型6:0-不显示, 1-显示 } diff --git a/internal/model/entity/game_notice.go b/internal/model/entity/game_notice.go index 4e3583e..983b09e 100644 --- a/internal/model/entity/game_notice.go +++ b/internal/model/entity/game_notice.go @@ -6,11 +6,12 @@ package entity // GameNotice is the golang structure for table game_notice. type GameNotice struct { - Id int64 `json:"id" description:"索引ID"` - NoticeType int `json:"noticeType" description:"公告类型:1表示弹窗公告,2表示登录公告,3表示维护公告"` + Id int64 `json:"id" description:"维护公告1.正常,2.白名单,3.维护"` + NoticeType int `json:"noticeType" description:"公告类型:1表示弹窗公告,2表示登录公告,3表示维护公告, 4客服界面, 5预览, 6新服公告,"` Channel string `json:"channel" description:"渠道号:第三方的登录渠道"` Content string `json:"content" description:""` - Status int `json:"status" description:"1.正常,2.白名单,3.维护"` + Status int `json:"status" description:"维护公告:1.正常,2.白名单,3.维护"` CDate int64 `json:"cDate" description:"公告创建时间"` ServerId int `json:"serverId" description:""` + IsShow int `json:"isShow" description:"公告类型6:0-不显示, 1-显示"` } diff --git a/internal/model/entity/game_notice_log.go b/internal/model/entity/game_notice_log.go index a946d37..f49328e 100644 --- a/internal/model/entity/game_notice_log.go +++ b/internal/model/entity/game_notice_log.go @@ -21,4 +21,5 @@ type GameNoticeLog struct { ServerId int `json:"serverId" description:""` Uids string `json:"uids" description:""` PopType int `json:"popType" description:"1.强制退出,2.普通弹窗"` + IsShow int `json:"isShow" description:"公告类型6:0-不显示, 1-显示"` } diff --git a/internal/serviceGame/cron.go b/internal/serviceGame/cron.go index 673894d..aa9fe46 100644 --- a/internal/serviceGame/cron.go +++ b/internal/serviceGame/cron.go @@ -116,11 +116,13 @@ func (c *gameCronImpl) Cron(sTime int64) { noticeModel.Where("notice_type=?", notice.NoticeType).Where("channel=?", notice.Channel).Scan(¬iceList) if len(noticeList) > 0 { _, _ = dao.GameNotice.Ctx(ctx).Where("id=", noticeList[0].Id).Data(&do.GameNotice{ + IsShow: notice.IsShow, Content: notice.Content, CDate: time.Now().Unix(), }).Update() } else { _, _ = dao.GameNotice.Ctx(ctx).Insert(&do.GameNotice{ + IsShow: notice.IsShow, Status: notice.Status, Content: notice.Content, NoticeType: notice.NoticeType, diff --git a/internal/serviceGame/internal/dbinit.go b/internal/serviceGame/internal/dbinit.go index f02b519..42856b1 100644 --- a/internal/serviceGame/internal/dbinit.go +++ b/internal/serviceGame/internal/dbinit.go @@ -28,6 +28,7 @@ type OceanengineMap struct { } var ( + MongoClientList map[string]*qmgo.QmgoClient MongoDatabaseList map[string]*qmgo.Database MongoConfigs map[string]MongoType RedisDbList []*redis.Client @@ -115,19 +116,36 @@ func MongoInit(ctx context.Context) { } config := mongoCfg.Maps() + v, err := g.Cfg().Get(ctx, "game.mongoConfig") + if err != nil { + return + } + m := v.MapStrVar() + var ( + maxSize = m["maxSize"].Uint64() + minSize = m["minSize"].Uint64() + socketTimeoutMS = m["socketTimeoutMS"].Int64() + connectTimeoutMS = m["connectTimeoutMS"].Int64() + ) log.Println("MongoInit: ", gjson.MustEncodeString(config)) + if len(MongoClientList) > 0 { + for _, v := range MongoClientList { + _ = v.Close(ctx) + } + } + MongoClientList = map[string]*qmgo.QmgoClient{} MongoDatabaseList = map[string]*qmgo.Database{} MongoConfigs = map[string]MongoType{} for _, v := range config { - mongoclient, err := qmgo.NewClient(ctx, &qmgo.Config{Uri: v["link"].(string)}) + mongoclient, err := qmgo.Open(ctx, &qmgo.Config{Uri: v["link"].(string), Database: v["name"].(string), Coll: "Account", MinPoolSize: &minSize, MaxPoolSize: &maxSize, SocketTimeoutMS: &socketTimeoutMS, ConnectTimeoutMS: &connectTimeoutMS}) if err != nil { continue } - db := mongoclient.Database(v["name"].(string)) - MongoDatabaseList[v["id"].(string)] = db + + MongoClientList[v["id"].(string)] = mongoclient + MongoDatabaseList[v["id"].(string)] = mongoclient.Database MongoConfigs[v["id"].(string)] = MongoType{Link: v["link"].(string), Link1: v["link1"].(string), Id: v["id"].(string), Name: v["name"].(string), Auth: v["auth"].(string)} } - } func InitServer(ctx context.Context) { diff --git a/internal/serviceGame/loginUrl.go b/internal/serviceGame/loginUrl.go index f2728ae..1f4aa2f 100644 --- a/internal/serviceGame/loginUrl.go +++ b/internal/serviceGame/loginUrl.go @@ -78,6 +78,8 @@ func (c *gameLoginUrlImpl) AddServerConfigGeneral(ctx context.Context, req *game dao.GameServerJsonGeneral.Columns().RechargeWhiteListIps: req.RechargeWhiteListIps, dao.GameServerJsonGeneral.Columns().GmWhiteListUrl: req.GmWhiteListUrl, dao.GameServerJsonGeneral.Columns().SdkAddress: req.SdkAddress, + dao.GameServerJsonGeneral.Columns().ActivityDbUrl: req.ActivityDbUrl, + dao.GameServerJsonGeneral.Columns().ActivityDbName: req.ActivityDbName, }) liberr.ErrIsNil(ctx, err, "mysql err") }) diff --git a/internal/serviceGame/notice.go b/internal/serviceGame/notice.go index 409b840..0b1771a 100644 --- a/internal/serviceGame/notice.go +++ b/internal/serviceGame/notice.go @@ -30,6 +30,7 @@ type IGameNotice interface { GetNoticeModel(ctx context.Context, req *game.GetNoticeModelReq) (res *game.GetNoticeModelRes, err error) AddNoticeModel(ctx context.Context, req *game.AddNoticeModelReq) (res *game.AddNoticeModelRes, err error) DelNoticeModel(ctx context.Context, req *game.DelNoticeModelReq) (res *game.DelNoticeModelRes, err error) + NoticeShow(ctx context.Context, req *game.NoticeShowReq) (res *game.NoticeShowRes, err error) } type gameNoticeImpl struct { @@ -96,6 +97,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot res.TimeStamp = int32(ipList[0].CDate) res.Content = ipList[0].Content res.Status = ipList[0].Status + res.IsShow = ipList[0].IsShow g.Log().Debugf(ctx, "ipList GetGameNotice ip: "+ip, "NoticeType: "+fmt.Sprint(req.NoticeType), "res: "+fmt.Sprint(res.Status)) return @@ -124,6 +126,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot res.TimeStamp = int32(v.CDate) res.Content = v.Content res.Status = v.Status + res.IsShow = v.IsShow break } } @@ -131,6 +134,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot res.TimeStamp = int32(noticeList[0].CDate) res.Content = noticeList[0].Content res.Status = noticeList[0].Status + res.IsShow = noticeList[0].IsShow } else if len(noticeList) == 0 { res.TimeStamp = 0 res.Content = "" @@ -173,7 +177,11 @@ func (c *gameNoticeImpl) GetGameNoticeList(ctx context.Context, req *game.GetGam req1.Channel = req.Channel res2, _ := c.GetGameNotice(ctx, req1) res.List = append(res.List, game.Notice{Content: res2.Content, Status: res2.Status, TimeStamp: res2.TimeStamp, NoticeType: consts.Notice_Type_Preview}) - //log.Printf("GetGameNotice res: %s", gjson.MustEncodeString(res.List)) + + req1.NoticeType = consts.Notice_Type_NewServer + req1.Channel = req.Channel + res3, _ := c.GetGameNotice(ctx, req1) + res.List = append(res.List, game.Notice{Content: res3.Content, Status: res3.Status, TimeStamp: res3.TimeStamp, IsShow: res3.IsShow, NoticeType: consts.Notice_Type_NewServer}) }) return } @@ -214,10 +222,12 @@ func (c *gameNoticeImpl) AddNotice(ctx context.Context, req *game.AddNoticeReq) NoticeType: req.NoticeType, NoticeId: req.NoticeId, Channel: req.Channel, + IsShow: req.IsShow, SendTime: SendTime, } cron := entity.GameNoticeLog{ Id: req.Id, + IsShow: req.IsShow, Status: req.Status, Content: req.Content, NoticeType: req.NoticeType, @@ -258,12 +268,14 @@ func (c *gameNoticeImpl) AddNotice(ctx context.Context, req *game.AddNoticeReq) noticeModel.Where("notice_type=?", req.NoticeType).Where("channel=?", req.Channel).Scan(¬iceList) if len(noticeList) > 0 { _, e = noticeModel.Where("id=?", noticeList[0].Id).Data(&do.GameNotice{ + IsShow: req.IsShow, Status: req.Status, Content: req.Content, CDate: time.Now().Unix(), }).Update() } else { _, e = noticeModel.Insert(&do.GameNotice{ + IsShow: req.IsShow, Status: req.Status, Content: req.Content, NoticeType: req.NoticeType, @@ -402,3 +414,20 @@ func (c *gameNoticeImpl) DelNoticeModel(ctx context.Context, req *game.DelNotice } return } + +func (c *gameNoticeImpl) NoticeShow(ctx context.Context, req *game.NoticeShowReq) (res *game.NoticeShowRes, err error) { + if req.Id == 0 { + err = errors.New("错误的id") + return + } + + err = g.Try(ctx, func(ctx context.Context) { + _, e := dao.GameNotice.Ctx(ctx).Where("id=", req.Id).Data(&do.GameNotice{IsShow: req.IsShow}).Update() + if e != nil { + liberr.ErrIsNil(ctx, e, "修改公告失败") + return + } + }) + + return +} diff --git a/pub_upload/icon.jpeg b/pub_upload/icon.jpeg new file mode 100644 index 0000000..bd7dbef Binary files /dev/null and b/pub_upload/icon.jpeg differ diff --git a/test/testMongo.go b/test/testMongo.go index 1e6c3ce..71222b5 100644 --- a/test/testMongo.go +++ b/test/testMongo.go @@ -63,7 +63,6 @@ func selectStores(ctx context.Context, serverId string, query bson.M) { break } } - } log.Printf("服务器编号[%s] 结束!", serverId) }