router.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. package server
  2. import (
  3. "gadmin/config"
  4. "gadmin/internal/admin/api"
  5. "gadmin/internal/admin/middleware"
  6. "gadmin/internal/admin/ws"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. "github.com/sirupsen/logrus"
  10. )
  11. // NewEngine 路由配置
  12. func NewEngine() *gin.Engine {
  13. r := gin.New()
  14. //gin.SetMode(os.Getenv(gin.EnvGinMode))
  15. gin.SetMode(gin.ReleaseMode)
  16. // 必要中间件
  17. r.Use(middleware.Recover, middleware.Cors)
  18. r.GET("/", func(c *gin.Context) {
  19. c.Redirect(http.StatusTemporaryRedirect, "/cadmin")
  20. })
  21. r.GET("/login", func(c *gin.Context) {
  22. c.Redirect(http.StatusTemporaryRedirect, "/cadmin")
  23. })
  24. // 静态资源目录
  25. //r.Static("resource", "../web/dist")
  26. //r.StaticFS("/gadmin", http.Dir("../web/dist"))
  27. r.Static("resource", "./resource/public")
  28. //r.StaticFS("/gadmin", packr.NewBox(config.RootPtah+"/resource/public/gadmin888"))
  29. //logrus.Warnf("config.RootPtah+\"/../web/dist\":%v", config.RootPtah+"/../web/dist")
  30. //r.StaticFS("/gadmin", packr.NewBox(config.RootPtah+"/../web/dist"))
  31. r.StaticFS("/cadmin", http.Dir("./resource/public/cadmin"))
  32. r.StaticFS("/json", http.Dir("./resource/public/json"))
  33. r.Handle("GET", "ws", ws.Websocket)
  34. // 日志中间件
  35. r.Use(middleware.Logger)
  36. // 路由
  37. group := r.Group("api")
  38. {
  39. group.GET("ping", api.Ping) // ping
  40. group.GET("download/json", api.JsonResource) // 内部代理下载资源
  41. //group.POST("user/register", api.UserRegister) // 用户注册
  42. //group.POST("user/login", api.UserLogin) // 用户登录
  43. //group.GET("service/list", api.ServiceList) // 服务列表
  44. //group.POST("service/select", api.ServiceSelect) // 选择系统
  45. group.GET("deploy/notify", api.DeployNotify)
  46. migrate := group.Group("migrate")
  47. migrate.Use(middleware.ApiToken())
  48. migrate.POST("userInfo", api.MigrateUserInfo)
  49. migrate.POST("complete", api.MigrateComplete)
  50. peripherals := group.Group("peripherals")
  51. peripherals.Use(middleware.ApiToken())
  52. peripherals.POST("receiveCdk", api.PeripheralsReceiveCdk)
  53. game := group.Group("game")
  54. //game.Use(middleware.GameApiToken())
  55. game.GET("announcement/info", api.AnnouncementInfo) // 获取游戏更新公告
  56. //feishu := group.Group("feishu")
  57. //feishu.Use(middleware.ApiToken())
  58. //feishu.GET("feiShuUserLogin", api.FeiShuUserInfoLogin)
  59. // 只需要验证token的
  60. checkToken := group.Group("")
  61. checkToken.Use(middleware.Token())
  62. {
  63. checkToken.GET("service/list", api.ServiceList) // 服务列表
  64. checkToken.POST("service/select", api.ServiceSelect) // 选择系统
  65. //checkToken.GET("user/checkRolePermission", api.RolePermission) // 管理员用户是否拥有权限管理
  66. }
  67. // 需要登录保护的
  68. auth := group.Group("")
  69. auth.Use(middleware.Token(), middleware.Permission()) // 顺序不能调整
  70. {
  71. auth.GET("user/me", api.UserMe) // 用户信息
  72. auth.POST("user/logout", api.UserLogout) // 退出登录
  73. auth.GET("menu/dynamic", api.MenuDynamic) // 动态菜单
  74. auth.GET("email/list", api.AdminEmailList) // 邮件列表
  75. auth.POST("email/add", api.AdminEmailAdd) // 邮件新增/编辑
  76. auth.POST("email/verify", api.AdminEmailVerify) // 邮件审核
  77. auth.GET("announcement/list", api.AnnouncementList) // 游戏更新公告列表
  78. auth.POST("announcement/add", api.AnnouncementAdd) // 游戏更新公告新增
  79. auth.POST("announcement/del", api.AnnouncementDel) // 游戏更新公告删除
  80. //auth.GET("notice/list", api.NoticeList) // V2广播列表
  81. //auth.POST("notice/add", api.NoticeAdd) // V2广播新增/编辑
  82. //auth.POST("notice/cancel", api.NoticeCancel) // V2广播取消
  83. //auth.GET("channel/stat", api.ChannelStat) // 渠道统计
  84. //auth.POST("channel/statEdit", api.ChannelStatEdit) // 渠道统计编辑
  85. //auth.GET("userAccount/banList", api.UserAccountBanList) // 拉黑玩家列表
  86. auth.GET("userAccount/list", api.UserAccountList) // 玩家列表
  87. auth.GET("userAccount/searchList", api.UserAccountSearch) // 玩家列表
  88. auth.GET("userAccount/get", api.UserAccountGet) // 获取指定玩家信息
  89. //auth.POST("userAccount/userBan", api.UserBan)
  90. //auth.POST("userAccount/singleBanUser", api.SingleBanUser)
  91. //auth.POST("userAccount/paySwitch", api.UpdatePlayerPaySwitch)
  92. //auth.POST("userAccount/banUserChat", api.BanUserChat) // 禁止玩家聊天
  93. //auth.GET("chat/reportList", api.ChatReportList) // 聊天举报列表
  94. //auth.GET("chat/logList", api.ChatLogList) // 聊天消息列表(模拟聊天框)
  95. //auth.GET("chat/download", api.DownloadChatLog) // COS聊天内容下载
  96. //auth.GET("chat/msgList", api.ChatMsgList) // 聊天消息列表
  97. //auth.POST("userAccount/updateNickname", api.UpdateNickname)
  98. //auth.POST("userAccount/compatibilityTestVerify", api.CompatibilityTestVerify)
  99. //auth.POST("userAccount/compatibilityTestMigrate", api.CompatibilityTestMigrate)
  100. //auth.GET("playerMaterial/equipments", api.PlayerEquipments) // 玩家装备列表
  101. auth.GET("playerAttr/get", api.PlayerAttrGet) // 获取指定玩家属性
  102. //auth.GET("playerAttr/getAll", api.PlayerAttrGetAll) // 获取指定玩家属性
  103. //auth.GET("order/userStatistics", api.OrderUserStatistics) // 获取指定玩家订单统计
  104. //auth.GET("signin/count", api.SigninCount) // 获取指定玩家当月签到次数
  105. //auth.GET("changedLogs/list", api.ChangedLogsList)
  106. //auth.GET("changedLogs/statistics", api.ConsumptionStatistics)
  107. //auth.GET("ranking/rechargeRanking", api.RechargeRanking)
  108. //auth.GET("ranking/diamondRanking", api.DiamondRanking)
  109. //auth.GET("ranking/itemRanking", api.ItemRanking)
  110. //auth.GET("ranking/levelRanking", api.LevelRanking) // 等级排名
  111. //auth.GET("ranking/getPVPRankingList", api.GetPVPRankingList) // PVP
  112. //auth.POST("ranking/clearPVPRank", api.ClearPVPRank) // 清除指定玩家PVP排名
  113. //auth.GET("ranking/getCurioRankingList", api.GetCurioRankingList) // 古玩
  114. //auth.POST("ranking/clearCurioRank", api.ClearCurioRank) // 清除指定玩家古玩排名
  115. //auth.GET("ranking/getIdiomRankingList", api.GetIdiomRankingList) // 金榜题名
  116. //auth.POST("ranking/clearIdiomRank", api.ClearIdiomRank) // 清除指定玩家金榜题名排名
  117. //auth.GET("ranking/getBossRankingList", api.GetBossRankingList) // 暗影突袭
  118. //auth.POST("ranking/clearBossRank", api.ClearBossRank) // 清除指定玩家暗影突袭排名
  119. //auth.GET("ranking/advRanking", api.AdvRanking) // 等级排名
  120. //auth.GET("ranking/loginRanking", api.LoginRanking) // 等级排名
  121. //auth.GET("chapter/ordinaryList", api.ChapterOrdinaryList) // 章节普通进度
  122. //auth.GET("chapter/activityList", api.ChapterActivityList) // 章节活动进度
  123. //auth.GET("chapter/reconnect", api.ChapterReconnect) // 重进
  124. auth.GET("retrofitGroup/addPlayer", api.RetrofitGroupAddPlayer) // 为玩家添加配装
  125. auth.GET("retrofitGroup/options", api.RetrofitGroupOptions) // 配装模板选项
  126. auth.GET("retrofitGroup/list", api.RetrofitGroupList) // 配装模板列表
  127. auth.POST("retrofitGroup/edit", api.RetrofitGroupEdit) // 配装模板编辑
  128. auth.POST("retrofitGroup/delete", api.RetrofitGroupDelete) // 配装模板删除
  129. auth.GET("retrofit/list", api.RetrofitList) // 配装列表
  130. auth.POST("retrofit/edit", api.RetrofitEdit) // 配装编辑
  131. auth.POST("retrofit/delete", api.RetrofitDelete) // 配装删除
  132. //auth.POST("cdk/add", api.CdkAdd) // 批量添加cdk
  133. //auth.POST("cdk/del", api.CdkDel) // 删除单个cdk
  134. //auth.GET("cdk/list", api.CdkList) // cdk列表
  135. //auth.GET("cdk/received", api.CdkReceived) // 已领取列表
  136. //auth.POST("cdk/batchInvalid", api.CdkBatchInvalid) // 兑换码批次作废
  137. //auth.GET("cdk/redeemCodeList", api.CdkRedeemCodeList) // 兑换码列表
  138. //auth.GET("gem/stat", api.GemStat) // 获取宝石综合统计
  139. //auth.GET("gem/partStat", api.PartStat) // 获取宝石部位统计
  140. //auth.GET("gem/gemLog", api.GemLog) // 获取宝石统计折线信息
  141. //auth.GET("limitgift/list", api.LimitGiftList) // 限时礼包统计信息
  142. auth.GET("deploy/list", api.DeployList)
  143. auth.POST("deploy/edit", api.DeployEdit)
  144. auth.POST("deploy/delete", api.DeployDelete)
  145. auth.POST("deploy/task", api.DeployTask)
  146. auth.POST("deploy/stop", api.DeployStop)
  147. auth.GET("deployLog/list", api.DeployLogList)
  148. auth.GET("deployLog/view", api.DeployLogView)
  149. // etcd设置
  150. auth.GET("drainageServer/get", api.GetDrainageServer)
  151. auth.POST("drainageServer/edit", api.EditDrainageServer)
  152. auth.GET("drainageServer/getDisplay", api.GetDisplayServer)
  153. auth.POST("drainageServer/editDisplay", api.EditDisplayServer)
  154. auth.GET("drainageServer/getWhiteList", api.GetWhiteListServer)
  155. auth.POST("drainageServer/editWhiteList", api.EditWhiteListServer)
  156. auth.GET("paySwitch/get", api.GetPaySwitch)
  157. //auth.POST("paySwitch/edit", api.EditPaySwitch)
  158. //auth.GET("treasure/list", api.GetTreasureList)
  159. //auth.GET("treasure_chest/list", api.GetTreasureChestList)
  160. //auth.GET("treasure/playerLevel", api.TreasurePlayerLevel)
  161. //auth.GET("treasure/roleWear", api.TreasureRoleWear)
  162. //auth.GET("treasure/level", api.TreasureLevel)
  163. //auth.GET("treasure/star", api.TreasureStar)
  164. //auth.GET("grandmaster/get", api.GetGrandmaster)
  165. //auth.POST("grandmaster/setDanScore", api.SetGrandmasterDanScore)
  166. //auth.GET("grandmaster/list", api.GetGrandmasterList)
  167. //auth.GET("grandmaster/waves", api.GrandmasterWaves)
  168. //auth.GET("grandmaster/seconds", api.GrandmasterSeconds)
  169. //auth.GET("grandmaster/dan", api.GrandmasterDan)
  170. //auth.GET("grandmaster/match", api.GrandmasterMatch)
  171. //auth.GET("alarm/game/list", api.AlarmGameDataList) //游戏异常信息
  172. //auth.GET("alarm/attr/list", api.AlarmAttrList) //玩家属性异常记录
  173. //auth.GET("alarm/cheating/list", api.AlarmCheatingList) //作弊数据列表
  174. // 管理员操作
  175. admin := auth.Group("admin")
  176. admin.GET("roleList", api.AdminRoleList) // 角色列表
  177. admin.GET("roleAuthOption", api.AdminRoleAuthOption) // 角色权限选项
  178. admin.GET("rolePageOption", api.AdminRolePageOption) // 角色可查看页面选项
  179. admin.POST("roleEdit", api.AdminRoleEdit) // 角色修改/创建
  180. admin.GET("roleOption", api.AdminRoleOption) // 角色选项
  181. admin.GET("userList", api.AdminUserList) // 用户列表
  182. admin.POST("userEdit", api.AdminUserEdit) // 用户修改/创建
  183. admin.POST("resetPassword", api.ResetPassword) // 用户重置密码
  184. admin.POST("updatePassword", api.UpdatePassword) // 用户修改密码
  185. admin.GET("logList", api.AdminLogList) // 操作日志
  186. admin.GET("logView", api.AdminLogView) // 操作日志详情
  187. // gm更新操作
  188. gm := auth.Group("gm")
  189. //gm.GET("/msdBalance", api.MsdBalance) // 米大师余额查询
  190. //gm.GET("/balance", api.GetBalance) //查询余额
  191. //gm.POST("/msdSettle", api.MsdSettle) // 米大师操作平账
  192. //gm.GET("/orderSettleList", api.OrderSettleList) // 平账操作记录列表
  193. //gm.POST("/userRoles", api.GetUserRolesInfo) // 获取用户的角色数量信息
  194. //gm.POST("updatePlayerBase", api.UpdatePlayerBase) // 更新玩家金币、钻石、 经验、体力、精力、天赋点
  195. gm.POST("updateChapter", api.UpdateChapter) // 更新关卡数据
  196. //gm.POST("updateTalents", api.UpdateTalents) // 修改天赋
  197. //gm.POST("updateGuides", api.UpdateGuides) // 更新关卡引导
  198. //gm.POST("addEquipment", api.AddEquipment) // 添加装备
  199. gm.POST("addMaterial", api.AddMaterial) // 添加材料
  200. //gm.POST("addExp", api.AddRoleExp) // 添加经验
  201. //gm.POST("addStamina", api.AddRoleStamina) // 添加体力
  202. //gm.POST("upgradeRole", api.UpgradeRole) // 升级角色
  203. //gm.POST("addCoin", api.AddCoin) // 添加钻石
  204. //gm.GET("payorder/sevenStatistics", api.OrderSevenStatistics) // 充值7日统计
  205. //gm.GET("payorder/dailyStatistics", api.OrderDailyStatistics) // 充值每日统计
  206. //gm.GET("orderList", api.OrderList) // 充值订单列表
  207. //gm.GET("abnormalOrderList", api.AbnormalOrderList) // 游戏服异常订单列表
  208. //gm.POST("abnormalOrderReissue", api.AbnormalOrderReissue) // 异常订单一键补发
  209. //gm.GET("payorder", api.QueryPayOrder)
  210. //gm.POST("payorder/export", api.ExportPayOrder)
  211. //gm.GET("payorder/export", api.ExportPayOrder)
  212. //gm.POST("tools/restart", api.ToolsRestart) // 提交重启
  213. //gm.GET("tools/restart_log", api.ToolsRestartLog) // 重启记录
  214. //gm.GET("tools/restartView", api.ToolsRestartView) // 获取指定重启日志
  215. gm.GET("config", api.GetConfig)
  216. //gm.GET("conf_path", api.GetJSONPath)
  217. //gm.POST("set_conf_path", api.SetNewJsonPath)
  218. gm.POST("updateSwitchers", api.EditPaySwitch) // 支付配置
  219. //gm.GET("notices", api.GetNoticeList)
  220. //gm.POST("notices", api.AddNotice)
  221. //gm.POST("del_notice", api.DelNotice)
  222. //gm.GET("letters", api.MailList)
  223. //gm.POST("letters/add", api.SendMail)
  224. //gm.POST("letters/del", api.DeleteMail)
  225. //gm.GET("get_all_exp", api.GetAllExp)
  226. //gm.GET("get_all_roles", api.GetAllRoles)
  227. //gm.GET("get_all_goods", api.GetAllGoods)
  228. //gm.GET("get_all_chapters", api.GetAllChapters)
  229. //gm.GET("get_all_talents", api.GetAllTalents) //
  230. //gm.GET("get_all_equipments", api.GetAllEquipments)
  231. gm.GET("get_all_materials", api.GetAllMaterials)
  232. gm.GET("get_all_runes", api.GetAllRunes)
  233. gm.GET("get_all_legends", api.GetAllLegends)
  234. //gm.POST("add_equipment", api.AddEquipment)
  235. gm.POST("add_material", api.AddMaterial)
  236. gm.POST("add_rune", api.AddRune)
  237. gm.POST("add_legend", api.AddLegend)
  238. //gm.POST("add_gift", api.AddGift)
  239. //gm.POST("upgrade_role", api.UpgradeRole)
  240. //gm.GET("get_role_level", api.GetRoleLevel) // 角色等级查询
  241. //gm.POST("update_el_rank", api.UpdatePlayerElRank)
  242. //gm.POST("delete_player", api.DeletePlayer)
  243. //gm.POST("delete_account", api.DeleteAccount)
  244. //gm.POST("openAccount", api.OpenAccount)
  245. //gm.POST("delRank", api.DelRank)
  246. //gm.GET("getServerDate", api.GetServerDate)
  247. //gm.POST("editServerDate", api.EditServerDate)
  248. //gm.POST("releaseVersion", api.ReleaseVersion)
  249. //gm.GET("versionList", api.VersionList)
  250. //gm.GET("getVersionIndex", api.GetVersionIndex)
  251. //gm.GET("chatLog/playerList", api.ChatLogPlayerList) //获取客服聊天用户列表
  252. //gm.GET("chatLog/info", api.ChatLogInfo) //获取聊天详情
  253. // dash
  254. dash := auth.Group("dash")
  255. //dash.GET("dict", api.DashboadDict)
  256. //dash.GET("events", api.GetAllEventsInfo)
  257. //dash.GET("chapters", api.GetAllChaptersInfo)
  258. //dash.GET("loginlog", api.DashboadLoginLog)
  259. //dash.GET("userChapterLog", api.DashboadUserChaperLog)
  260. //dash.GET("dieLog", api.DashboardDieLog)
  261. //dash.GET("conditionUsers", api.DashboadConditionUsers)
  262. //dash.GET("basicInfo", api.DashboardBasicInfo)
  263. //dash.GET("basicReport", api.DashboardBasicReport)
  264. //dash.GET("basicRetention", api.DashboardBasicRetention)
  265. //dash.GET("conditionReport", api.DashboardEventReport)
  266. //dash.GET("advReport", api.DashboardAdvReport)
  267. //dash.GET("advDetails", api.DashboardAdvDetails)
  268. //dash.GET("advUserDetails", api.DashboardAdvUserDetails)
  269. //dash.GET("advEcharts", api.DashboardAdvEcharts)
  270. //dash.GET("advSumm", api.DashboardAdvSumm)
  271. //dash.GET("goodsReport", api.DashboardGoodsReport)
  272. //dash.GET("chapterPass", api.DashboardChapterPassLog)
  273. //dash.GET("gudongInfo", api.DashboardGudongLog) // 统计古玩信息
  274. //dash.GET("usersMap", api.DashboardUserRolesMap) // 角色数据
  275. //dash.GET("expeditionInfo", api.DashboardExpeditionLog) // 统计远征信息
  276. //dash.GET("expeditionFloor", api.DashboardExpeditionFloor) // 远征关卡未通关信息
  277. //dash.GET("duelInfo", api.DashboardDuelLog) // 统计狭路对决信息
  278. //dash.GET("gradeDistribution", api.GradeDistribution) // 等级分布
  279. dash.GET("console", api.Console) // 控制台统计
  280. //dash.GET("idiomInfo", api.DashboardIdiomLog) // 统计金榜题名信息
  281. //dash.GET("heroLevelDistribution", api.HeroLevelDistribution) // 统计英雄等级分布信息
  282. //dash.POST("levelProgress", api.LevelProgress) // 普通关卡进度
  283. //dash.GET("fightingList", api.FightingList) // 战斗数据列表
  284. //dash.GET("fightingExtra", api.FightingExtra) // 战斗数据详情
  285. //dash.GET("fightingExport", api.FightingExport) // 战斗数据列表
  286. //dash.GET("bossInfo", api.DashboardBossLog) // 统计暗影突袭信息
  287. //dash.GET("sevenBasic", api.DashboardSevenBasic) // 七日任务 基础信息
  288. //dash.GET("sevenTask", api.DashboardSevenTask) // 七日任务 任务统计
  289. //dash.GET("sevenAward", api.DashboardSevenAward) // 七日任务 奖励统计
  290. //dash.GET("disconnectList", api.DashboardDisconnectList) // 重连统计列表
  291. //dash.GET("firstAdv", api.DashboardFirstAdv)
  292. //dash.GET("firstAdvStat", api.DashboardFirstAdvStat)
  293. //dash.GET("levelOutputLog", api.LevelOutputLog)
  294. //dash.GET("loginList", api.LoginList)
  295. //dash.GET("export/statistics", api.StatisticsExport)
  296. }
  297. }
  298. for _, info := range r.Routes() {
  299. if info.Method == http.MethodPost && !config.HasMenu(info.Path) {
  300. logrus.Panicf("菜单未绑定名称:%v", info.Path)
  301. }
  302. }
  303. return r
  304. }