-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
70 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ | |
@Getter | ||
@Setter | ||
public class ResUserNameDto { | ||
private String name; | ||
private String username; | ||
} |
2 changes: 1 addition & 1 deletion
2
...aguitar/site/demo/Dto/ReqStopUserDto.java → ...ite/demo/Dto/StopUser/ReqStopUserDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/getaguitar/site/demo/Repository/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package getaguitar.site.demo.Repository; | ||
|
||
import getaguitar.site.demo.Entity.UserEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface UserRepository extends JpaRepository<UserEntity, Integer> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 33 additions & 5 deletions
38
src/main/java/getaguitar/site/demo/Service/MapServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,56 @@ | ||
package getaguitar.site.demo.Service; | ||
import getaguitar.site.demo.Dto.ReqStopUserDto; | ||
import getaguitar.site.demo.Dto.ResStopUserDto; | ||
import getaguitar.site.demo.Dto.MoveUser.ResMoveUserDto; | ||
import getaguitar.site.demo.Dto.StopUser.ReqStopUserDto; | ||
import getaguitar.site.demo.Dto.StopUser.ResStopUserDto; | ||
import getaguitar.site.demo.Dto.NewUser.ReqNewUserDto; | ||
import getaguitar.site.demo.Dto.NewUser.ResNewUserDto; | ||
|
||
import getaguitar.site.demo.Entity.UserEntity; | ||
import getaguitar.site.demo.Repository.UserRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
public class MapServiceImpl implements MapService { | ||
private final UserRepository userRepository; | ||
|
||
public MapServiceImpl(UserRepository userRepository) { | ||
this.userRepository = userRepository; | ||
} | ||
|
||
@Override | ||
public ResNewUserDto createUser(ReqNewUserDto newUser){ | ||
ResNewUserDto resNewUserDto = new ResNewUserDto("testId",0,0,"down"); | ||
String username = userRepository.save(UserEntity.builder().username("TestName").x(0).y(0).build()).getUsername(); | ||
ResNewUserDto resNewUserDto = new ResNewUserDto(username,0,0,"down"); | ||
return resNewUserDto; | ||
} | ||
|
||
@Override | ||
public ResMoveUserDto moveUser(String direction) { | ||
ResMoveUserDto moveUserDto = new ResMoveUserDto("testId", 1, 1, direction); | ||
Optional<UserEntity> user = Optional.of(userRepository.findById(1).get()); | ||
UserEntity userEntity = user.get(); | ||
|
||
int x = userEntity.getX(); | ||
int y = userEntity.getY(); | ||
if(direction.equals("up")) y++; | ||
else if(direction.equals("down")) y--; | ||
else if(direction.equals("left")) x--; | ||
else if(direction.equals("right")) x++; | ||
|
||
UserEntity storedUser = userRepository.save(UserEntity.builder() | ||
.id(userEntity.getId()) | ||
.x(x) | ||
.y(y) | ||
.build()); | ||
|
||
ResMoveUserDto moveUserDto = new ResMoveUserDto(userEntity.getUsername(), storedUser.getX(), storedUser.getY(), direction); | ||
return moveUserDto; | ||
} | ||
|
||
@Override | ||
public ResStopUserDto stopUser(ReqStopUserDto stopUser){ | ||
ResStopUserDto resStopUserDto = new ResStopUserDto("testId", 0, 0); | ||
ResStopUserDto resStopUserDto = new ResStopUserDto(stopUser.getUsername(), 0, 0); | ||
return resStopUserDto; | ||
} | ||
} |