继续补齐核心模块 Context 超时控制
This commit is contained in:
@@ -96,7 +96,7 @@ func (s *Service) Create(ctx context.Context, ownerID uint64, req CreateRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.Create(ownerID, req, reviewRequired)
|
||||
return s.repo.Create(ctx, ownerID, req, reviewRequired)
|
||||
}
|
||||
|
||||
func (s *Service) ImportExternalUpload(ctx context.Context, req ExternalUploadRequest, meta ExternalUploadMeta) (*ExternalUploadResponse, error) {
|
||||
@@ -132,7 +132,7 @@ func (s *Service) ImportExternalUpload(ctx context.Context, req ExternalUploadRe
|
||||
continue
|
||||
}
|
||||
parsedPayload, _ := json.Marshal(item)
|
||||
dto, err := s.repo.CreateFromExternalUpload(externalUploadCreate{
|
||||
dto, err := s.repo.CreateFromExternalUpload(ctx, externalUploadCreate{
|
||||
UploaderName: uploaderName,
|
||||
ClientUploadTime: clientUploadTime,
|
||||
ClientIP: meta.IP,
|
||||
@@ -187,7 +187,7 @@ func (s *Service) Update(ctx context.Context, ownerID uint64, id uint64, req Upd
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.Update(ownerID, id, req, reviewRequired)
|
||||
return s.repo.Update(ctx, ownerID, id, req, reviewRequired)
|
||||
}
|
||||
|
||||
func (s *Service) SubmitReview(ctx context.Context, ownerID uint64, id uint64) (*ListingDTO, error) {
|
||||
@@ -198,124 +198,124 @@ func (s *Service) SubmitReview(ctx context.Context, ownerID uint64, id uint64) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.SubmitReview(ownerID, id, reviewRequired)
|
||||
return s.repo.SubmitReview(ctx, ownerID, id, reviewRequired)
|
||||
}
|
||||
|
||||
func (s *Service) ListPendingReview() ([]ListingDTO, error) {
|
||||
func (s *Service) ListPendingReview(ctx context.Context) ([]ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.ListPendingReview()
|
||||
return s.repo.ListPendingReview(ctx)
|
||||
}
|
||||
|
||||
func (s *Service) ListAdmin(query AdminListQuery) (*AdminListResult, error) {
|
||||
func (s *Service) ListAdmin(ctx context.Context, query AdminListQuery) (*AdminListResult, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.ListAdmin(query)
|
||||
return s.repo.ListAdmin(ctx, query)
|
||||
}
|
||||
|
||||
func (s *Service) FindAdmin(id uint64) (*ListingDTO, error) {
|
||||
func (s *Service) FindAdmin(ctx context.Context, id uint64) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.FindAdmin(id)
|
||||
return s.repo.FindAdmin(ctx, id)
|
||||
}
|
||||
|
||||
func (s *Service) AdminOffline(adminID uint64, id uint64, req AdminActionRequest, meta AuditMeta) (*ListingDTO, error) {
|
||||
func (s *Service) AdminOffline(ctx context.Context, adminID uint64, id uint64, req AdminActionRequest, meta AuditMeta) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if req.Reason == "" {
|
||||
return nil, ErrInvalidInput
|
||||
}
|
||||
return s.repo.AdminOffline(adminID, id, req, meta)
|
||||
return s.repo.AdminOffline(ctx, adminID, id, req, meta)
|
||||
}
|
||||
|
||||
func (s *Service) AdminMarkAbnormal(adminID uint64, id uint64, req AdminActionRequest, meta AuditMeta) (*ListingDTO, error) {
|
||||
func (s *Service) AdminMarkAbnormal(ctx context.Context, adminID uint64, id uint64, req AdminActionRequest, meta AuditMeta) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if req.Reason == "" {
|
||||
return nil, ErrInvalidInput
|
||||
}
|
||||
return s.repo.AdminMarkAbnormal(adminID, id, req, meta)
|
||||
return s.repo.AdminMarkAbnormal(ctx, adminID, id, req, meta)
|
||||
}
|
||||
|
||||
func (s *Service) Approve(id uint64) (*ListingDTO, error) {
|
||||
func (s *Service) Approve(ctx context.Context, id uint64) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.Approve(id)
|
||||
return s.repo.Approve(ctx, id)
|
||||
}
|
||||
|
||||
func (s *Service) AdjustReviewPrice(adminID uint64, id uint64, req AdminPriceAdjustRequest, meta AuditMeta) (*ListingDTO, error) {
|
||||
func (s *Service) AdjustReviewPrice(ctx context.Context, adminID uint64, id uint64, req AdminPriceAdjustRequest, meta AuditMeta) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if req.BuyerRatio <= 0 && req.BuyerTotalPriceCent <= 0 {
|
||||
return nil, ErrInvalidPrice
|
||||
}
|
||||
return s.repo.AdjustReviewPrice(adminID, id, req, meta)
|
||||
return s.repo.AdjustReviewPrice(ctx, adminID, id, req, meta)
|
||||
}
|
||||
|
||||
func (s *Service) Reject(id uint64, req ReviewRequest) (*ListingDTO, error) {
|
||||
func (s *Service) Reject(ctx context.Context, id uint64, req ReviewRequest) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if req.Reason == "" {
|
||||
return nil, ErrInvalidInput
|
||||
}
|
||||
return s.repo.Reject(id, req)
|
||||
return s.repo.Reject(ctx, id, req)
|
||||
}
|
||||
|
||||
func (s *Service) Offline(ownerID uint64, id uint64) (*ListingDTO, error) {
|
||||
func (s *Service) Offline(ctx context.Context, ownerID uint64, id uint64) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.Offline(ownerID, id)
|
||||
return s.repo.Offline(ctx, ownerID, id)
|
||||
}
|
||||
|
||||
func (s *Service) ListPublic(query PublicListQuery) (*PublicListResult, error) {
|
||||
func (s *Service) ListPublic(ctx context.Context, query PublicListQuery) (*PublicListResult, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.ListPublic(query)
|
||||
return s.repo.ListPublic(ctx, query)
|
||||
}
|
||||
|
||||
func (s *Service) ListMine(ownerID uint64) ([]ListingDTO, error) {
|
||||
func (s *Service) ListMine(ctx context.Context, ownerID uint64) ([]ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.ListMine(ownerID)
|
||||
return s.repo.ListMine(ctx, ownerID)
|
||||
}
|
||||
|
||||
func (s *Service) FindPublic(id uint64) (*ListingDTO, error) {
|
||||
func (s *Service) FindPublic(ctx context.Context, id uint64) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.FindPublic(id)
|
||||
return s.repo.FindPublic(ctx, id)
|
||||
}
|
||||
|
||||
func (s *Service) FindPublicCoverKey(id uint64) (string, error) {
|
||||
func (s *Service) FindPublicCoverKey(ctx context.Context, id uint64) (string, error) {
|
||||
if s.repo == nil {
|
||||
return "", ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.FindPublicCoverKey(id)
|
||||
return s.repo.FindPublicCoverKey(ctx, id)
|
||||
}
|
||||
|
||||
func (s *Service) FindPublicScreenshotKey(id uint64, index int) (string, error) {
|
||||
func (s *Service) FindPublicScreenshotKey(ctx context.Context, id uint64, index int) (string, error) {
|
||||
if s.repo == nil {
|
||||
return "", ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.FindPublicScreenshotKey(id, index)
|
||||
return s.repo.FindPublicScreenshotKey(ctx, id, index)
|
||||
}
|
||||
|
||||
func (s *Service) FindMine(ownerID uint64, id uint64) (*ListingDTO, error) {
|
||||
func (s *Service) FindMine(ctx context.Context, ownerID uint64, id uint64) (*ListingDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.FindMine(ownerID, id)
|
||||
return s.repo.FindMine(ctx, ownerID, id)
|
||||
}
|
||||
|
||||
type publishRules struct {
|
||||
|
||||
Reference in New Issue
Block a user