feat(emergency): 移动端宣教详情接口增加阅读记录逻辑
This commit is contained in:
+9
-2
@@ -28,12 +28,19 @@ public class FirstAidResourceApiController {
|
||||
@Autowired
|
||||
private IFirstAidResourceService resourceService;
|
||||
|
||||
@Operation(summary = "根据宣教ID查询详情")
|
||||
@Operation(summary = "根据宣教ID查询详情(含阅读记录)")
|
||||
@GetMapping("/queryById")
|
||||
public Result<FirstAidResource> queryById(@RequestParam("id") String id) {
|
||||
LoginUser loginUser = GlobalUtils.getLoginUser();
|
||||
String userId = loginUser != null ? loginUser.getId() : null;
|
||||
FirstAidResource entity = resourceService.getDetail(id, userId);
|
||||
return entity == null ? Result.error("未找到对应数据") : Result.OK(entity);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
// 记录阅读(已读自动去重)
|
||||
if (userId != null) {
|
||||
resourceService.incrementViewCount(id, userId);
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user