Fix Profiles on project
This commit is contained in:
parent
eb2fdbb035
commit
d144587ee4
13 changed files with 44 additions and 11 deletions
|
|
@ -0,0 +1,16 @@
|
|||
package main.java.models.responses;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
import main.java.models.enums.*;
|
||||
|
||||
public record UserResponse(
|
||||
String id,
|
||||
String name,
|
||||
String email,
|
||||
String password,
|
||||
Set<ProfileEnum> profiles) implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
Binary file not shown.
BIN
hd-commons-lib/target/classes/models/enums/ProfileEnum.class
Normal file
BIN
hd-commons-lib/target/classes/models/enums/ProfileEnum.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1,2 @@
|
|||
main/java/models/enums/ProfileEnum.class
|
||||
main/java/models/responses/UserResponse.class
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/home/dev/projetos/Help Desk 2.0/hd-commons-lib/src/main/java/models.enums/ProfileEnum.java
|
||||
/home/dev/projetos/Help Desk 2.0/hd-commons-lib/src/main/java/models/enums/ProfileEnum.java
|
||||
/home/dev/projetos/Help Desk 2.0/hd-commons-lib/src/main/java/models/responses/UserResponse.java
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import main.java.models.responses.UserResponse;
|
||||
|
||||
import br.com.rayankonecny.userserviceapi.entity.User;
|
||||
|
||||
@RequestMapping("/api/users")
|
||||
public interface UserController {
|
||||
|
||||
@GetMapping("/{id}")
|
||||
ResponseEntity<User> findById(@PathVariable(name = "id") final String id);
|
||||
ResponseEntity<UserResponse> findById(@PathVariable(name = "id") final String id);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package br.com.rayankonecny.userserviceapi.controller.impl;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import br.com.rayankonecny.userserviceapi.controller.UserController;
|
||||
import br.com.rayankonecny.userserviceapi.entity.User;
|
||||
|
||||
import br.com.rayankonecny.userserviceapi.service.UserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import main.java.models.responses.UserResponse;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -16,7 +16,7 @@ public class UserControllerImpl implements UserController {
|
|||
private final UserService userService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<User> findById(String id) {
|
||||
public ResponseEntity<UserResponse> findById(String id) {
|
||||
return ResponseEntity.ok().body(userService.findById(id));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package br.com.rayankonecny.userserviceapi.mapper;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import br.com.rayankonecny.userserviceapi.entity.User;
|
||||
import main.java.models.responses.UserResponse;
|
||||
|
||||
import static org.mapstruct.NullValuePropertyMappingStrategy.IGNORE;
|
||||
import static org.mapstruct.NullValueCheckStrategy.ALWAYS;
|
||||
|
||||
@Mapper(componentModel = "spring", nullValuePropertyMappingStrategy = IGNORE, nullValueCheckStrategy = ALWAYS)
|
||||
public interface UserMapper {
|
||||
|
||||
UserResponse fromEntity(final User entity);
|
||||
}
|
||||
|
|
@ -2,18 +2,20 @@ package br.com.rayankonecny.userserviceapi.service;
|
|||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import br.com.rayankonecny.userserviceapi.entity.User;
|
||||
import br.com.rayankonecny.userserviceapi.mapper.UserMapper;
|
||||
import br.com.rayankonecny.userserviceapi.repository.UserRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import main.java.models.responses.UserResponse;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final UserMapper userMapper;
|
||||
|
||||
public User findById(final String id) {
|
||||
return userRepository.findById(id).orElse(null);
|
||||
public UserResponse findById(final String id) {
|
||||
return userMapper.fromEntity(userRepository.findById(id).orElse(null));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ spring.data.mongodb.authentication-database=admin
|
|||
|
||||
|
||||
# Eureka Server Configuration
|
||||
spring.application.name=user-service-api
|
||||
server.port=8081
|
||||
eureka.client.register-with-eureka=true
|
||||
eureka.client.fetch-registry=true
|
||||
eureka.client.serviceUrl.defaultZone=http://175.15.15.91:8761/eureka/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue