feat: 打卡详情页一键分享到社区功能
- 新增后端接口 POST /api/front/tool/checkin/{checkinId}/share-to-community
- 实现 shareCheckinToCommunity 方法,复制打卡数据到社区帖子表
- 前端修改 handleCopyCheckin 方法,直接调用后端接口创建帖子
- 支持将打卡图片、描述、营养分析数据复制到社区
- 添加重复分享检查,防止重复创建帖子
- 创建成功后显示提示并可跳转到社区详情页
This commit is contained in:
@@ -7,6 +7,7 @@ import com.zbkj.common.request.PageParamRequest;
|
||||
import com.zbkj.common.response.NutritionAdoptResponse;
|
||||
import com.zbkj.common.response.NutritionCalculateResponse;
|
||||
import com.zbkj.common.result.CommonResult;
|
||||
import com.zbkj.common.token.FrontTokenComponent;
|
||||
import com.zbkj.service.service.tool.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -65,6 +66,9 @@ public class ToolController {
|
||||
@Autowired
|
||||
private ToolUploadService toolUploadService;
|
||||
|
||||
@Autowired
|
||||
private FrontTokenComponent frontTokenComponent;
|
||||
|
||||
// ==================== 食谱计算器相关 ====================
|
||||
|
||||
/**
|
||||
@@ -230,6 +234,17 @@ public class ToolController {
|
||||
return CommonResult.success(toolCheckinService.learn((Long) data.get("sourcePostId"), data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享打卡记录到社区
|
||||
*/
|
||||
@ApiOperation(value = "分享打卡记录到社区")
|
||||
@PostMapping("/checkin/{checkinId}/share-to-community")
|
||||
public CommonResult<Map<String, Object>> shareCheckinToCommunity(
|
||||
@ApiParam(value = "打卡记录ID", required = true) @PathVariable Integer checkinId) {
|
||||
Integer userId = frontTokenComponent.getUserId();
|
||||
return CommonResult.success(toolCheckinService.shareCheckinToCommunity(checkinId, userId));
|
||||
}
|
||||
|
||||
// ==================== 食物百科相关 ====================
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user