feat: tenant-scoped routing and portal navigation

This commit is contained in:
2026-01-08 21:30:46 +08:00
parent f3aa92078a
commit 3e095c57f3
52 changed files with 1111 additions and 670 deletions

View File

@@ -39,6 +39,7 @@ func Test_Tenant(t *testing.T) {
func (s *TenantTestSuite) Test_Follow() {
Convey("Follow Flow", s.T(), func() {
ctx := s.T().Context()
tenantID := int64(0)
database.Truncate(ctx, s.DB, models.TableNameTenant, models.TableNameTenantUser, models.TableNameUser)
// User
@@ -49,29 +50,30 @@ func (s *TenantTestSuite) Test_Follow() {
// Tenant
t := &models.Tenant{Name: "Tenant A", Status: consts.TenantStatusVerified}
models.TenantQuery.WithContext(ctx).Create(t)
tenantID = t.ID
Convey("should follow tenant", func() {
err := Tenant.Follow(ctx, u.ID, t.ID)
err := Tenant.Follow(ctx, tenantID, u.ID)
So(err, ShouldBeNil)
// Verify stats
profile, err := Tenant.GetPublicProfile(ctx, u.ID, t.ID)
profile, err := Tenant.GetPublicProfile(ctx, tenantID, u.ID)
So(err, ShouldBeNil)
So(profile.IsFollowing, ShouldBeTrue)
So(profile.Stats.Followers, ShouldEqual, 1)
// List Followed
list, err := Tenant.ListFollowed(ctx, u.ID)
list, err := Tenant.ListFollowed(ctx, tenantID, u.ID)
So(err, ShouldBeNil)
So(len(list), ShouldEqual, 1)
So(list[0].Name, ShouldEqual, "Tenant A")
// Unfollow
err = Tenant.Unfollow(ctx, u.ID, t.ID)
err = Tenant.Unfollow(ctx, tenantID, u.ID)
So(err, ShouldBeNil)
// Verify
profile, err = Tenant.GetPublicProfile(ctx, u.ID, t.ID)
profile, err = Tenant.GetPublicProfile(ctx, tenantID, u.ID)
So(err, ShouldBeNil)
So(profile.IsFollowing, ShouldBeFalse)
So(profile.Stats.Followers, ShouldEqual, 0)