Browse Source

添加单体bug

yjp 1 year ago
parent
commit
a2b8991ce1

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module baize-demo
 go 1.22.3
 
 require (
-	git.sxidc.com/go-framework/baize v0.8.1
+	git.sxidc.com/go-framework/baize v0.9.0-alpha1
 	git.sxidc.com/go-tools/utils v1.5.15
 	git.sxidc.com/service-supports/fserr v0.3.5
 	git.sxidc.com/service-supports/fslog v0.5.9

+ 2 - 2
go.sum

@@ -1,5 +1,5 @@
-git.sxidc.com/go-framework/baize v0.8.1 h1:99FEhI66oQwR/hxrhMl7BnTE0mCNBJ2mbDC/mX9aivk=
-git.sxidc.com/go-framework/baize v0.8.1/go.mod h1:xE4XwsvwSO8tR5j8BaVZUTngU+HLNICHwdl5x1LULa0=
+git.sxidc.com/go-framework/baize v0.9.0-alpha1 h1:4EKaNJrETKF4kp6woTdsqNFiiyMMbcIJZkVkuLW15YM=
+git.sxidc.com/go-framework/baize v0.9.0-alpha1/go.mod h1:xE4XwsvwSO8tR5j8BaVZUTngU+HLNICHwdl5x1LULa0=
 git.sxidc.com/go-tools/utils v1.5.15 h1:7xs/EM8XZyKycrSSHcPZ6wvyYs+v8uWQ7ZmPP/fHyFI=
 git.sxidc.com/go-tools/utils v1.5.15/go.mod h1:fkobAXFpOMTvkZ82TQXWcpsayePcyk/MS5TN6GTlRDg=
 git.sxidc.com/service-supports/fserr v0.3.5 h1:1SDC60r3FIDd2iRq/oHRLK4OMa1gf67h9B7kierKTUE=

+ 7 - 11
project/mono/application/service/auth.go

@@ -3,7 +3,6 @@ package service
 import (
 	"git.sxidc.com/go-framework/baize/convenient/domain/auth"
 	"git.sxidc.com/go-framework/baize/convenient/domain/auth/middlewares"
-	"git.sxidc.com/go-framework/baize/framework/binding"
 	"git.sxidc.com/go-framework/baize/framework/core/api"
 	"git.sxidc.com/go-framework/baize/framework/core/application"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure"
@@ -20,8 +19,6 @@ var authService = &AuthService{}
 type AuthService struct{}
 
 func (svc *AuthService) Init(appInstance *application.App) error {
-	// TODO 初始化超管用户
-
 	svc.prefixRoot(appInstance)
 	return nil
 }
@@ -31,13 +28,12 @@ func (svc *AuthService) Destroy() error {
 }
 
 func (svc *AuthService) prefixRoot(appInstance *application.App) {
-	prefixRootBinder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, ""), appInstance.Infrastructure())
-
-	auth.BindAuth(prefixRootBinder, &auth.Simple{
-		Schema:         dbSchema,
-		AESKey:         aesKey,
-		JWTSecretKey:   jwtSecretKey,
-		JWTExpiredSec:  24 * 3600,
-		AuthMiddleware: middlewares.Authentication(dbSchema, jwtSecretKey),
+	auth.BindAuth(appInstance, &auth.Simple{
+		Schema:            dbSchema,
+		AESKey:            aesKey,
+		JWTSecretKey:      jwtSecretKey,
+		JWTExpiredSec:     24 * 3600,
+		AuthMiddleware:    middlewares.Authentication(dbSchema, jwtSecretKey),
+		AdminUserPassword: "123456",
 	})
 }

+ 50 - 0
project/mono/deployment/data_service/data_containers/permission.yaml

@@ -0,0 +1,50 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.permissions
+  spec:
+    table_name: test.permissions
+    columns:
+      - name: id
+        type: "varchar(32)"
+        comment: id
+        primary_key: true
+      - name: name
+        type: "varchar(256)"
+        comment: 权限名称
+        not_null: true
+        index: true
+        unique: true
+      - name: description
+        type: "text"
+        comment: 权限描述
+        not_null: true
+      - name: resource
+        type: "text"
+        comment: resource
+        not_null: true
+        index: true
+        unique_index: "permission_resource_action"
+      - name: action
+        type: "varchar(128)"
+        comment: action
+        not_null: true
+        index: true
+        unique_index: "permission_resource_action"
+      - name: create_user_id
+        type: "varchar(32)"
+        comment: 创建用户ID
+        not_null: true
+      - name: last_update_user_id
+        type: "varchar(32)"
+        comment: 最近更新用户ID
+        not_null: true
+      - name: created_time
+        type: "timestamp with time zone"
+        comment: 创建时间
+        not_null: true
+      - name: last_updated_time
+        type: "timestamp with time zone"
+        comment: 最近更新时间
+        not_null: true

+ 38 - 0
project/mono/deployment/data_service/data_containers/permission_group.yaml

@@ -0,0 +1,38 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.permission_groups
+  spec:
+    table_name: test.permission_groups
+    columns:
+      - name: id
+        type: "varchar(32)"
+        comment: id
+        primary_key: true
+      - name: name
+        type: "varchar(256)"
+        comment: 权限名称
+        not_null: true
+        index: true
+        unique: true
+      - name: description
+        type: "text"
+        comment: 权限描述
+        not_null: true
+      - name: create_user_id
+        type: "varchar(32)"
+        comment: 创建用户ID
+        not_null: true
+      - name: last_update_user_id
+        type: "varchar(32)"
+        comment: 最近更新用户ID
+        not_null: true
+      - name: created_time
+        type: "timestamp with time zone"
+        comment: 创建时间
+        not_null: true
+      - name: last_updated_time
+        type: "timestamp with time zone"
+        comment: 最近更新时间
+        not_null: true

+ 16 - 0
project/mono/deployment/data_service/data_containers/permission_group_and_permission.yaml

@@ -0,0 +1,16 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.permission_group_and_permission
+  spec:
+    table_name: test.permission_group_and_permission
+    columns:
+      - name: permission_group_id
+        type: "varchar(32)"
+        comment: 权限组ID
+        primary_key: true
+      - name: permission_id
+        type: "varchar(32)"
+        comment: 权限ID
+        primary_key: true

+ 38 - 0
project/mono/deployment/data_service/data_containers/role.yaml

@@ -0,0 +1,38 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.roles
+  spec:
+    table_name: test.roles
+    columns:
+      - name: id
+        type: "varchar(32)"
+        comment: id
+        primary_key: true
+      - name: name
+        type: "varchar(256)"
+        comment: 权限名称
+        not_null: true
+        index: true
+        unique: true
+      - name: description
+        type: "text"
+        comment: 权限描述
+        not_null: true
+      - name: create_user_id
+        type: "varchar(32)"
+        comment: 创建用户ID
+        not_null: true
+      - name: last_update_user_id
+        type: "varchar(32)"
+        comment: 最近更新用户ID
+        not_null: true
+      - name: created_time
+        type: "timestamp with time zone"
+        comment: 创建时间
+        not_null: true
+      - name: last_updated_time
+        type: "timestamp with time zone"
+        comment: 最近更新时间
+        not_null: true

+ 16 - 0
project/mono/deployment/data_service/data_containers/role_and_permission.yaml

@@ -0,0 +1,16 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.role_and_permission
+  spec:
+    table_name: test.role_and_permission
+    columns:
+      - name: role_id
+        type: "varchar(32)"
+        comment: 角色ID
+        primary_key: true
+      - name: permission_id
+        type: "varchar(32)"
+        comment: 权限ID
+        primary_key: true

+ 51 - 0
project/mono/deployment/data_service/data_containers/user.yaml

@@ -0,0 +1,51 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.users
+  spec:
+    table_name: test.users
+    columns:
+      - name: id
+        type: "varchar(32)"
+        comment: id
+        primary_key: true
+      - name: user_name
+        type: "varchar(256)"
+        comment: 用户名
+        not_null: true
+        index: true
+        unique: true
+      - name: password
+        type: "varchar(512)"
+        comment: 密码
+        not_null: true
+      - name: name
+        type: "varchar(256)"
+        comment: 姓名
+        not_null: true
+      - name: phone
+        type: "varchar(128)"
+        comment: 手机号
+        not_null: true
+      - name: email
+        type: "varchar(512)"
+        comment: 邮箱
+        not_null: true
+      - name: token
+        type: "text"
+        comment: token
+        not_null: true
+        index: true
+      - name: last_login_time
+        type: "timestamp with time zone"
+        comment: 最近登录时间
+        not_null: true
+      - name: created_time
+        type: "timestamp with time zone"
+        comment: 创建时间
+        not_null: true
+      - name: last_updated_time
+        type: "timestamp with time zone"
+        comment: 最近更新时间
+        not_null: true

+ 16 - 0
project/mono/deployment/data_service/data_containers/user_and_role.yaml

@@ -0,0 +1,16 @@
+kind: DataContainer
+spec:
+  namespace: baize
+  data_source: baize
+  name: test.user_and_role
+  spec:
+    table_name: test.user_and_role
+    columns:
+      - name: user_id
+        type: "varchar(32)"
+        comment: 用户ID
+        primary_key: true
+      - name: role_id
+        type: "varchar(32)"
+        comment: 角色ID
+        primary_key: true

+ 1 - 1
project/mono/main.go

@@ -7,7 +7,7 @@ import (
 )
 
 // Version
-// curl -X GET "http://localhost:31000/example/api/version"
+// curl -X GET "http://localhost:32000/mono/api/version"
 
 func main() {
 	application.NewApp()