| | |
| | | package com.tcm.training.admin.app.statistics.controller; |
| | | |
| | | import com.tcm.training.admin.app.auth.support.StpAppUserUtil; |
| | | 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; |
| | |
| | | public class AppUserEntryLogController { |
| | | |
| | | private final AppUserEntryLogAppService appUserEntryLogAppService; |
| | | private final AppAuthSessionService appAuthSessionService; |
| | | |
| | | /** |
| | | * 注入 APP 用户进入记录服务。 |
| | | */ |
| | | public AppUserEntryLogController(AppUserEntryLogAppService appUserEntryLogAppService) { |
| | | public AppUserEntryLogController(AppUserEntryLogAppService appUserEntryLogAppService, |
| | | AppAuthSessionService appAuthSessionService) { |
| | | this.appUserEntryLogAppService = appUserEntryLogAppService; |
| | | this.appAuthSessionService = appAuthSessionService; |
| | | } |
| | | |
| | | /** |
| | | * 记录 APP 用户进入行为。 |
| | | * 记录 APP 用户进入行为,游客访问时静默跳过。 |
| | | */ |
| | | @PostMapping("/user-entry-logs") |
| | | public ApiResponse<Void> record() { |
| | | appUserEntryLogAppService.record(StpAppUserUtil.getLoginIdAsLong()); |
| | | if (!appAuthSessionService.isLogin()) { |
| | | return ApiResponse.ok(null); |
| | | } |
| | | appUserEntryLogAppService.record(appAuthSessionService.getLoginUserId()); |
| | | return ApiResponse.ok(null); |
| | | } |
| | | } |