Skip to content

Instantly share code, notes, and snippets.

@zzerjae
Created October 31, 2020 08:13
Show Gist options
  • Save zzerjae/9e7cc3065954cfb27f500cedb6182e06 to your computer and use it in GitHub Desktop.
Save zzerjae/9e7cc3065954cfb27f500cedb6182e06 to your computer and use it in GitHub Desktop.
package worker
type NewArticleEvent struct {
RegionId int64
PublishRange int
WriterId int64
ArticleId int64
Title string
}
type Matched struct {
UserId int64
Keyword string
}
type Worker struct {
RegionSvc RegionService
NotificationSvc NotificationService
UserSvc UserService
DB DB
}
type RegionService interface {
GetRegionIdsByRange(regionId int64, publishRange int) ([]int64, error)
}
type NotificationService interface {
Send(userId int64, keyword string, articleId int64, Title string)
}
type UserService interface {
BatchGetBlockingUsers(userIds []int64, userId int64) (map[int64]bool, error)
}
type DB interface {
FindMatchedUsers(title string, regionIdsByRange [][]int64) ([][]Matched, error)
}
// 내가 작성해야할 서비스
func (w *Worker) Work(e NewArticleEvent) {
// 게시글의 인접지역을 조회하여, 노출 범위별로 지역을 나눈다.
// Title에 매칭되는 키워드를 구독하고 있는 유저를 각 지역별로 찾는다.
// 대상 유저들이 작성자를 차단하는지 찾는다.
// 알림을 전송한다.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment