feat: url func
This commit is contained in:
		
						commit
						6fe39b6c61
					
				| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
# Default ignored files
 | 
			
		||||
/shelf/
 | 
			
		||||
/workspace.xml
 | 
			
		||||
# Editor-based HTTP Client requests
 | 
			
		||||
/httpRequests/
 | 
			
		||||
# Datasource local storage ignored files
 | 
			
		||||
/dataSources/
 | 
			
		||||
/dataSources.local.xml
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="MaterialThemeProjectNewConfig">
 | 
			
		||||
    <option name="metadata">
 | 
			
		||||
      <MTProjectMetadataState>
 | 
			
		||||
        <option name="migrated" value="true" />
 | 
			
		||||
        <option name="pristineConfig" value="false" />
 | 
			
		||||
        <option name="userId" value="54486609:193ed9d45bc:-7ffe" />
 | 
			
		||||
      </MTProjectMetadataState>
 | 
			
		||||
    </option>
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="ProjectModuleManager">
 | 
			
		||||
    <modules>
 | 
			
		||||
      <module fileurl="file://$PROJECT_DIR$/.idea/url_generate.iml" filepath="$PROJECT_DIR$/.idea/url_generate.iml" />
 | 
			
		||||
    </modules>
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="SwaggerSettings">
 | 
			
		||||
    <option name="defaultPreviewType" value="SWAGGER_UI" />
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<module type="WEB_MODULE" version="4">
 | 
			
		||||
  <component name="Go" enabled="true" />
 | 
			
		||||
  <component name="NewModuleRootManager">
 | 
			
		||||
    <content url="file://$MODULE_DIR$" />
 | 
			
		||||
    <orderEntry type="inheritedJdk" />
 | 
			
		||||
    <orderEntry type="sourceFolder" forTests="false" />
 | 
			
		||||
  </component>
 | 
			
		||||
</module>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
GO_CTL_NAME=goctl
 | 
			
		||||
 | 
			
		||||
# go-zero 生成風格
 | 
			
		||||
GO_ZERO_STYLE=go_zero
 | 
			
		||||
 | 
			
		||||
GO ?= go
 | 
			
		||||
GOFMT ?= gofmt "-s"
 | 
			
		||||
GOFILES := $(shell find . -name "*.go")
 | 
			
		||||
LDFLAGS := -s -w
 | 
			
		||||
VERSION="v1.0.1"
 | 
			
		||||
DOCKER_REPO="igs170911/feed"
 | 
			
		||||
 | 
			
		||||
.PHONY: test
 | 
			
		||||
test: # 進行測試
 | 
			
		||||
	go test -v --cover ./...
 | 
			
		||||
 | 
			
		||||
.PHONY: fmt
 | 
			
		||||
fmt: # 格式優化
 | 
			
		||||
	$(GOFMT) -w $(GOFILES)
 | 
			
		||||
	goimports -w  ./
 | 
			
		||||
	golangci-lint run
 | 
			
		||||
 | 
			
		||||
.PHONY: gen-swagger
 | 
			
		||||
gen-swagger: # 格式優化
 | 
			
		||||
	goctl api plugin -plugin goctl-swagger="swagger -filename url.json -host 127.0.0.1:8888" -api ./generate/api/url_generate.api -dir .
 | 
			
		||||
 | 
			
		||||
.PHONY: gen-api
 | 
			
		||||
gen-api: # 產生 api
 | 
			
		||||
	goctl api go -api ./generate/api/url_generate.api -dir . -style go_zero
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.PHONY: mock-gen
 | 
			
		||||
mock-gen: # 建立 mock 資料
 | 
			
		||||
	mockgen -source=./internal/module/product/domain/repository/category.go -destination=./internal/module/product/mock/repository/category.go -package=mock
 | 
			
		||||
	mockgen -source=./internal/module/product/domain/repository/supplementary_info.go -destination=./internal/module/product/mock/repository/supplementary_info.go -package=mock
 | 
			
		||||
	mockgen -source=./internal/module/product/domain/repository/product.go -destination=./internal/module/product/mock/repository/product.go -package=mock
 | 
			
		||||
	mockgen -source=./internal/module/product/domain/repository/tags.go -destination=./internal/module/product/mock/repository/tags.go -package=mock
 | 
			
		||||
	mockgen -source=./internal/module/product/domain/repository/product_item.go -destination=./internal/module/product/mock/repository/product_item.go -package=mock
 | 
			
		||||
	mockgen -source=./internal/module/cart/domain/repository/cart.go -destination=./internal/module/cart/mock/repository/cart.go -package=mock
 | 
			
		||||
	@echo "Generate mock files successfully"
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
Name: url
 | 
			
		||||
Host: 0.0.0.0
 | 
			
		||||
Port: 8888
 | 
			
		||||
 | 
			
		||||
Cache:
 | 
			
		||||
  - Host: 127.0.0.1:6379
 | 
			
		||||
    type: node
 | 
			
		||||
 | 
			
		||||
Mongo:
 | 
			
		||||
  Schema: 
 | 
			
		||||
  Host:
 | 
			
		||||
  User:
 | 
			
		||||
  Password:
 | 
			
		||||
  Database: digimon_url
 | 
			
		||||
  ReplicaName: "rs0"
 | 
			
		||||
  MaxStaleness: 30m
 | 
			
		||||
  MaxPoolSize: 30
 | 
			
		||||
  MinPoolSize: 10
 | 
			
		||||
  MaxConnIdleTime: 30m
 | 
			
		||||
  Compressors       :
 | 
			
		||||
    -
 | 
			
		||||
  EnableStandardReadWriteSplitMode: false
 | 
			
		||||
  ConnectTimeoutMs: 3000
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
syntax = "v1"
 | 
			
		||||
 | 
			
		||||
info (
 | 
			
		||||
	title:   "Short URL Gateway"
 | 
			
		||||
	desc:    "Service for generating, retrieving, and deleting short URLs"
 | 
			
		||||
	author:  "Daniel Wang"
 | 
			
		||||
	email:   "igs170911@gmail.com"
 | 
			
		||||
	version: "0.0.1"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type RespOK {}
 | 
			
		||||
 | 
			
		||||
type CreateShortURLRequest {
 | 
			
		||||
	URL string `json:"url" validate:"required"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLRequest {
 | 
			
		||||
	ShortCode string `path:"short_code"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Status {
 | 
			
		||||
	Code    int64       `json:"code"` // 狀態碼
 | 
			
		||||
	Message string      `json:"message"` // 訊息
 | 
			
		||||
	Data    interface{} `json:"data,omitempty"` // 可選的資料,當有返回時才出現
 | 
			
		||||
	Error   interface{} `json:"error,omitempty"` // 可選的錯誤信息
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLResponse {
 | 
			
		||||
	URL string `json:"url" validate:"required"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLCodeResponse {
 | 
			
		||||
	Code string `json:"short_code"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@server (
 | 
			
		||||
	group:   url
 | 
			
		||||
	prefix:  /api/v1/url
 | 
			
		||||
	schemes: https
 | 
			
		||||
	timeout: 10s
 | 
			
		||||
)
 | 
			
		||||
service url {
 | 
			
		||||
	/* @respdoc-400 (BaseResponse) // Invalid input parameters */
 | 
			
		||||
	/* @respdoc-500 (BaseResponse) // Server error */
 | 
			
		||||
	@doc (
 | 
			
		||||
		summary:     "Create Short URL"
 | 
			
		||||
		description: "Map a long URL to a short URL"
 | 
			
		||||
	)
 | 
			
		||||
	@handler createShortURL
 | 
			
		||||
	post / (CreateShortURLRequest) returns (URLCodeResponse)
 | 
			
		||||
 | 
			
		||||
	/* @respdoc-400 (BaseResponse) // Invalid input parameters */
 | 
			
		||||
	/* @respdoc-500 (BaseResponse) // Server error */
 | 
			
		||||
	@doc (
 | 
			
		||||
		summary:     "Retrieve Short URL"
 | 
			
		||||
		description: "Retrieve the original URL using the short URL"
 | 
			
		||||
	)
 | 
			
		||||
	@handler getOriginalURL
 | 
			
		||||
	get /:short_code (URLRequest) returns (URLResponse)
 | 
			
		||||
 | 
			
		||||
	/* @respdoc-400 (BaseResponse) // Invalid input parameters */
 | 
			
		||||
	/* @respdoc-500 (BaseResponse) // Server error */
 | 
			
		||||
	@doc (
 | 
			
		||||
		summary:     "Delete Short URL"
 | 
			
		||||
		description: "Delete a short URL mapping"
 | 
			
		||||
	)
 | 
			
		||||
	@handler deleteShortURL
 | 
			
		||||
	delete /:short_code (URLRequest) returns (RespOK)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,105 @@
 | 
			
		|||
module url_generate
 | 
			
		||||
 | 
			
		||||
go 1.23.4
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	code.30cm.net/digimon/library-go/errs v1.2.12
 | 
			
		||||
	code.30cm.net/digimon/library-go/mongo v0.0.9
 | 
			
		||||
	github.com/alicebob/miniredis/v2 v2.33.0
 | 
			
		||||
	github.com/stretchr/testify v1.9.0
 | 
			
		||||
	github.com/testcontainers/testcontainers-go v0.34.0
 | 
			
		||||
	github.com/zeromicro/go-zero v1.7.4
 | 
			
		||||
	go.mongodb.org/mongo-driver v1.17.1
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	dario.cat/mergo v1.0.0 // indirect
 | 
			
		||||
	github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
 | 
			
		||||
	github.com/Microsoft/go-winio v0.6.2 // indirect
 | 
			
		||||
	github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
 | 
			
		||||
	github.com/beorn7/perks v1.0.1 // indirect
 | 
			
		||||
	github.com/cenkalti/backoff/v4 v4.3.0 // indirect
 | 
			
		||||
	github.com/cespare/xxhash/v2 v2.3.0 // indirect
 | 
			
		||||
	github.com/containerd/containerd v1.7.18 // indirect
 | 
			
		||||
	github.com/containerd/log v0.1.0 // indirect
 | 
			
		||||
	github.com/containerd/platforms v0.2.1 // indirect
 | 
			
		||||
	github.com/cpuguy83/dockercfg v0.3.2 // indirect
 | 
			
		||||
	github.com/davecgh/go-spew v1.1.1 // indirect
 | 
			
		||||
	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 | 
			
		||||
	github.com/distribution/reference v0.6.0 // indirect
 | 
			
		||||
	github.com/docker/docker v27.1.1+incompatible // indirect
 | 
			
		||||
	github.com/docker/go-connections v0.5.0 // indirect
 | 
			
		||||
	github.com/docker/go-units v0.5.0 // indirect
 | 
			
		||||
	github.com/fatih/color v1.18.0 // indirect
 | 
			
		||||
	github.com/felixge/httpsnoop v1.0.4 // indirect
 | 
			
		||||
	github.com/go-logr/logr v1.4.2 // indirect
 | 
			
		||||
	github.com/go-logr/stdr v1.2.2 // indirect
 | 
			
		||||
	github.com/go-ole/go-ole v1.2.6 // indirect
 | 
			
		||||
	github.com/gogo/protobuf v1.3.2 // indirect
 | 
			
		||||
	github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
 | 
			
		||||
	github.com/golang/snappy v0.0.4 // indirect
 | 
			
		||||
	github.com/google/uuid v1.6.0 // indirect
 | 
			
		||||
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
 | 
			
		||||
	github.com/klauspost/compress v1.17.9 // indirect
 | 
			
		||||
	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
 | 
			
		||||
	github.com/magiconair/properties v1.8.7 // indirect
 | 
			
		||||
	github.com/mattn/go-colorable v0.1.13 // indirect
 | 
			
		||||
	github.com/mattn/go-isatty v0.0.20 // indirect
 | 
			
		||||
	github.com/moby/docker-image-spec v1.3.1 // indirect
 | 
			
		||||
	github.com/moby/patternmatcher v0.6.0 // indirect
 | 
			
		||||
	github.com/moby/sys/sequential v0.5.0 // indirect
 | 
			
		||||
	github.com/moby/sys/user v0.1.0 // indirect
 | 
			
		||||
	github.com/moby/term v0.5.0 // indirect
 | 
			
		||||
	github.com/montanaflynn/stats v0.7.1 // indirect
 | 
			
		||||
	github.com/morikuni/aec v1.0.0 // indirect
 | 
			
		||||
	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 | 
			
		||||
	github.com/opencontainers/go-digest v1.0.0 // indirect
 | 
			
		||||
	github.com/opencontainers/image-spec v1.1.0 // indirect
 | 
			
		||||
	github.com/openzipkin/zipkin-go v0.4.3 // indirect
 | 
			
		||||
	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
 | 
			
		||||
	github.com/pkg/errors v0.9.1 // indirect
 | 
			
		||||
	github.com/pmezard/go-difflib v1.0.0 // indirect
 | 
			
		||||
	github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
 | 
			
		||||
	github.com/prometheus/client_golang v1.20.5 // indirect
 | 
			
		||||
	github.com/prometheus/client_model v0.6.1 // indirect
 | 
			
		||||
	github.com/prometheus/common v0.55.0 // indirect
 | 
			
		||||
	github.com/prometheus/procfs v0.15.1 // indirect
 | 
			
		||||
	github.com/redis/go-redis/v9 v9.7.0 // indirect
 | 
			
		||||
	github.com/shirou/gopsutil/v3 v3.23.12 // indirect
 | 
			
		||||
	github.com/shoenig/go-m1cpu v0.1.6 // indirect
 | 
			
		||||
	github.com/shopspring/decimal v1.4.0 // indirect
 | 
			
		||||
	github.com/sirupsen/logrus v1.9.3 // indirect
 | 
			
		||||
	github.com/spaolacci/murmur3 v1.1.0 // indirect
 | 
			
		||||
	github.com/tklauser/go-sysconf v0.3.12 // indirect
 | 
			
		||||
	github.com/tklauser/numcpus v0.6.1 // indirect
 | 
			
		||||
	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 | 
			
		||||
	github.com/xdg-go/scram v1.1.2 // indirect
 | 
			
		||||
	github.com/xdg-go/stringprep v1.0.4 // indirect
 | 
			
		||||
	github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
 | 
			
		||||
	github.com/yuin/gopher-lua v1.1.1 // indirect
 | 
			
		||||
	github.com/yusufpapurcu/wmi v1.2.3 // indirect
 | 
			
		||||
	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/metric v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/sdk v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/trace v1.24.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/proto/otlp v1.3.1 // indirect
 | 
			
		||||
	go.uber.org/automaxprocs v1.6.0 // indirect
 | 
			
		||||
	golang.org/x/crypto v0.29.0 // indirect
 | 
			
		||||
	golang.org/x/net v0.31.0 // indirect
 | 
			
		||||
	golang.org/x/sync v0.9.0 // indirect
 | 
			
		||||
	golang.org/x/sys v0.27.0 // indirect
 | 
			
		||||
	golang.org/x/text v0.20.0 // indirect
 | 
			
		||||
	google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
 | 
			
		||||
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
 | 
			
		||||
	google.golang.org/grpc v1.65.0 // indirect
 | 
			
		||||
	google.golang.org/protobuf v1.35.2 // indirect
 | 
			
		||||
	gopkg.in/yaml.v2 v2.4.0 // indirect
 | 
			
		||||
	gopkg.in/yaml.v3 v3.0.1 // indirect
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,299 @@
 | 
			
		|||
code.30cm.net/digimon/library-go/errs v1.2.12 h1:y4lIUTrJJh4W3lrwnfDsQ9wyGYGk5ivi9wrFrOh6YFI=
 | 
			
		||||
code.30cm.net/digimon/library-go/errs v1.2.12/go.mod h1:Hs4v7SbXNggDVBGXSYsFMjkii1qLF+rugrIpWePN4/o=
 | 
			
		||||
code.30cm.net/digimon/library-go/mongo v0.0.9 h1:fPciIE5B85tXpLg8aeVQqKVbLnfpVAk9xbMu7pE2tVw=
 | 
			
		||||
code.30cm.net/digimon/library-go/mongo v0.0.9/go.mod h1:KBVKz/Ci5IheI77BgZxPUeKkaGvDy8fV8EDHSCOLIO4=
 | 
			
		||||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
 | 
			
		||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
 | 
			
		||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
 | 
			
		||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
 | 
			
		||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
 | 
			
		||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
 | 
			
		||||
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
 | 
			
		||||
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
 | 
			
		||||
github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
 | 
			
		||||
github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
 | 
			
		||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
 | 
			
		||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
 | 
			
		||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
 | 
			
		||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
 | 
			
		||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
 | 
			
		||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
 | 
			
		||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
 | 
			
		||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
			
		||||
github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao=
 | 
			
		||||
github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4=
 | 
			
		||||
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
 | 
			
		||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
 | 
			
		||||
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
 | 
			
		||||
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
 | 
			
		||||
github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA=
 | 
			
		||||
github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
 | 
			
		||||
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
 | 
			
		||||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
 | 
			
		||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
 | 
			
		||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
 | 
			
		||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
 | 
			
		||||
github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY=
 | 
			
		||||
github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 | 
			
		||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
 | 
			
		||||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
 | 
			
		||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
 | 
			
		||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
 | 
			
		||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
 | 
			
		||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
 | 
			
		||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
 | 
			
		||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
 | 
			
		||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
 | 
			
		||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
 | 
			
		||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 | 
			
		||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
 | 
			
		||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
 | 
			
		||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
 | 
			
		||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
 | 
			
		||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
 | 
			
		||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
 | 
			
		||||
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
 | 
			
		||||
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
 | 
			
		||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
 | 
			
		||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 | 
			
		||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
			
		||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 | 
			
		||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 | 
			
		||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 | 
			
		||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 | 
			
		||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
 | 
			
		||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
 | 
			
		||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
 | 
			
		||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
 | 
			
		||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 | 
			
		||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
 | 
			
		||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
 | 
			
		||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
 | 
			
		||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 | 
			
		||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 | 
			
		||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 | 
			
		||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
 | 
			
		||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
 | 
			
		||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
 | 
			
		||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
 | 
			
		||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
 | 
			
		||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 | 
			
		||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
 | 
			
		||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
 | 
			
		||||
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
 | 
			
		||||
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
 | 
			
		||||
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
 | 
			
		||||
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
 | 
			
		||||
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
 | 
			
		||||
github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU=
 | 
			
		||||
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
 | 
			
		||||
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
 | 
			
		||||
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
 | 
			
		||||
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
 | 
			
		||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
 | 
			
		||||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
 | 
			
		||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
 | 
			
		||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
 | 
			
		||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
 | 
			
		||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
 | 
			
		||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
 | 
			
		||||
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
 | 
			
		||||
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
 | 
			
		||||
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
 | 
			
		||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
 | 
			
		||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
 | 
			
		||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
 | 
			
		||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
			
		||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
 | 
			
		||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
 | 
			
		||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
 | 
			
		||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
 | 
			
		||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
 | 
			
		||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
 | 
			
		||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
 | 
			
		||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
 | 
			
		||||
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
 | 
			
		||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
 | 
			
		||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
 | 
			
		||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
 | 
			
		||||
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
 | 
			
		||||
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
 | 
			
		||||
github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4=
 | 
			
		||||
github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM=
 | 
			
		||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
 | 
			
		||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
 | 
			
		||||
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
 | 
			
		||||
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
 | 
			
		||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
 | 
			
		||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
 | 
			
		||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
 | 
			
		||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
 | 
			
		||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
 | 
			
		||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 | 
			
		||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
 | 
			
		||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 | 
			
		||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
 | 
			
		||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
 | 
			
		||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
 | 
			
		||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 | 
			
		||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
 | 
			
		||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
 | 
			
		||||
github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo=
 | 
			
		||||
github.com/testcontainers/testcontainers-go v0.34.0/go.mod h1:6P/kMkQe8yqPHfPWNulFGdFHTD8HB2vLq/231xY2iPQ=
 | 
			
		||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
 | 
			
		||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
 | 
			
		||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
 | 
			
		||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
 | 
			
		||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
 | 
			
		||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
 | 
			
		||||
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
 | 
			
		||||
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
 | 
			
		||||
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
 | 
			
		||||
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
 | 
			
		||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
 | 
			
		||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
 | 
			
		||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
			
		||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
			
		||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 | 
			
		||||
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
 | 
			
		||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
 | 
			
		||||
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
 | 
			
		||||
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
 | 
			
		||||
github.com/zeromicro/go-zero v1.7.4 h1:lyIUsqbpVRzM4NmXu5pRM3XrdRdUuWOkQmHiNmJF0VU=
 | 
			
		||||
github.com/zeromicro/go-zero v1.7.4/go.mod h1:jmv4hTdUBkDn6kxgI+WrKQw0q6LKxDElGPMfCLOeeEY=
 | 
			
		||||
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
 | 
			
		||||
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
 | 
			
		||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
 | 
			
		||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
 | 
			
		||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
 | 
			
		||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
 | 
			
		||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
 | 
			
		||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
			
		||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
 | 
			
		||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
 | 
			
		||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 | 
			
		||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 | 
			
		||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 | 
			
		||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
			
		||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
			
		||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
			
		||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 | 
			
		||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 | 
			
		||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 | 
			
		||||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
 | 
			
		||||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
 | 
			
		||||
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 | 
			
		||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
 | 
			
		||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 | 
			
		||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 | 
			
		||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 | 
			
		||||
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
 | 
			
		||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
 | 
			
		||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
			
		||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
			
		||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 | 
			
		||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
 | 
			
		||||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
 | 
			
		||||
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
 | 
			
		||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
 | 
			
		||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 | 
			
		||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
			
		||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
			
		||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 | 
			
		||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
 | 
			
		||||
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
 | 
			
		||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
 | 
			
		||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
 | 
			
		||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
 | 
			
		||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
			
		||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
 | 
			
		||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
 | 
			
		||||
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
 | 
			
		||||
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
 | 
			
		||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 | 
			
		||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 | 
			
		||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
			
		||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 | 
			
		||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
			
		||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
 | 
			
		||||
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
 | 
			
		||||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
 | 
			
		||||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	mgo "code.30cm.net/digimon/library-go/mongo"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/cache"
 | 
			
		||||
	"github.com/zeromicro/go-zero/rest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Config struct {
 | 
			
		||||
	rest.RestConf
 | 
			
		||||
	// 快取
 | 
			
		||||
	Cache cache.CacheConf
 | 
			
		||||
	Mongo mgo.Conf
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
// Code generated by goctl. DO NOT EDIT.
 | 
			
		||||
// goctl 1.7.3
 | 
			
		||||
 | 
			
		||||
package handler
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	url "url_generate/internal/handler/url"
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/rest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 | 
			
		||||
	server.AddRoutes(
 | 
			
		||||
		[]rest.Route{
 | 
			
		||||
			{
 | 
			
		||||
				// Create Short URL
 | 
			
		||||
				Method:  http.MethodPost,
 | 
			
		||||
				Path:    "/",
 | 
			
		||||
				Handler: url.CreateShortURLHandler(serverCtx),
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				// Retrieve Short URL
 | 
			
		||||
				Method:  http.MethodGet,
 | 
			
		||||
				Path:    "/:short_code",
 | 
			
		||||
				Handler: url.GetOriginalURLHandler(serverCtx),
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				// Delete Short URL
 | 
			
		||||
				Method:  http.MethodDelete,
 | 
			
		||||
				Path:    "/:short_code",
 | 
			
		||||
				Handler: url.DeleteShortURLHandler(serverCtx),
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		rest.WithPrefix("/api/v1/url"),
 | 
			
		||||
		rest.WithTimeout(10000*time.Millisecond),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
package url
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/rest/httpx"
 | 
			
		||||
	"url_generate/internal/logic/url"
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
	"url_generate/internal/types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Create Short URL
 | 
			
		||||
func CreateShortURLHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		var req types.CreateShortURLRequest
 | 
			
		||||
		if err := httpx.Parse(r, &req); err != nil {
 | 
			
		||||
			httpx.ErrorCtx(r.Context(), w, err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		l := url.NewCreateShortURLLogic(r.Context(), svcCtx)
 | 
			
		||||
		resp, err := l.CreateShortURL(&req)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			httpx.ErrorCtx(r.Context(), w, err)
 | 
			
		||||
		} else {
 | 
			
		||||
			httpx.OkJsonCtx(r.Context(), w, resp)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
package url
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/rest/httpx"
 | 
			
		||||
	"url_generate/internal/logic/url"
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
	"url_generate/internal/types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Delete Short URL
 | 
			
		||||
func DeleteShortURLHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		var req types.URLRequest
 | 
			
		||||
		if err := httpx.Parse(r, &req); err != nil {
 | 
			
		||||
			httpx.ErrorCtx(r.Context(), w, err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		l := url.NewDeleteShortURLLogic(r.Context(), svcCtx)
 | 
			
		||||
		resp, err := l.DeleteShortURL(&req)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			httpx.ErrorCtx(r.Context(), w, err)
 | 
			
		||||
		} else {
 | 
			
		||||
			httpx.OkJsonCtx(r.Context(), w, resp)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
package url
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/rest/httpx"
 | 
			
		||||
	"url_generate/internal/logic/url"
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
	"url_generate/internal/types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Retrieve Short URL
 | 
			
		||||
func GetOriginalURLHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		var req types.URLRequest
 | 
			
		||||
		if err := httpx.Parse(r, &req); err != nil {
 | 
			
		||||
			httpx.ErrorCtx(r.Context(), w, err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		l := url.NewGetOriginalURLLogic(r.Context(), svcCtx)
 | 
			
		||||
		resp, err := l.GetOriginalURL(&req)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			httpx.ErrorCtx(r.Context(), w, err)
 | 
			
		||||
		} else {
 | 
			
		||||
			httpx.OkJsonCtx(r.Context(), w, resp)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,36 @@
 | 
			
		|||
package url
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
	"url_generate/internal/types"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/logx"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CreateShortURLLogic struct {
 | 
			
		||||
	logx.Logger
 | 
			
		||||
	ctx    context.Context
 | 
			
		||||
	svcCtx *svc.ServiceContext
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create Short URL
 | 
			
		||||
func NewCreateShortURLLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateShortURLLogic {
 | 
			
		||||
	return &CreateShortURLLogic{
 | 
			
		||||
		Logger: logx.WithContext(ctx),
 | 
			
		||||
		ctx:    ctx,
 | 
			
		||||
		svcCtx: svcCtx,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *CreateShortURLLogic) CreateShortURL(req *types.CreateShortURLRequest) (*types.URLCodeResponse, error) {
 | 
			
		||||
	code, err := l.svcCtx.URLUseCase.CreateShortCode(l.ctx, req.URL)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &types.URLCodeResponse{
 | 
			
		||||
		Code: code,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
package url
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
	"url_generate/internal/types"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/logx"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type DeleteShortURLLogic struct {
 | 
			
		||||
	logx.Logger
 | 
			
		||||
	ctx    context.Context
 | 
			
		||||
	svcCtx *svc.ServiceContext
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Delete Short URL
 | 
			
		||||
func NewDeleteShortURLLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteShortURLLogic {
 | 
			
		||||
	return &DeleteShortURLLogic{
 | 
			
		||||
		Logger: logx.WithContext(ctx),
 | 
			
		||||
		ctx:    ctx,
 | 
			
		||||
		svcCtx: svcCtx,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *DeleteShortURLLogic) DeleteShortURL(req *types.URLRequest) (*types.RespOK, error) {
 | 
			
		||||
	err := l.svcCtx.URLUseCase.DeleteShortCode(l.ctx, req.ShortCode)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &types.RespOK{}, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
package url
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
	"url_generate/internal/types"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/logx"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GetOriginalURLLogic struct {
 | 
			
		||||
	logx.Logger
 | 
			
		||||
	ctx    context.Context
 | 
			
		||||
	svcCtx *svc.ServiceContext
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Retrieve Short URL
 | 
			
		||||
func NewGetOriginalURLLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOriginalURLLogic {
 | 
			
		||||
	return &GetOriginalURLLogic{
 | 
			
		||||
		Logger: logx.WithContext(ctx),
 | 
			
		||||
		ctx:    ctx,
 | 
			
		||||
		svcCtx: svcCtx,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *GetOriginalURLLogic) GetOriginalURL(req *types.URLRequest) (*types.URLResponse, error) {
 | 
			
		||||
	url, err := l.svcCtx.URLUseCase.GetURLByShortCode(l.ctx, req.ShortCode)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &types.URLResponse{URL: url}, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
package entity
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"go.mongodb.org/mongo-driver/bson/primitive"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type URLTable struct {
 | 
			
		||||
	ID        primitive.ObjectID `bson:"_id,omitempty"`
 | 
			
		||||
	ShortCode string             `bson:"short_code"`
 | 
			
		||||
	URL       string             `bson:"url"`
 | 
			
		||||
	UpdateAt  *int64             `bson:"update_at,omitempty"`
 | 
			
		||||
	CreateAt  *int64             `bson:"create_at,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *URLTable) CollectionName() string {
 | 
			
		||||
	return "url"
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
package domain
 | 
			
		||||
 | 
			
		||||
import "code.30cm.net/digimon/library-go/errs"
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	FailedToGetURLEmptyCount errs.ErrorCode = 1 + iota
 | 
			
		||||
	FailedToBindShortCode
 | 
			
		||||
	FailedToFindURLByShortCode
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
package domain
 | 
			
		||||
 | 
			
		||||
import "strings"
 | 
			
		||||
 | 
			
		||||
type RedisKey string
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	URLRedisKey RedisKey = "url"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (key RedisKey) ToString() string {
 | 
			
		||||
	return string(key)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (key RedisKey) With(s ...string) RedisKey {
 | 
			
		||||
	parts := append([]string{string(key)}, s...)
 | 
			
		||||
 | 
			
		||||
	return RedisKey(strings.Join(parts, ":"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetURLCodeRedisKey(code string) string {
 | 
			
		||||
	return URLRedisKey.With(code).ToString()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
package repository
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"go.mongodb.org/mongo-driver/mongo"
 | 
			
		||||
	"url_generate/internal/module/url/domain/entity"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type URLRepository interface {
 | 
			
		||||
	InsertMany(ctx context.Context, urls []*entity.URLTable) error
 | 
			
		||||
	FindOne(ctx context.Context, shortCode string) (*entity.URLTable, error)
 | 
			
		||||
	Delete(ctx context.Context, shortCode string) (int64, error)
 | 
			
		||||
	Update(ctx context.Context, shortCode string, url string) error
 | 
			
		||||
	EmptyCount(ctx context.Context) (int, error)
 | 
			
		||||
	BindOne(ctx context.Context, url string) (string, error)
 | 
			
		||||
	UrlIndexUP
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type UrlIndexUP interface {
 | 
			
		||||
	Index20241226001UP(ctx context.Context) (*mongo.Cursor, error)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
package usecase
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// URLUseCase defines the core business logic interface for managing short URLs.
 | 
			
		||||
type URLUseCase interface {
 | 
			
		||||
	// CreateShortCode creates a short code for the given URL.
 | 
			
		||||
	CreateShortCode(ctx context.Context, url string) (string, error)
 | 
			
		||||
	// GetURLByShortCode retrieves the original URL associated with a given short code.
 | 
			
		||||
	GetURLByShortCode(ctx context.Context, shortCode string) (string, error)
 | 
			
		||||
	// DeleteShortCode removes the mapping of a given short code.
 | 
			
		||||
	DeleteShortCode(ctx context.Context, shortCode string) error
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
package repository
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/mon"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	ErrNotFound        = mon.ErrNotFound
 | 
			
		||||
	ErrInvalidObjectID = errors.New("invalid objectId")
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,46 @@
 | 
			
		|||
package repository
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"github.com/testcontainers/testcontainers-go"
 | 
			
		||||
	"github.com/testcontainers/testcontainers-go/wait"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func startMongoContainer() (string, string, func(), error) {
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
 | 
			
		||||
	req := testcontainers.ContainerRequest{
 | 
			
		||||
		Image:        "mongo:latest",
 | 
			
		||||
		ExposedPorts: []string{"27017/tcp"},
 | 
			
		||||
		WaitingFor:   wait.ForListeningPort("27017/tcp"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mongoC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
 | 
			
		||||
		ContainerRequest: req,
 | 
			
		||||
		Started:          true,
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", "", nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	port, err := mongoC.MappedPort(ctx, "27017")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", "", nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	host, err := mongoC.Host(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", "", nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uri := fmt.Sprintf("mongodb://%s:%s", host, port.Port())
 | 
			
		||||
	tearDown := func() {
 | 
			
		||||
		mongoC.Terminate(ctx)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fmt.Printf("Connecting to %s\n", uri)
 | 
			
		||||
 | 
			
		||||
	return host, port.Port(), tearDown, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,180 @@
 | 
			
		|||
package repository
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	mgo "code.30cm.net/digimon/library-go/mongo"
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/cache"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/mon"
 | 
			
		||||
	"go.mongodb.org/mongo-driver/bson"
 | 
			
		||||
	"go.mongodb.org/mongo-driver/bson/primitive"
 | 
			
		||||
	"go.mongodb.org/mongo-driver/mongo"
 | 
			
		||||
	"go.mongodb.org/mongo-driver/mongo/options"
 | 
			
		||||
	"time"
 | 
			
		||||
	"url_generate/internal/module/url/domain"
 | 
			
		||||
	"url_generate/internal/module/url/domain/entity"
 | 
			
		||||
	"url_generate/internal/module/url/domain/repository"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type URLRepositoryParam struct {
 | 
			
		||||
	Conf      *mgo.Conf
 | 
			
		||||
	CacheConf cache.CacheConf
 | 
			
		||||
	DbOpts    []mon.Option
 | 
			
		||||
	CacheOpts []cache.Option
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLRepository struct {
 | 
			
		||||
	DB mgo.DocumentDBWithCacheUseCase
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewURLRepository(param URLRepositoryParam) repository.URLRepository {
 | 
			
		||||
	e := entity.URLTable{}
 | 
			
		||||
	documentDB, err := mgo.MustDocumentDBWithCache(
 | 
			
		||||
		param.Conf,
 | 
			
		||||
		e.CollectionName(),
 | 
			
		||||
		param.CacheConf,
 | 
			
		||||
		param.DbOpts,
 | 
			
		||||
		param.CacheOpts,
 | 
			
		||||
	)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &URLRepository{
 | 
			
		||||
		DB: documentDB,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) BindOne(ctx context.Context, url string) (string, error) {
 | 
			
		||||
	filter := bson.M{"url": bson.M{"$eq": ""}}
 | 
			
		||||
	// 排序條件:按 `create_at` 降序排列
 | 
			
		||||
	sort := bson.D{{"create_at", -1}}
 | 
			
		||||
	// 定義變量存儲查詢結果
 | 
			
		||||
	var existing entity.URLTable
 | 
			
		||||
 | 
			
		||||
	// 查詢 MongoDB
 | 
			
		||||
	err := repo.DB.GetClient().FindOne(ctx, &existing, filter, options.FindOne().SetSort(sort))
 | 
			
		||||
	if errors.Is(err, mon.ErrNotFound) {
 | 
			
		||||
		// 如果沒有符合條件的記錄
 | 
			
		||||
		return "", fmt.Errorf("no available empty records found")
 | 
			
		||||
	}
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		// 處理其他錯誤
 | 
			
		||||
		return "", fmt.Errorf("failed to query empty record: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 更新該記錄的 URL 並返回短碼
 | 
			
		||||
	rk := domain.GetURLCodeRedisKey(existing.ShortCode)
 | 
			
		||||
	_, err = repo.DB.UpdateOne(ctx, rk, bson.M{"_id": existing.ID}, bson.M{"$set": bson.M{
 | 
			
		||||
		"url":       url,
 | 
			
		||||
		"update_at": time.Now().UTC().UnixNano(),
 | 
			
		||||
	}})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", fmt.Errorf("failed to update URL record: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 返回分配的短碼
 | 
			
		||||
	return existing.ShortCode, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) Insert(ctx context.Context, data *entity.URLTable) error {
 | 
			
		||||
	if data.ID.IsZero() {
 | 
			
		||||
		now := time.Now().UTC().UnixNano()
 | 
			
		||||
		data.ID = primitive.NewObjectID()
 | 
			
		||||
		data.CreateAt = &now
 | 
			
		||||
		data.UpdateAt = &now
 | 
			
		||||
	}
 | 
			
		||||
	rk := domain.GetURLCodeRedisKey(data.ShortCode)
 | 
			
		||||
	_, err := repo.DB.InsertOne(ctx, rk, data)
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) FindOne(ctx context.Context, shortCode string) (*entity.URLTable, error) {
 | 
			
		||||
	var data entity.URLTable
 | 
			
		||||
	rk := domain.GetURLCodeRedisKey(shortCode)
 | 
			
		||||
	err := repo.DB.FindOne(ctx, rk, &data, bson.M{"short_code": shortCode})
 | 
			
		||||
 | 
			
		||||
	switch {
 | 
			
		||||
	case err == nil:
 | 
			
		||||
		return &data, nil
 | 
			
		||||
	case errors.Is(err, mon.ErrNotFound):
 | 
			
		||||
		return nil, ErrNotFound
 | 
			
		||||
	default:
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) Delete(ctx context.Context, shortCode string) (int64, error) {
 | 
			
		||||
	rk := domain.GetURLCodeRedisKey(shortCode)
 | 
			
		||||
 | 
			
		||||
	return repo.DB.DeleteOne(ctx, rk, bson.M{"short_code": shortCode})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) InsertMany(ctx context.Context, urls []*entity.URLTable) error {
 | 
			
		||||
	if len(urls) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	now := time.Now().UTC().UnixNano()
 | 
			
		||||
	var documents []interface{}
 | 
			
		||||
	for _, url := range urls {
 | 
			
		||||
		u := url
 | 
			
		||||
		u.ID = primitive.NewObjectID()
 | 
			
		||||
		u.CreateAt = &now
 | 
			
		||||
		u.UpdateAt = &now
 | 
			
		||||
		documents = append(documents, u)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_, err := repo.DB.GetClient().InsertMany(ctx, documents)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("failed to insert many URLs: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) Update(ctx context.Context, shortCode string, newURL string) error {
 | 
			
		||||
	filter := bson.M{"short_code": shortCode}
 | 
			
		||||
	update := bson.M{
 | 
			
		||||
		"$set": bson.M{
 | 
			
		||||
			"url":       newURL,
 | 
			
		||||
			"update_at": time.Now().UTC().UnixNano(),
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rk := domain.GetURLCodeRedisKey(shortCode)
 | 
			
		||||
	result, err := repo.DB.UpdateOne(ctx, rk, filter, update, options.Update().SetUpsert(false))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("failed to update URL for short code %s: %w", shortCode, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if result.MatchedCount == 0 {
 | 
			
		||||
		return ErrNotFound
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) EmptyCount(ctx context.Context) (int, error) {
 | 
			
		||||
	filter := bson.M{"url": ""}
 | 
			
		||||
	count, err := repo.DB.GetClient().CountDocuments(ctx, filter)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, fmt.Errorf("failed to count empty URLs: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return int(count), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (repo *URLRepository) Index20241226001UP(ctx context.Context) (*mongo.Cursor, error) {
 | 
			
		||||
	// 等價於 db.createIndex({"short_code": 1},{unique: true})
 | 
			
		||||
	repo.DB.PopulateIndex(ctx, "short_code", 1, true)
 | 
			
		||||
 | 
			
		||||
	return repo.DB.GetClient().Indexes().List(ctx)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ptr 是一個幫助函數,用於生成指針
 | 
			
		||||
func ptr[T any](v T) *T {
 | 
			
		||||
	return &v
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,112 @@
 | 
			
		|||
package repository
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	mgo "code.30cm.net/digimon/library-go/mongo"
 | 
			
		||||
	"context"
 | 
			
		||||
	"github.com/alicebob/miniredis/v2"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/cache"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/redis"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
	"url_generate/internal/module/url/domain/entity"
 | 
			
		||||
	"url_generate/internal/module/url/domain/repository"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func SetupTestURLRepository(db string) (repository.URLRepository, func(), error) {
 | 
			
		||||
	h, p, tearDown, err := startMongoContainer()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, nil, err
 | 
			
		||||
	}
 | 
			
		||||
	s, _ := miniredis.Run()
 | 
			
		||||
 | 
			
		||||
	conf := &mgo.Conf{
 | 
			
		||||
		Schema:                           "mongodb",
 | 
			
		||||
		Host:                             h,
 | 
			
		||||
		Port:                             p,
 | 
			
		||||
		Database:                         db,
 | 
			
		||||
		MaxStaleness:                     300,
 | 
			
		||||
		MaxPoolSize:                      100,
 | 
			
		||||
		MinPoolSize:                      100,
 | 
			
		||||
		MaxConnIdleTime:                  300,
 | 
			
		||||
		Compressors:                      []string{},
 | 
			
		||||
		EnableStandardReadWriteSplitMode: false,
 | 
			
		||||
		ConnectTimeoutMs:                 3000,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cacheConf := cache.CacheConf{
 | 
			
		||||
		cache.NodeConf{
 | 
			
		||||
			RedisConf: redis.RedisConf{
 | 
			
		||||
				Host: s.Addr(),
 | 
			
		||||
				Type: redis.NodeType,
 | 
			
		||||
			},
 | 
			
		||||
			Weight: 100,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cacheOpts := []cache.Option{
 | 
			
		||||
		cache.WithExpiry(1000 * time.Microsecond),
 | 
			
		||||
		cache.WithNotFoundExpiry(1000 * time.Microsecond),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	param := URLRepositoryParam{
 | 
			
		||||
		conf:      conf,
 | 
			
		||||
		cacheConf: cacheConf,
 | 
			
		||||
		cacheOpts: cacheOpts,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	repo := NewURLRepository(param)
 | 
			
		||||
	_, _ = repo.Index20241226001UP(context.Background())
 | 
			
		||||
 | 
			
		||||
	return repo, tearDown, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestAccountModel_Insert(t *testing.T) {
 | 
			
		||||
	repo, tearDown, err := SetupTestURLRepository("testDB")
 | 
			
		||||
	defer tearDown()
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		name        string
 | 
			
		||||
		account     *entity.URLTable
 | 
			
		||||
		expectError bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			name: "Valid account insert",
 | 
			
		||||
			account: &entity.URLTable{
 | 
			
		||||
				ShortCode: "123",
 | 
			
		||||
				URL:       "https://www.google.com",
 | 
			
		||||
			},
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			// 插入測試帳戶
 | 
			
		||||
			err := repo.InsertMany(context.Background(), []*entity.URLTable{tt.account})
 | 
			
		||||
			if tt.expectError {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
			} else {
 | 
			
		||||
				assert.NoError(t, err, "插入操作應該成功")
 | 
			
		||||
 | 
			
		||||
				//// 檢查是否生成了 ObjectID 和時間戳
 | 
			
		||||
				//assert.NotZero(t, tt.account.ID, "ID 應該被生成")
 | 
			
		||||
				//assert.NotNil(t, tt.account.CreateAt, "CreateAt 應該被設置")
 | 
			
		||||
				//assert.NotNil(t, tt.account.UpdateAt, "UpdateAt 應該被設置")
 | 
			
		||||
				//
 | 
			
		||||
				//// 檢查插入的時間是否合理
 | 
			
		||||
				//now := time.Now().UTC().UnixNano()
 | 
			
		||||
				//assert.LessOrEqual(t, *tt.account.CreateAt, now, "CreateAt 應在當前時間之前")
 | 
			
		||||
				//assert.LessOrEqual(t, *tt.account.UpdateAt, now, "UpdateAt 應在當前時間之前")
 | 
			
		||||
				//
 | 
			
		||||
				//// 確認插入的資料
 | 
			
		||||
				//insertedAccount, err := repo.FindOne(context.Background(), tt.account.ID.Hex())
 | 
			
		||||
				//assert.NoError(t, err, "應該可以找到插入的帳號資料")
 | 
			
		||||
				//assert.Equal(t, tt.account.LoginID, insertedAccount.LoginID, "LoginID 應相同")
 | 
			
		||||
				//assert.Equal(t, tt.account.Token, insertedAccount.Token, "Token 應相同")
 | 
			
		||||
				//assert.Equal(t, tt.account.Platform, insertedAccount.Platform, "Platform 應相同")
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,82 @@
 | 
			
		|||
package usecase
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"math/big"
 | 
			
		||||
	"sync"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// IDAllocator 管理 ID 分配與釋放
 | 
			
		||||
type IDAllocator struct {
 | 
			
		||||
	bitmap *big.Int // 位圖,用於記錄 ID 使用狀態
 | 
			
		||||
	mu     sync.Mutex
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewIDAllocator 初始化一個新的 IDAllocator
 | 
			
		||||
func NewIDAllocator() *IDAllocator {
 | 
			
		||||
	return &IDAllocator{
 | 
			
		||||
		bitmap: big.NewInt(0), // 初始化位圖為 0
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Allocate 分配一個未使用的 ID
 | 
			
		||||
func (alloc *IDAllocator) Allocate() (string, error) {
 | 
			
		||||
	alloc.mu.Lock()
 | 
			
		||||
	defer alloc.mu.Unlock()
 | 
			
		||||
 | 
			
		||||
	// 找到第一個未使用的位
 | 
			
		||||
	for i := 0; i < 64; i++ {
 | 
			
		||||
		if alloc.bitmap.Bit(i) == 0 { // 如果該位為 0,表示可用
 | 
			
		||||
			alloc.bitmap.SetBit(alloc.bitmap, i, 1) // 設置該位為 1,表示已使用
 | 
			
		||||
			return encodeIndex(i), nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return "", fmt.Errorf("no available IDs")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Release 釋放一個已使用的 ID
 | 
			
		||||
func (alloc *IDAllocator) Release(id string) error {
 | 
			
		||||
	alloc.mu.Lock()
 | 
			
		||||
	defer alloc.mu.Unlock()
 | 
			
		||||
 | 
			
		||||
	// 解碼 ID 得到索引
 | 
			
		||||
	index, err := decodeIndex(id)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("invalid ID: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 將對應位設置為 0
 | 
			
		||||
	alloc.bitmap.SetBit(alloc.bitmap, index, 0)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// encodeIndex 將索引轉換為固定長度字符串
 | 
			
		||||
func encodeIndex(index int) string {
 | 
			
		||||
	alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
			
		||||
	result := make([]byte, 5) // 固定長度為 5
 | 
			
		||||
	for i := 4; i >= 0; i-- {
 | 
			
		||||
		result[i] = alphabet[index%64]
 | 
			
		||||
		index /= 64
 | 
			
		||||
	}
 | 
			
		||||
	return string(result)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// decodeIndex 將固定長度字符串轉換回索引
 | 
			
		||||
func decodeIndex(id string) (int, error) {
 | 
			
		||||
	alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
			
		||||
	lookup := make(map[byte]int)
 | 
			
		||||
	for i, ch := range alphabet {
 | 
			
		||||
		lookup[byte(ch)] = i
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	index := 0
 | 
			
		||||
	for _, ch := range id {
 | 
			
		||||
		val, ok := lookup[byte(ch)]
 | 
			
		||||
		if !ok {
 | 
			
		||||
			return 0, fmt.Errorf("invalid character: %c", ch)
 | 
			
		||||
		}
 | 
			
		||||
		index = index*64 + val
 | 
			
		||||
	}
 | 
			
		||||
	return index, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,173 @@
 | 
			
		|||
package usecase
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"code.30cm.net/digimon/library-go/errs"
 | 
			
		||||
	"code.30cm.net/digimon/library-go/errs/code"
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/logx"
 | 
			
		||||
	"url_generate/internal/module/url/domain"
 | 
			
		||||
	"url_generate/internal/module/url/domain/entity"
 | 
			
		||||
	"url_generate/internal/module/url/domain/repository"
 | 
			
		||||
	"url_generate/internal/module/url/domain/usecase"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	MinEmptyCodeLen = 50
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type URLUseCaseParam struct {
 | 
			
		||||
	URLRepo repository.URLRepository
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLUseCase struct {
 | 
			
		||||
	Repo  repository.URLRepository
 | 
			
		||||
	IDGen *IDAllocator
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (use *URLUseCase) CreateShortCode(ctx context.Context, url string) (string, error) {
 | 
			
		||||
	count, err := use.Repo.EmptyCount(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", errs.DatabaseErrorWithScopeL(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToGetURLEmptyCount,
 | 
			
		||||
			logx.WithContext(ctx),
 | 
			
		||||
			[]logx.LogField{
 | 
			
		||||
				{Key: "url", Value: url},
 | 
			
		||||
				{Key: "func", Value: "URLRepo.EmptyCount"},
 | 
			
		||||
				{Key: "err", Value: err.Error()},
 | 
			
		||||
			},
 | 
			
		||||
			"failed to create url short code").Wrap(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 產生更多的 Code
 | 
			
		||||
	if count < MinEmptyCodeLen {
 | 
			
		||||
		err := use.GenerateCode(ctx, MinEmptyCodeLen)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", errs.SystemInternalError("failed to create url short code")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	shortCode, err := use.Repo.BindOne(ctx, url)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", errs.DatabaseErrorWithScopeL(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToBindShortCode,
 | 
			
		||||
			logx.WithContext(ctx),
 | 
			
		||||
			[]logx.LogField{
 | 
			
		||||
				{Key: "url", Value: url},
 | 
			
		||||
				{Key: "func", Value: "URLRepo.BindOne"},
 | 
			
		||||
				{Key: "err", Value: err.Error()},
 | 
			
		||||
			},
 | 
			
		||||
			"failed to create url short code").Wrap(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return shortCode, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (use *URLUseCase) GetURLByShortCode(ctx context.Context, shortCode string) (string, error) {
 | 
			
		||||
	url, err := use.Repo.FindOne(ctx, shortCode)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", errs.DatabaseErrorWithScopeL(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToFindURLByShortCode,
 | 
			
		||||
			logx.WithContext(ctx),
 | 
			
		||||
			[]logx.LogField{
 | 
			
		||||
				{Key: "shortCode", Value: shortCode},
 | 
			
		||||
				{Key: "func", Value: "URLRepo.FindOne"},
 | 
			
		||||
				{Key: "err", Value: err.Error()},
 | 
			
		||||
			},
 | 
			
		||||
			"failed to find url short code").Wrap(err)
 | 
			
		||||
	}
 | 
			
		||||
	if url.URL == "" {
 | 
			
		||||
		return "", errs.ResourceNotFoundWithScope(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToFindURLByShortCode,
 | 
			
		||||
			"failed to find url short code")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return url.URL, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (use *URLUseCase) DeleteShortCode(ctx context.Context, shortCode string) error {
 | 
			
		||||
	url, err := use.Repo.FindOne(ctx, shortCode)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errs.DatabaseErrorWithScopeL(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToFindURLByShortCode,
 | 
			
		||||
			logx.WithContext(ctx),
 | 
			
		||||
			[]logx.LogField{
 | 
			
		||||
				{Key: "shortCode", Value: shortCode},
 | 
			
		||||
				{Key: "func", Value: "URLRepo.FindOne"},
 | 
			
		||||
				{Key: "err", Value: err.Error()},
 | 
			
		||||
			},
 | 
			
		||||
			"failed to find url short code").Wrap(err)
 | 
			
		||||
	}
 | 
			
		||||
	if url.URL == "" {
 | 
			
		||||
		return errs.ResourceNotFoundWithScope(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToFindURLByShortCode,
 | 
			
		||||
			"failed to find url short code")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = use.Repo.Update(ctx, shortCode, "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errs.DatabaseErrorWithScopeL(
 | 
			
		||||
			code.CloudEPPortalGW,
 | 
			
		||||
			domain.FailedToFindURLByShortCode,
 | 
			
		||||
			logx.WithContext(ctx),
 | 
			
		||||
			[]logx.LogField{
 | 
			
		||||
				{Key: "shortCode", Value: shortCode},
 | 
			
		||||
				{Key: "func", Value: "URLRepo.Delete"},
 | 
			
		||||
				{Key: "err", Value: err.Error()},
 | 
			
		||||
			},
 | 
			
		||||
			"failed to del url short code").Wrap(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 目前先不考慮錯誤狀況,因為還要插入回去
 | 
			
		||||
	_ = use.IDGen.Release(shortCode)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (use *URLUseCase) GenerateCode(ctx context.Context, num int) error {
 | 
			
		||||
	// 確保請求的生成數量合法
 | 
			
		||||
	if num <= 0 {
 | 
			
		||||
		return fmt.Errorf("num must be greater than 0")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 保存結果的 URLTable 列表
 | 
			
		||||
	var result []*entity.URLTable
 | 
			
		||||
 | 
			
		||||
	// 循環生成指定數量的短碼
 | 
			
		||||
	for i := 0; i < num; i++ {
 | 
			
		||||
		shortCode, err := use.IDGen.Allocate()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logx.Errorf("Failed to allocate ID: %v\n", err)
 | 
			
		||||
			continue // 分配失敗直接跳過
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		urlTable := &entity.URLTable{
 | 
			
		||||
			ShortCode: shortCode,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 插入到結果列表中
 | 
			
		||||
		result = append(result, urlTable)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err := use.Repo.InsertMany(ctx, result)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Printf("Failed to insert URLTable: %v\n", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func MustURLUseCase(param URLUseCaseParam) usecase.URLUseCase {
 | 
			
		||||
	res := &URLUseCase{
 | 
			
		||||
		Repo:  param.URLRepo,
 | 
			
		||||
		IDGen: NewIDAllocator(),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return res
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
package svc
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/cache"
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/stores/mon"
 | 
			
		||||
	"time"
 | 
			
		||||
	"url_generate/internal/config"
 | 
			
		||||
	"url_generate/internal/module/url/domain/usecase"
 | 
			
		||||
	"url_generate/internal/module/url/repository"
 | 
			
		||||
	uc "url_generate/internal/module/url/usecase"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ServiceContext struct {
 | 
			
		||||
	Config     config.Config
 | 
			
		||||
	URLUseCase usecase.URLUseCase
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	DefaultSingleFlyCacheTimeout   = 60 * time.Second
 | 
			
		||||
	DefaultFindDataNotFoundTimeout = 5 * time.Second
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func NewServiceContext(c config.Config) *ServiceContext {
 | 
			
		||||
	ur := repository.NewURLRepository(repository.URLRepositoryParam{
 | 
			
		||||
		Conf:      &c.Mongo,
 | 
			
		||||
		CacheConf: c.Cache,
 | 
			
		||||
		DbOpts:    []mon.Option{},
 | 
			
		||||
		CacheOpts: []cache.Option{
 | 
			
		||||
			cache.WithExpiry(DefaultSingleFlyCacheTimeout),
 | 
			
		||||
			cache.WithNotFoundExpiry(DefaultFindDataNotFoundTimeout),
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	urlUseCase := uc.MustURLUseCase(uc.URLUseCaseParam{
 | 
			
		||||
		URLRepo: ur,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	return &ServiceContext{
 | 
			
		||||
		Config:     c,
 | 
			
		||||
		URLUseCase: urlUseCase,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
// Code generated by goctl. DO NOT EDIT.
 | 
			
		||||
// goctl 1.7.3
 | 
			
		||||
 | 
			
		||||
package types
 | 
			
		||||
 | 
			
		||||
type CreateShortURLRequest struct {
 | 
			
		||||
	URL string `json:"url" validate:"required"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type RespOK struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Status struct {
 | 
			
		||||
	Code    int64       `json:"code"`            // 狀態碼
 | 
			
		||||
	Message string      `json:"message"`         // 訊息
 | 
			
		||||
	Data    interface{} `json:"data,omitempty"`  // 可選的資料,當有返回時才出現
 | 
			
		||||
	Error   interface{} `json:"error,omitempty"` // 可選的錯誤信息
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLCodeResponse struct {
 | 
			
		||||
	Code string `json:"short_code"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLRequest struct {
 | 
			
		||||
	ShortCode string `path:"short_code"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type URLResponse struct {
 | 
			
		||||
	URL string `json:"url" validate:"required"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,31 @@
 | 
			
		|||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"url_generate/internal/config"
 | 
			
		||||
	"url_generate/internal/handler"
 | 
			
		||||
	"url_generate/internal/svc"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/conf"
 | 
			
		||||
	"github.com/zeromicro/go-zero/rest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var configFile = flag.String("f", "etc/url.yaml", "the config file")
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
	var c config.Config
 | 
			
		||||
	conf.MustLoad(*configFile, &c)
 | 
			
		||||
 | 
			
		||||
	server := rest.MustNewServer(c.RestConf)
 | 
			
		||||
	defer server.Stop()
 | 
			
		||||
 | 
			
		||||
	ctx := svc.NewServiceContext(c)
 | 
			
		||||
	handler.RegisterHandlers(server, ctx)
 | 
			
		||||
 | 
			
		||||
	fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
 | 
			
		||||
	server.Start()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,188 @@
 | 
			
		|||
{
 | 
			
		||||
  "swagger": "2.0",
 | 
			
		||||
  "info": {
 | 
			
		||||
    "title": "Short URL Gateway",
 | 
			
		||||
    "description": "Service for generating, retrieving, and deleting short URLs",
 | 
			
		||||
    "version": "0.0.1"
 | 
			
		||||
  },
 | 
			
		||||
  "host": "127.0.0.1:8888",
 | 
			
		||||
  "schemes": [
 | 
			
		||||
    "http",
 | 
			
		||||
    "https"
 | 
			
		||||
  ],
 | 
			
		||||
  "consumes": [
 | 
			
		||||
    "application/json"
 | 
			
		||||
  ],
 | 
			
		||||
  "produces": [
 | 
			
		||||
    "application/json"
 | 
			
		||||
  ],
 | 
			
		||||
  "paths": {
 | 
			
		||||
    "/api/v1/url/": {
 | 
			
		||||
      "post": {
 | 
			
		||||
        "summary": "Create Short URL",
 | 
			
		||||
        "description": "Map a long URL to a short URL",
 | 
			
		||||
        "operationId": "createShortURL",
 | 
			
		||||
        "responses": {
 | 
			
		||||
          "200": {
 | 
			
		||||
            "description": "A successful response.",
 | 
			
		||||
            "schema": {
 | 
			
		||||
              "$ref": "#/definitions/URLCodeResponse"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "parameters": [
 | 
			
		||||
          {
 | 
			
		||||
            "name": "body",
 | 
			
		||||
            "in": "body",
 | 
			
		||||
            "required": true,
 | 
			
		||||
            "schema": {
 | 
			
		||||
              "$ref": "#/definitions/CreateShortURLRequest"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "tags": [
 | 
			
		||||
          "url"
 | 
			
		||||
        ]
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "/api/v1/url/{short_code}": {
 | 
			
		||||
      "get": {
 | 
			
		||||
        "summary": "Retrieve Short URL",
 | 
			
		||||
        "description": "Retrieve the original URL using the short URL",
 | 
			
		||||
        "operationId": "getOriginalURL",
 | 
			
		||||
        "responses": {
 | 
			
		||||
          "200": {
 | 
			
		||||
            "description": "A successful response.",
 | 
			
		||||
            "schema": {
 | 
			
		||||
              "$ref": "#/definitions/URLResponse"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "parameters": [
 | 
			
		||||
          {
 | 
			
		||||
            "name": "short_code",
 | 
			
		||||
            "in": "path",
 | 
			
		||||
            "required": true,
 | 
			
		||||
            "type": "string"
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "tags": [
 | 
			
		||||
          "url"
 | 
			
		||||
        ]
 | 
			
		||||
      },
 | 
			
		||||
      "delete": {
 | 
			
		||||
        "summary": "Delete Short URL",
 | 
			
		||||
        "description": "Delete a short URL mapping",
 | 
			
		||||
        "operationId": "deleteShortURL",
 | 
			
		||||
        "responses": {
 | 
			
		||||
          "200": {
 | 
			
		||||
            "description": "A successful response.",
 | 
			
		||||
            "schema": {
 | 
			
		||||
              "$ref": "#/definitions/RespOK"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "parameters": [
 | 
			
		||||
          {
 | 
			
		||||
            "name": "short_code",
 | 
			
		||||
            "in": "path",
 | 
			
		||||
            "required": true,
 | 
			
		||||
            "type": "string"
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "name": "body",
 | 
			
		||||
            "in": "body",
 | 
			
		||||
            "required": true,
 | 
			
		||||
            "schema": {
 | 
			
		||||
              "$ref": "#/definitions/URLRequest"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "tags": [
 | 
			
		||||
          "url"
 | 
			
		||||
        ]
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "definitions": {
 | 
			
		||||
    "CreateShortURLRequest": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "url": {
 | 
			
		||||
          "type": "string"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "title": "CreateShortURLRequest",
 | 
			
		||||
      "required": [
 | 
			
		||||
        "url"
 | 
			
		||||
      ]
 | 
			
		||||
    },
 | 
			
		||||
    "RespOK": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "title": "RespOK"
 | 
			
		||||
    },
 | 
			
		||||
    "Status": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "code": {
 | 
			
		||||
          "type": "integer",
 | 
			
		||||
          "format": "int64",
 | 
			
		||||
          "description": " 狀態碼"
 | 
			
		||||
        },
 | 
			
		||||
        "message": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "description": " 訊息"
 | 
			
		||||
        },
 | 
			
		||||
        "data": {
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "description": " 可選的資料,當有返回時才出現"
 | 
			
		||||
        },
 | 
			
		||||
        "error": {
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "description": " 可選的錯誤信息"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "title": "Status",
 | 
			
		||||
      "required": [
 | 
			
		||||
        "code",
 | 
			
		||||
        "message"
 | 
			
		||||
      ]
 | 
			
		||||
    },
 | 
			
		||||
    "URLCodeResponse": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "short_code": {
 | 
			
		||||
          "type": "string"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "title": "URLCodeResponse",
 | 
			
		||||
      "required": [
 | 
			
		||||
        "short_code"
 | 
			
		||||
      ]
 | 
			
		||||
    },
 | 
			
		||||
    "URLRequest": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "title": "URLRequest"
 | 
			
		||||
    },
 | 
			
		||||
    "URLResponse": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "url": {
 | 
			
		||||
          "type": "string"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "title": "URLResponse",
 | 
			
		||||
      "required": [
 | 
			
		||||
        "url"
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "securityDefinitions": {
 | 
			
		||||
    "apiKey": {
 | 
			
		||||
      "type": "apiKey",
 | 
			
		||||
      "description": "Enter JWT Bearer token **_only_**",
 | 
			
		||||
      "name": "Authorization",
 | 
			
		||||
      "in": "header"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue