feat: 다운로드 정보에 fileHash 필드 추가
All checks were successful
Server CI/CD / deploy (push) Successful in 38s
All checks were successful
Server CI/CD / deploy (push) Successful in 38s
게임 EXE의 SHA256 해시를 저장하여 런처가 버전 검증에 활용 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,11 +24,12 @@ func (h *Handler) Upsert(c *fiber.Ctx) error {
|
|||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
FileName string `json:"fileName"`
|
FileName string `json:"fileName"`
|
||||||
FileSize string `json:"fileSize"`
|
FileSize string `json:"fileSize"`
|
||||||
|
FileHash string `json:"fileHash"`
|
||||||
}
|
}
|
||||||
if err := c.BodyParser(&body); err != nil || body.URL == "" || body.Version == "" {
|
if err := c.BodyParser(&body); err != nil || body.URL == "" || body.Version == "" || body.FileHash == "" {
|
||||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "url과 version은 필수입니다"})
|
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "url, version, fileHash는 필수입니다"})
|
||||||
}
|
}
|
||||||
info, err := h.svc.Upsert(body.URL, body.Version, body.FileName, body.FileSize)
|
info, err := h.svc.Upsert(body.URL, body.Version, body.FileName, body.FileSize, body.FileHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "업데이트에 실패했습니다"})
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "업데이트에 실패했습니다"})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ type Info struct {
|
|||||||
Version string `json:"version" gorm:"not null"`
|
Version string `json:"version" gorm:"not null"`
|
||||||
FileName string `json:"fileName" gorm:"not null"`
|
FileName string `json:"fileName" gorm:"not null"`
|
||||||
FileSize string `json:"fileSize" gorm:"not null"`
|
FileSize string `json:"fileSize" gorm:"not null"`
|
||||||
|
FileHash string `json:"fileHash" gorm:"not null;default:''"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func (s *Service) GetInfo() (*Info, error) {
|
|||||||
return s.repo.GetLatest()
|
return s.repo.GetLatest()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Upsert(url, version, fileName, fileSize string) (*Info, error) {
|
func (s *Service) Upsert(url, version, fileName, fileSize, fileHash string) (*Info, error) {
|
||||||
info, err := s.repo.GetLatest()
|
info, err := s.repo.GetLatest()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
info = &Info{}
|
info = &Info{}
|
||||||
@@ -21,5 +21,6 @@ func (s *Service) Upsert(url, version, fileName, fileSize string) (*Info, error)
|
|||||||
info.Version = version
|
info.Version = version
|
||||||
info.FileName = fileName
|
info.FileName = fileName
|
||||||
info.FileSize = fileSize
|
info.FileSize = fileSize
|
||||||
|
info.FileHash = fileHash
|
||||||
return info, s.repo.Save(info)
|
return info, s.repo.Save(info)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user