iT邦幫忙

2025 iThome 鐵人賽

DAY 5
0
AI & Data

ML/DL實作-「營養抗老」專題製作系列 第 5

Day5_ML/DL實作-「營養抗老」專題-db schema 建立 3/3

  • 分享至 

  • xImage
  •  
  • 目標

Spring Boot 成功連 MySQL,可查 effects / foods / evidence

/api/effects 回資料(從 DB 讀)

打好 DAO / RowMapper / Service 骨架


工作項目

- 設定連線

src/main/resources/application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/mymall?useSSL=false&serverTimezone=Asia/Taipei&characterEncoding=utf8

spring.datasource.username=mall

spring.datasource.password=mallpass

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
- 建表與最小測試資料

- db/schema.sql、db/data.sql

- 確保 effects 有 E001/E002;evidence 有基本資料

- DAO & RowMapper

- EffectDao:List<EffectDto> findAll()

- EvidenceDao:List<EvidenceRow> findByEffect(String effectId)

- RowMapper:EffectRowMapper、RecommendationItemRowMapper

- Service

- EffectService.listEffects() 直接呼叫 EffectDao

- RecommendationService.recommend(effectId) 先直接回 evidence 的原始清單(暫不算分)

- Controller

EffectController → GET /api/effects

RecommendationController → GET /api/recommendations?effectId=E001|E002

- 驗收

curl "http://localhost:8080/api/effects":看到 E001/E002

curl "http://localhost:8080/api/recommendations?effectId=E002":至少有清單(尚未排序)

上一篇
Day4_ML/DL實作-「營養抗老」專題- db schema 建立 -2/2
系列文
ML/DL實作-「營養抗老」專題製作5
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言