Эх сурвалжийг харах

feat(internal/repository): 添加查询现有 IP 功能

- 在 GameShieldRepository 接口中新增 GetGameShieldExistingIps 方法
- 实现该方法以查询与指定 IP 相关的所有 IP 地址
- 更新 go.mod 文件,移除不必要的依赖并添加新依赖
- 删除 README.md 和 README_zh.md 文件
fusu 3 сар өмнө
parent
commit
74c38d9d0f
5 өөрчлөгдсөн 15 нэмэгдсэн , 37 устгасан
  1. 0 18
      README.md
  2. 0 18
      README_zh.md
  3. 2 1
      go.mod
  4. 2 0
      go.sum
  5. 11 0
      internal/repository/gameshield.go

+ 0 - 18
README.md

@@ -1,18 +0,0 @@
-# Nunu — A CLI tool for building Go applications.
-
-Nunu is a scaffolding tool for building Go applications. Its name comes from a game character in League of Legends, a little boy riding on the shoulders of a Yeti. Just like Nunu, this project stands on the shoulders of giants, as it is built upon a combination of popular libraries from the Go ecosystem. This combination allows you to quickly build efficient and reliable applications.
-
-[简体中文介绍](https://github.com/go-nunu/nunu/blob/main/README_zh.md)
-
-![Nunu](https://github.com/go-nunu/nunu/blob/main/.github/assets/banner.png)
-
-## Documentation
-* [User Guide](https://github.com/go-nunu/nunu/blob/main/docs/en/guide.md)
-* [Architecture](https://github.com/go-nunu/nunu/blob/main/docs/en/architecture.md)
-* [Getting Started Tutorial](https://github.com/go-nunu/nunu/blob/main/docs/en/tutorial.md)
-* [Unit Testing](https://github.com/go-nunu/nunu/blob/main/docs/en/unit_testing.md)
-
-
-## License
-
-Nunu is released under the MIT License. For more information, see the [LICENSE](LICENSE) file.

+ 0 - 18
README_zh.md

@@ -1,18 +0,0 @@
-# Nunu — A CLI tool for building go aplication.
-
-
-Nunu是一个基于Golang的应用脚手架,它的名字来自于英雄联盟中的游戏角色,一个骑在雪怪肩膀上的小男孩。和努努一样,该项目也是站在巨人的肩膀上,它是由Golang生态中各种非常流行的库整合而成的,它们的组合可以帮助你快速构建一个高效、可靠的应用程序。
-
-[英文介绍](https://github.com/go-nunu/nunu/blob/main/README.md)
-
-![Nunu](https://github.com/go-nunu/nunu/blob/main/.github/assets/banner.png)
-
-## 文档
-* [使用指南](https://github.com/go-nunu/nunu/blob/main/docs/zh/guide.md)
-* [分层架构](https://github.com/go-nunu/nunu/blob/main/docs/zh/architecture.md)
-* [上手教程](https://github.com/go-nunu/nunu/blob/main/docs/zh/tutorial.md)
-* [高效编写单元测试](https://github.com/go-nunu/nunu/blob/main/docs/zh/unit_testing.md)
-
-## 许可证
-
-Nunu是根据MIT许可证发布的。有关更多信息,请参见[LICENSE](LICENSE)文件。

+ 2 - 1
go.mod

@@ -15,8 +15,10 @@ require (
 	github.com/golang-jwt/jwt/v5 v5.2.2
 	github.com/golang/mock v1.6.0
 	github.com/google/wire v0.5.0
+	github.com/mcuadros/go-defaults v1.2.0
 	github.com/redis/go-redis/v9 v9.0.5
 	github.com/sony/sonyflake v1.1.0
+	github.com/sourcegraph/conc v0.3.0
 	github.com/spf13/cast v1.5.1
 	github.com/spf13/viper v1.8.1
 	github.com/stretchr/testify v1.8.4
@@ -84,7 +86,6 @@ require (
 	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/mattn/go-colorable v0.1.13 // indirect
 	github.com/mattn/go-isatty v0.0.20 // indirect
-	github.com/mcuadros/go-defaults v1.2.0 // indirect
 	github.com/mitchellh/go-wordwrap v1.0.1 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect

+ 2 - 0
go.sum

@@ -396,6 +396,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 github.com/sony/sonyflake v1.1.0 h1:wnrEcL3aOkWmPlhScLEGAXKkLAIslnBteNUq4Bw6MM4=
 github.com/sony/sonyflake v1.1.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y=
+github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
+github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
 github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
 github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
 github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=

+ 11 - 0
internal/repository/gameshield.go

@@ -13,6 +13,7 @@ type GameShieldRepository interface {
 	DeleteGameShield(ctx context.Context, ruleId int) error
 	GetGameShieldIsBuy(ctx context.Context, uid int64) (int64, error)
 	GetGameShieldNextduedate(ctx context.Context, uid int64, productID string) (string, error)
+	GetGameShieldExistingIps(ctx context.Context, ip string) ([]string, error)
 }
 
 func NewGameShieldRepository(
@@ -91,3 +92,13 @@ func (r *gameShieldRepository) GetGameShieldNextduedate(ctx context.Context, uid
 
 	return nextDueDate, nil
 }
+
+func (r *gameShieldRepository) GetGameShieldExistingIps(ctx context.Context, ip string) ([]string, error) {
+	var res []string
+	if err := r.DB(ctx).Model(&model.GameShield{}).
+		Where("app_ip LIKE ?", ip+"%").
+		Pluck("app_ip", &res).Error; err != nil {
+		return nil, err
+	}
+	return res, nil
+}