Documentation
¶
Overview ¶
Package support is the facade of the support module: tickets, announcements, documents, ads and marketing tasks. Admin and public handlers call the same service; access-plane concerns such as auth and field trimming stay in the handlers. See docs/design/adr-001-modular-monolith.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRepoBuilder ¶ added in v1.15.2
func NewRepoBuilder() repository.SupportBuilder
NewRepoBuilder exports the module-owned repository implementations for store assembly (ADR-001 step-6 preparation).
Types ¶
type AuditLog ¶ added in v1.21.0
AuditLog records the administrators' mutations (ticket replies and status changes, marketing tasks) in the platform's system log; the platform kernel's log repository satisfies it.
type BatchEmailStopper ¶
type BatchEmailStopper interface {
StopBatchEmail(taskID int64)
}
BatchEmailStopper aborts a running batch-email worker, if any.
type Deps ¶
type Deps struct {
Announcements repository.AnnouncementRepo
Ads repository.AdsRepo
Documents repository.DocumentRepo
Tickets repository.TicketRepo
Tasks repository.TaskRepo
Subscriptions SubscriptionReader
Recipients EmailRecipientReader
QuotaTargets SubscriptionSelector
Queue MarketingQueue
EmailStopper BatchEmailStopper
// TicketNotify mirrors ticket lifecycle into the Telegram admin group;
// nil disables the mirror. Best-effort by contract.
TicketNotify ticket.Notifier
// Redis backs the per-user ticket creation and reply limits; nil
// disables them.
Redis *redis.Client
// AuditLogs records the administrators' mutations; nil records nothing.
AuditLogs AuditLog
}
Deps declares everything the module needs; the composition root (internal/app) provides them. The ticket, announcement, ads and document repositories are the module's own (see NewRepoBuilder); the rest are ports onto other domains.
type EmailRecipientReader ¶
type EmailRecipientReader interface {
QueryEmailRecipients(ctx context.Context, filter *user.EmailRecipientFilter) ([]string, error)
CountEmailRecipients(ctx context.Context, filter *user.EmailRecipientFilter) (int64, error)
}
EmailRecipientReader is the module's port onto the identity domain for selecting campaign recipients; the identity user repository satisfies it structurally.
type MarketingQueue ¶
type MarketingQueue interface {
EnqueueBatchEmail(ctx context.Context, taskID int64, processAt time.Time) (queueTaskID string, err error)
EnqueueQuota(ctx context.Context, taskID int64) error
}
MarketingQueue schedules asynchronous execution of marketing tasks; the composition root adapts the asynq client so queue task types stay out of the module.
type Service ¶
type Service interface {
// TicketReads serves the dashboard's ticket figures and the bot's ticket
// views.
TicketReads
CreateAnnouncement(ctx context.Context, req *dto.CreateAnnouncementRequest) error
UpdateAnnouncement(ctx context.Context, req *dto.UpdateAnnouncementRequest) error
DeleteAnnouncement(ctx context.Context, req *dto.DeleteAnnouncementRequest) error
GetAnnouncement(ctx context.Context, req *dto.GetAnnouncementRequest) (*dto.Announcement, error)
GetAnnouncementList(ctx context.Context, req *dto.GetAnnouncementListRequest) (*dto.GetAnnouncementListResponse, error)
// QueryAnnouncement lists announcements visible to end users; Show=true is
// enforced here, not trusted from the request.
QueryAnnouncement(ctx context.Context, req *dto.QueryAnnouncementRequest) (*dto.QueryAnnouncementResponse, error)
CreateAds(ctx context.Context, req *dto.CreateAdsRequest) error
UpdateAds(ctx context.Context, req *dto.UpdateAdsRequest) error
DeleteAds(ctx context.Context, req *dto.DeleteAdsRequest) error
GetAdsDetail(ctx context.Context, req *dto.GetAdsDetailRequest) (*dto.Ads, error)
GetAdsList(ctx context.Context, req *dto.GetAdsListRequest) (*dto.GetAdsListResponse, error)
// GetPublicAds lists the active ads for the public site.
GetPublicAds(ctx context.Context, req *dto.GetAdsRequest) (*dto.GetAdsResponse, error)
CreateDocument(ctx context.Context, req *dto.CreateDocumentRequest) error
UpdateDocument(ctx context.Context, req *dto.UpdateDocumentRequest) error
DeleteDocument(ctx context.Context, req *dto.DeleteDocumentRequest) error
BatchDeleteDocument(ctx context.Context, req *dto.BatchDeleteDocumentRequest) error
GetDocumentDetail(ctx context.Context, req *dto.GetDocumentDetailRequest) (*dto.Document, error)
GetDocumentList(ctx context.Context, req *dto.GetDocumentListRequest) (*dto.GetDocumentListResponse, error)
// QueryDocumentDetail renders subscription-gated blocks for the current
// user before returning the content.
QueryDocumentDetail(ctx context.Context, req *dto.QueryDocumentDetailRequest) (*dto.Document, error)
QueryDocumentList(ctx context.Context) (*dto.QueryDocumentListResponse, error)
CreateTicketFollow(ctx context.Context, req *dto.CreateTicketFollowRequest) error
GetTicketList(ctx context.Context, req *dto.GetTicketListRequest) (*dto.GetTicketListResponse, error)
GetTicket(ctx context.Context, req *dto.GetTicketRequest) (*dto.Ticket, error)
UpdateTicketStatus(ctx context.Context, req *dto.UpdateTicketStatusRequest) error
// The user-facing ticket operations resolve the current user from the
// request context and enforce ticket ownership.
CreateUserTicket(ctx context.Context, req *dto.CreateUserTicketRequest) error
CreateUserTicketFollow(ctx context.Context, req *dto.CreateUserTicketFollowRequest) error
GetUserTicketDetails(ctx context.Context, req *dto.GetUserTicketDetailRequest) (*dto.Ticket, error)
GetUserTicketList(ctx context.Context, req *dto.GetUserTicketListRequest) (*dto.GetUserTicketListResponse, error)
UpdateUserTicketStatus(ctx context.Context, req *dto.UpdateUserTicketStatusRequest) error
// UpdateTicketAsStaff applies a ticket change staff made outside the
// admin panel (the Telegram bot): a reply, or a status change. It runs
// the same use case as the admin panel's reply and status endpoints, so
// the change is mirrored the same way, except back into the channel it
// came from.
UpdateTicketAsStaff(ctx context.Context, cmd *dto.StaffTicketUpdateCommand) (*dto.StaffTicketUpdateResult, error)
CreateBatchSendEmailTask(ctx context.Context, req *dto.CreateBatchSendEmailTaskRequest) error
GetPreSendEmailCount(ctx context.Context, req *dto.GetPreSendEmailCountRequest) (*dto.GetPreSendEmailCountResponse, error)
GetBatchSendEmailTaskList(ctx context.Context, req *dto.GetBatchSendEmailTaskListRequest) (*dto.GetBatchSendEmailTaskListResponse, error)
GetBatchSendEmailTaskStatus(ctx context.Context, req *dto.GetBatchSendEmailTaskStatusRequest) (*dto.GetBatchSendEmailTaskStatusResponse, error)
StopBatchSendEmailTask(ctx context.Context, req *dto.StopBatchSendEmailTaskRequest) error
CreateQuotaTask(ctx context.Context, req *dto.CreateQuotaTaskRequest) error
QueryQuotaTaskList(ctx context.Context, req *dto.QueryQuotaTaskListRequest) (*dto.QueryQuotaTaskListResponse, error)
QueryQuotaTaskPreCount(ctx context.Context, req *dto.QueryQuotaTaskPreCountRequest) (*dto.QueryQuotaTaskPreCountResponse, error)
}
Service is the only surface other code may depend on; the implementation lives under internal/ where the compiler seals it off.
type SubscriptionReader ¶
type SubscriptionReader interface {
HasActiveSubscription(ctx context.Context, userID int64) (bool, error)
}
SubscriptionReader is the support module's port onto the subscription domain (dependency inversion: the consumer owns the interface); the composition root adapts the subscription domain's repository to it.
type SubscriptionSelector ¶
type SubscriptionSelector interface {
QuerySubscribeIdsByFilter(ctx context.Context, filter *usersub.SubscribeFilter) ([]int64, error)
CountSubscribesByFilter(ctx context.Context, filter *usersub.SubscribeFilter) (int64, error)
}
SubscriptionSelector is the module's port onto the subscription domain for selecting quota-task targets; the subscription domain's user-subscription repository satisfies it structurally.
type TicketReads ¶ added in v1.21.0
type TicketReads interface {
TicketStatistics
// ListTickets pages the tickets of every user, only those in status when
// it is set.
ListTickets(ctx context.Context, page, size int, status *uint8) (int64, []*ticket.Ticket, error)
// FindTicket returns the ticket; TicketDetails returns it with its
// follow-ups.
FindTicket(ctx context.Context, id int64) (*ticket.Ticket, error)
TicketDetails(ctx context.Context, id int64) (*ticket.Details, error)
}
TicketReads is the part of the facade the other modules read tickets through instead of the ticket repository (ADR-001 rule 4): the dashboard figures and the Telegram bot's ticket views. The reads return the repository's results and errors as they are, so a miss is still gorm.ErrRecordNotFound.
type TicketStatistics ¶ added in v1.21.0
type TicketStatistics interface {
// CountTicketsAwaitingReply counts the tickets waiting for a staff reply.
CountTicketsAwaitingReply(ctx context.Context) (int64, error)
}
TicketStatistics is the part of the facade the platform's dashboard reads the ticket figures through, instead of the ticket repository (ADR-001 rule 4).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dto holds the support module's contract: the requests and responses of the ticket, announcement, document, ads and marketing endpoints.
|
Package dto holds the support module's contract: the requests and responses of the ticket, announcement, document, ads and marketing endpoints. |
|
entity
|
|
|
ads
Package ads holds the ads row (the ads table): an ad the public site shows while it is enabled and inside its schedule.
|
Package ads holds the ads row (the ads table): an ad the public site shows while it is enabled and inside its schedule. |
|
announcement
Package announcement holds the announcement row (the announcement table) and its list filter.
|
Package announcement holds the announcement row (the announcement table) and its list filter. |
|
document
Package document holds the help document row (the document table).
|
Package document holds the help document row (the document table). |
|
ticket
Package ticket holds the support ticket rows (the ticket and ticket_follow tables), the ticket statuses and the follow types.
|
Package ticket holds the support ticket rows (the ticket and ticket_follow tables), the ticket statuses and the follow types. |
|
internal
|
|
|
ads
Package ads implements the ads subdomain of the support module.
|
Package ads implements the ads subdomain of the support module. |
|
announcement
Package announcement implements the announcement subdomain of the support module.
|
Package announcement implements the announcement subdomain of the support module. |
|
document
Package document implements the document subdomain of the support module.
|
Package document implements the document subdomain of the support module. |
|
marketing
Package marketing implements the marketing subdomain of the support module (batch email campaigns and quota gift tasks).
|
Package marketing implements the marketing subdomain of the support module (batch email campaigns and quota gift tasks). |
|
repo
Package repo holds the support module's repository implementations: tickets, announcements, ads and documents, each cached in Redis.
|
Package repo holds the support module's repository implementations: tickets, announcements, ads and documents, each cached in Redis. |
|
supporttest
Package supporttest is the support module's behaviour-test harness: the module's real repositories (tickets, announcements, ads and documents) and the platform's task bookkeeping the marketing tasks write, over a private in-memory SQLite database with miniredis as their cache, together with recording fakes of the module's ports onto the other domains, seeding and reading helpers, a way to make the database refuse statements, the API views of stored rows and a client for the Hertz handlers.
|
Package supporttest is the support module's behaviour-test harness: the module's real repositories (tickets, announcements, ads and documents) and the platform's task bookkeeping the marketing tasks write, over a private in-memory SQLite database with miniredis as their cache, together with recording fakes of the module's ports onto the other domains, seeding and reading helpers, a way to make the database refuse statements, the API views of stored rows and a client for the Hertz handlers. |
|
ticket
Package ticket implements the ticket subdomain of the support module.
|
Package ticket implements the ticket subdomain of the support module. |
|
transport
|
|
|
http/admin/ads
Package ads holds the Hertz handlers of the admin ads management.
|
Package ads holds the Hertz handlers of the admin ads management. |
|
http/admin/announcement
Package announcement holds the Hertz handlers of the admin announcement management.
|
Package announcement holds the Hertz handlers of the admin announcement management. |
|
http/admin/document
Package document holds the Hertz handlers of the admin help document management.
|
Package document holds the Hertz handlers of the admin help document management. |
|
http/admin/marketing
Package marketing holds the Hertz handlers of the admin marketing tasks: batch email campaigns and quota gifts.
|
Package marketing holds the Hertz handlers of the admin marketing tasks: batch email campaigns and quota gifts. |
|
http/admin/ticket
Package ticket holds the Hertz handlers of the admin ticket desk.
|
Package ticket holds the Hertz handlers of the admin ticket desk. |
|
http/common
Package common holds the Hertz handler of the ads the public site shows.
|
Package common holds the Hertz handler of the ads the public site shows. |
|
http/public/announcement
Package announcement holds the Hertz handler of the announcements users see.
|
Package announcement holds the Hertz handler of the announcements users see. |
|
http/public/document
Package document holds the Hertz handlers of the help documents users read.
|
Package document holds the Hertz handlers of the help documents users read. |
|
http/public/ticket
Package ticket holds the Hertz handlers of a user's own tickets: opening, following up, reading and closing them.
|
Package ticket holds the Hertz handlers of a user's own tickets: opening, following up, reading and closing them. |