Skip to content

Commit 8a272f0

Browse files
Merge pull request #9 from alessandrobrunoh/main
Update Docker and Kafka configs; refactor TomatoesControllers
2 parents b38bff8 + 738168b commit 8a272f0

6 files changed

Lines changed: 33 additions & 15 deletions

File tree

.DS_Store

8 KB
Binary file not shown.

docker-compose.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
version: "3.8"
21
services:
32
ketchapp-api:
43
build: .
54
ports:
65
- "8081:8081"
76
environment:
87
- GEMINI_API_KEY=AIzaSyCkkuxXPPoohG40PbiIFECLbr7sjAqo-a0
8+
networks:
9+
- ketchapp-net
10+
11+
networks:
12+
ketchapp-net:
13+
external: true

src/.DS_Store

6 KB
Binary file not shown.

src/main/java/com/alessandra_alessandro/ketchapp/KetchappApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public class KetchappApplication {
99
public static void main(String[] args) {
1010
SpringApplication.run(KetchappApplication.class, args);
1111
}
12-
}
12+
}

src/main/java/com/alessandra_alessandro/ketchapp/controllers/TomatoesControllers.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,28 @@
77
import com.alessandra_alessandro.ketchapp.repositories.ActivitiesRepository;
88
import com.alessandra_alessandro.ketchapp.repositories.TomatoesRepository;
99
import com.alessandra_alessandro.ketchapp.utils.EntityMapper;
10-
import org.springframework.beans.factory.annotation.Autowired;
11-
import org.springframework.stereotype.Service;
10+
import java.util.List;
1211
import org.slf4j.Logger;
1312
import org.slf4j.LoggerFactory;
14-
15-
import java.util.List;
13+
import org.springframework.beans.factory.annotation.Autowired;
14+
import org.springframework.stereotype.Service;
1615

1716
@Service
1817
public class TomatoesControllers {
19-
private static final Logger log = LoggerFactory.getLogger(TomatoesControllers.class);
18+
19+
private static final Logger log = LoggerFactory.getLogger(
20+
TomatoesControllers.class
21+
);
2022
final TomatoesRepository tomatoesRepository;
2123
private final ActivitiesRepository activitiesRepository;
2224
private final EntityMapper entityMapper;
2325

2426
@Autowired
25-
public TomatoesControllers(TomatoesRepository tomatoesRepository, ActivitiesRepository activitiesRepository, EntityMapper entityMapper) {
27+
public TomatoesControllers(
28+
TomatoesRepository tomatoesRepository,
29+
ActivitiesRepository activitiesRepository,
30+
EntityMapper entityMapper
31+
) {
2632
this.tomatoesRepository = tomatoesRepository;
2733
this.activitiesRepository = activitiesRepository;
2834
this.entityMapper = entityMapper;
@@ -59,12 +65,19 @@ public TomatoDto createTomato(TomatoDto tomatoDto) {
5965
*/
6066
public List<ActivityDto> getActivitiesByTomatoId(Integer tomatoId) {
6167
log.info("Fetching activities for tomatoId: {}", tomatoId);
62-
List<ActivityEntity> activities = activitiesRepository.findByTomatoId(tomatoId);
63-
log.info("Found {} activities for tomatoId {}", activities.size(), tomatoId);
64-
List<ActivityDto> result = activities.stream()
65-
.map(entityMapper::activityEntityToDto)
66-
.collect(java.util.stream.Collectors.toList());
68+
List<ActivityEntity> activities = activitiesRepository.findByTomatoId(
69+
tomatoId
70+
);
71+
log.info(
72+
"Found {} activities for tomatoId {}",
73+
activities.size(),
74+
tomatoId
75+
);
76+
List<ActivityDto> result = activities
77+
.stream()
78+
.map(entityMapper::activityEntityToDto)
79+
.collect(java.util.stream.Collectors.toList());
6780
log.info("Mapped activities to ActivityDto list: {}", result);
6881
return result;
6982
}
70-
}
83+
}

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GEMINI_API_KEY=AIzaSyClXWWxzTCaB6mMZl1Uqcr_3Pe2xZgFHyE
3131

3232
# Kafka Configuration
3333
app.kafka.topic.mail-service=MailService
34-
spring.kafka.bootstrap-servers=151.42.165.160:29092
34+
spring.kafka.bootstrap-servers=kafka:9092
3535
spring.kafka.consumer.group-id=KafkaID
3636
spring.kafka.consumer.auto-offset-reset=earliest
3737
# important for initial consumer

0 commit comments

Comments
 (0)