package com.tcm.training.admin.app.statistics.controller;
|
|
import com.tcm.training.admin.app.auth.service.AppAuthSessionService;
|
import com.tcm.training.admin.common.ApiResponse;
|
import com.tcm.training.admin.statistics.service.AppUserEntryLogAppService;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
/**
|
* APP 用户进入记录接口。
|
*/
|
@Validated
|
@RestController
|
@RequestMapping({"/api/app", "/api/v1/app"})
|
public class AppUserEntryLogController {
|
|
private final AppUserEntryLogAppService appUserEntryLogAppService;
|
private final AppAuthSessionService appAuthSessionService;
|
|
/**
|
* 注入 APP 用户进入记录服务。
|
*/
|
public AppUserEntryLogController(AppUserEntryLogAppService appUserEntryLogAppService,
|
AppAuthSessionService appAuthSessionService) {
|
this.appUserEntryLogAppService = appUserEntryLogAppService;
|
this.appAuthSessionService = appAuthSessionService;
|
}
|
|
/**
|
* 记录 APP 用户进入行为,游客访问时静默跳过。
|
*/
|
@PostMapping("/user-entry-logs")
|
public ApiResponse<Void> record() {
|
if (!appAuthSessionService.isLogin()) {
|
return ApiResponse.ok(null);
|
}
|
appUserEntryLogAppService.record(appAuthSessionService.getLoginUserId());
|
return ApiResponse.ok(null);
|
}
|
}
|