You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

location.go 878 B

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  1. package db
  2. /*
  3. import (
  4. "fmt"
  5. "github.com/jmoiron/sqlx"
  6. "gitlink.org.cn/cloudream/storage/common/pkgs/db/model"
  7. )
  8. type LocationDB struct {
  9. *DB
  10. }
  11. func (db *DB) Location() *LocationDB {
  12. return &LocationDB{DB: db}
  13. }
  14. func (*LocationDB) GetByID(ctx SQLContext, id int64) (model.Location, error) {
  15. var ret model.Location
  16. err := sqlx.Get(ctx, &ret, "select * from Location where LocationID = ?", id)
  17. return ret, err
  18. }
  19. func (db *LocationDB) FindLocationByExternalIP(ctx SQLContext, ip string) (model.Location, error) {
  20. var locID int64
  21. err := sqlx.Get(ctx, &locID, "select LocationID from Node where ExternalIP = ?", ip)
  22. if err != nil {
  23. return model.Location{}, fmt.Errorf("finding node by external ip: %w", err)
  24. }
  25. loc, err := db.GetByID(ctx, locID)
  26. if err != nil {
  27. return model.Location{}, fmt.Errorf("getting location by id: %w", err)
  28. }
  29. return loc, nil
  30. }
  31. */

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。