feat: add tenant entry registration APIs
This commit is contained in:
@@ -173,6 +173,52 @@ func (thirdPartyConfigMapper) Get(group string, keys ...string) (map[string]stri
|
||||
return configAdp.ThirdPartyConfig(group, keys...)
|
||||
}
|
||||
|
||||
type TenantEntryPersistenceInterface interface {
|
||||
CreatePublicUpload(upload *types.PublicUpload) (*types.PublicUpload, error)
|
||||
CreateTenantApplication(application *types.TenantApplication) (*types.TenantApplication, error)
|
||||
CreateTenantEntryFeedback(feedback *types.TenantEntryFeedback) (*types.TenantEntryFeedback, error)
|
||||
}
|
||||
|
||||
type tenantEntryMapper struct{}
|
||||
|
||||
var TenantEntry TenantEntryPersistenceInterface
|
||||
|
||||
func (tenantEntryMapper) CreatePublicUpload(upload *types.PublicUpload) (*types.PublicUpload, error) {
|
||||
if upload == nil || strings.TrimSpace(upload.FileID) == "" || strings.TrimSpace(upload.Purpose) == "" ||
|
||||
strings.TrimSpace(upload.MimeType) == "" || strings.TrimSpace(upload.Location) == "" || upload.Size <= 0 {
|
||||
return nil, types.ErrMalformed
|
||||
}
|
||||
entryAdp, ok := adp.(adapter.TenantEntryAdapter)
|
||||
if !ok {
|
||||
return nil, types.ErrUnsupported
|
||||
}
|
||||
return entryAdp.PublicUploadCreate(upload)
|
||||
}
|
||||
|
||||
func (tenantEntryMapper) CreateTenantApplication(application *types.TenantApplication) (*types.TenantApplication, error) {
|
||||
if application == nil || strings.TrimSpace(application.ApplicationID) == "" ||
|
||||
strings.TrimSpace(application.CreditCode) == "" || strings.TrimSpace(application.IdempotencyKey) == "" {
|
||||
return nil, types.ErrMalformed
|
||||
}
|
||||
entryAdp, ok := adp.(adapter.TenantEntryAdapter)
|
||||
if !ok {
|
||||
return nil, types.ErrUnsupported
|
||||
}
|
||||
return entryAdp.TenantApplicationCreate(application)
|
||||
}
|
||||
|
||||
func (tenantEntryMapper) CreateTenantEntryFeedback(feedback *types.TenantEntryFeedback) (*types.TenantEntryFeedback, error) {
|
||||
if feedback == nil || strings.TrimSpace(feedback.FeedbackID) == "" ||
|
||||
strings.TrimSpace(feedback.Description) == "" || strings.TrimSpace(feedback.IdempotencyKey) == "" {
|
||||
return nil, types.ErrMalformed
|
||||
}
|
||||
entryAdp, ok := adp.(adapter.TenantEntryAdapter)
|
||||
if !ok {
|
||||
return nil, types.ErrUnsupported
|
||||
}
|
||||
return entryAdp.TenantEntryFeedbackCreate(feedback)
|
||||
}
|
||||
|
||||
// GetByCode resolves a tenant by its public enterprise code.
|
||||
func (tenantsMapper) GetByCode(code string) (*types.Tenant, error) {
|
||||
tenantAdp, ok := adp.(adapter.TenantAdapter)
|
||||
@@ -3693,6 +3739,7 @@ func init() {
|
||||
Store = storeObj{}
|
||||
Tenants = tenantsMapper{}
|
||||
RegistrationConfig = registrationConfigMapper{}
|
||||
TenantEntry = tenantEntryMapper{}
|
||||
Users = usersMapper{}
|
||||
Topics = topicsMapper{}
|
||||
Subs = subsMapper{}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package types
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
PublicUploadPurposeEnterpriseLicense = "enterprise_license"
|
||||
PublicUploadPurposeTenantFeedback = "tenant_entry_feedback"
|
||||
|
||||
TenantApplicationStatusReceived = "received"
|
||||
TenantEntryFeedbackReceived = "received"
|
||||
)
|
||||
|
||||
type PublicUpload struct {
|
||||
FileID string
|
||||
Purpose string
|
||||
MimeType string
|
||||
Size int64
|
||||
ETag string
|
||||
Location string
|
||||
ExpiresAt time.Time
|
||||
CreatedAt time.Time
|
||||
UploadedAt time.Time
|
||||
}
|
||||
|
||||
type TenantApplication struct {
|
||||
ApplicationID string
|
||||
CreditCode string
|
||||
EnterpriseEmail string
|
||||
LicenseFileID string
|
||||
TenantCodeHint string
|
||||
ClientContext map[string]any
|
||||
IdempotencyKey string
|
||||
Status string
|
||||
EstimatedReviewHour int
|
||||
SubmittedAt time.Time
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type TenantEntryFeedback struct {
|
||||
FeedbackID string
|
||||
Description string
|
||||
Contact string
|
||||
TenantCodeHint string
|
||||
ScreenshotFileIDs []string
|
||||
ClientContext map[string]any
|
||||
IdempotencyKey string
|
||||
Status string
|
||||
SubmittedAt time.Time
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user