diff --git a/protoc-gen-go-crud/internal/authorization/deliveries/role.go b/protoc-gen-go-crud/internal/authorization/deliveries/role.go index 6c88f95..cec1cb7 100644 --- a/protoc-gen-go-crud/internal/authorization/deliveries/role.go +++ b/protoc-gen-go-crud/internal/authorization/deliveries/role.go @@ -1,10 +1,7 @@ package deliveries import ( - authorizationV1 "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/api/v1/authorization" components "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/api/v1/components" - "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/internal/authorization/usecase" - "github.com/gin-gonic/gin" empty "github.com/golang/protobuf/ptypes/empty" ) diff --git a/protoc-gen-go-crud/internal/authorization/repositories/authorization.go b/protoc-gen-go-crud/internal/authorization/repositories/authorization.go index ef7f50d..58fdfc9 100644 --- a/protoc-gen-go-crud/internal/authorization/repositories/authorization.go +++ b/protoc-gen-go-crud/internal/authorization/repositories/authorization.go @@ -4,7 +4,7 @@ type IAuthRepo interface { CreateAuth(ctx context.Context, Auth *entities.Auth) error UpdateAuth(ctx context.Context, updateFields []string, Auth *entities.Auth) error GetAuth(ctx context.Context, id entity.ID) (*entities.Auth, error) - GetAuths(ctx context.Context, filter *database.Filter) (res []*entities.User, count int64, err error) + GetAuths(ctx context.Context, filter *database.Filter) (res []*entities.Auth, count int64, err error) DeleteAuth(ctx context.Context, id entity.ID) error Log(ctx context.Context) *zap.SugaredLogger } @@ -39,3 +39,7 @@ func (a AuthRepo) GetAuths(ctx context.Context, filter *database.Filter) (res [] func (a AuthRepo) Log(ctx context.Context) *zap.SugaredLogger { return global.Logger(ctx).Named("AuthRepo") } + +func NewAuthRepo() IAuthRepo { + return &AuthRepo{} +} diff --git a/protoc-gen-go-crud/internal/authorization/repositories/role.go b/protoc-gen-go-crud/internal/authorization/repositories/role.go index 523e446..11d9ba3 100644 --- a/protoc-gen-go-crud/internal/authorization/repositories/role.go +++ b/protoc-gen-go-crud/internal/authorization/repositories/role.go @@ -4,7 +4,7 @@ type IRoleRepo interface { CreateRole(ctx context.Context, Role *entities.Role) error UpdateRole(ctx context.Context, updateFields []string, Role *entities.Role) error GetRole(ctx context.Context, id entity.ID) (*entities.Role, error) - GetRoles(ctx context.Context, filter *database.Filter) (res []*entities.User, count int64, err error) + GetRoles(ctx context.Context, filter *database.Filter) (res []*entities.Role, count int64, err error) DeleteRole(ctx context.Context, id entity.ID) error Log(ctx context.Context) *zap.SugaredLogger } @@ -39,3 +39,7 @@ func (r RoleRepo) GetRoles(ctx context.Context, filter *database.Filter) (res [] func (r RoleRepo) Log(ctx context.Context) *zap.SugaredLogger { return global.Logger(ctx).Named("RoleRepo") } + +func NewRoleRepo() IRoleRepo { + return &RoleRepo{} +} diff --git a/protoc-gen-go-crud/internal/users/repositories/users.go b/protoc-gen-go-crud/internal/users/repositories/users.go index 4733a40..bd51fb1 100644 --- a/protoc-gen-go-crud/internal/users/repositories/users.go +++ b/protoc-gen-go-crud/internal/users/repositories/users.go @@ -39,3 +39,7 @@ func (u UserRepo) GetUsers(ctx context.Context, filter *database.Filter) (res [] func (u UserRepo) Log(ctx context.Context) *zap.SugaredLogger { return global.Logger(ctx).Named("UserRepo") } + +func NewUserRepo() IUserRepo { + return &UserRepo{} +} diff --git a/protoc-gen-go-crud/protoc-gen-go-crud b/protoc-gen-go-crud/protoc-gen-go-crud index 5c2633f..80b784c 100755 Binary files a/protoc-gen-go-crud/protoc-gen-go-crud and b/protoc-gen-go-crud/protoc-gen-go-crud differ diff --git a/protoc-gen-go-crud/repositories/template.go b/protoc-gen-go-crud/repositories/template.go index 384715c..efdbaa1 100644 --- a/protoc-gen-go-crud/repositories/template.go +++ b/protoc-gen-go-crud/repositories/template.go @@ -12,7 +12,7 @@ type I{{.ServiceType}}Repo interface { Create{{.ServiceType}}(ctx context.Context, {{.ServiceType}} *entities.{{.ServiceType}}) error Update{{.ServiceType}}(ctx context.Context, updateFields []string,{{.ServiceType}} *entities.{{.ServiceType}}) error Get{{.ServiceType}}(ctx context.Context, id entity.ID) (*entities.{{.ServiceType}}, error) - Get{{.ServiceType}}s(ctx context.Context, filter *database.Filter) (res []*entities.User, count int64, err error) + Get{{.ServiceType}}s(ctx context.Context, filter *database.Filter) (res []*entities.{{.ServiceType}}, count int64, err error) Delete{{.ServiceType}}(ctx context.Context, id entity.ID) error Log(ctx context.Context) *zap.SugaredLogger } @@ -53,7 +53,9 @@ func ({{$firstLetter}} {{.ServiceType}}Repo) Log(ctx context.Context) *zap.Sugar return global.Logger(ctx).Named("{{.ServiceType}}Repo") } - +func New{{.ServiceType}}Repo() I{{.ServiceType}}Repo{ + return &{{.ServiceType}}Repo{} +} ` type serviceDesc struct {