Skip to content

Commit

Permalink
fix: inline variable 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
yunuo46 committed May 10, 2024
1 parent 8192173 commit b151204
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class APIController {
@GetMapping("/user")
@CrossOrigin(origins = "*", allowedHeaders = "*")
public ResUserNameDto getUser() throws JsonProcessingException {
ResUserNameDto userDto = apiService.getUser();
return userDto;
return apiService.getUser();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class ChatController {
@MessageMapping("/message")
@SendTo("/topic/chat/message")
public ResChatMessageDto sendMessage(@Payload ReqChatMessageDto message) {
ResChatMessageDto resChatMessageDto = new ResChatMessageDto(message.getText(), message.getUsername());
return resChatMessageDto;
return new ResChatMessageDto(message.getText(), message.getUsername());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ public class MapController {
@MessageMapping("/move")
@SendTo("/topic/map/move")
public MoveUserDto moveUser(MoveUserDto position) {
MoveUserDto moveUserDto = mapService.moveUser(position);
return moveUserDto;
return mapService.moveUser(position);
}

@MessageMapping("/new")
@SendTo("/topic/map/new")
public ResNewUserDto newUser(@Payload ReqNewUserDto newUser) {
ResNewUserDto resNewUserDto = mapService.createUser(newUser);
return resNewUserDto;
return mapService.createUser(newUser);
}

@MessageMapping("/all")
Expand All @@ -46,7 +44,6 @@ public List<UserEntity> allUser(){
@MessageMapping("/stop")
@SendTo("/topic/map/stop")
public ResStopUserDto stopUser(ReqStopUserDto stopUser) {
ResStopUserDto resStopUserDto= mapService.stopUser(stopUser);
return resStopUserDto;
return mapService.stopUser(stopUser);
}
}
3 changes: 1 addition & 2 deletions src/main/java/getaguitar/site/demo/Entity/UserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@ToString
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
Expand All @@ -19,10 +20,8 @@ public class UserEntity {
@Column(length = 45)
private String username;

@NotNull
private Integer x;

@NotNull
private Integer y;

private String direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class APIServiceImpl implements APIService{
@Override
public ResUserNameDto getUser(){
String username = RandomStringUtils.randomAlphanumeric(5);
ResUserNameDto userDto = new ResUserNameDto(username);
return userDto;
return new ResUserNameDto(username);
}
}
24 changes: 8 additions & 16 deletions src/main/java/getaguitar/site/demo/Service/MapServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import getaguitar.site.demo.Entity.UserEntity;
import getaguitar.site.demo.Repository.UserRepository;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -28,8 +29,7 @@ public ResNewUserDto createUser(ReqNewUserDto newUser){
.y(300)
.direction("down")
.build()).getUsername();
ResNewUserDto resNewUserDto = new ResNewUserDto(username,400,300,"down");
return resNewUserDto;
return new ResNewUserDto(username,400,300,"down");
}

@Override
Expand All @@ -38,6 +38,7 @@ public List<UserEntity> getAllUser(){
}

@Override
@Transactional
public MoveUserDto moveUser(MoveUserDto position) {
String username = position.getUsername();
UserEntity user = userRepository.findByUsername(username);
Expand All @@ -46,21 +47,12 @@ public MoveUserDto moveUser(MoveUserDto position) {
int y = position.getY();
String direction = position.getDirection();

if(direction.equals("up")) y-=2;
else if(direction.equals("down")) y+=2;
else if(direction.equals("left")) x-=2;
else if(direction.equals("right")) x+=2;
if(direction.equals("up")) { y-=2; user.setY(y); }
else if(direction.equals("down")) { y+=2; user.setY(y); }
else if(direction.equals("left")) { x-=2; user.setX(x); }
else if(direction.equals("right")) { x+=2; user.setX(x); }

userRepository.save(UserEntity.builder()
.id(user.getId())
.username(username)
.x(x)
.y(y)
.direction(direction)
.build());

MoveUserDto moveUserDto = new MoveUserDto(username, x, y, direction);
return moveUserDto;
return new MoveUserDto(username, x, y, direction);
}

@Override
Expand Down

0 comments on commit b151204

Please sign in to comment.