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.

185 lines
11 KiB

  1. package source
  2. import (
  3. "gin-vue-admin/global"
  4. gormadapter "github.com/casbin/gorm-adapter/v3"
  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: "888", V1: "/autoCode/getSysHistory", V2: "POST"},
  85. {PType: "p", V0: "888", V1: "/autoCode/rollback", V2: "POST"},
  86. {PType: "p", V0: "888", V1: "/autoCode/getMeta", V2: "POST"},
  87. {PType: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"},
  88. {PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
  89. {PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
  90. {PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
  91. {PType: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
  92. {PType: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"},
  93. {PType: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"},
  94. {PType: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"},
  95. {PType: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"},
  96. {PType: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"},
  97. {PType: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"},
  98. {PType: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"},
  99. {PType: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"},
  100. {PType: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"},
  101. {PType: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"},
  102. {PType: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"},
  103. {PType: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"},
  104. {PType: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"},
  105. {PType: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"},
  106. {PType: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"},
  107. {PType: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"},
  108. {PType: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"},
  109. {PType: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"},
  110. {PType: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"},
  111. {PType: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"},
  112. {PType: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"},
  113. {PType: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
  114. {PType: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
  115. {PType: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"},
  116. {PType: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
  117. {PType: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"},
  118. {PType: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"},
  119. {PType: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"},
  120. {PType: "p", V0: "8881", V1: "/customer/customer", V2: "POST"},
  121. {PType: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"},
  122. {PType: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"},
  123. {PType: "p", V0: "8881", V1: "/customer/customer", V2: "GET"},
  124. {PType: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"},
  125. {PType: "p", V0: "9528", V1: "/base/login", V2: "POST"},
  126. {PType: "p", V0: "9528", V1: "/user/register", V2: "POST"},
  127. {PType: "p", V0: "9528", V1: "/api/createApi", V2: "POST"},
  128. {PType: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"},
  129. {PType: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"},
  130. {PType: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"},
  131. {PType: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"},
  132. {PType: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"},
  133. {PType: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"},
  134. {PType: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"},
  135. {PType: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"},
  136. {PType: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"},
  137. {PType: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"},
  138. {PType: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"},
  139. {PType: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"},
  140. {PType: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"},
  141. {PType: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"},
  142. {PType: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"},
  143. {PType: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"},
  144. {PType: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"},
  145. {PType: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"},
  146. {PType: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"},
  147. {PType: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"},
  148. {PType: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"},
  149. {PType: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"},
  150. {PType: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
  151. {PType: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
  152. {PType: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"},
  153. {PType: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
  154. {PType: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"},
  155. {PType: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"},
  156. {PType: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"},
  157. {PType: "p", V0: "9528", V1: "/customer/customer", V2: "POST"},
  158. {PType: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"},
  159. {PType: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"},
  160. {PType: "p", V0: "9528", V1: "/customer/customer", V2: "GET"},
  161. {PType: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"},
  162. {PType: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
  163. }
  164. //@author: [SliverHorn](https://github.com/SliverHorn)
  165. //@description: casbin_rule 表数据初始化
  166. func (c *casbin) Init() error {
  167. global.GVA_DB.AutoMigrate(gormadapter.CasbinRule{})
  168. return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
  169. if tx.Find(&[]gormadapter.CasbinRule{}).RowsAffected == 154 {
  170. color.Danger.Println("\n[Mysql] --> casbin_rule 表的初始数据已存在!")
  171. return nil
  172. }
  173. if err := tx.Create(&carbines).Error; err != nil { // 遇到错误时回滚事务
  174. return err
  175. }
  176. color.Info.Println("\n[Mysql] --> casbin_rule 表初始数据成功!")
  177. return nil
  178. })
  179. }