Fix local dev config and ALOTTTT OFF FLUTTER, im tired boss..
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.walkguide.service;
|
||||
|
||||
import com.walkguide.enums.ActivityLogType;
|
||||
import com.walkguide.repository.UserRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final ActivityLogService activityLogService;
|
||||
|
||||
public Map<String, Object> getProfile(Long userId) {
|
||||
var user = userRepository.findById(userId)
|
||||
.orElseThrow(() -> new RuntimeException("User tidak ditemukan"));
|
||||
return Map.of(
|
||||
"id", user.getId(),
|
||||
"email", user.getEmail(),
|
||||
"displayName", user.getDisplayName() != null ? user.getDisplayName() : "",
|
||||
"role", user.getRole(),
|
||||
"uniqueUserId", user.getUniqueUserId() != null ? user.getUniqueUserId() : ""
|
||||
);
|
||||
}
|
||||
|
||||
public void logWalkGuideStart(Long userId) {
|
||||
userRepository.findById(userId).ifPresent(user ->
|
||||
activityLogService.createLog(user, ActivityLogType.WALKGUIDE_START,
|
||||
"WalkGuide dimulai", null));
|
||||
}
|
||||
|
||||
public void logWalkGuideStop(Long userId) {
|
||||
userRepository.findById(userId).ifPresent(user ->
|
||||
activityLogService.createLog(user, ActivityLogType.WALKGUIDE_STOP,
|
||||
"WalkGuide dihentikan", null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user