123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- package server
- import (
- "gadmin/config"
- "gadmin/internal/admin/api"
- "gadmin/internal/admin/middleware"
- "gadmin/internal/admin/ws"
- "net/http"
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- )
- // NewEngine 路由配置
- func NewEngine() *gin.Engine {
- r := gin.New()
- //gin.SetMode(os.Getenv(gin.EnvGinMode))
- gin.SetMode(gin.ReleaseMode)
- // 必要中间件
- r.Use(middleware.Recover, middleware.Cors)
- r.GET("/", func(c *gin.Context) {
- c.Redirect(http.StatusTemporaryRedirect, "/cadmin")
- })
- r.GET("/login", func(c *gin.Context) {
- c.Redirect(http.StatusTemporaryRedirect, "/cadmin")
- })
- // 静态资源目录
- //r.Static("resource", "../web/dist")
- //r.StaticFS("/gadmin", http.Dir("../web/dist"))
- r.Static("resource", "./resource/public")
- //r.StaticFS("/gadmin", packr.NewBox(config.RootPtah+"/resource/public/gadmin888"))
- //logrus.Warnf("config.RootPtah+\"/../web/dist\":%v", config.RootPtah+"/../web/dist")
- //r.StaticFS("/gadmin", packr.NewBox(config.RootPtah+"/../web/dist"))
- r.StaticFS("/cadmin", http.Dir("./resource/public/cadmin"))
- r.StaticFS("/json", http.Dir("./resource/public/json"))
- r.Handle("GET", "ws", ws.Websocket)
- // 日志中间件
- r.Use(middleware.Logger)
- // 路由
- group := r.Group("api")
- {
- group.GET("ping", api.Ping) // ping
- group.GET("download/json", api.JsonResource) // 内部代理下载资源
- //group.POST("user/register", api.UserRegister) // 用户注册
- group.POST("user/login", api.UserLogin) // 用户登录
- //group.GET("service/list", api.ServiceList) // 服务列表
- //group.POST("service/select", api.ServiceSelect) // 选择系统
- group.GET("deploy/notify", api.DeployNotify)
- migrate := group.Group("migrate")
- migrate.Use(middleware.ApiToken())
- migrate.POST("userInfo", api.MigrateUserInfo)
- migrate.POST("complete", api.MigrateComplete)
- peripherals := group.Group("peripherals")
- peripherals.Use(middleware.ApiToken())
- peripherals.POST("receiveCdk", api.PeripheralsReceiveCdk)
- peripherals.GET("announcement/info", api.AnnouncementInfo) // 获取游戏更新公告
- feishu := group.Group("feishu")
- //feishu.Use(middleware.ApiToken())
- feishu.GET("feiShuUserLogin", api.FeiShuUserInfoLogin)
- // 只需要验证token的
- checkToken := group.Group("")
- checkToken.Use(middleware.Token())
- {
- checkToken.GET("service/list", api.ServiceList) // 服务列表
- checkToken.POST("service/select", api.ServiceSelect) // 选择系统
- checkToken.GET("user/checkRolePermission", api.RolePermission) // 管理员用户是否拥有权限管理
- }
- // 需要登录保护的
- auth := group.Group("")
- auth.Use(middleware.Token(), middleware.Permission()) // 顺序不能调整
- {
- auth.GET("user/me", api.UserMe) // 用户信息
- auth.POST("user/logout", api.UserLogout) // 退出登录
- auth.GET("menu/dynamic", api.MenuDynamic) // 动态菜单
- //auth.GET("email/list", api.AdminEmailList) // V2邮件列表
- //auth.POST("email/add", api.AdminEmailAdd) // V2邮件新增/编辑
- //auth.POST("email/verify", api.AdminEmailVerify) // V2邮件审核
- auth.GET("announcement/list", api.AnnouncementList) // 游戏更新公告列表
- auth.POST("announcement/add", api.AnnouncementAdd) // 游戏更新公告新增
- auth.POST("announcement/del", api.AnnouncementDel) // 游戏更新公告删除
- auth.GET("notice/list", api.NoticeList) // V2广播列表
- auth.POST("notice/add", api.NoticeAdd) // V2广播新增/编辑
- auth.POST("notice/cancel", api.NoticeCancel) // V2广播取消
- auth.GET("channel/stat", api.ChannelStat) // 渠道统计
- auth.POST("channel/statEdit", api.ChannelStatEdit) // 渠道统计编辑
- auth.GET("userAccount/banList", api.UserAccountBanList) // 拉黑玩家列表
- auth.GET("userAccount/list", api.UserAccountList) // 玩家列表
- auth.GET("userAccount/searchList", api.UserAccountSearch) // 玩家列表
- auth.GET("userAccount/get", api.UserAccountGet) // 获取指定玩家信息
- auth.POST("userAccount/userBan", api.UserBan)
- //auth.POST("userAccount/singleBanUser", api.SingleBanUser)
- //auth.POST("userAccount/paySwitch", api.UpdatePlayerPaySwitch)
- auth.POST("userAccount/banUserChat", api.BanUserChat) // 禁止玩家聊天
- auth.GET("chat/reportList", api.ChatReportList) // 聊天举报列表
- auth.GET("chat/logList", api.ChatLogList) // 聊天消息列表(模拟聊天框)
- auth.GET("chat/download", api.DownloadChatLog) // COS聊天内容下载
- auth.GET("chat/msgList", api.ChatMsgList) // 聊天消息列表
- //auth.POST("userAccount/updateNickname", api.UpdateNickname)
- auth.POST("userAccount/compatibilityTestVerify", api.CompatibilityTestVerify)
- //auth.POST("userAccount/compatibilityTestMigrate", api.CompatibilityTestMigrate)
- auth.GET("playerMaterial/equipments", api.PlayerEquipments) // 玩家装备列表
- auth.GET("playerAttr/get", api.PlayerAttrGet) // 获取指定玩家属性
- auth.GET("playerAttr/getAll", api.PlayerAttrGetAll) // 获取指定玩家属性
- auth.GET("order/userStatistics", api.OrderUserStatistics) // 获取指定玩家订单统计
- auth.GET("signin/count", api.SigninCount) // 获取指定玩家当月签到次数
- auth.GET("changedLogs/list", api.ChangedLogsList)
- auth.GET("changedLogs/statistics", api.ConsumptionStatistics)
- auth.GET("ranking/rechargeRanking", api.RechargeRanking)
- auth.GET("ranking/diamondRanking", api.DiamondRanking)
- auth.GET("ranking/itemRanking", api.ItemRanking)
- auth.GET("ranking/levelRanking", api.LevelRanking) // 等级排名
- auth.GET("ranking/getPVPRankingList", api.GetPVPRankingList) // PVP
- auth.POST("ranking/clearPVPRank", api.ClearPVPRank) // 清除指定玩家PVP排名
- auth.GET("ranking/getCurioRankingList", api.GetCurioRankingList) // 古玩
- auth.POST("ranking/clearCurioRank", api.ClearCurioRank) // 清除指定玩家古玩排名
- auth.GET("ranking/getIdiomRankingList", api.GetIdiomRankingList) // 金榜题名
- auth.POST("ranking/clearIdiomRank", api.ClearIdiomRank) // 清除指定玩家金榜题名排名
- auth.GET("ranking/getBossRankingList", api.GetBossRankingList) // 暗影突袭
- auth.POST("ranking/clearBossRank", api.ClearBossRank) // 清除指定玩家暗影突袭排名
- auth.GET("ranking/advRanking", api.AdvRanking) // 等级排名
- auth.GET("ranking/loginRanking", api.LoginRanking) // 等级排名
- auth.GET("chapter/ordinaryList", api.ChapterOrdinaryList) // 章节普通进度
- auth.GET("chapter/activityList", api.ChapterActivityList) // 章节活动进度
- auth.GET("chapter/reconnect", api.ChapterReconnect) // 重进
- auth.GET("retrofitGroup/addPlayer", api.RetrofitGroupAddPlayer) // 为玩家添加配装
- auth.GET("retrofitGroup/options", api.RetrofitGroupOptions) // 配装模板选项
- auth.GET("retrofitGroup/list", api.RetrofitGroupList) // 配装模板列表
- auth.POST("retrofitGroup/edit", api.RetrofitGroupEdit) // 配装模板编辑
- auth.POST("retrofitGroup/delete", api.RetrofitGroupDelete) // 配装模板删除
- auth.GET("retrofit/list", api.RetrofitList) // 配装列表
- auth.POST("retrofit/edit", api.RetrofitEdit) // 配装编辑
- auth.POST("retrofit/delete", api.RetrofitDelete) // 配装删除
- //auth.POST("cdk/add", api.CdkAdd) // 批量添加cdk
- //auth.POST("cdk/del", api.CdkDel) // 删除单个cdk
- //auth.GET("cdk/list", api.CdkList) // cdk列表
- //auth.GET("cdk/received", api.CdkReceived) // 已领取列表
- //auth.POST("cdk/batchInvalid", api.CdkBatchInvalid) // 兑换码批次作废
- //auth.GET("cdk/redeemCodeList", api.CdkRedeemCodeList) // 兑换码列表
- auth.GET("gem/stat", api.GemStat) // 获取宝石综合统计
- auth.GET("gem/partStat", api.PartStat) // 获取宝石部位统计
- auth.GET("gem/gemLog", api.GemLog) // 获取宝石统计折线信息
- auth.GET("limitgift/list", api.LimitGiftList) // 限时礼包统计信息
- auth.GET("deploy/list", api.DeployList)
- auth.POST("deploy/edit", api.DeployEdit)
- auth.POST("deploy/delete", api.DeployDelete)
- auth.POST("deploy/task", api.DeployTask)
- auth.POST("deploy/stop", api.DeployStop)
- auth.GET("deployLog/list", api.DeployLogList)
- auth.GET("deployLog/view", api.DeployLogView)
- // etcd设置
- auth.GET("drainageServer/get", api.GetDrainageServer)
- auth.POST("drainageServer/edit", api.EditDrainageServer)
- auth.GET("drainageServer/getDisplay", api.GetDisplayServer)
- auth.POST("drainageServer/editDisplay", api.EditDisplayServer)
- auth.GET("drainageServer/getWhiteList", api.GetWhiteListServer)
- auth.POST("drainageServer/editWhiteList", api.EditWhiteListServer)
- auth.GET("treasure/list", api.GetTreasureList)
- auth.GET("treasure_chest/list", api.GetTreasureChestList)
- auth.GET("treasure/playerLevel", api.TreasurePlayerLevel)
- auth.GET("treasure/roleWear", api.TreasureRoleWear)
- auth.GET("treasure/level", api.TreasureLevel)
- auth.GET("treasure/star", api.TreasureStar)
- auth.GET("grandmaster/get", api.GetGrandmaster)
- auth.POST("grandmaster/setDanScore", api.SetGrandmasterDanScore)
- auth.GET("grandmaster/list", api.GetGrandmasterList)
- auth.GET("grandmaster/waves", api.GrandmasterWaves)
- auth.GET("grandmaster/seconds", api.GrandmasterSeconds)
- auth.GET("grandmaster/dan", api.GrandmasterDan)
- auth.GET("grandmaster/match", api.GrandmasterMatch)
- auth.GET("alarm/game/list", api.AlarmGameDataList) //游戏异常信息
- auth.GET("alarm/attr/list", api.AlarmAttrList) //玩家属性异常记录
- auth.GET("alarm/cheating/list", api.AlarmCheatingList) //作弊数据列表
- // 管理员操作
- admin := auth.Group("admin")
- admin.GET("roleList", api.AdminRoleList) // 角色列表
- admin.GET("roleAuthOption", api.AdminRoleAuthOption) // 角色权限选项
- admin.GET("rolePageOption", api.AdminRolePageOption) // 角色可查看页面选项
- admin.POST("roleEdit", api.AdminRoleEdit) // 角色修改/创建
- admin.GET("roleOption", api.AdminRoleOption) // 角色选项
- admin.GET("userList", api.AdminUserList) // 用户列表
- admin.POST("userEdit", api.AdminUserEdit) // 用户修改/创建
- admin.POST("resetPassword", api.ResetPassword) // 用户重置密码
- admin.POST("updatePassword", api.UpdatePassword) // 用户修改密码
- admin.GET("logList", api.AdminLogList) // 操作日志
- admin.GET("logView", api.AdminLogView) // 操作日志详情
- // gm更新操作
- gm := auth.Group("gm")
- gm.GET("/msdBalance", api.MsdBalance) // 米大师余额查询
- gm.GET("/balance", api.GetBalance) //查询余额
- gm.POST("/msdSettle", api.MsdSettle) // 米大师操作平账
- gm.GET("/orderSettleList", api.OrderSettleList) // 平账操作记录列表
- gm.POST("/userRoles", api.GetUserRolesInfo) // 获取用户的角色数量信息
- //gm.POST("updatePlayerBase", api.UpdatePlayerBase) // 更新玩家金币、钻石、 经验、体力、精力、天赋点
- //gm.POST("updateChapter", api.UpdateChapter) // 更新关卡数据
- //gm.POST("updateTalents", api.UpdateTalents) // 修改天赋
- //gm.POST("updateGuides", api.UpdateGuides) // 更新关卡引导
- gm.POST("addEquipment", api.AddEquipment) // 添加装备
- gm.POST("addMaterial", api.AddMaterial) // 添加材料
- gm.POST("addExp", api.AddRoleExp) // 添加经验
- gm.POST("addStamina", api.AddRoleStamina) // 添加体力
- gm.POST("upgradeRole", api.UpgradeRole) // 升级角色
- gm.POST("addCoin", api.AddCoin) // 添加钻石
- gm.GET("payorder/sevenStatistics", api.OrderSevenStatistics) // 充值7日统计
- gm.GET("payorder/dailyStatistics", api.OrderDailyStatistics) // 充值每日统计
- gm.GET("orderList", api.OrderList) // 充值订单列表
- gm.GET("abnormalOrderList", api.AbnormalOrderList) // 游戏服异常订单列表
- gm.POST("abnormalOrderReissue", api.AbnormalOrderReissue) // 异常订单一键补发
- //gm.GET("payorder", api.QueryPayOrder)
- //gm.POST("payorder/export", api.ExportPayOrder)
- //gm.GET("payorder/export", api.ExportPayOrder)
- gm.POST("tools/restart", api.ToolsRestart) // 提交重启
- gm.GET("tools/restart_log", api.ToolsRestartLog) // 重启记录
- gm.GET("tools/restartView", api.ToolsRestartView) // 获取指定重启日志
- gm.GET("config", api.GetConfig)
- gm.GET("conf_path", api.GetJSONPath)
- gm.POST("set_conf_path", api.SetNewJsonPath)
- gm.POST("updateSwitchers", api.UpdateSwitcher)
- gm.GET("notices", api.GetNoticeList)
- gm.POST("notices", api.AddNotice)
- gm.POST("del_notice", api.DelNotice)
- gm.GET("letters", api.MailList)
- gm.POST("letters/add", api.SendMail)
- gm.POST("letters/del", api.DeleteMail)
- //gm.GET("get_all_exp", api.GetAllExp)
- //gm.GET("get_all_roles", api.GetAllRoles)
- gm.GET("get_all_goods", api.GetAllGoods)
- gm.GET("get_all_chapters", api.GetAllChapters)
- gm.GET("get_all_talents", api.GetAllTalents) //
- gm.GET("get_all_equipments", api.GetAllEquipments)
- gm.GET("get_all_materials", api.GetAllMaterials)
- gm.GET("get_all_runes", api.GetAllRunes)
- gm.POST("add_equipment", api.AddEquipment)
- gm.POST("add_material", api.AddMaterial)
- gm.POST("add_rune", api.AddRune)
- gm.POST("add_gift", api.AddGift)
- gm.POST("upgrade_role", api.UpgradeRole)
- gm.GET("get_role_level", api.GetRoleLevel) // 角色等级查询
- gm.POST("update_el_rank", api.UpdatePlayerElRank)
- gm.POST("delete_player", api.DeletePlayer)
- gm.POST("delete_account", api.DeleteAccount)
- gm.POST("openAccount", api.OpenAccount)
- //gm.POST("delRank", api.DelRank)
- gm.GET("getServerDate", api.GetServerDate)
- gm.POST("editServerDate", api.EditServerDate)
- gm.POST("releaseVersion", api.ReleaseVersion)
- gm.GET("versionList", api.VersionList)
- gm.GET("getVersionIndex", api.GetVersionIndex)
- gm.GET("chatLog/playerList", api.ChatLogPlayerList) //获取客服聊天用户列表
- gm.GET("chatLog/info", api.ChatLogInfo) //获取聊天详情
- // dash
- dash := auth.Group("dash")
- dash.GET("dict", api.DashboadDict)
- //dash.GET("events", api.GetAllEventsInfo)
- dash.GET("chapters", api.GetAllChaptersInfo)
- dash.GET("loginlog", api.DashboadLoginLog)
- dash.GET("userChapterLog", api.DashboadUserChaperLog)
- dash.GET("dieLog", api.DashboardDieLog)
- dash.GET("conditionUsers", api.DashboadConditionUsers)
- dash.GET("basicInfo", api.DashboardBasicInfo)
- dash.GET("basicReport", api.DashboardBasicReport)
- dash.GET("basicRetention", api.DashboardBasicRetention)
- dash.GET("conditionReport", api.DashboardEventReport)
- dash.GET("advReport", api.DashboardAdvReport)
- dash.GET("advDetails", api.DashboardAdvDetails)
- dash.GET("advUserDetails", api.DashboardAdvUserDetails)
- dash.GET("advEcharts", api.DashboardAdvEcharts)
- dash.GET("advSumm", api.DashboardAdvSumm)
- dash.GET("goodsReport", api.DashboardGoodsReport)
- dash.GET("chapterPass", api.DashboardChapterPassLog)
- dash.GET("gudongInfo", api.DashboardGudongLog) // 统计古玩信息
- dash.GET("usersMap", api.DashboardUserRolesMap) // 角色数据
- dash.GET("expeditionInfo", api.DashboardExpeditionLog) // 统计远征信息
- dash.GET("expeditionFloor", api.DashboardExpeditionFloor) // 远征关卡未通关信息
- dash.GET("duelInfo", api.DashboardDuelLog) // 统计狭路对决信息
- dash.GET("gradeDistribution", api.GradeDistribution) // 等级分布
- dash.GET("console", api.Console) // 控制台统计
- dash.GET("idiomInfo", api.DashboardIdiomLog) // 统计金榜题名信息
- dash.GET("heroLevelDistribution", api.HeroLevelDistribution) // 统计英雄等级分布信息
- //dash.POST("levelProgress", api.LevelProgress) // 普通关卡进度
- dash.GET("fightingList", api.FightingList) // 战斗数据列表
- dash.GET("fightingExtra", api.FightingExtra) // 战斗数据详情
- dash.GET("fightingExport", api.FightingExport) // 战斗数据列表
- dash.GET("bossInfo", api.DashboardBossLog) // 统计暗影突袭信息
- dash.GET("sevenBasic", api.DashboardSevenBasic) // 七日任务 基础信息
- dash.GET("sevenTask", api.DashboardSevenTask) // 七日任务 任务统计
- dash.GET("sevenAward", api.DashboardSevenAward) // 七日任务 奖励统计
- dash.GET("disconnectList", api.DashboardDisconnectList) // 重连统计列表
- dash.GET("firstAdv", api.DashboardFirstAdv)
- dash.GET("firstAdvStat", api.DashboardFirstAdvStat)
- dash.GET("levelOutputLog", api.LevelOutputLog)
- dash.GET("loginList", api.LoginList)
- dash.GET("export/statistics", api.StatisticsExport)
- }
- }
- for _, info := range r.Routes() {
- if info.Method == http.MethodPost && !config.HasMenu(info.Path) {
- logrus.Panicf("菜单未绑定名称:%v", info.Path)
- }
- }
- return r
- }
|