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.

hub.go 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package models
  2. import (
  3. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  4. "gorm.io/gorm"
  5. )
  6. type Hub struct {
  7. HubID cdssdk.HubID `gorm:"column:HubID; primaryKey; type:bigint; autoIncrement" json:"hubID"`
  8. Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"`
  9. Address cdssdk.HubAddressInfo `gorm:"column:Address; type:json; " json:"address"`
  10. }
  11. func (Hub) TableName() string { return "hub" }
  12. type HubRepository struct {
  13. repo *GormRepository
  14. }
  15. func NewHubRepository(db *gorm.DB) *HubRepository {
  16. return &HubRepository{repo: NewGormRepository(db)}
  17. }
  18. func (r *HubRepository) CreateHub(hub *Hub) error {
  19. return r.repo.Create(hub)
  20. }
  21. func (r *HubRepository) UpdateHub(hub *Hub) error {
  22. return r.repo.Update(hub)
  23. }
  24. func (r *HubRepository) DeleteHub(hub *Hub) error {
  25. return r.repo.Delete(hub, uint(hub.HubID))
  26. }
  27. func (r *HubRepository) GetHubByID(id int) (*Hub, error) {
  28. var hub Hub
  29. err := r.repo.GetByID(uint(id), &hub)
  30. if err != nil {
  31. return nil, err
  32. }
  33. return &hub, nil
  34. }
  35. func (r *HubRepository) GetAllHubs() ([]Hub, error) {
  36. var hubs []Hub
  37. err := r.repo.GetAll(&hubs)
  38. if err != nil {
  39. return nil, err
  40. }
  41. return hubs, nil
  42. }

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