You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
11 KiB

  1. package source
  2. import (
  3. "gin-vue-admin/global"
  4. "gin-vue-admin/utils/gormadapter"
  5. "github.com/gookit/color"
  6. "gorm.io/gorm"
  7. )
  8. var Casbin = new(casbin)
  9. type casbin struct{}
  10. var carbines = []gormadapter.CasbinRule{
  11. {Ptype: "p", V0: "888", V1: "/base/login", V2: "POST"},
  12. {Ptype: "p", V0: "888", V1: "/user/register", V2: "POST"},
  13. {Ptype: "p", V0: "888", V1: "/api/createApi", V2: "POST"},
  14. {Ptype: "p", V0: "888", V1: "/api/getApiList", V2: "POST"},
  15. {Ptype: "p", V0: "888", V1: "/api/getApiById", V2: "POST"},
  16. {Ptype: "p", V0: "888", V1: "/api/deleteApi", V2: "POST"},
  17. {Ptype: "p", V0: "888", V1: "/api/updateApi", V2: "POST"},
  18. {Ptype: "p", V0: "888", V1: "/api/getAllApis", V2: "POST"},
  19. {Ptype: "p", V0: "888", V1: "/authority/createAuthority", V2: "POST"},
  20. {Ptype: "p", V0: "888", V1: "/authority/deleteAuthority", V2: "POST"},
  21. {Ptype: "p", V0: "888", V1: "/authority/getAuthorityList", V2: "POST"},
  22. {Ptype: "p", V0: "888", V1: "/authority/setDataAuthority", V2: "POST"},
  23. {Ptype: "p", V0: "888", V1: "/authority/updateAuthority", V2: "PUT"},
  24. {Ptype: "p", V0: "888", V1: "/authority/copyAuthority", V2: "POST"},
  25. {Ptype: "p", V0: "888", V1: "/menu/getMenu", V2: "POST"},
  26. {Ptype: "p", V0: "888", V1: "/menu/getMenuList", V2: "POST"},
  27. {Ptype: "p", V0: "888", V1: "/menu/addBaseMenu", V2: "POST"},
  28. {Ptype: "p", V0: "888", V1: "/menu/getBaseMenuTree", V2: "POST"},
  29. {Ptype: "p", V0: "888", V1: "/menu/addMenuAuthority", V2: "POST"},
  30. {Ptype: "p", V0: "888", V1: "/menu/getMenuAuthority", V2: "POST"},
  31. {Ptype: "p", V0: "888", V1: "/menu/deleteBaseMenu", V2: "POST"},
  32. {Ptype: "p", V0: "888", V1: "/menu/updateBaseMenu", V2: "POST"},
  33. {Ptype: "p", V0: "888", V1: "/menu/getBaseMenuById", V2: "POST"},
  34. {Ptype: "p", V0: "888", V1: "/user/changePassword", V2: "POST"},
  35. {Ptype: "p", V0: "888", V1: "/user/getUserList", V2: "POST"},
  36. {Ptype: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"},
  37. {Ptype: "p", V0: "888", V1: "/user/deleteUser", V2: "DELETE"},
  38. {Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"},
  39. {Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
  40. {Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
  41. {Ptype: "p", V0: "888", V1: "/casbin/updateCasbin", V2: "POST"},
  42. {Ptype: "p", V0: "888", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
  43. {Ptype: "p", V0: "888", V1: "/casbin/casbinTest/:pathParam", V2: "GET"},
  44. {Ptype: "p", V0: "888", V1: "/jwt/jsonInBlacklist", V2: "POST"},
  45. {Ptype: "p", V0: "888", V1: "/system/getSystemConfig", V2: "POST"},
  46. {Ptype: "p", V0: "888", V1: "/system/setSystemConfig", V2: "POST"},
  47. {Ptype: "p", V0: "888", V1: "/system/getServerInfo", V2: "POST"},
  48. {Ptype: "p", V0: "888", V1: "/customer/customer", V2: "POST"},
  49. {Ptype: "p", V0: "888", V1: "/customer/customer", V2: "PUT"},
  50. {Ptype: "p", V0: "888", V1: "/customer/customer", V2: "DELETE"},
  51. {Ptype: "p", V0: "888", V1: "/customer/customer", V2: "GET"},
  52. {Ptype: "p", V0: "888", V1: "/customer/customerList", V2: "GET"},
  53. {Ptype: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
  54. {Ptype: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"},
  55. {Ptype: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
  56. {Ptype: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
  57. {Ptype: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},
  58. {Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"},
  59. {Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"},
  60. {Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"},
  61. {Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/findSysDictionaryDetail", V2: "GET"},
  62. {Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/getSysDictionaryDetailList", V2: "GET"},
  63. {Ptype: "p", V0: "888", V1: "/sysDictionary/createSysDictionary", V2: "POST"},
  64. {Ptype: "p", V0: "888", V1: "/sysDictionary/deleteSysDictionary", V2: "DELETE"},
  65. {Ptype: "p", V0: "888", V1: "/sysDictionary/updateSysDictionary", V2: "PUT"},
  66. {Ptype: "p", V0: "888", V1: "/sysDictionary/findSysDictionary", V2: "GET"},
  67. {Ptype: "p", V0: "888", V1: "/sysDictionary/getSysDictionaryList", V2: "GET"},
  68. {Ptype: "p", V0: "888", V1: "/sysOperationRecord/createSysOperationRecord", V2: "POST"},
  69. {Ptype: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecord", V2: "DELETE"},
  70. {Ptype: "p", V0: "888", V1: "/sysOperationRecord/updateSysOperationRecord", V2: "PUT"},
  71. {Ptype: "p", V0: "888", V1: "/sysOperationRecord/findSysOperationRecord", V2: "GET"},
  72. {Ptype: "p", V0: "888", V1: "/sysOperationRecord/getSysOperationRecordList", V2: "GET"},
  73. {Ptype: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecordByIds", V2: "DELETE"},
  74. {Ptype: "p", V0: "888", V1: "/user/setUserInfo", V2: "PUT"},
  75. {Ptype: "p", V0: "888", V1: "/email/emailTest", V2: "POST"},
  76. {Ptype: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
  77. {Ptype: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
  78. {Ptype: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
  79. {Ptype: "p", V0: "888", V1: "/excel/importExcel", V2: "POST"},
  80. {Ptype: "p", V0: "888", V1: "/excel/loadExcel", V2: "GET"},
  81. {Ptype: "p", V0: "888", V1: "/excel/exportExcel", V2: "POST"},
  82. {Ptype: "p", V0: "888", V1: "/excel/downloadTemplate", V2: "GET"},
  83. {Ptype: "p", V0: "888", V1: "/api/deleteApisByIds", V2: "DELETE"},
  84. {Ptype: "p", V0: "8881", V1: "/base/login", V2: "POST"},
  85. {Ptype: "p", V0: "8881", V1: "/user/register", V2: "POST"},
  86. {Ptype: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
  87. {Ptype: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
  88. {Ptype: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"},
  89. {Ptype: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"},
  90. {Ptype: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"},
  91. {Ptype: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"},
  92. {Ptype: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"},
  93. {Ptype: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"},
  94. {Ptype: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"},
  95. {Ptype: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"},
  96. {Ptype: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"},
  97. {Ptype: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"},
  98. {Ptype: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"},
  99. {Ptype: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"},
  100. {Ptype: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"},
  101. {Ptype: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"},
  102. {Ptype: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"},
  103. {Ptype: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"},
  104. {Ptype: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"},
  105. {Ptype: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"},
  106. {Ptype: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"},
  107. {Ptype: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"},
  108. {Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"},
  109. {Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
  110. {Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
  111. {Ptype: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"},
  112. {Ptype: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
  113. {Ptype: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"},
  114. {Ptype: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"},
  115. {Ptype: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"},
  116. {Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "POST"},
  117. {Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"},
  118. {Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"},
  119. {Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "GET"},
  120. {Ptype: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"},
  121. {Ptype: "p", V0: "9528", V1: "/base/login", V2: "POST"},
  122. {Ptype: "p", V0: "9528", V1: "/user/register", V2: "POST"},
  123. {Ptype: "p", V0: "9528", V1: "/api/createApi", V2: "POST"},
  124. {Ptype: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"},
  125. {Ptype: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"},
  126. {Ptype: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"},
  127. {Ptype: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"},
  128. {Ptype: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"},
  129. {Ptype: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"},
  130. {Ptype: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"},
  131. {Ptype: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"},
  132. {Ptype: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"},
  133. {Ptype: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"},
  134. {Ptype: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"},
  135. {Ptype: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"},
  136. {Ptype: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"},
  137. {Ptype: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"},
  138. {Ptype: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"},
  139. {Ptype: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"},
  140. {Ptype: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"},
  141. {Ptype: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"},
  142. {Ptype: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"},
  143. {Ptype: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"},
  144. {Ptype: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"},
  145. {Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"},
  146. {Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
  147. {Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
  148. {Ptype: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"},
  149. {Ptype: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
  150. {Ptype: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"},
  151. {Ptype: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"},
  152. {Ptype: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"},
  153. {Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "POST"},
  154. {Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"},
  155. {Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"},
  156. {Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "GET"},
  157. {Ptype: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"},
  158. {Ptype: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
  159. }
  160. //@author: [SliverHorn](https://github.com/SliverHorn)
  161. //@description: casbin_rule 表数据初始化
  162. func (c *casbin) Init() error {
  163. global.GVA_DB.AutoMigrate(gormadapter.CasbinRule{})
  164. return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
  165. if tx.Find(&[]gormadapter.CasbinRule{}).RowsAffected == 154 {
  166. color.Danger.Println("\n[Mysql] --> casbin_rule 表的初始数据已存在!")
  167. return nil
  168. }
  169. if err := tx.Create(&carbines).Error; err != nil { // 遇到错误时回滚事务
  170. return err
  171. }
  172. color.Info.Println("\n[Mysql] --> casbin_rule 表初始数据成功!")
  173. return nil
  174. })
  175. }