router.go 17 KB

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