Encapsulated methods that are allowed only for admins. Removed ability to add new user, new user must be registered using auth.

This commit is contained in:
Dmitrii Cravcenco
2023-10-07 10:18:02 +03:00
parent 128a1fabc1
commit 19ac92f268
6 changed files with 31 additions and 21 deletions

View File

@@ -3,10 +3,10 @@ package com.faf223.expensetrackerfaf.dto.mappers;
import com.faf223.expensetrackerfaf.dto.UserCreationDTO;
import com.faf223.expensetrackerfaf.dto.UserDTO;
import com.faf223.expensetrackerfaf.model.User;
import com.faf223.expensetrackerfaf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@Component
public class UserMapper {
@@ -14,6 +14,16 @@ public class UserMapper {
return new UserDTO(user.getFirstName(), user.getLastName(), user.getUsername());
}
public ArrayList<UserDTO> toDto(ArrayList<User> user) {
ArrayList<UserDTO> list = new ArrayList<>();
for (User u: user)
list.add(toDto(u));
return list;
}
public User toUser(UserCreationDTO userDTO) {
User user = new User();