Skip to content

Commit

Permalink
Merge pull request #15 from Kusitms-Hackathon-B/jaehyeon
Browse files Browse the repository at this point in the history
feat: flask server connect
  • Loading branch information
versatile0010 authored Oct 7, 2023
2 parents 97f222b + 7881a9c commit 25e318c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.example.kusitmshackthon.exception.notfound.FoodInfoNotFoundException;
import com.example.kusitmshackthon.exception.notfound.MemberNotFoundException;
import com.example.kusitmshackthon.support.APIOpenFeign;
import com.example.kusitmshackthon.support.dto.response.FlaskResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -49,9 +48,11 @@ public ImageUploadResponse analysUserDiet(MultipartFile image, Long userId) {
Diet diet = dietRepository.save(Diet.of(member));

// ai 모델로부터 얻어낸 음식 리스트 get
FlaskResponse response = apiOpenFeign.call(image);
String response = apiOpenFeign.call(image);

List<String> foodNameList = response.getFoodNameList();
List<String> foodNameList = new ArrayList<>();
foodNameList.add(response);
//List<String> foodNameList = response.getFoodNameList();
List<Food> foodEntities = new ArrayList<>();

for (String foodName : foodNameList) {
Expand Down Expand Up @@ -140,9 +141,9 @@ public GetDietResponse getDietDetails(Long dietId) {
Float diff = entry.getValue();

if (diff >= 0) {
enoughList.add(GetDietResponse.NutrientInfo.of(name, accuHm.get(name), diff));
enoughList.add(GetDietResponse.NutrientInfo.of(name, accuHm.get(name), diff));
} else {
lackList.add(GetDietResponse.NutrientInfo.of(name, accuHm.get(name), diff));
lackList.add(GetDietResponse.NutrientInfo.of(name, accuHm.get(name), diff));
}
}
return GetDietResponse.of(lackList, enoughList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

import com.example.kusitmshackthon.support.dto.response.FlaskResponse;
import feign.Headers;
import feign.form.ContentType;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@FeignClient(name = "APIOpenFeign", url = "http://localhost:8080/api/diet/test") // todo: setting
@FeignClient(name = "APIOpenFeign", url = "${myapi.path}") // todo: setting
public interface APIOpenFeign {
@Headers("Content-Type: multipart/form-data")
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
FlaskResponse call(@RequestPart(value = "image") MultipartFile image);
String call(@RequestPart(value = "image") MultipartFile image);
}

0 comments on commit 25e318c

Please sign in to comment.