-
Notifications
You must be signed in to change notification settings - Fork 7
/
CreateFoodService.java
38 lines (33 loc) · 1.51 KB
/
CreateFoodService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.gaebaljip.exceed.application.service.food;
import org.springframework.stereotype.Service;
import com.gaebaljip.exceed.adapter.out.jpa.food.FoodEntity;
import com.gaebaljip.exceed.application.domain.member.MemberEntity;
import com.gaebaljip.exceed.application.port.in.food.CreateFoodUseCase;
import com.gaebaljip.exceed.application.port.out.food.FoodPort;
import com.gaebaljip.exceed.application.port.out.member.MemberPort;
import com.gaebaljip.exceed.adapter.in.food.request.CreateFoodRequest;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class CreateFoodService implements CreateFoodUseCase {
private final FoodPort foodPort;
private final MemberPort memberPort;
@Override
public void execute(CreateFoodRequest request, Long memberId) {
MemberEntity memberEntity = memberPort.query(memberId);
FoodEntity foodEntity =
FoodEntity.builder()
.calorie(request.calorie())
.dietaryFiber(request.dietaryFiber())
.carbohydrate(request.carbohydrate())
.name(request.name())
.protein(request.protein())
.servingSize(request.servingSize())
.sodium(request.sodium())
.sugars(request.sugars())
.fat(request.fat())
.memberEntity(memberEntity)
.build();
foodPort.command(foodEntity);
}
}