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.

165 lines
10 KiB

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