File tree Expand file tree Collapse file tree 16 files changed +54
-86
lines changed
src/main/java/hexlet/code Expand file tree Collapse file tree 16 files changed +54
-86
lines changed Original file line number Diff line number Diff line change 1111import hexlet .code .service .UserService ;
1212import lombok .AllArgsConstructor ;
1313import net .datafaker .Faker ;
14- import org .springframework .beans .factory .annotation .Autowired ;
1514import org .springframework .boot .ApplicationArguments ;
1615import org .springframework .boot .ApplicationRunner ;
1716import org .springframework .stereotype .Component ;
2322@ Component
2423@ AllArgsConstructor
2524public class DataInitializer implements ApplicationRunner {
26- @ Autowired
2725 private final UserRepository userRepository ;
28-
29- @ Autowired
3026 private final UserService userService ;
31-
32- @ Autowired
3327 private final TaskStatusService taskStatusService ;
34-
35- @ Autowired
3628 private final TaskService taskService ;
37-
38- @ Autowired
3929 private final LabelService labelService ;
40-
41- @ Autowired
4230 private final Faker faker ;
4331
4432 @ Override
Original file line number Diff line number Diff line change 77import com .nimbusds .jose .jwk .source .JWKSource ;
88import com .nimbusds .jose .proc .SecurityContext ;
99import hexlet .code .component .RsaKeyProperties ;
10- import org . springframework . beans . factory . annotation . Autowired ;
10+ import lombok . AllArgsConstructor ;
1111import org .springframework .context .annotation .Bean ;
1212import org .springframework .context .annotation .Configuration ;
1313import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
1818import org .springframework .security .oauth2 .jwt .NimbusJwtEncoder ;
1919
2020@ Configuration
21+ @ AllArgsConstructor
2122public class EncodersConfig {
22- @ Autowired
23- private RsaKeyProperties rsaKeys ;
23+ private final RsaKeyProperties rsaKeys ;
2424
2525 @ Bean
2626 public PasswordEncoder passwordEncoder () {
Original file line number Diff line number Diff line change 11package hexlet .code .config ;
22
33import hexlet .code .service .CustomUserDetailsService ;
4- import org . springframework . beans . factory . annotation . Autowired ;
4+ import lombok . AllArgsConstructor ;
55import org .springframework .context .annotation .Bean ;
66import org .springframework .context .annotation .Configuration ;
77import org .springframework .security .authentication .AuthenticationManager ;
2121
2222@ Configuration
2323@ EnableWebSecurity
24+ @ AllArgsConstructor
2425@ EnableMethodSecurity
2526public class SecurityConfig {
26- @ Autowired
27- private JwtDecoder jwtDecoder ;
28-
29- @ Autowired
30- private PasswordEncoder passwordEncoder ;
31-
32- @ Autowired
33- private CustomUserDetailsService userDetailsService ;
27+ private final JwtDecoder jwtDecoder ;
28+ private final PasswordEncoder passwordEncoder ;
29+ private final CustomUserDetailsService userDetailsService ;
3430
3531 @ Bean
3632 public SecurityFilterChain securityFilterChain (HttpSecurity http , HandlerMappingIntrospector introspector )
Original file line number Diff line number Diff line change 22
33import hexlet .code .model .AuthRequest ;
44import hexlet .code .service .AuthenticationService ;
5- import org . springframework . beans . factory . annotation . Autowired ;
5+ import lombok . AllArgsConstructor ;
66import org .springframework .web .bind .annotation .PostMapping ;
77import org .springframework .web .bind .annotation .RequestBody ;
88import org .springframework .web .bind .annotation .RequestMapping ;
99import org .springframework .web .bind .annotation .RestController ;
1010
1111@ RestController
12+ @ AllArgsConstructor
1213@ RequestMapping ("/api/login" )
1314public class AuthenticationController {
14- @ Autowired
15- private AuthenticationService authenticationService ;
15+ private final AuthenticationService authenticationService ;
1616
1717 @ PostMapping
1818 public String create (@ RequestBody AuthRequest authRequest ) {
Original file line number Diff line number Diff line change 55import hexlet .code .dto .label .LabelUpdateDTO ;
66import hexlet .code .service .LabelService ;
77import jakarta .validation .Valid ;
8- import org . springframework . beans . factory . annotation . Autowired ;
8+ import lombok . AllArgsConstructor ;
99import org .springframework .http .HttpStatus ;
1010import org .springframework .http .ResponseEntity ;
1111import org .springframework .web .bind .annotation .DeleteMapping ;
2121import java .util .List ;
2222
2323@ RestController
24+ @ AllArgsConstructor
2425@ RequestMapping ("/api/labels" )
2526public class LabelController {
26- @ Autowired
27- private LabelService labelService ;
27+ private final LabelService labelService ;
2828
2929 @ GetMapping
3030 ResponseEntity <List <LabelDTO >> index () {
Original file line number Diff line number Diff line change 66import hexlet .code .dto .task .TaskUpdateDTO ;
77import hexlet .code .service .TaskService ;
88import jakarta .validation .Valid ;
9- import org . springframework . beans . factory . annotation . Autowired ;
9+ import lombok . AllArgsConstructor ;
1010import org .springframework .http .HttpStatus ;
1111import org .springframework .http .ResponseEntity ;
1212import org .springframework .web .bind .annotation .DeleteMapping ;
2222import java .util .List ;
2323
2424@ RestController
25+ @ AllArgsConstructor
2526@ RequestMapping ("/api/tasks" )
2627public class TaskController {
27- @ Autowired
28- private TaskService taskService ;
28+ private final TaskService taskService ;
2929
3030 @ GetMapping
3131 ResponseEntity <List <TaskDTO >> index (TaskParamsDTO params ) {
Original file line number Diff line number Diff line change 55import hexlet .code .dto .taskStatus .TaskStatusUpdateDTO ;
66import hexlet .code .service .TaskStatusService ;
77import jakarta .validation .Valid ;
8- import org . springframework . beans . factory . annotation . Autowired ;
8+ import lombok . AllArgsConstructor ;
99import org .springframework .http .HttpStatus ;
1010import org .springframework .http .ResponseEntity ;
1111import org .springframework .web .bind .annotation .DeleteMapping ;
2121import java .util .List ;
2222
2323@ RestController
24+ @ AllArgsConstructor
2425@ RequestMapping ("/api/task_statuses" )
2526public class TaskStatusController {
26- @ Autowired
27- private TaskStatusService taskStatusService ;
27+ private final TaskStatusService taskStatusService ;
2828
2929 @ GetMapping
3030 ResponseEntity <List <TaskStatusDTO >> index () {
Original file line number Diff line number Diff line change 55import hexlet .code .dto .user .UserUpdateDTO ;
66import hexlet .code .service .UserService ;
77import jakarta .validation .Valid ;
8- import org . springframework . beans . factory . annotation . Autowired ;
8+ import lombok . AllArgsConstructor ;
99import org .springframework .http .HttpStatus ;
1010import org .springframework .http .ResponseEntity ;
1111import org .springframework .web .bind .annotation .DeleteMapping ;
2121import java .util .List ;
2222
2323@ RestController
24+ @ AllArgsConstructor
2425@ RequestMapping ("/api/users" )
2526public class UserController {
26- @ Autowired
27- private UserService userService ;
27+ private final UserService userService ;
2828
2929 @ GetMapping
3030 ResponseEntity <List <UserDTO >> index () {
Original file line number Diff line number Diff line change 22
33import hexlet .code .model .AuthRequest ;
44import hexlet .code .util .JWTUtils ;
5- import org . springframework . beans . factory . annotation . Autowired ;
5+ import lombok . AllArgsConstructor ;
66import org .springframework .security .authentication .AuthenticationManager ;
77import org .springframework .security .authentication .UsernamePasswordAuthenticationToken ;
88import org .springframework .stereotype .Service ;
99
1010@ Service
11+ @ AllArgsConstructor
1112public class AuthenticationService {
12- @ Autowired
13- private JWTUtils jwtUtils ;
14-
15- @ Autowired
16- private AuthenticationManager authenticationManager ;
13+ private final JWTUtils jwtUtils ;
14+ private final AuthenticationManager authenticationManager ;
1715
1816 public String createAuthentication (AuthRequest authRequest ) {
1917 var authentication = new UsernamePasswordAuthenticationToken (
Original file line number Diff line number Diff line change 22
33import hexlet .code .exception .ResourceNotFoundException ;
44import hexlet .code .repository .UserRepository ;
5- import org . springframework . beans . factory . annotation . Autowired ;
5+ import lombok . AllArgsConstructor ;
66import org .springframework .security .core .userdetails .UserDetails ;
77import org .springframework .security .core .userdetails .UsernameNotFoundException ;
88import org .springframework .security .crypto .password .PasswordEncoder ;
99import org .springframework .security .provisioning .UserDetailsManager ;
1010import org .springframework .stereotype .Service ;
1111
1212@ Service
13+ @ AllArgsConstructor
1314public class CustomUserDetailsService implements UserDetailsManager {
14-
15- @ Autowired
16- private UserRepository userRepository ;
17-
18- @ Autowired
19- private PasswordEncoder passwordEncoder ;
15+ private final UserRepository userRepository ;
16+ private final PasswordEncoder passwordEncoder ;
2017
2118 @ Override
2219 public UserDetails loadUserByUsername (String email ) throws UsernameNotFoundException {
You can’t perform that action at this time.
0 commit comments