From a14747bbd77be898f15ac4f9dcf242bcb7a40c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Thu, 10 Apr 2025 15:59:30 +0800 Subject: [PATCH] add go lint --- gen_result/pb/product/product.pb.go | 5 +++-- gen_result/pb/product/product_grpc.pb.go | 1 + internal/config/config.go | 5 +++-- internal/logic/category_service/create_logic.go | 3 ++- internal/logic/category_service/list_logic.go | 3 ++- internal/logic/category_service/modify_logic.go | 3 ++- internal/logic/kyc_service/create_logic.go | 3 ++- internal/logic/kyc_service/list_logic.go | 3 ++- internal/logic/kyc_service/update_logic.go | 3 ++- internal/logic/product_item_service/create_logic.go | 3 ++- internal/logic/product_item_service/get_logic.go | 3 ++- .../logic/product_item_service/list_by_product_id_logic.go | 3 ++- internal/logic/product_item_service/update_logic.go | 3 ++- internal/logic/product_item_service/update_status_logic.go | 3 ++- internal/logic/tag_service/create_logic.go | 3 ++- internal/logic/tag_service/list_logic.go | 3 ++- internal/logic/tag_service/modify_logic.go | 3 ++- internal/server/category_service/category_service_server.go | 2 +- internal/server/kyc_service/kyc_service_server.go | 2 +- .../product_item_service/product_item_service_server.go | 2 +- internal/server/tag_service/tag_service_server.go | 2 +- pkg/domain/product/item_types.go | 3 +++ pkg/domain/product/show_type.go | 3 +++ pkg/repository/kyc.go | 6 +++--- 24 files changed, 48 insertions(+), 25 deletions(-) diff --git a/gen_result/pb/product/product.pb.go b/gen_result/pb/product/product.pb.go index 3e4e9b9..ad26053 100644 --- a/gen_result/pb/product/product.pb.go +++ b/gen_result/pb/product/product.pb.go @@ -7,10 +7,11 @@ package product import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/gen_result/pb/product/product_grpc.pb.go b/gen_result/pb/product/product_grpc.pb.go index 40b3733..fdd3219 100644 --- a/gen_result/pb/product/product_grpc.pb.go +++ b/gen_result/pb/product/product_grpc.pb.go @@ -8,6 +8,7 @@ package product import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/internal/config/config.go b/internal/config/config.go index 94afd5e..f581237 100755 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,9 +1,10 @@ package config import ( + "time" + "github.com/zeromicro/go-zero/core/stores/cache" "github.com/zeromicro/go-zero/zrpc" - "time" ) type Config struct { @@ -12,7 +13,7 @@ type Config struct { Cache cache.CacheConf CacheExpireTime time.Duration CacheWithNotFoundExpiry time.Duration - + Mongo struct { Schema string User string diff --git a/internal/logic/category_service/create_logic.go b/internal/logic/category_service/create_logic.go index 04c19b5..f079d8c 100644 --- a/internal/logic/category_service/create_logic.go +++ b/internal/logic/category_service/create_logic.go @@ -1,9 +1,10 @@ package categoryservicelogic import ( - "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" "context" + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/category_service/list_logic.go b/internal/logic/category_service/list_logic.go index e09b277..d102d18 100644 --- a/internal/logic/category_service/list_logic.go +++ b/internal/logic/category_service/list_logic.go @@ -1,9 +1,10 @@ package categoryservicelogic import ( - "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "context" + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/category_service/modify_logic.go b/internal/logic/category_service/modify_logic.go index 8714324..982f96b 100644 --- a/internal/logic/category_service/modify_logic.go +++ b/internal/logic/category_service/modify_logic.go @@ -1,9 +1,10 @@ package categoryservicelogic import ( - "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" "context" + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/kyc_service/create_logic.go b/internal/logic/kyc_service/create_logic.go index 77362dd..9251136 100644 --- a/internal/logic/kyc_service/create_logic.go +++ b/internal/logic/kyc_service/create_logic.go @@ -1,9 +1,10 @@ package kycservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/kyc" - "context" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/kyc_service/list_logic.go b/internal/logic/kyc_service/list_logic.go index b913082..7ba7119 100644 --- a/internal/logic/kyc_service/list_logic.go +++ b/internal/logic/kyc_service/list_logic.go @@ -1,9 +1,10 @@ package kycservicelogic import ( - "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "context" + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/kyc_service/update_logic.go b/internal/logic/kyc_service/update_logic.go index 4c6f0a6..cfa1667 100644 --- a/internal/logic/kyc_service/update_logic.go +++ b/internal/logic/kyc_service/update_logic.go @@ -1,8 +1,9 @@ package kycservicelogic import ( - "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "context" + + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "google.golang.org/protobuf/proto" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" diff --git a/internal/logic/product_item_service/create_logic.go b/internal/logic/product_item_service/create_logic.go index 3c56a90..45e8ff5 100644 --- a/internal/logic/product_item_service/create_logic.go +++ b/internal/logic/product_item_service/create_logic.go @@ -1,11 +1,12 @@ package productitemservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/internal/utils" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "code.30cm.net/digimon/library-go/errs" - "context" PB "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/product_item_service/get_logic.go b/internal/logic/product_item_service/get_logic.go index 7571a80..e945fb1 100644 --- a/internal/logic/product_item_service/get_logic.go +++ b/internal/logic/product_item_service/get_logic.go @@ -1,8 +1,9 @@ package productitemservicelogic import ( - "code.30cm.net/digimon/app-cloudep-product-service/internal/utils" "context" + + "code.30cm.net/digimon/app-cloudep-product-service/internal/utils" "google.golang.org/protobuf/proto" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" diff --git a/internal/logic/product_item_service/list_by_product_id_logic.go b/internal/logic/product_item_service/list_by_product_id_logic.go index 101d9d0..ae19143 100644 --- a/internal/logic/product_item_service/list_by_product_id_logic.go +++ b/internal/logic/product_item_service/list_by_product_id_logic.go @@ -1,11 +1,12 @@ package productitemservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/internal/utils" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "code.30cm.net/digimon/library-go/errs" - "context" "google.golang.org/protobuf/proto" PB "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" diff --git a/internal/logic/product_item_service/update_logic.go b/internal/logic/product_item_service/update_logic.go index 0c24dac..75c2326 100644 --- a/internal/logic/product_item_service/update_logic.go +++ b/internal/logic/product_item_service/update_logic.go @@ -1,12 +1,13 @@ package productitemservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "code.30cm.net/digimon/library-go/errs" - "context" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/internal/logic/product_item_service/update_status_logic.go b/internal/logic/product_item_service/update_status_logic.go index a06f142..7c07563 100644 --- a/internal/logic/product_item_service/update_status_logic.go +++ b/internal/logic/product_item_service/update_status_logic.go @@ -1,9 +1,10 @@ package productitemservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/library-go/errs" - "context" PB "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/logic/tag_service/create_logic.go b/internal/logic/tag_service/create_logic.go index e7b062f..e3c7010 100644 --- a/internal/logic/tag_service/create_logic.go +++ b/internal/logic/tag_service/create_logic.go @@ -1,12 +1,13 @@ package tagservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" domainProduct "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/library-go/errs" - "context" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/internal/logic/tag_service/list_logic.go b/internal/logic/tag_service/list_logic.go index 3febc64..f52a9a4 100644 --- a/internal/logic/tag_service/list_logic.go +++ b/internal/logic/tag_service/list_logic.go @@ -1,13 +1,14 @@ package tagservicelogic import ( + "context" + "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/entity" domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "code.30cm.net/digimon/library-go/errs" - "context" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/internal/logic/tag_service/modify_logic.go b/internal/logic/tag_service/modify_logic.go index 060c228..7d1b705 100644 --- a/internal/logic/tag_service/modify_logic.go +++ b/internal/logic/tag_service/modify_logic.go @@ -1,10 +1,11 @@ package tagservicelogic import ( + "context" + domain "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/product" "code.30cm.net/digimon/app-cloudep-product-service/pkg/domain/usecase" "code.30cm.net/digimon/library-go/errs" - "context" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" diff --git a/internal/server/category_service/category_service_server.go b/internal/server/category_service/category_service_server.go index 8c17628..3266368 100644 --- a/internal/server/category_service/category_service_server.go +++ b/internal/server/category_service/category_service_server.go @@ -8,7 +8,7 @@ import ( "context" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" - "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/category_service" + categoryservicelogic "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/category_service" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" ) diff --git a/internal/server/kyc_service/kyc_service_server.go b/internal/server/kyc_service/kyc_service_server.go index c130fd8..91d755f 100644 --- a/internal/server/kyc_service/kyc_service_server.go +++ b/internal/server/kyc_service/kyc_service_server.go @@ -8,7 +8,7 @@ import ( "context" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" - "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/kyc_service" + kycservicelogic "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/kyc_service" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" ) diff --git a/internal/server/product_item_service/product_item_service_server.go b/internal/server/product_item_service/product_item_service_server.go index ced85db..7814ae5 100644 --- a/internal/server/product_item_service/product_item_service_server.go +++ b/internal/server/product_item_service/product_item_service_server.go @@ -8,7 +8,7 @@ import ( "context" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" - "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/product_item_service" + productitemservicelogic "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/product_item_service" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" ) diff --git a/internal/server/tag_service/tag_service_server.go b/internal/server/tag_service/tag_service_server.go index 6bb7273..8682644 100644 --- a/internal/server/tag_service/tag_service_server.go +++ b/internal/server/tag_service/tag_service_server.go @@ -8,7 +8,7 @@ import ( "context" "code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product" - "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/tag_service" + tagservicelogic "code.30cm.net/digimon/app-cloudep-product-service/internal/logic/tag_service" "code.30cm.net/digimon/app-cloudep-product-service/internal/svc" ) diff --git a/pkg/domain/product/item_types.go b/pkg/domain/product/item_types.go index d5040d9..17e3e10 100644 --- a/pkg/domain/product/item_types.go +++ b/pkg/domain/product/item_types.go @@ -11,6 +11,7 @@ const ( func (t *ItemType) ToString() string { s, _ := ItemTypeToString(*t) + return s } @@ -38,11 +39,13 @@ var stringToItemTypeMap = map[string]ItemType{ // ItemTypeToString 將 ItemType 轉換為字串 func ItemTypeToString(it ItemType) (string, bool) { str, ok := itemTypeToStringMap[it] + return str, ok } // StringToItemType 將字串轉換為 ItemType func StringToItemType(str string) (ItemType, bool) { it, ok := stringToItemTypeMap[str] + return it, ok } diff --git a/pkg/domain/product/show_type.go b/pkg/domain/product/show_type.go index d755d08..f753211 100644 --- a/pkg/domain/product/show_type.go +++ b/pkg/domain/product/show_type.go @@ -8,6 +8,7 @@ const ( func (s *ShowType) ToString() string { str, _ := ShowTypeToString(*s) + return str } @@ -26,11 +27,13 @@ var stringToShowTypeMap = map[string]ShowType{ // ShowTypeToString 將 ShowType 轉換為字串 func ShowTypeToString(st ShowType) (string, bool) { str, ok := showTypeToStringMap[st] + return str, ok } // StringToShowType 將字串轉換為 ShowType func StringToShowType(str string) (ShowType, bool) { st, ok := stringToShowTypeMap[str] + return st, ok } diff --git a/pkg/repository/kyc.go b/pkg/repository/kyc.go index c7e5e93..be9b27c 100644 --- a/pkg/repository/kyc.go +++ b/pkg/repository/kyc.go @@ -104,11 +104,11 @@ func (repo *KYCRepository) List(ctx context.Context, params repository.KYCQueryP // 設置排序選項 opts := options.Find().SetSkip((params.PageIndex - 1) * params.PageSize).SetLimit(params.PageSize) - //if params.SortByDate { + // if params.SortByDate { // opts.SetSort(bson.E{Key: "created_at", Value: -1}) - //} else { + // } else { // opts.SetSort(bson.D{{Key: "updated_at", Value: -1}}) - //} + // } // 查詢符合條件的總數 total, err := repo.DB.GetClient().CountDocuments(ctx, filter) if err != nil {