Parcourir la source

fix(health): 心情打卡同步情绪日记—checkinDate 空值兜底为当天

syncToEmotionDiary 现在兼容 checkinDate 为 null 的情况(前端未传时默认当天)
iwt il y a 1 mois
Parent
commit
ebf7325d8b

+ 6 - 3
cfc-backend/src/main/java/com/etotem/cfc/service/DailyCheckinService.java

@@ -67,10 +67,13 @@ public class DailyCheckinService {
      */
     private void syncToEmotionDiary(DailyHealthCheckin checkin) {
         java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
-        String dateStr = sdf.format(checkin.getCheckinDate());
-        Date todayDate = sdf.parse(dateStr);
+        Date dateForSync = checkin.getCheckinDate() != null ? checkin.getCheckinDate() : new Date();
+        String dateStr = sdf.format(dateForSync);
+        try {
+            dateForSync = sdf.parse(dateStr);
+        } catch (Exception ignored) {}
 
-        EmotionCheckin existing = emotionCheckinMapper.selectByChildIdAndDate(checkin.getMemberId(), todayDate);
+        EmotionCheckin existing = emotionCheckinMapper.selectByChildIdAndDate(checkin.getMemberId(), dateForSync);
 
         EmotionCheckin ec = new EmotionCheckin();
         ec.setChildId(checkin.getMemberId());

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-f6f5327609b4ceb3b3593ffb3971e4f2c64e87ab
+38751a310a990c960e0f797cd800894130640042

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1142",
+  "version": "1.0.1143",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.1142",
+      "version": "1.0.1143",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1143",
+  "version": "1.0.1144",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 13 - 0
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,6 +4,19 @@
 
 ---
 
+## v1.0.1144 (2026-08-18)
+
+### 新功能
+- 心情打卡同步到情绪日记
+
+### 其他
+- - DailyCheckinService.createCheckin 在 moodScore 有值时自动同步到 emotion_checkin 表
+- - upsert 逻辑:今日已有记录则更新,否则新建
+- - moodScore 1-10 → moodWeather 映射(sunny/cloudy/rainy/stormy)
+- - 同步失败不影响主流程
+- 
+
+
 ## v1.0.1143 (2026-08-18)
 
 ### Bug 修复

+ 14 - 1
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.1143
+> 当前版本: v1.0.1144
 
 ## 历史版本
 
@@ -8,6 +8,19 @@
 
 ---
 
+## v1.0.1144 (2026-08-18)
+
+### 新功能
+- 心情打卡同步到情绪日记
+
+### 其他
+- - DailyCheckinService.createCheckin 在 moodScore 有值时自动同步到 emotion_checkin 表
+- - upsert 逻辑:今日已有记录则更新,否则新建
+- - moodScore 1-10 → moodWeather 映射(sunny/cloudy/rainy/stormy)
+- - 同步失败不影响主流程
+- 
+
+
 ## v1.0.1143 (2026-08-18)
 
 ### Bug 修复