feat(calculator): 食谱计算器历史记录功能(test-0415 反馈2-2)

后端:
- GET /api/front/tool/calculator/history 倒序分页返回当前用户记录摘要
- ToolCalculatorService.getHistory(PageParamRequest) 实现
- 摘要含 id / createdAt / bmi / ckdStage / proteinIntake / energyIntake / isAdopted / hasDialysis

前端:
- api/tool.js 新增 getCalculatorHistory(params)
- pages/tool/calculator-history.vue 历史列表页(下拉刷新 + 触底加载)
- 点击行跳转 calculator-result?id=xxx 复用结果页,自然支持「重新载入参数」
- pages.json 注册路由

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
msh-agent
2026-05-03 03:24:30 +08:00
parent 229181f1e0
commit fde0d555fa
6 changed files with 288 additions and 6 deletions

View File

@@ -722,5 +722,36 @@ public class ToolCalculatorServiceImpl extends ServiceImpl<V2CalculatorResultDao
if (value.compareTo(max) > 0) return "above";
return "normal";
}
/**
* 获取当前用户的计算历史记录test-0415 反馈2-2
*/
@Override
public List<Map<String, Object>> getHistory(com.zbkj.common.request.PageParamRequest pageParamRequest) {
Integer userId = tokenComponent.getUserId();
if (userId == null) {
throw new CrmebException("请先登录");
}
com.github.pagehelper.PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
LambdaQueryWrapper<V2CalculatorResult> lqw = new LambdaQueryWrapper<>();
lqw.eq(V2CalculatorResult::getUserId, userId.longValue())
.orderByDesc(V2CalculatorResult::getCreatedAt);
List<V2CalculatorResult> list = calculatorResultDao.selectList(lqw);
List<Map<String, Object>> result = new ArrayList<>();
for (V2CalculatorResult e : list) {
Map<String, Object> m = new HashMap<>();
m.put("id", e.getResultId());
m.put("createdAt", e.getCreatedAt());
m.put("bmi", e.getBmi());
m.put("bmiStatus", e.getBmiStatus());
m.put("ckdStage", e.getCkdStage());
m.put("proteinIntake", e.getProteinIntake());
m.put("energyIntake", e.getEnergyIntake());
m.put("isAdopted", e.getIsAdopted());
m.put("hasDialysis", e.getHasDialysis());
result.add(m);
}
return result;
}
}

View File

@@ -1,9 +1,13 @@
package com.zbkj.service.service.tool;
import com.zbkj.common.request.NutritionCalculateRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.response.NutritionAdoptResponse;
import com.zbkj.common.response.NutritionCalculateResponse;
import java.util.List;
import java.util.Map;
/**
* 食谱计算器服务接口
* +----------------------------------------------------------------------
@@ -55,5 +59,11 @@ public interface ToolCalculatorService {
* @return 采纳结果包含计划ID、日期范围、积分奖励
*/
NutritionAdoptResponse adopt(Long resultId);
/**
* 获取当前登录用户的计算历史记录test-0415 反馈2-2
* 仅返回摘要id、createdAt、bmi、ckdStage、proteinIntake、energyIntake、isAdopted
*/
List<Map<String, Object>> getHistory(PageParamRequest pageParamRequest);
}