admin.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package router
  2. import (
  3. _ "Gwen/docs/admin"
  4. "Gwen/http/controller/admin"
  5. "Gwen/http/middleware"
  6. "github.com/gin-gonic/gin"
  7. swaggerFiles "github.com/swaggo/files"
  8. ginSwagger "github.com/swaggo/gin-swagger"
  9. )
  10. func Init(g *gin.Engine) {
  11. //swagger
  12. //g.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  13. g.GET("/admin/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("admin")))
  14. adg := g.Group("/api/admin")
  15. LoginBind(adg)
  16. adg.Use(middleware.AdminAuth())
  17. //FileBind(adg)
  18. UserBind(adg)
  19. GroupBind(adg)
  20. TagBind(adg)
  21. AddressBookBind(adg)
  22. PeerBind(adg)
  23. OauthBind(adg)
  24. LoginLogBind(adg)
  25. AuditBind(adg)
  26. AddressBookCollectionBind(adg)
  27. AddressBookCollectionRuleBind(adg)
  28. rs := &admin.Rustdesk{}
  29. adg.GET("/server-config", rs.ServerConfig)
  30. adg.GET("/app-config", rs.AppConfig)
  31. //访问静态文件
  32. //g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/upload"))
  33. }
  34. func LoginBind(rg *gin.RouterGroup) {
  35. cont := &admin.Login{}
  36. rg.POST("/login", cont.Login)
  37. rg.POST("/logout", cont.Logout)
  38. rg.GET("/login-options", cont.LoginOptions)
  39. rg.POST("/oidc/auth", cont.OidcAuth)
  40. rg.GET("/oidc/auth-query", cont.OidcAuthQuery)
  41. }
  42. func UserBind(rg *gin.RouterGroup) {
  43. aR := rg.Group("/user")
  44. {
  45. cont := &admin.User{}
  46. aR.GET("/current", cont.Current)
  47. aR.POST("/changeCurPwd", cont.ChangeCurPwd)
  48. aR.POST("/myOauth", cont.MyOauth)
  49. aR.POST("/groupUsers", cont.GroupUsers)
  50. }
  51. aRP := rg.Group("/user").Use(middleware.AdminPrivilege())
  52. {
  53. cont := &admin.User{}
  54. aRP.GET("/list", cont.List)
  55. aRP.GET("/detail/:id", cont.Detail)
  56. aRP.POST("/create", cont.Create)
  57. aRP.POST("/update", cont.Update)
  58. aRP.POST("/delete", cont.Delete)
  59. aRP.POST("/changePwd", cont.UpdatePassword)
  60. }
  61. }
  62. func GroupBind(rg *gin.RouterGroup) {
  63. aR := rg.Group("/group").Use(middleware.AdminPrivilege())
  64. {
  65. cont := &admin.Group{}
  66. aR.GET("/list", cont.List)
  67. aR.GET("/detail/:id", cont.Detail)
  68. aR.POST("/create", cont.Create)
  69. aR.POST("/update", cont.Update)
  70. aR.POST("/delete", cont.Delete)
  71. }
  72. }
  73. func TagBind(rg *gin.RouterGroup) {
  74. aR := rg.Group("/tag")
  75. {
  76. cont := &admin.Tag{}
  77. aR.GET("/list", cont.List)
  78. aR.GET("/detail/:id", cont.Detail)
  79. aR.POST("/create", cont.Create)
  80. aR.POST("/update", cont.Update)
  81. aR.POST("/delete", cont.Delete)
  82. }
  83. }
  84. func AddressBookBind(rg *gin.RouterGroup) {
  85. aR := rg.Group("/address_book")
  86. {
  87. cont := &admin.AddressBook{}
  88. aR.GET("/list", cont.List)
  89. aR.GET("/detail/:id", cont.Detail)
  90. aR.POST("/create", cont.Create)
  91. aR.POST("/update", cont.Update)
  92. aR.POST("/delete", cont.Delete)
  93. aR.POST("/shareByWebClient", cont.ShareByWebClient)
  94. arp := aR.Use(middleware.AdminPrivilege())
  95. arp.POST("/batchCreate", cont.BatchCreate)
  96. }
  97. }
  98. func PeerBind(rg *gin.RouterGroup) {
  99. aR := rg.Group("/peer")
  100. {
  101. cont := &admin.Peer{}
  102. aR.GET("/list", cont.List)
  103. aR.GET("/detail/:id", cont.Detail)
  104. aR.POST("/create", cont.Create)
  105. aR.POST("/update", cont.Update)
  106. aR.POST("/delete", cont.Delete)
  107. aR.POST("/simpleData", cont.SimpleData)
  108. arp := aR.Use(middleware.AdminPrivilege())
  109. arp.POST("/batchDelete", cont.BatchDelete)
  110. }
  111. }
  112. func OauthBind(rg *gin.RouterGroup) {
  113. aR := rg.Group("/oauth")
  114. {
  115. cont := &admin.Oauth{}
  116. aR.POST("/confirm", cont.Confirm)
  117. aR.POST("/bind", cont.ToBind)
  118. aR.POST("/bindConfirm", cont.BindConfirm)
  119. aR.POST("/unbind", cont.Unbind)
  120. aR.GET("/info", cont.Info)
  121. }
  122. arp := aR.Use(middleware.AdminPrivilege())
  123. {
  124. cont := &admin.Oauth{}
  125. arp.GET("/list", cont.List)
  126. arp.GET("/detail/:id", cont.Detail)
  127. arp.POST("/create", cont.Create)
  128. arp.POST("/update", cont.Update)
  129. arp.POST("/delete", cont.Delete)
  130. }
  131. }
  132. func LoginLogBind(rg *gin.RouterGroup) {
  133. aR := rg.Group("/login_log")
  134. cont := &admin.LoginLog{}
  135. aR.GET("/list", cont.List)
  136. aR.POST("/delete", cont.Delete)
  137. }
  138. func AuditBind(rg *gin.RouterGroup) {
  139. cont := &admin.Audit{}
  140. aR := rg.Group("/audit_conn").Use(middleware.AdminPrivilege())
  141. aR.GET("/list", cont.ConnList)
  142. aR.POST("/delete", cont.ConnDelete)
  143. afR := rg.Group("/audit_file").Use(middleware.AdminPrivilege())
  144. afR.GET("/list", cont.FileList)
  145. afR.POST("/delete", cont.FileDelete)
  146. }
  147. func AddressBookCollectionBind(rg *gin.RouterGroup) {
  148. aR := rg.Group("/address_book_collection")
  149. {
  150. cont := &admin.AddressBookCollection{}
  151. aR.GET("/list", cont.List)
  152. aR.GET("/detail/:id", cont.Detail)
  153. aR.POST("/create", cont.Create)
  154. aR.POST("/update", cont.Update)
  155. aR.POST("/delete", cont.Delete)
  156. }
  157. }
  158. func AddressBookCollectionRuleBind(rg *gin.RouterGroup) {
  159. aR := rg.Group("/address_book_collection_rule")
  160. {
  161. cont := &admin.AddressBookCollectionRule{}
  162. aR.GET("/list", cont.List)
  163. aR.GET("/detail/:id", cont.Detail)
  164. aR.POST("/create", cont.Create)
  165. aR.POST("/update", cont.Update)
  166. aR.POST("/delete", cont.Delete)
  167. }
  168. }
  169. /*
  170. func FileBind(rg *gin.RouterGroup) {
  171. aR := rg.Group("/file")
  172. {
  173. cont := &admin.File{}
  174. aR.POST("/notify", cont.Notify)
  175. aR.OPTIONS("/oss_token", nil)
  176. aR.OPTIONS("/upload", nil)
  177. aR.GET("/oss_token", cont.OssToken)
  178. aR.POST("/upload", cont.Upload)
  179. }
  180. }*/