From 59aa60a9746acaa72a2d848f1f73c2c1c55af4c5 Mon Sep 17 00:00:00 2001 From: FynnTang Date: Tue, 29 Aug 2023 18:17:10 +0800 Subject: [PATCH] feat: Optimize curd --- protoc-gen-go-crud/repositories/template.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protoc-gen-go-crud/repositories/template.go b/protoc-gen-go-crud/repositories/template.go index a0403f7..fdb2664 100644 --- a/protoc-gen-go-crud/repositories/template.go +++ b/protoc-gen-go-crud/repositories/template.go @@ -28,11 +28,11 @@ func New{{.ServiceType}}Repo() I{{.ServiceType}}Repo{ return &{{.ServiceType}}Repo{} } -func ({{$firstLetter}} *{{.ServiceType}}Repo) log(ctx context.Context) *zap.SugaredLogger { +func (r *{{.ServiceType}}Repo) log(ctx context.Context) *zap.SugaredLogger { return global.Logger(ctx).Named("{{.ServiceType}}Repo") } -func ({{$firstLetter}} *{{.ServiceType}}Repo) DB(ctx context.Context) *gorm.DB { +func (r *{{.ServiceType}}Repo) DB(ctx context.Context) *gorm.DB { return global.DBFromContext(ctx).Model(&entities.{{.ServiceType}}{}) }