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.

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