File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/main/java/com/back/domain/profile/service Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .back .domain .profile .service ;
2+
3+ import com .back .domain .profile .dto .ProfileResponseDto ;
4+ import com .back .domain .user .entity .User ;
5+ import com .back .domain .user .repository .UserRepository ;
6+ import com .back .domain .user .support .AbvView ;
7+ import com .back .global .exception .ServiceException ;
8+ import lombok .RequiredArgsConstructor ;
9+ import org .springframework .stereotype .Service ;
10+ import org .springframework .transaction .annotation .Transactional ;
11+
12+ @ Service
13+ @ RequiredArgsConstructor
14+ public class ProfileService {
15+
16+ private final UserRepository userRepository ;
17+
18+ @ Transactional (readOnly = true )
19+ public ProfileResponseDto getProfile (Long id ) {
20+ User user = userRepository .findById (id ).orElseThrow (() -> new ServiceException (404 , "사용자를 찾을 수 없습니다." ));
21+
22+ Double percent = user .getAbvDegree ();
23+ int level = AbvView .levelOf (percent );
24+ String label = AbvView .percentLabel (percent );
25+
26+ return ProfileResponseDto .builder ()
27+ .id (user .getId ())
28+ .nickname (user .getNickname ())
29+ .abvDegree (percent )
30+ .abvLevel (level )
31+ .abvLabel (label )
32+ .build ();
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments