рефакторинг

This commit is contained in:
Никита Потапов 2024-06-20 10:27:36 +04:00
parent e88f712c8c
commit f1666446aa
4 changed files with 6 additions and 12 deletions

View File

@ -28,8 +28,10 @@ public class NekontakteApplication implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
_logger.info("Create default user values");
// UserEntity admin = new UserEntity("admin", "admin", UserRole.ADMIN);
// userService.create(admin);
if (userService.getAll().isEmpty()) {
UserEntity admin = new UserEntity("admin", "admin", UserRole.ADMIN);
userService.create(admin);
}
_logger.info(String.format("users count: %s", userService.getAll().size()));
}

View File

@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Objects;
@Controller
@RequestMapping(AdminUserController.URL)
public class AdminUserController {
public static final String URL = Constants.ADMIN_PREFIX + "/user";
@ -39,10 +40,6 @@ public class AdminUserController {
this.userService = userService;
}
private UserEntity toEntity(UserDTO dto) {
return modelMapper.map(dto, UserEntity.class);
}
private UserDTO toDTO(UserEntity entity) {
return modelMapper.map(entity, UserDTO.class);
}

View File

@ -2,7 +2,6 @@ package com.example.nekontakte.users.api;
import java.util.Objects;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
@ -26,13 +25,10 @@ public class UserSignupController {
private static final String USER_ATTRIBUTE = "user";
private final UserService userService;
private final ModelMapper modelMapper;
public UserSignupController(
UserService userService,
ModelMapper modelMapper) {
UserService userService) {
this.userService = userService;
this.modelMapper = modelMapper;
}
private UserEntity toEntity(UserSignupDto dto) {

View File

@ -6,7 +6,6 @@ import java.util.HashSet;
import java.util.Set;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import com.example.nekontakte.core.model.BaseEntity;
import com.example.nekontakte.posts.model.PostEntity;