Profile page
This commit is contained in:
parent
4f94d47a56
commit
8408eb874e
@ -74,19 +74,15 @@ public class StaticController {
|
||||
public String profilePage(@PathVariable("id") Long id, Model model) {
|
||||
User self = AuthenticationUtil.authProfile(model, userService);
|
||||
User u = userService.findById(id);
|
||||
FriendFollowState state = FriendFollowState.NOT_FOLLOWED;
|
||||
FriendStatus fs = friendService.getFollow(self.getId(), u.getId());
|
||||
if( fs != null ) {
|
||||
if( fs.getFirstUserId().longValue() == self.getId().longValue() ) {
|
||||
state = FriendFollowState.FOLLOWED;
|
||||
} else {
|
||||
state = FriendFollowState.ACCEPT;
|
||||
}
|
||||
}
|
||||
if( friendService.getFriend(self.getId(), u.getId()) != null ) {
|
||||
state = FriendFollowState.FOLLOWED;
|
||||
}
|
||||
model.addAttribute("page_user", new ProfilePageResult("", "background-image: url(\"/image/store/"+u.getAvatarId()+"\");", u.getUsername(), u.getId(), u.getDisplayName(), 0, 0, friendService.getFriendsOfUserId(u.getId()).size(), state));
|
||||
model.addAttribute("page_user", new ProfilePageResult("",
|
||||
"background-image: url(\"/image/store/"+u.getAvatarId()+"\");",
|
||||
u.getUsername(),
|
||||
u.getId(),
|
||||
u.getDisplayName(),
|
||||
0,
|
||||
0,
|
||||
friendService.getFriendsOfUserId(u.getId()).size(),
|
||||
friendService.getFriendState(self.getId(), u.getId())));
|
||||
return "profile";
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.alterdekim.game.service;
|
||||
|
||||
import com.alterdekim.game.dto.FriendFollowState;
|
||||
import com.alterdekim.game.entities.FriendStatus;
|
||||
import com.alterdekim.game.repository.FriendRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -35,4 +36,16 @@ public class FriendServiceImpl {
|
||||
public FriendStatus getFriend(Long userId, Long friendId) {
|
||||
return repository.getFriend(userId, friendId);
|
||||
}
|
||||
|
||||
public FriendFollowState getFriendState(Long userId, Long friendId) {
|
||||
FriendStatus fs = this.getFollow(userId, friendId);
|
||||
if( fs != null ) {
|
||||
if( fs.getFirstUserId().longValue() == userId.longValue() ||
|
||||
this.getFriend(userId, friendId) != null ) {
|
||||
return FriendFollowState.FOLLOWED;
|
||||
}
|
||||
return FriendFollowState.ACCEPT;
|
||||
}
|
||||
return FriendFollowState.NOT_FOLLOWED;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user