Files
BountyBoard/internal/domain/customer.go
T
etalon f3897907a3 feat: WeKan ticketing source
- wekan connector: board id as project key, cards assigned to the
  consultant's WeKan username (assignees with member fallback), archived
  cards skipped, client-side modifiedAt since-filtering, username/password
  login with token reuse (or pre-issued token), case-insensitive identity
- fake-WeKan unit tests: factory validation, test-connection, fetch
  filtering, key listing, token reuse
- admin customer wizard: WeKan option + credential fields
- OpenAPI enum + credential shapes, README identity mapping docs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 21:15:34 +02:00

58 lines
1.9 KiB
Go

package domain
import "time"
type TicketingType string
const (
TicketingJira TicketingType = "jira"
TicketingAzure TicketingType = "azure_devops"
TicketingYouTrack TicketingType = "youtrack"
TicketingWekan TicketingType = "wekan"
// TicketingDemo fabricates tickets locally so the whole flow works
// offline (§11.11).
TicketingDemo TicketingType = "demo"
)
func (t TicketingType) Valid() bool {
switch t {
case TicketingJira, TicketingAzure, TicketingYouTrack, TicketingWekan, TicketingDemo:
return true
}
return false
}
type Ticketing struct {
Type TicketingType `bson:"type" json:"type"`
BaseURL string `bson:"baseUrl" json:"baseUrl"`
CredentialsEnc string `bson:"credentialsEnc" json:"-"`
ProjectKey string `bson:"projectKey" json:"projectKey"`
PollIntervalSec int `bson:"pollIntervalSec" json:"pollIntervalSec"`
LastSyncAt time.Time `bson:"lastSyncAt" json:"lastSyncAt"`
LastSyncStatus string `bson:"lastSyncStatus" json:"lastSyncStatus"` // "", ok, error
LastSyncError string `bson:"lastSyncError" json:"lastSyncError"`
}
// Customer == "project" in the UI (§4.2).
type Customer struct {
ID string `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Ticketing Ticketing `bson:"ticketing" json:"ticketing"`
ConsultantIDs []string `bson:"consultantIds" json:"consultantIds"`
DefaultBudget float64 `bson:"defaultBudget" json:"defaultBudget"`
Archived bool `bson:"archived" json:"archived"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
Version int64 `bson:"version" json:"version"`
}
// HasConsultant reports membership in the customer's consultant set.
func (c *Customer) HasConsultant(userID string) bool {
for _, id := range c.ConsultantIDs {
if id == userID {
return true
}
}
return false
}