Initial submission of data desensitization strategy backend

This commit is contained in:
Liujian
2024-11-21 17:36:13 +08:00
parent 3c59985734
commit ce53bb2d47
26 changed files with 1196 additions and 18 deletions
+11 -10
View File
@@ -2,9 +2,10 @@ package commit
import (
"context"
"github.com/eolinker/go-common/utils"
"gorm.io/gorm"
"github.com/APIParkLab/APIPark/stores/universally/commit"
)
@@ -18,7 +19,7 @@ type imlCommitWithKeyService[T any] struct {
}
func (i *imlCommitWithKeyService[T]) List(ctx context.Context, uuids ...string) ([]*Commit[T], error) {
list, err := i.store.List(ctx, uuids...)
if err != nil {
return nil, err
@@ -31,7 +32,7 @@ func (i *imlCommitWithKeyService[T]) ListLatest(ctx context.Context, target ...s
if err != nil {
return nil, err
}
return utils.SliceToSlice(list, newCommit[T]), nil
}
@@ -40,7 +41,7 @@ func (i *imlCommitWithKeyService[T]) Get(ctx context.Context, uuid string) (*Com
if err != nil {
return nil, err
}
return newCommit(r), nil
}
@@ -52,7 +53,7 @@ func (i *imlCommitWithKeyService[T]) Latest(ctx context.Context, target string)
if len(list) == 0 {
return nil, gorm.ErrRecordNotFound
}
result := list[0]
return result, nil
}
@@ -70,13 +71,13 @@ func (i *imlCommitService[T]) List(ctx context.Context, uuids ...string) ([]*Com
if err != nil {
return nil, err
}
return utils.SliceToSlice(list, newCommit[T]), nil
}
func (i *imlCommitService[T]) ListLatest(ctx context.Context, target ...string) ([]*Commit[T], error) {
list, err := i.store.Latest(ctx, "", target...)
func (i *imlCommitService[T]) ListLatest(ctx context.Context, key string, target ...string) ([]*Commit[T], error) {
list, err := i.store.Latest(ctx, key, target...)
if err != nil {
return nil, err
}
@@ -88,7 +89,7 @@ func (i *imlCommitService[T]) Get(ctx context.Context, uuid string) (*Commit[T],
if err != nil {
return nil, err
}
return newCommit(r), nil
}
+3 -3
View File
@@ -3,7 +3,7 @@ package commit
import (
"context"
"reflect"
"github.com/APIParkLab/APIPark/stores/universally/commit"
"github.com/eolinker/go-common/autowire"
)
@@ -18,7 +18,7 @@ type ICommitWithKeyService[T any] interface {
func InitCommitWithKeyService[T any](name string, key string) {
autowire.Auto[commit.ICommitWKStore[T]](func() reflect.Value {
return reflect.ValueOf(commit.NewCommitWithKey[T](name, key))
})
autowire.Auto[ICommitWithKeyService[T]](func() reflect.Value {
@@ -28,7 +28,7 @@ func InitCommitWithKeyService[T any](name string, key string) {
type ICommitService[T any] interface {
Latest(ctx context.Context, target string, key string) (*Commit[T], error)
ListLatest(ctx context.Context, target ...string) ([]*Commit[T], error)
ListLatest(ctx context.Context, key string, target ...string) ([]*Commit[T], error)
Save(ctx context.Context, target string, key string, data *T) error
Get(ctx context.Context, uuid string) (*Commit[T], error)
List(ctx context.Context, uuids ...string) ([]*Commit[T], error)