diff --git a/repository/gorm/stamp.go b/repository/gorm/stamp.go index 94bb9a67d..78d2fa20d 100644 --- a/repository/gorm/stamp.go +++ b/repository/gorm/stamp.go @@ -343,39 +343,3 @@ func (r *stampRepository) GetStampStats(stampID uuid.UUID) (*repository.StampSta } return &stats, nil } - -func (r *stampRepository) StampThumbnailExists(stamps []*model.Stamp) (stampsWithThumb []repository.StampWithThumbnail, err error) { - IDs := make([]uuid.UUID, len(stamps)) - - for i, s := range stamps { - IDs[i] = s.FileID - } - ts := []uuid.UUID{} - if err = r.db. - Table("files_thumbnails ft"). - Select("file_id"). - Where("file_id IN (?)", IDs). - Find(&ts). - Error; err != nil { - return stampsWithThumb, err - } - tm := make(map[uuid.UUID]struct{}, len(ts)) - for _, v := range ts { - tm[v] = struct{}{} - } - - for _, s := range(stamps) { - _, ok := tm[s.FileID] - stampsWithThumb = append(stampsWithThumb, repository.StampWithThumbnail{ - ID: s.ID, - Name: s.Name, - CreatorID: s.CreatorID, - FileID: s.FileID, - IsUnicode: s.IsUnicode, - CreatedAt: s.CreatedAt, - UpdatedAt: s.UpdatedAt, - HasThumbnail: ok, - }) - } - return -} diff --git a/repository/stamp.go b/repository/stamp.go index 3564e926a..d9188a9fb 100644 --- a/repository/stamp.go +++ b/repository/stamp.go @@ -36,17 +36,6 @@ type StampStats struct { TotalCount int64 `json:"totalCount"` } -type StampWithThumbnail struct { - ID uuid.UUID `json:"id"` - Name string `json:"name"` - CreatorID uuid.UUID `json:"creatorId"` - FileID uuid.UUID `json:"fileId"` - IsUnicode bool `json:"isUnicode"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - HasThumbnail bool `json:"hasThumbnail"` -} - // StampType スタンプの種類 type StampType string @@ -125,9 +114,4 @@ type StampRepository interface { // stampIDにNILを渡した場合、(nil, ErrNilID)を返します。 // DBによるエラーを返すことがあります。 GetStampStats(stampID uuid.UUID) (*StampStats, error) - // StampThumbnailExists スタンプ情報にサムネイルの有無を示すbool値を付加した構造体の配列を返します - // - // 成功した場合、当該配列とnilを返します - // DBによるエラーを返すことがあります。 - StampThumbnailExists(stamps []*model.Stamp) (stampsWithThumb []StampWithThumbnail, err error) } diff --git a/router/v3/stamps.go b/router/v3/stamps.go index 966d627b4..6f2991ee0 100644 --- a/router/v3/stamps.go +++ b/router/v3/stamps.go @@ -71,12 +71,7 @@ func (h *Handlers) GetStamps(c echo.Context) error { return herror.InternalServerError(err) } - stampsWithThumb, err := h.Repo.StampThumbnailExists(stamps) - if err != nil { - return herror.InternalServerError(err) - } - - return extension.ServeJSONWithETag(c, stampsWithThumb) + return extension.ServeJSONWithETag(c, stamps) } // CreateStamp POST /stamps