Skip to content

Commit

Permalink
update user details
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Muremwa Mburu committed Aug 9, 2024
1 parent 06896b7 commit cc741c2
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -89,6 +90,12 @@
<artifactId>jjwt</artifactId>
<version>0.12.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapstruct/mapstruct -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>
</dependencies>

<build>
Expand All @@ -101,10 +108,30 @@
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.5.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
22 changes: 17 additions & 5 deletions src/main/java/com/tyne/finance/core/controller/CoreController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.tyne.finance.core.dto.AuthRequest;
import com.tyne.finance.core.dto.AuthResponse;
import com.tyne.finance.core.dto.UserCreationRequest;
import com.tyne.finance.core.dto.UserInformation;
import com.tyne.finance.core.mappers.UserInformationMapper;
import com.tyne.finance.core.models.Currency;
import com.tyne.finance.core.models.Group;
import com.tyne.finance.core.models.User;
Expand Down Expand Up @@ -43,6 +45,7 @@ public class CoreController {
private final CoreUserRepository userRepository;
private final PasswordValidatorService passwordValidatorService;
private final Group defaultUserGroup;
private final UserInformationMapper userInformationMapper;

private ResponseEntity<TyneResponse<AuthResponse>> simpleBadRequest(String message) {
return ResponseEntity
Expand Down Expand Up @@ -141,11 +144,20 @@ public ResponseEntity<TyneResponse<AuthResponse>> #(@Valid @RequestBody Use


@GetMapping("/account")
public ResponseEntity<String> accountDetails(Principal principal) {
System.out.println(">>>>>>>>>>>>>>>>>");
System.out.println(principal);
System.out.println(">>>>>>>>>>>>>>>>>");
public ResponseEntity<TyneResponse<UserInformation>> accountDetails(Principal principal) {
User user = this.userRepository.findUserByUsername(principal.getName());

return ResponseEntity.ok("SOMETHING");

UserInformation information = userInformationMapper.userToUserInformation(user);
System.out.println(user);
System.out.println(information);

return ResponseEntity.ok(
TyneResponse.<UserInformation>builder()
.message("Success")
.status(true)
.data(information)
.build()
);
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/tyne/finance/core/dto/UserInformation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.tyne.finance.core.dto;

import com.tyne.finance.core.models.Currency;
import lombok.Data;

import java.sql.Timestamp;


@Data
public class UserInformation {
private String username;

private String firstName;

private String lastName;

private String email;

private Timestamp lastLogin;

private Timestamp dateJoined;

private Currency currency;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.tyne.finance.core.mappers;

import com.tyne.finance.core.dto.UserInformation;
import com.tyne.finance.core.models.User;
import org.mapstruct.Mapper;

@Mapper(componentModel = "spring")
public interface UserInformationMapper {
UserInformation userToUserInformation(User user);
}

0 comments on commit cc741c2

Please # to comment.