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

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

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