-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from JokerTrickster/feat/196/image_upload_che…
…ck_api {feat} - 음식 이미지 업로드 체크 api 구현 \n #196
- Loading branch information
Showing
15 changed files
with
396 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
_interface "main/features/food/model/interface" | ||
"main/features/food/model/request" | ||
"main/utils" | ||
|
||
"net/http" | ||
|
||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
type CheckImageUploadFoodHandler struct { | ||
UseCase _interface.ICheckImageUploadFoodUseCase | ||
} | ||
|
||
func NewCheckImageUploadFoodHandler(c *echo.Echo, useCase _interface.ICheckImageUploadFoodUseCase) _interface.ICheckImageUploadFoodHandler { | ||
handler := &CheckImageUploadFoodHandler{ | ||
UseCase: useCase, | ||
} | ||
c.POST("/v0.1/foods/images/upload-check", handler.CheckImageUpload) | ||
return handler | ||
} | ||
|
||
// 음식 이미지 업로드 체크하기 | ||
// @Router /v0.1/foods/images/upload-check [post] | ||
// @Summary 음식 이미지 업로드 체크하기 | ||
// @Description | ||
// @Description ■ errCode with 400 | ||
// @Description PARAM_BAD : 파라미터 오류 | ||
// @Description USER_NOT_FOUND : 유저가 존재하지 않음 | ||
// @Description ■ errCode with 401 | ||
// @Description INVALID_AUTH_CODE : 인증 코드 검증 실패 | ||
// @Description TOKEN_BAD : 잘못된 토큰 | ||
// @Description INVALID_ACCESS_TOKEN : 잘못된 액세스 토큰 | ||
// @Description | ||
// @Description ■ errCode with 500 | ||
// @Description INTERNAL_SERVER : 내부 로직 처리 실패 | ||
// @Description INTERNAL_DB : DB 처리 실패 | ||
// @Description GEMINI_INTERNAL_SERVER : Gemini 서버 내부 오류 | ||
// @Param type body request.ReqCheckImageUploadFood true "type" | ||
// @Produce json | ||
// @Success 200 {object} bool | ||
// @Failure 400 {object} error | ||
// @Failure 500 {object} error | ||
// @Tags food | ||
func (d *CheckImageUploadFoodHandler) CheckImageUpload(c echo.Context) error { | ||
ctx := context.Background() | ||
req := &request.ReqCheckImageUploadFood{} | ||
if err := utils.ValidateReq(c, req); err != nil { | ||
return err | ||
} | ||
|
||
//business logic | ||
err := d.UseCase.CheckImageUpload(ctx, req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.JSON(http.StatusOK, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package request | ||
|
||
type ReqCheckImageUploadFood struct { | ||
FailedFoodList []string `json:"failedFoodList"` | ||
SuccessFoodList []string `json:"successFoodList"` | ||
} |
11 changes: 11 additions & 0 deletions
11
src/features/food/repository/checkImageUploadFoodRepository.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package repository | ||
|
||
import ( | ||
_interface "main/features/food/model/interface" | ||
|
||
"gorm.io/gorm" | ||
) | ||
|
||
func NewCheckImageUploadFoodRepository(gormDB *gorm.DB) _interface.ICheckImageUploadFoodRepository { | ||
return &CheckImageUploadFoodRepository{GormDB: gormDB} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package usecase | ||
|
||
import ( | ||
"context" | ||
|
||
_interface "main/features/food/model/interface" | ||
"main/features/food/model/request" | ||
"main/utils/aws" | ||
|
||
"time" | ||
) | ||
|
||
type CheckImageUploadFoodUseCase struct { | ||
Repository _interface.ICheckImageUploadFoodRepository | ||
ContextTimeout time.Duration | ||
} | ||
|
||
func NewCheckImageUploadFoodUseCase(repo _interface.ICheckImageUploadFoodRepository, timeout time.Duration) _interface.ICheckImageUploadFoodUseCase { | ||
return &CheckImageUploadFoodUseCase{Repository: repo, ContextTimeout: timeout} | ||
} | ||
|
||
func (d *CheckImageUploadFoodUseCase) CheckImageUpload(c context.Context, req *request.ReqCheckImageUploadFood) error { | ||
_, cancel := context.WithTimeout(c, d.ContextTimeout) | ||
defer cancel() | ||
|
||
aws.EmailSendFoodUploadReport(req.SuccessFoodList, req.FailedFoodList) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,12 @@ import ( | |
type emailType string | ||
|
||
const ( | ||
emailTypePassword = emailType("password") | ||
emailTypeAuth = emailType("authCode") | ||
emailTypeReport = emailType("report") | ||
emailTypeSignup = emailType("signup") | ||
emailTypeFoodNameReport = emailType("foodNameReport") | ||
emailTypePassword = emailType("password") | ||
emailTypeAuth = emailType("authCode") | ||
emailTypeReport = emailType("report") | ||
emailTypeSignup = emailType("signup") | ||
emailTypeFoodNameReport = emailType("foodNameReport") | ||
emailTypeFoodUploadReport = emailType("foodUploadReport") | ||
) | ||
|
||
type sesMailData struct { | ||
|
@@ -35,6 +36,19 @@ type ReqReportSES struct { | |
Reason string | ||
} | ||
|
||
func EmailSendFoodUploadReport(successFoodList, failedFoodList []string) { | ||
templateDataMap := map[string]string{ | ||
"successFoodList": strings.Join(successFoodList, ", "), | ||
"failedFoodList": strings.Join(failedFoodList, ", "), | ||
} | ||
templateDataJson, err := json.Marshal(templateDataMap) | ||
if err != nil { | ||
fmt.Println("Error marshaling template data:", err) | ||
return | ||
} | ||
//"[email protected]" | ||
emailSend([]string{"[email protected]"}, emailTypeFoodNameReport, string(templateDataJson), "foodUploadReport") | ||
} | ||
func EmailSendFoodNameReport(foodNames []string) { | ||
currentDate := time.Now().Format("01-02") | ||
templateDataMap := map[string]string{ | ||
|
Oops, something went wrong.