Коммит на 20.02.2025 - конец разработки
Сделано: Пагинация, спринг секюрити, админ функции, полноценная работа с qr, а также добавлены проходы и терминалы
This commit is contained in:
parent
4f17ffeca8
commit
5ba0f225e6
@ -3,9 +3,10 @@ package com.example.nto;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication()
|
||||||
public class App {
|
public class App {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(App.class);
|
SpringApplication.run(App.class,args);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
src/main/java/com/example/nto/Generate.java
Normal file
16
src/main/java/com/example/nto/Generate.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.example.nto;
|
||||||
|
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
|
public class Generate {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
String rawPassword = "admin";
|
||||||
|
|
||||||
|
|
||||||
|
String hashedPassword = passwordEncoder.encode(rawPassword);
|
||||||
|
|
||||||
|
System.out.println("Хеш пароля: " + hashedPassword);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.nto.config;
|
package com.example.nto.confg;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -18,4 +18,4 @@ public class SwaggerConfig {
|
|||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,9 @@
|
|||||||
package com.example.nto.config;
|
package com.example.nto.confg;
|
||||||
|
|
||||||
import com.example.nto.service.EmployeeService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.boot.web.servlet.support.ErrorPageFilter;
|
import org.springframework.boot.web.servlet.support.ErrorPageFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
@ -15,7 +12,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
|||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ -28,16 +25,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.csrf().disable()
|
.csrf().disable()
|
||||||
|
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
.antMatchers("/h2-console/**").permitAll()
|
.antMatchers("/h2-console/**").permitAll()
|
||||||
.antMatchers("/api/employees/register").permitAll()
|
.antMatchers("/api/users/register").permitAll()
|
||||||
.antMatchers("/api/employees/{username}").permitAll()
|
.antMatchers("/api/users/username/{username}").permitAll()
|
||||||
.antMatchers("/api/employees/paginated").permitAll()
|
.antMatchers("/api/users/paginated").permitAll()
|
||||||
.antMatchers("/api/employees/unoccupied").permitAll()
|
.antMatchers("/api/users/login").permitAll()
|
||||||
.antMatchers("/api/authority/").permitAll()
|
.antMatchers("/api/authority/").permitAll()
|
||||||
.antMatchers("/api/employees/**").hasAnyAuthority("ROLE_USER", "ROLE_ADMIN")
|
|
||||||
.antMatchers("/api/employees/login").permitAll()
|
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
.and()
|
.and()
|
||||||
.httpBasic()
|
.httpBasic()
|
||||||
@ -52,7 +46,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.passwordEncoder(passwordEncoder());
|
.passwordEncoder(passwordEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PasswordEncoder passwordEncoder() {
|
public PasswordEncoder passwordEncoder() {
|
||||||
return new BCryptPasswordEncoder();
|
return new BCryptPasswordEncoder();
|
@ -1,4 +1,5 @@
|
|||||||
package com.example.nto.controller;
|
package com.example.nto.controller;
|
||||||
|
|
||||||
import com.example.nto.entity.Authority;
|
import com.example.nto.entity.Authority;
|
||||||
import com.example.nto.service.AuthorityService;
|
import com.example.nto.service.AuthorityService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -30,12 +31,12 @@ public class AuthorityController {
|
|||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@ResponseStatus(HttpStatus.OK)
|
@ResponseStatus(HttpStatus.OK)
|
||||||
public ResponseEntity<String> idRole(@PathVariable Long id) {
|
public ResponseEntity<String> login(@PathVariable Long id) {
|
||||||
String idn = authorityService.isAdmin(id);
|
String idn = authorityService.isAdmin(id);
|
||||||
if (Objects.equals(idn, "ROLE_ADMIN")) {
|
if (Objects.equals(idn, "ROLE_ADMIN")) {
|
||||||
return ResponseEntity.ok("Является администратором");}
|
return ResponseEntity.ok("is Admin");}
|
||||||
else {
|
else {
|
||||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("Не является администратором");
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("is Not Admin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
package com.example.nto.controller;
|
package com.example.nto.controller;
|
||||||
|
|
||||||
import com.example.nto.entity.Code;
|
import com.example.nto.dto.CodeDTO;
|
||||||
import com.example.nto.entity.Employee;
|
import com.example.nto.entity.Users;
|
||||||
import com.example.nto.service.CodeService;
|
import com.example.nto.service.CodeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CodeController {
|
public class CodeController {
|
||||||
|
|
||||||
private final CodeService codeService;
|
private final CodeService codeService;
|
||||||
|
|
||||||
@PatchMapping("/api/{username}/open")
|
@PatchMapping("/api/open")
|
||||||
public Employee update(@PathVariable String username, @RequestBody Code newCode) {
|
public Optional<Users> update(Authentication authentication, @RequestBody CodeDTO newCode) {
|
||||||
// return codeService.openDoor(username, newCode.getValue());
|
String username = authentication.getName();
|
||||||
return null;
|
return codeService.openDoor(username, newCode.getValue());
|
||||||
//TODO Service доделать и открыть тут коммент
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package com.example.nto.controller;
|
|
||||||
|
|
||||||
import com.example.nto.dto.EmployeeDTO;
|
|
||||||
import com.example.nto.dto.UserRegisterDTO;
|
|
||||||
import com.example.nto.entity.Employee;
|
|
||||||
import com.example.nto.service.EmployeeService;
|
|
||||||
import io.swagger.models.Response;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/employees")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class EmployeeController {
|
|
||||||
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{username}")
|
|
||||||
@ResponseStatus(HttpStatus.OK)
|
|
||||||
public ResponseEntity<String> findByUsername(@PathVariable String username) {
|
|
||||||
if (employeeService.findExistByUsername(username)) {
|
|
||||||
return ResponseEntity.ok("Done");
|
|
||||||
} else return ResponseEntity.badRequest().body("User is not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/login")
|
|
||||||
public ResponseEntity<EmployeeDTO> login(Authentication authentication) {
|
|
||||||
System.out.println("Authentication object: " + authentication);
|
|
||||||
String username = authentication.getName();
|
|
||||||
System.out.println("Username: " + username);
|
|
||||||
|
|
||||||
EmployeeDTO employeeDTO = employeeService.getUserByUsername(username);
|
|
||||||
if (employeeDTO == null) {
|
|
||||||
System.out.println("User not found for username: " + username);
|
|
||||||
return ResponseEntity.status(404).body(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("EmployeeDTO: " + employeeDTO);
|
|
||||||
return ResponseEntity.ok(employeeDTO);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,22 @@
|
|||||||
package com.example.nto.controller;
|
package com.example.nto.controller;
|
||||||
|
|
||||||
import com.example.nto.dto.PassDTO;
|
import com.example.nto.dto.PassDTO;
|
||||||
import com.example.nto.dto.TerminalDTO;
|
import com.example.nto.entity.Users;
|
||||||
|
import com.example.nto.repository.UsersRepository;
|
||||||
import com.example.nto.service.PassService;
|
import com.example.nto.service.PassService;
|
||||||
import com.example.nto.service.TerminalService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -20,14 +25,29 @@ import java.util.List;
|
|||||||
public class PassController {
|
public class PassController {
|
||||||
|
|
||||||
private final PassService passService;
|
private final PassService passService;
|
||||||
|
private final UsersRepository usersRepository;
|
||||||
|
|
||||||
@GetMapping("/paginated/")
|
@GetMapping("/paginated/")
|
||||||
public ResponseEntity<List<PassDTO>> getAllPassesAtUser(
|
public ResponseEntity<List<PassDTO>> getAllPassesAtUser(
|
||||||
@RequestParam long userId,
|
@RequestParam(required = false) String username,
|
||||||
@RequestParam(defaultValue = "0") int page,
|
@RequestParam(defaultValue = "0") int page,
|
||||||
@RequestParam(defaultValue = "10") int size
|
@RequestParam(defaultValue = "10") int size,
|
||||||
|
Authentication authentication
|
||||||
) {
|
) {
|
||||||
|
String name = authentication.getName();
|
||||||
|
if (username == null) {
|
||||||
|
username = authentication.getName();
|
||||||
|
}
|
||||||
|
Optional<Users> user = usersRepository.findByUsername(username);
|
||||||
|
if (user.isPresent()) {
|
||||||
|
if (Objects.equals(user.get().getAuthority().getAuthority(), "ROLE_ADMIN")) {
|
||||||
|
Pageable pageable = PageRequest.of(page, size);
|
||||||
|
return ResponseEntity.ok(passService.getAllPassesPaginated(pageable, username));
|
||||||
|
}
|
||||||
|
username = authentication.getName();
|
||||||
|
}
|
||||||
|
System.out.println(username);
|
||||||
Pageable pageable = PageRequest.of(page, size);
|
Pageable pageable = PageRequest.of(page, size);
|
||||||
return ResponseEntity.ok(passService.getAllPassesPaginated(pageable, userId));
|
return ResponseEntity.ok(passService.getAllPassesPaginated(pageable, username));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,13 @@
|
|||||||
package com.example.nto.controller;
|
package com.example.nto.controller;
|
||||||
|
|
||||||
import com.example.nto.dto.CredentialsDTO;
|
|
||||||
import com.example.nto.dto.TerminalDTO;
|
import com.example.nto.dto.TerminalDTO;
|
||||||
import com.example.nto.service.CredentialsService;
|
|
||||||
import com.example.nto.service.TerminalService;
|
import com.example.nto.service.TerminalService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/terminal")
|
@RequestMapping("/api/terminal")
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.example.nto.controller;
|
||||||
|
|
||||||
|
import com.example.nto.dto.UsersDTO;
|
||||||
|
import com.example.nto.entity.Users;
|
||||||
|
import com.example.nto.exception.RoleisNotAdmin;
|
||||||
|
import com.example.nto.repository.UsersRepository;
|
||||||
|
import com.example.nto.service.UsersService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/users")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UsersController {
|
||||||
|
|
||||||
|
private final UsersService usersService;
|
||||||
|
private final UsersRepository usersRepository;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public List<UsersDTO> getAllUsers() {
|
||||||
|
return usersService.getAllUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
public ResponseEntity<UsersDTO> getUserByUsername(@RequestParam String username, Authentication authentication) {
|
||||||
|
String name = authentication.getName();
|
||||||
|
Optional<Users> user = usersRepository.findByUsername(name);
|
||||||
|
if (user.isPresent()) {
|
||||||
|
if(Objects.equals(user.get().getAuthority().getAuthority(), "ROLE_ADMIN")) {
|
||||||
|
return ResponseEntity.ok(usersService.getUserByUsername(username));
|
||||||
|
}
|
||||||
|
throw new RoleisNotAdmin("User with username " + user.get().getUsername() + " is not admin");
|
||||||
|
}
|
||||||
|
throw new RuntimeException("User is not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/username/{username}")
|
||||||
|
public ResponseEntity<String> getByUsername(@PathVariable String username) {
|
||||||
|
UsersDTO usersDTO = usersService.getUserByUsername(username);
|
||||||
|
return ResponseEntity.ok("User " + usersDTO.getUsername() + " is registered");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/login")
|
||||||
|
public ResponseEntity<UsersDTO> login(Authentication authentication) {
|
||||||
|
return ResponseEntity.ok(usersService.getUserByUsername(authentication.getName()));
|
||||||
|
}
|
||||||
|
@PatchMapping("/block")
|
||||||
|
public ResponseEntity<String> BlockUser(
|
||||||
|
@RequestParam() String username, Authentication authentication) {
|
||||||
|
String name = authentication.getName();
|
||||||
|
Optional<Users> user = usersRepository.findByUsername(name);
|
||||||
|
if (user.isPresent()) {
|
||||||
|
if (Objects.equals(user.get().getAuthority().getAuthority(), "ROLE_ADMIN")) {
|
||||||
|
return ResponseEntity.ok(usersService.blockUser(username));
|
||||||
|
}
|
||||||
|
throw new RoleisNotAdmin("User with username " + user.get().getUsername() + " is not admin");
|
||||||
|
|
||||||
|
}
|
||||||
|
throw new RuntimeException("User not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/unblock")
|
||||||
|
public ResponseEntity<String> UnblockUser(
|
||||||
|
@RequestParam() String username, Authentication authentication) {
|
||||||
|
String name = authentication.getName();
|
||||||
|
Optional<Users> user = usersRepository.findByUsername(name);
|
||||||
|
if (user.isPresent()) {
|
||||||
|
if (Objects.equals(user.get().getAuthority().getAuthority(), "ROLE_ADMIN")) {
|
||||||
|
return ResponseEntity.ok(usersService.unblockUser(username));
|
||||||
|
}
|
||||||
|
throw new RoleisNotAdmin("User with username " + user.get().getUsername() + " is not admin");
|
||||||
|
|
||||||
|
}
|
||||||
|
throw new RuntimeException("User not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class AuthorityDTO {
|
public class AuthorityDTO {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String authority;
|
private String name;
|
||||||
}
|
}
|
||||||
|
8
src/main/java/com/example/nto/dto/CodeDTO.java
Normal file
8
src/main/java/com/example/nto/dto/CodeDTO.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.example.nto.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CodeDTO {
|
||||||
|
private Long value;
|
||||||
|
}
|
@ -4,8 +4,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CredentialsDTO {
|
public class CredentialsDTO {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String login;
|
private String login;
|
||||||
private String hashedPassword;
|
private String hashedPassword;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.example.nto.dto;
|
package com.example.nto.dto;
|
||||||
|
|
||||||
|
import com.example.nto.entity.Terminal;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PassDTO {
|
public class PassDTO {
|
||||||
private long id;
|
|
||||||
private long employee;
|
|
||||||
private LocalDateTime localDateTime;
|
private LocalDateTime localDateTime;
|
||||||
private long terminal;
|
private Terminal terminal;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ package com.example.nto.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TerminalDTO {
|
public class TerminalDTO {
|
||||||
private long id;
|
private long id;
|
||||||
|
@ -8,4 +8,5 @@ public class UserRegisterDTO {
|
|||||||
private String password;
|
private String password;
|
||||||
private String name;
|
private String name;
|
||||||
private String lastname;
|
private String lastname;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
@ -5,15 +5,14 @@ import lombok.Data;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EmployeeDTO {
|
public class UsersDTO {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String username;
|
private String username;
|
||||||
private String name;
|
private String name;
|
||||||
private String password;
|
|
||||||
private long authority_id;
|
private long authority_id;
|
||||||
private long credentials;
|
|
||||||
private String photo;
|
private String photo;
|
||||||
private String position;
|
private String position;
|
||||||
|
private Boolean isCardBlocked;
|
||||||
private LocalDateTime lastVisit;
|
private LocalDateTime lastVisit;
|
||||||
|
|
||||||
}
|
}
|
@ -1,28 +1,19 @@
|
|||||||
package com.example.nto.entity;
|
package com.example.nto.entity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Builder
|
@Table(name = "authority")
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Table(name = "Authority")
|
|
||||||
public class Authority implements GrantedAuthority {
|
public class Authority implements GrantedAuthority {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@Column(name = "authority")
|
@Column(name = "authority")
|
||||||
private String authority;
|
private String authority;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getAuthority() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package com.example.nto.entity;
|
package com.example.nto.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -17,6 +18,10 @@ public class Code {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private long id;
|
private long id;
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name="terminal")
|
||||||
|
@JsonIgnore
|
||||||
|
private Terminal terminal;
|
||||||
@Column(name = "value")
|
@Column(name = "value")
|
||||||
private long value;
|
private long value;
|
||||||
}
|
}
|
||||||
|
@ -19,4 +19,7 @@ public class Credentials {
|
|||||||
@Column(name = "hashed_password")
|
@Column(name = "hashed_password")
|
||||||
private String hashedPassword;
|
private String hashedPassword;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "credentials")
|
||||||
|
@JsonIgnore
|
||||||
|
private List<Users> users;
|
||||||
}
|
}
|
@ -2,10 +2,9 @@ package com.example.nto.entity;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@ -16,9 +15,9 @@ public class Pass {
|
|||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "employee")
|
@JoinColumn(name = "users")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Employee employee;
|
private Users users;
|
||||||
|
|
||||||
@Column(name = "time")
|
@Column(name = "time")
|
||||||
private LocalDateTime time;
|
private LocalDateTime time;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package com.example.nto.entity;
|
package com.example.nto.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.example.nto.entity;
|
package com.example.nto.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
@ -16,11 +13,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Builder
|
@Table(name = "users")
|
||||||
@NoArgsConstructor
|
public class Users implements UserDetails {
|
||||||
@AllArgsConstructor
|
|
||||||
@Table(name = "Employee")
|
|
||||||
public class Employee implements UserDetails {
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private long id;
|
private long id;
|
||||||
@ -42,18 +36,20 @@ public class Employee implements UserDetails {
|
|||||||
private String photo;
|
private String photo;
|
||||||
@Column(name = "position")
|
@Column(name = "position")
|
||||||
private String position;
|
private String position;
|
||||||
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
private Set<Authority> authorities;
|
||||||
@Column(name = "lastVisit")
|
@Column(name = "lastVisit")
|
||||||
private LocalDateTime lastVisit;
|
private LocalDateTime lastVisit;
|
||||||
|
@Column(name = "iscardblocked")
|
||||||
|
private Boolean isCardBlocked;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsername() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAccountNonExpired() {
|
public boolean isAccountNonExpired() {
|
||||||
@ -74,4 +70,5 @@ public class Employee implements UserDetails {
|
|||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
@ -4,4 +4,4 @@ public class PersonAlreadyExistsException extends RuntimeException {
|
|||||||
public PersonAlreadyExistsException(String message) {
|
public PersonAlreadyExistsException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,4 @@ public class PersonNotFoundException extends RuntimeException {
|
|||||||
public PersonNotFoundException(String message) {
|
public PersonNotFoundException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,4 @@ public class RoleisNotAdmin extends RuntimeException {
|
|||||||
public RoleisNotAdmin(String message) {
|
public RoleisNotAdmin(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.example.nto.exception.handler;
|
package com.example.nto.exception.handler;
|
||||||
|
|
||||||
|
|
||||||
import com.example.nto.exception.PersonAlreadyExistsException;
|
import com.example.nto.exception.PersonAlreadyExistsException;
|
||||||
import com.example.nto.exception.PersonNotFoundException;
|
import com.example.nto.exception.PersonNotFoundException;
|
||||||
import com.example.nto.exception.RoleisNotAdmin;
|
import com.example.nto.exception.RoleisNotAdmin;
|
||||||
@ -11,16 +10,19 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|||||||
|
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class GlobalExceptionHandler {
|
public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(RoleisNotAdmin.class)
|
|
||||||
public ResponseEntity<String> handleRoleisNotAdmin(RoleisNotAdmin e) {
|
|
||||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
@ExceptionHandler(PersonNotFoundException.class)
|
@ExceptionHandler(PersonNotFoundException.class)
|
||||||
public ResponseEntity<String> handlePersonNotFound(PersonNotFoundException e) {
|
public ResponseEntity<String> handlePersonNotFoundException(PersonNotFoundException e) {
|
||||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(PersonAlreadyExistsException.class)
|
@ExceptionHandler(PersonAlreadyExistsException.class)
|
||||||
public ResponseEntity<String> handlePersonAlreadyExists(PersonAlreadyExistsException e) {
|
public ResponseEntity<String> handlePersonAlreadyExistsException(PersonAlreadyExistsException e) {
|
||||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_GATEWAY);
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(RoleisNotAdmin.class)
|
||||||
|
public ResponseEntity<String> hadnleRoleisNotAdmin(RoleisNotAdmin e) {
|
||||||
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package com.example.nto.repository;
|
package com.example.nto.repository;
|
||||||
|
|
||||||
import com.example.nto.dto.AuthorityDTO;
|
|
||||||
import com.example.nto.entity.Authority;
|
import com.example.nto.entity.Authority;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@ -10,4 +9,4 @@ import java.util.Optional;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface AuthorityRepository extends JpaRepository<Authority, Long> {
|
public interface AuthorityRepository extends JpaRepository<Authority, Long> {
|
||||||
Optional<Authority> findByAuthority(String Authority);
|
Optional<Authority> findByAuthority(String Authority);
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@ package com.example.nto.repository;
|
|||||||
|
|
||||||
import com.example.nto.entity.Code;
|
import com.example.nto.entity.Code;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CodeRepository extends JpaRepository<Code, Long> {
|
public interface CodeRepository extends JpaRepository<Code, Long> {
|
||||||
|
|
||||||
@Query("select count(e) = 1 from Code e where value = ?1")
|
|
||||||
boolean findExistByValue(Long value);
|
|
||||||
|
|
||||||
|
Optional<Code> findByValue(Long value);
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ import java.util.Optional;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CredentialsRepository extends JpaRepository<Credentials, Long> {
|
public interface CredentialsRepository extends JpaRepository<Credentials, Long> {
|
||||||
Optional<Credentials> findByLogin(String username);
|
Optional<Credentials> findByLogin(String login);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package com.example.nto.repository;
|
|
||||||
|
|
||||||
import com.example.nto.entity.Employee;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
|
||||||
|
|
||||||
Optional<Employee> findByUsername(String username);
|
|
||||||
Employee findById(long id);
|
|
||||||
Boolean findExistByUsername(String username);
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package com.example.nto.repository;
|
package com.example.nto.repository;
|
||||||
|
|
||||||
import com.example.nto.entity.Pass;
|
import com.example.nto.entity.Pass;
|
||||||
import com.example.nto.entity.Terminal;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.example.nto.repository;
|
||||||
|
|
||||||
|
import com.example.nto.entity.Users;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UsersRepository extends JpaRepository<Users, Long> {
|
||||||
|
Optional<Users> findByCredentialsId(Integer credentialsId);
|
||||||
|
Optional<Users> findByAuthorityId(Integer authorityId);
|
||||||
|
Optional<Users> findByUsername(String username);
|
||||||
|
|
||||||
|
|
||||||
|
Page<Users> findAll(Pageable pageable);
|
||||||
|
}
|
@ -11,4 +11,4 @@ public interface AuthorityService {
|
|||||||
List<Authority> getAll();
|
List<Authority> getAll();
|
||||||
|
|
||||||
String isAdmin(Long id);
|
String isAdmin(Long id);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.example.nto.service;
|
package com.example.nto.service;
|
||||||
|
|
||||||
|
|
||||||
import com.example.nto.entity.Employee;
|
import com.example.nto.entity.Users;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface CodeService {
|
public interface CodeService {
|
||||||
|
|
||||||
Boolean findExistByValue(Long value);
|
Boolean findExistByValue(Long value);
|
||||||
Optional<Employee> openDoor(String username, Long value);
|
Optional<Users> openDoor(String username, Long value);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package com.example.nto.service;
|
package com.example.nto.service;
|
||||||
|
|
||||||
import com.example.nto.dto.CredentialsDTO;
|
import com.example.nto.dto.CredentialsDTO;
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package com.example.nto.service;
|
|
||||||
|
|
||||||
import com.example.nto.dto.EmployeeDTO;
|
|
||||||
import com.example.nto.dto.UserRegisterDTO;
|
|
||||||
import com.example.nto.entity.Employee;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface EmployeeService {
|
|
||||||
|
|
||||||
Employee updateEmployee(long id, Employee newEmployee);
|
|
||||||
Optional<Employee> findByUsername(String username);
|
|
||||||
|
|
||||||
EmployeeDTO findById(Long id);
|
|
||||||
|
|
||||||
boolean findExistByUsername(String username);
|
|
||||||
|
|
||||||
EmployeeDTO createUser(UserRegisterDTO dto);
|
|
||||||
|
|
||||||
EmployeeDTO getUserByUsername(String username);
|
|
||||||
|
|
||||||
EmployeeDTO get(String name);
|
|
||||||
}
|
|
@ -2,17 +2,14 @@
|
|||||||
package com.example.nto.service;
|
package com.example.nto.service;
|
||||||
|
|
||||||
import com.example.nto.dto.PassDTO;
|
import com.example.nto.dto.PassDTO;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public interface PassService {
|
public interface PassService {
|
||||||
List<PassDTO> getPassAtUser(long id);
|
List<PassDTO> getPassAtUser(long id);
|
||||||
|
|
||||||
|
List<PassDTO> getAllPassesPaginated(Pageable pageable, String username);
|
||||||
List<PassDTO> getAllPassesPaginated(Pageable pageable, long id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
|
|
||||||
package com.example.nto.service;
|
package com.example.nto.service;
|
||||||
|
|
||||||
import com.example.nto.dto.CredentialsDTO;
|
|
||||||
import com.example.nto.dto.TerminalDTO;
|
import com.example.nto.dto.TerminalDTO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public interface TerminalService {
|
public interface TerminalService {
|
||||||
TerminalDTO getTerminalbyId(Long id);
|
TerminalDTO getTerminalbyId(Long id);
|
||||||
|
22
src/main/java/com/example/nto/service/UsersService.java
Normal file
22
src/main/java/com/example/nto/service/UsersService.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.example.nto.service;
|
||||||
|
|
||||||
|
import com.example.nto.dto.UsersDTO;
|
||||||
|
import com.example.nto.entity.Users;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public interface UsersService {
|
||||||
|
List<UsersDTO> getAllUsers();
|
||||||
|
UsersDTO getUserbyId(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
Users updateEmployee(long id, Users newUser);
|
||||||
|
String blockUser(String username);
|
||||||
|
|
||||||
|
String unblockUser(String username);
|
||||||
|
|
||||||
|
UsersDTO getUserByUsername(String username);
|
||||||
|
|
||||||
|
}
|
@ -19,7 +19,9 @@ public class AuthorityServiceImpl implements AuthorityService {
|
|||||||
public Authority add(Authority authority) {
|
public Authority add(Authority authority) {
|
||||||
|
|
||||||
Optional<Authority> optionalAuthority = authorityRepository.findByAuthority(authority.getAuthority());
|
Optional<Authority> optionalAuthority = authorityRepository.findByAuthority(authority.getAuthority());
|
||||||
return optionalAuthority.orElseGet(() -> authorityRepository.save(authority));
|
|
||||||
|
if (optionalAuthority.isPresent()) return optionalAuthority.get();
|
||||||
|
else return authorityRepository.save(authority);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<Authority> getAll() {
|
public List<Authority> getAll() {
|
||||||
@ -33,4 +35,4 @@ public class AuthorityServiceImpl implements AuthorityService {
|
|||||||
|
|
||||||
return existingsAuthority.getAuthority();
|
return existingsAuthority.getAuthority();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.example.nto.service.impl;
|
||||||
|
|
||||||
|
import com.example.nto.entity.Code;
|
||||||
|
import com.example.nto.entity.Pass;
|
||||||
|
import com.example.nto.entity.Users;
|
||||||
|
import com.example.nto.exception.RoleisNotAdmin;
|
||||||
|
import com.example.nto.repository.CodeRepository;
|
||||||
|
import com.example.nto.repository.PassRepository;
|
||||||
|
import com.example.nto.repository.UsersRepository;
|
||||||
|
import com.example.nto.service.CodeService;
|
||||||
|
import com.example.nto.service.UsersService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CodeServiceImpl implements CodeService {
|
||||||
|
|
||||||
|
private final CodeRepository codeRepository;
|
||||||
|
private final UsersRepository usersRepository;
|
||||||
|
private final UsersService usersService;
|
||||||
|
private final PassRepository passRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean findExistByValue(Long value) {
|
||||||
|
return codeRepository.findByValue(value).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Users> openDoor(String username, Long value) {
|
||||||
|
if (usersRepository.findByUsername(username).isPresent() && findExistByValue(value)) {
|
||||||
|
Optional<Users> user = usersRepository.findByUsername(username);
|
||||||
|
Optional<Code> code = codeRepository.findByValue(value);
|
||||||
|
if (!user.get().getIsCardBlocked()) {
|
||||||
|
Pass pass = new Pass();
|
||||||
|
pass.setTerminal(code.get().getTerminal());
|
||||||
|
pass.setUsers(user.get());
|
||||||
|
pass.setTime(LocalDateTime.now());
|
||||||
|
passRepository.save(pass);
|
||||||
|
user.get().setLastVisit(LocalDateTime.now());
|
||||||
|
|
||||||
|
return Optional.ofNullable(usersService.updateEmployee(user.get().getId(), user.orElse(null)));
|
||||||
|
}
|
||||||
|
throw new RoleisNotAdmin("Card is blocked");
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import com.example.nto.dto.CredentialsDTO;
|
|||||||
import com.example.nto.entity.Credentials;
|
import com.example.nto.entity.Credentials;
|
||||||
import com.example.nto.repository.CredentialsRepository;
|
import com.example.nto.repository.CredentialsRepository;
|
||||||
import com.example.nto.service.CredentialsService;
|
import com.example.nto.service.CredentialsService;
|
||||||
import com.example.nto.utils.CredentialsMapper;
|
import com.example.nto.util.CredentialsMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -64,4 +64,4 @@ public class CredentialsServiceImpl implements CredentialsService {
|
|||||||
public void deleteCredentials(Long id) {
|
public void deleteCredentials(Long id) {
|
||||||
credentialsRepository.deleteById(id);
|
credentialsRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,139 +0,0 @@
|
|||||||
package com.example.nto.service.impl;
|
|
||||||
|
|
||||||
import com.example.nto.dto.EmployeeDTO;
|
|
||||||
import com.example.nto.dto.UserRegisterDTO;
|
|
||||||
import com.example.nto.entity.Authority;
|
|
||||||
import com.example.nto.entity.Credentials;
|
|
||||||
import com.example.nto.entity.Employee;
|
|
||||||
import com.example.nto.exception.PersonAlreadyExistsException;
|
|
||||||
import com.example.nto.exception.PersonNotFoundException;
|
|
||||||
import com.example.nto.repository.AuthorityRepository;
|
|
||||||
import com.example.nto.repository.CodeRepository;
|
|
||||||
import com.example.nto.repository.CredentialsRepository;
|
|
||||||
import com.example.nto.repository.EmployeeRepository;
|
|
||||||
import com.example.nto.service.CodeService;
|
|
||||||
import com.example.nto.service.EmployeeService;
|
|
||||||
import com.example.nto.utils.EmployeeMapper;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class EmployeeCodeServiceImpl implements EmployeeService, CodeService {
|
|
||||||
|
|
||||||
private final EmployeeRepository employeeRepository;
|
|
||||||
private final CodeRepository codeRepository;
|
|
||||||
private final PasswordEncoder passwordEncoder;
|
|
||||||
private final AuthorityRepository authorityRepository;
|
|
||||||
private final CredentialsRepository credentialsRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Employee updateEmployee(long id, Employee newEmployee) {
|
|
||||||
Optional<Employee> optionalEmployee = Optional.ofNullable(employeeRepository.findById(id));
|
|
||||||
if (optionalEmployee.isEmpty()) throw new RuntimeException("No such user with id " + id);
|
|
||||||
|
|
||||||
Employee employee = optionalEmployee.get();
|
|
||||||
employee.setName(newEmployee.getName());
|
|
||||||
employee.setUsername(newEmployee.getUsername());
|
|
||||||
employee.setPhoto(newEmployee.getPhoto());
|
|
||||||
employee.setPosition(newEmployee.getPosition());
|
|
||||||
employee.setLastVisit(newEmployee.getLastVisit());
|
|
||||||
|
|
||||||
return employeeRepository.save(employee);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Employee> findByUsername(String username) {
|
|
||||||
if (employeeRepository.findExistByUsername(username))
|
|
||||||
return employeeRepository.findByUsername(username);
|
|
||||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
|
||||||
"There is no account with login " + username + " or it is incorrect");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EmployeeDTO findById(Long id) {
|
|
||||||
return employeeRepository.findById(id)
|
|
||||||
.map(EmployeeMapper::convertDTO)
|
|
||||||
.orElseThrow(() -> new PersonNotFoundException("Person not found!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean findExistByUsername(String username) {
|
|
||||||
if (employeeRepository.findExistByUsername(username))
|
|
||||||
throw new ResponseStatusException(HttpStatus.OK, "Login is existing, processing");
|
|
||||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
|
||||||
"There is no account with login " + username + " or it is incorrect");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Employee> openDoor(String username, Long value) {
|
|
||||||
// if (findByLogin(login) != null && findExistByValue(value)) {
|
|
||||||
// Optional<Employee> employee = findByLogin(login);
|
|
||||||
// employee.ifPresent(employee1 -> employee1.setLastVisit(LocalDateTime.now()));
|
|
||||||
// employee.setLastVisit(LocalDateTime.now());
|
|
||||||
//
|
|
||||||
// return updateEmployee(employee.getId(), employee);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
|
|
||||||
return null;
|
|
||||||
// TODO Доделать элемент с OpenDoor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean findExistByValue(Long value) {
|
|
||||||
if (codeRepository.findExistByValue(value))
|
|
||||||
return codeRepository.findExistByValue(value);
|
|
||||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public EmployeeDTO createUser(UserRegisterDTO dto) {
|
|
||||||
|
|
||||||
|
|
||||||
Optional<Authority> roleUser = authorityRepository.findByAuthority("ROlE_USER");
|
|
||||||
System.out.println(roleUser);
|
|
||||||
|
|
||||||
if (roleUser.isEmpty()) throw new RuntimeException("Roles not found");
|
|
||||||
Credentials credentials = new Credentials();
|
|
||||||
credentials.setLogin(dto.getUsername());
|
|
||||||
credentials.setHashedPassword(passwordEncoder.encode(dto.getPassword()));
|
|
||||||
Credentials credentialSave = credentialsRepository.save(credentials);
|
|
||||||
Employee employee = new Employee();
|
|
||||||
employee.setUsername(dto.getUsername());
|
|
||||||
employee.setName(dto.getName());
|
|
||||||
employee.setPassword(passwordEncoder.encode(dto.getPassword()));
|
|
||||||
employee.setCredentials(credentials);
|
|
||||||
employee.setAuthority(roleUser.get());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Employee savedUser = employeeRepository.save(employee);
|
|
||||||
return EmployeeMapper.convertDTO(savedUser);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public EmployeeDTO getUserByUsername(String username) {
|
|
||||||
System.out.println(username);
|
|
||||||
Optional<Employee> optionalUsers = employeeRepository.findByUsername(username);
|
|
||||||
System.out.println(optionalUsers);
|
|
||||||
if (optionalUsers.isEmpty()) {
|
|
||||||
throw new PersonNotFoundException("User with username " + username + "not found");
|
|
||||||
}
|
|
||||||
return EmployeeMapper.convertDTO(optionalUsers.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EmployeeDTO get(String name) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,13 +3,13 @@ package com.example.nto.service.impl;
|
|||||||
import com.example.nto.dto.PassDTO;
|
import com.example.nto.dto.PassDTO;
|
||||||
import com.example.nto.repository.PassRepository;
|
import com.example.nto.repository.PassRepository;
|
||||||
import com.example.nto.service.PassService;
|
import com.example.nto.service.PassService;
|
||||||
import com.example.nto.utils.PassMapper;
|
import com.example.nto.util.PassMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -22,14 +22,16 @@ public class PassServiceImpl implements PassService {
|
|||||||
@Override
|
@Override
|
||||||
public List<PassDTO> getPassAtUser(long id) {
|
public List<PassDTO> getPassAtUser(long id) {
|
||||||
return passRepository.findAll().stream()
|
return passRepository.findAll().stream()
|
||||||
.filter(pass -> pass.getEmployee().toString().equals(id))
|
.filter(pass -> pass.getUsers().getId() == id)
|
||||||
.map(PassMapper::convertDTO)
|
.map(PassMapper::convertDTO)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<PassDTO> getAllPassesPaginated(Pageable pageable, long id) {
|
public List<PassDTO> getAllPassesPaginated(Pageable pageable, String username) {
|
||||||
return passRepository.findAll(pageable)
|
return passRepository.findAll(pageable).stream()
|
||||||
.filter(pass -> pass.getEmployee().toString().equals(id))
|
.filter(pass -> Objects.equals(pass.getUsers().getUsername(), username))
|
||||||
.map(PassMapper::convertDTO).toList();
|
.map(PassMapper::convertDTO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,14 @@
|
|||||||
package com.example.nto.service.impl;
|
package com.example.nto.service.impl;
|
||||||
|
|
||||||
import com.example.nto.dto.CredentialsDTO;
|
|
||||||
import com.example.nto.dto.TerminalDTO;
|
import com.example.nto.dto.TerminalDTO;
|
||||||
import com.example.nto.entity.Credentials;
|
|
||||||
import com.example.nto.entity.Terminal;
|
import com.example.nto.entity.Terminal;
|
||||||
import com.example.nto.repository.CredentialsRepository;
|
|
||||||
import com.example.nto.repository.TerminalRepository;
|
import com.example.nto.repository.TerminalRepository;
|
||||||
import com.example.nto.service.CredentialsService;
|
|
||||||
import com.example.nto.service.TerminalService;
|
import com.example.nto.service.TerminalService;
|
||||||
import com.example.nto.utils.CredentialsMapper;
|
import com.example.nto.util.TerminalMapper;
|
||||||
import com.example.nto.utils.TerminalMapper;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.example.nto.service.impl;
|
package com.example.nto.service.impl;
|
||||||
|
|
||||||
import com.example.nto.entity.Employee;
|
import com.example.nto.entity.Users;
|
||||||
import com.example.nto.repository.EmployeeRepository;
|
import com.example.nto.repository.UsersRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
@ -14,14 +14,14 @@ import java.util.Optional;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||||
|
|
||||||
private final EmployeeRepository employeeRepository;
|
private final UsersRepository usersRepository;
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
||||||
Optional<Employee> optionalUsers = employeeRepository.findByUsername(s);
|
Optional<Users> optionalUsers = usersRepository.findByUsername(s);
|
||||||
|
|
||||||
if(optionalUsers.isEmpty()) {
|
if(optionalUsers.isEmpty()) {
|
||||||
throw new UsernameNotFoundException("User not found");
|
throw new UsernameNotFoundException("User not found");
|
||||||
}
|
}
|
||||||
return optionalUsers.get();
|
return optionalUsers.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package com.example.nto.service.impl;
|
||||||
|
|
||||||
|
import com.example.nto.dto.UsersDTO;
|
||||||
|
import com.example.nto.entity.*;
|
||||||
|
import com.example.nto.exception.PersonNotFoundException;
|
||||||
|
import com.example.nto.repository.*;
|
||||||
|
import com.example.nto.service.UsersService;
|
||||||
|
import com.example.nto.util.UsersMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UsersServiceImpl implements UsersService {
|
||||||
|
|
||||||
|
private final UsersRepository usersRepository;
|
||||||
|
private final CredentialsRepository credentialsRepository;
|
||||||
|
private final AuthorityRepository rolesRepository;
|
||||||
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UsersDTO> getAllUsers() {
|
||||||
|
return usersRepository.findAll().stream()
|
||||||
|
.map(UsersMapper::convertDTO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UsersDTO getUserbyId(Long id) {
|
||||||
|
return usersRepository.findById(id)
|
||||||
|
.map(UsersMapper::convertDTO)
|
||||||
|
.orElseThrow(() -> new PersonNotFoundException("Person not found!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Users updateEmployee(long id, Users newUser) {
|
||||||
|
Optional<Users> optionalEmployee = usersRepository.findById(id);
|
||||||
|
if (optionalEmployee.isEmpty()) throw new RuntimeException("No such user with id " + id);
|
||||||
|
|
||||||
|
Pass pass = new Pass();
|
||||||
|
Users users = optionalEmployee.get();
|
||||||
|
users.setName(newUser.getName());
|
||||||
|
users.setUsername(newUser.getUsername());
|
||||||
|
users.setPhoto(newUser.getPhoto());
|
||||||
|
users.setPosition(newUser.getPosition());
|
||||||
|
users.setLastVisit(newUser.getLastVisit());
|
||||||
|
|
||||||
|
return usersRepository.save(users);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String blockUser(String username) {
|
||||||
|
Optional<Users> users = usersRepository.findByUsername(username);
|
||||||
|
|
||||||
|
if (users.isPresent()) {
|
||||||
|
Users user = users.get();
|
||||||
|
user.setIsCardBlocked(true);
|
||||||
|
usersRepository.save(user);
|
||||||
|
return "Blocked user";
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No such user with username " + username);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String unblockUser(String username) {
|
||||||
|
Optional<Users> users = usersRepository.findByUsername(username);
|
||||||
|
|
||||||
|
if (users.isPresent()) {
|
||||||
|
Users user = users.get();
|
||||||
|
user.setIsCardBlocked(false);
|
||||||
|
usersRepository.save(user);
|
||||||
|
return "Unblocked user";
|
||||||
|
}
|
||||||
|
throw new PersonNotFoundException("No such user with username " + username);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UsersDTO getUserByUsername(String username) {
|
||||||
|
Optional<Users> optionalUsers = usersRepository.findByUsername(username);
|
||||||
|
|
||||||
|
if (optionalUsers.isEmpty()) {
|
||||||
|
throw new PersonNotFoundException("User with username " + username + "not found");
|
||||||
|
}
|
||||||
|
return UsersMapper.convertDTO(optionalUsers.get());
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,15 @@
|
|||||||
package com.example.nto.utils;
|
package com.example.nto.util;
|
||||||
import com.example.nto.entity.Authority;
|
|
||||||
import com.example.nto.dto.AuthorityDTO;
|
import com.example.nto.dto.AuthorityDTO;
|
||||||
|
import com.example.nto.entity.Authority;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class AuthorityMapper {
|
public class AuthorityMapper {
|
||||||
public static AuthorityDTO convertDTO(Authority role) {
|
public static AuthorityDTO convertDTO(Authority role) {
|
||||||
AuthorityDTO authorityDTO = new AuthorityDTO();
|
AuthorityDTO rolesDTO = new AuthorityDTO();
|
||||||
authorityDTO.setId(role.getId());
|
rolesDTO.setId(role.getId());
|
||||||
authorityDTO.setAuthority(role.getAuthority());
|
rolesDTO.setName(role.getAuthority());
|
||||||
return authorityDTO;
|
return rolesDTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package com.example.nto.utils;
|
package com.example.nto.util;
|
||||||
|
|
||||||
import com.example.nto.dto.AuthorityDTO;
|
|
||||||
import com.example.nto.dto.CredentialsDTO;
|
import com.example.nto.dto.CredentialsDTO;
|
||||||
import com.example.nto.entity.Authority;
|
|
||||||
import com.example.nto.entity.Credentials;
|
import com.example.nto.entity.Credentials;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@ -15,4 +13,4 @@ public class CredentialsMapper {
|
|||||||
credentialsDTO.setHashedPassword(credentials.getHashedPassword());
|
credentialsDTO.setHashedPassword(credentials.getHashedPassword());
|
||||||
return credentialsDTO;
|
return credentialsDTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.nto.utils;
|
package com.example.nto.util;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -6,20 +6,19 @@ import com.example.nto.dto.PassDTO;
|
|||||||
import com.example.nto.entity.Pass;
|
import com.example.nto.entity.Pass;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class PassMapper {
|
public class PassMapper {
|
||||||
public static PassDTO convertDTO(Pass pass) {
|
public static PassDTO convertDTO(Pass pass) {
|
||||||
PassDTO passDTO = new PassDTO();
|
PassDTO passDTO = new PassDTO();
|
||||||
passDTO.setId(pass.getId());
|
|
||||||
if (pass.getEmployee() != null) {
|
|
||||||
passDTO.setEmployee(pass.getEmployee().getId());
|
|
||||||
}
|
|
||||||
passDTO.setLocalDateTime(pass.getTime());
|
passDTO.setLocalDateTime(pass.getTime());
|
||||||
if (pass.getTerminal() != null) {
|
if (pass.getTerminal() != null) {
|
||||||
passDTO.setTerminal(pass.getTerminal().getId());
|
passDTO.setTerminal(pass.getTerminal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return passDTO;
|
return passDTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.nto.utils;
|
package com.example.nto.util;
|
||||||
|
|
||||||
|
|
||||||
|
|
27
src/main/java/com/example/nto/util/UsersMapper.java
Normal file
27
src/main/java/com/example/nto/util/UsersMapper.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.nto.util;
|
||||||
|
|
||||||
|
import com.example.nto.dto.UsersDTO;
|
||||||
|
import com.example.nto.entity.Users;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class UsersMapper {
|
||||||
|
public static UsersDTO convertDTO(Users user) {
|
||||||
|
UsersDTO usersDTO = new UsersDTO();
|
||||||
|
usersDTO.setId(user.getId());
|
||||||
|
usersDTO.setUsername(user.getUsername());
|
||||||
|
usersDTO.setName(user.getName());
|
||||||
|
if (user.getAuthority() != null) {
|
||||||
|
usersDTO.setAuthority_id(user.getAuthority().getId());
|
||||||
|
}
|
||||||
|
usersDTO.setPhoto(user.getPhoto());
|
||||||
|
usersDTO.setPosition(user.getPosition());
|
||||||
|
usersDTO.setLastVisit(user.getLastVisit());
|
||||||
|
usersDTO.setIsCardBlocked(false);
|
||||||
|
|
||||||
|
|
||||||
|
return usersDTO;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,28 +0,0 @@
|
|||||||
package com.example.nto.utils;
|
|
||||||
|
|
||||||
|
|
||||||
import com.example.nto.dto.EmployeeDTO;
|
|
||||||
import com.example.nto.entity.Employee;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class EmployeeMapper {
|
|
||||||
public static EmployeeDTO convertDTO(Employee user) {
|
|
||||||
EmployeeDTO employeeDTO = new EmployeeDTO();
|
|
||||||
employeeDTO.setId(user.getId());
|
|
||||||
employeeDTO.setUsername(user.getUsername());
|
|
||||||
employeeDTO.setName(user.getName());
|
|
||||||
if (user.getAuthority() != null) {
|
|
||||||
employeeDTO.setAuthority_id(user.getAuthority().getId());
|
|
||||||
}
|
|
||||||
if (user.getCredentials() != null) {
|
|
||||||
employeeDTO.setCredentials(user.getCredentials().getId());
|
|
||||||
}
|
|
||||||
employeeDTO.setPassword(user.getPassword());
|
|
||||||
employeeDTO.setPhoto(user.getPhoto());
|
|
||||||
employeeDTO.setPosition(user.getPosition());
|
|
||||||
employeeDTO.setLastVisit(user.getLastVisit());
|
|
||||||
|
|
||||||
return employeeDTO;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,6 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
url: jdbc:h2:mem:testdb
|
url: jdbc:h2:mem:testdb
|
||||||
|
|
||||||
|
|
||||||
h2:
|
h2:
|
||||||
console:
|
console:
|
||||||
enabled: true
|
enabled: true
|
||||||
@ -18,9 +17,4 @@ spring:
|
|||||||
generate-ddl: false
|
generate-ddl: false
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: none
|
ddl-auto: none
|
||||||
show-sql: true
|
show-sql: true
|
||||||
|
|
||||||
spring-doc:
|
|
||||||
swagger-ui:
|
|
||||||
path: /swagger-ui.html
|
|
||||||
operationsSorter: method
|
|
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||||
|
|
||||||
|
<changeSet id="2025-02-19--0001-code-terminal" author="IgraM">
|
||||||
|
<createTable tableName="code_terminal">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="code_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_codes_key" referencedTableName="code"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="terminal_ids" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_codeterminal_key"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -13,6 +13,8 @@
|
|||||||
</column>
|
</column>
|
||||||
<column name="value" type="INT">
|
<column name="value" type="INT">
|
||||||
</column>
|
</column>
|
||||||
|
<column name="terminal" type="INT">
|
||||||
|
</column>
|
||||||
|
|
||||||
</createTable>
|
</createTable>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||||
|
|
||||||
|
<changeSet id="2025-02-19--0001-pass-terminal" author="IgraM">
|
||||||
|
<createTable tableName="pass_terminal">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="pass_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_passs_key" referencedTableName="pass"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="terminal_ids" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_passterminal_key"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||||
|
|
||||||
|
<changeSet id="2025-02-19--0001-pass-users" author="IgraM">
|
||||||
|
<createTable tableName="pass_users">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="pass_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_passsu_key" referencedTableName="pass"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="users_ids" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_passusers_key"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -11,11 +11,11 @@
|
|||||||
<column name="id" type="BIGINT" autoIncrement="true">
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
<constraints primaryKey="true" nullable="false"/>
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="employee" type="INT">
|
<column name="users" type="BIGINT">
|
||||||
</column>
|
</column>
|
||||||
<column name="time" type="TIMESTAMP">
|
<column name="time" type="TIMESTAMP">
|
||||||
</column>
|
</column>
|
||||||
<column name="terminal" type="INT">
|
<column name="terminal" type="BIGINT">
|
||||||
</column>
|
</column>
|
||||||
|
|
||||||
</createTable>
|
</createTable>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||||
|
|
||||||
<changeSet id="2025-02-02--0001-employee-authorities" author="IgraM">
|
<changeSet id="2025-02-02--0001-users-authorities" author="IgraM">
|
||||||
<createTable tableName="employee_authorities">
|
<createTable tableName="users_authorities">
|
||||||
<column name="id" type="BIGINT" autoIncrement="true">
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
<constraints primaryKey="true" nullable="false"/>
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="employee_id" type="BIGINT">
|
<column name="users_id" type="BIGINT">
|
||||||
<constraints nullable="false" foreignKeyName="fk_userauth_usr" referencedTableName="employee"
|
<constraints nullable="false" foreignKeyName="fk_userauth_usr" referencedTableName="users"
|
||||||
referencedColumnNames="id"/>
|
referencedColumnNames="id"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="authorities_id" type="BIGINT">
|
<column name="authorities_id" type="BIGINT">
|
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||||
|
|
||||||
|
<changeSet id="2025-02-19--0001-users-is-card-blocked" author="IgraM">
|
||||||
|
<createTable tableName="iscardblocked">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="users_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_usersc_key" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="card_blocked" type="BOOLEAN">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_userscard_key"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -6,8 +6,8 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||||
|
|
||||||
<changeSet id="2025-02-19--0001-employee" author="IgraM">
|
<changeSet id="2025-02-19--0001-users" author="IgraM">
|
||||||
<createTable tableName="employee">
|
<createTable tableName="users">
|
||||||
<column name="id" type="BIGINT" autoIncrement="true">
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
<constraints primaryKey="true" nullable="false"/>
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
@ -23,6 +23,9 @@
|
|||||||
</column>
|
</column>
|
||||||
<column name="last_visit" type="TIMESTAMP">
|
<column name="last_visit" type="TIMESTAMP">
|
||||||
</column>
|
</column>
|
||||||
|
<column name="iscardblocked" type="BOOLEAN">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
<column name="username" type="VARCHAR(100)">
|
<column name="username" type="VARCHAR(100)">
|
||||||
<constraints nullable="false" unique="true"/>
|
<constraints nullable="false" unique="true"/>
|
||||||
</column>
|
</column>
|
@ -5,12 +5,12 @@
|
|||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
<preConditions onFail="WARN">
|
<preConditions onFail="WARN">
|
||||||
<not>
|
<not>
|
||||||
<tableExists tableName="employee_authorities"/>
|
<tableExists tableName="code_terminal"/>
|
||||||
</not>
|
</not>
|
||||||
</preConditions>
|
</preConditions>
|
||||||
<changeSet id="2025-02-19--0001-employee-authorities-data" author="IgraM">
|
<changeSet id="2025-02-19--0001-code-terminal-data" author="IgraM">
|
||||||
<loadData tableName="employee_authorities"
|
<loadData tableName="code_terminal"
|
||||||
file="db.changelog/data/csv/2025-02-19--0001-employee-authorities-data.csv"
|
file="db.changelog/data/csv/2025-02-19--0001-code-terminal-data.csv"
|
||||||
separator=";"
|
separator=";"
|
||||||
encoding="UTF-8"/>
|
encoding="UTF-8"/>
|
||||||
</changeSet>
|
</changeSet>
|
@ -0,0 +1,17 @@
|
|||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
|
<preConditions onFail="WARN">
|
||||||
|
<not>
|
||||||
|
<tableExists tableName="pass_terminal"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-pass-terminal-data" author="IgraM">
|
||||||
|
<loadData tableName="pass_terminal"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-pass-terminal-data.csv"
|
||||||
|
separator=";"
|
||||||
|
encoding="UTF-8"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,17 @@
|
|||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
|
<preConditions onFail="WARN">
|
||||||
|
<not>
|
||||||
|
<tableExists tableName="pass_users"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-pass-users-data" author="IgraM">
|
||||||
|
<loadData tableName="pass_users"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-pass-users-data.csv"
|
||||||
|
separator=";"
|
||||||
|
encoding="UTF-8"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -5,7 +5,7 @@
|
|||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
<preConditions onFail="WARN">
|
<preConditions onFail="WARN">
|
||||||
<not>
|
<not>
|
||||||
<tableExists tableName="code"/>
|
<tableExists tableName="terminal"/>
|
||||||
</not>
|
</not>
|
||||||
</preConditions>
|
</preConditions>
|
||||||
<changeSet id="2025-02-19--0001-terminal-data" author="IgraM">
|
<changeSet id="2025-02-19--0001-terminal-data" author="IgraM">
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
|
<preConditions onFail="WARN">
|
||||||
|
<not>
|
||||||
|
<tableExists tableName="users_authorities"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-users-authorities-data" author="IgraM">
|
||||||
|
<loadData tableName="users_authorities"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-users-authorities-data.csv"
|
||||||
|
separator=";"
|
||||||
|
encoding="UTF-8"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -5,12 +5,12 @@
|
|||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
<preConditions onFail="WARN">
|
<preConditions onFail="WARN">
|
||||||
<not>
|
<not>
|
||||||
<tableExists tableName="employee"/>
|
<tableExists tableName="users"/>
|
||||||
</not>
|
</not>
|
||||||
</preConditions>
|
</preConditions>
|
||||||
<changeSet id="2025-02-19--0001-employee-data" author="IgraM">
|
<changeSet id="2025-02-19--0001-users-data" author="IgraM">
|
||||||
<loadData tableName="employee"
|
<loadData tableName="users"
|
||||||
file="db.changelog/data/csv/2025-02-19--0001-employee-data.csv"
|
file="db.changelog/data/csv/2025-02-19--0001-users-data.csv"
|
||||||
separator=";"
|
separator=";"
|
||||||
encoding="UTF-8"/>
|
encoding="UTF-8"/>
|
||||||
</changeSet>
|
</changeSet>
|
@ -0,0 +1,17 @@
|
|||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
|
<preConditions onFail="WARN">
|
||||||
|
<not>
|
||||||
|
<tableExists tableName="iscardblocked"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-users-is-card-blocked-data" author="IgraM">
|
||||||
|
<loadData tableName="iscardblocked"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-users-is-card-blocked-data.csv"
|
||||||
|
separator=";"
|
||||||
|
encoding="UTF-8"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -1,6 +1,6 @@
|
|||||||
value
|
value;terminal
|
||||||
123456789
|
123456789;2
|
||||||
123456789
|
1234567891;1
|
||||||
123456789
|
1234567892;1
|
||||||
123456789
|
1234567893;2
|
||||||
123456789
|
1234567894;2
|
|
@ -0,0 +1,6 @@
|
|||||||
|
code_id;terminal_ids
|
||||||
|
1;1
|
||||||
|
2;2
|
||||||
|
3;2
|
||||||
|
4;1
|
||||||
|
5;1
|
|
@ -1,5 +0,0 @@
|
|||||||
employee_id;authorities_id
|
|
||||||
1;1
|
|
||||||
2;1
|
|
||||||
3;1
|
|
||||||
4;2
|
|
|
@ -1,5 +0,0 @@
|
|||||||
username;credentials;name;password;photo;position
|
|
||||||
pivanov;1; Иванов Петр Федорович;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Разработчик
|
|
||||||
ipetrov;2; Петров Иван Константинович;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Аналитик
|
|
||||||
asemenov;3; Семенов Анатолий Анатольевич;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Разработчик
|
|
||||||
afedorov;4; Федоров Александр Сергеевич;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Тестировщик
|
|
|
@ -1,5 +1,5 @@
|
|||||||
employee;time
|
users;time;terminal
|
||||||
1;2023-05-29T10:15:30
|
1;2023-05-29T10:15:30;1
|
||||||
2;2021-05-29T10:15:30
|
2;2021-05-29T10:15:30;2
|
||||||
3;2022-05-29T10:15:30
|
3;2022-05-29T10:15:30;2
|
||||||
4;2025-05-29T10:15:30
|
4;2025-05-29T10:15:30;1
|
|
@ -0,0 +1,5 @@
|
|||||||
|
pass_id;terminal_ids
|
||||||
|
1;1
|
||||||
|
2;1
|
||||||
|
2;1
|
||||||
|
1;1
|
|
@ -0,0 +1,5 @@
|
|||||||
|
pass_id;users_ids
|
||||||
|
1;1
|
||||||
|
2;2
|
||||||
|
2;3
|
||||||
|
2;4
|
|
@ -0,0 +1,5 @@
|
|||||||
|
users_id;authorities_id
|
||||||
|
1;1
|
||||||
|
2;1
|
||||||
|
3;1
|
||||||
|
4;2
|
|
@ -0,0 +1,5 @@
|
|||||||
|
username;credentials;authority_id;name;password;photo;position;isCardBlocked
|
||||||
|
pivanov;1;1; Иванов Петр Федорович;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Разработчик;false
|
||||||
|
ipetrov;2;1; Петров Иван Константинович;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Аналитик;false
|
||||||
|
asemenov;3;1; Семенов Анатолий Анатольевич;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Разработчик;false
|
||||||
|
afedorov;4;2; Федоров Александр Сергеевич;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e;https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg;Тестировщик;false
|
|
@ -0,0 +1,5 @@
|
|||||||
|
users_id;card_blocked
|
||||||
|
1;false
|
||||||
|
2;false
|
||||||
|
3;false
|
||||||
|
4;false
|
|
@ -4,21 +4,29 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
|
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-employee.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-users.xml"/>
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-authority.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-authority.xml"/>
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-credentials.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-credentials.xml"/>
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-employee-authorities.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-users-authorities.xml"/>
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-pass.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-pass.xml"/>
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-code.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-code.xml"/>
|
||||||
<include file="db.changelog/1.0/2025-02-19--0001-terminal.xml"/>
|
<include file="db.changelog/1.0/2025-02-19--0001-terminal.xml"/>
|
||||||
|
<include file="db.changelog/1.0/2025-02-19--0001-pass-terminal.xml"/>
|
||||||
|
<include file="db.changelog/1.0/2025-02-19--0001-pass-users.xml"/>
|
||||||
|
<include file="db.changelog/1.0/2025-02-19--0001-code-terminal.xml"/>
|
||||||
|
|
||||||
|
<include file="db.changelog/data/2025-02-19--0001-users-data.xml"/>
|
||||||
<include file="db.changelog/data/2025-02-19--0001-employee-data.xml"/>
|
|
||||||
<include file="db.changelog/data/2025-02-19--0001-authority-data.xml"/>
|
<include file="db.changelog/data/2025-02-19--0001-authority-data.xml"/>
|
||||||
<include file="db.changelog/data/2025-02-19--0001-employee-authorities-data.xml"/>
|
<include file="db.changelog/data/2025-02-19--0001-users-authorities-data.xml"/>
|
||||||
<include file="db.changelog/data/2025-02-19--0001-credentials-data.xml"/>
|
<include file="db.changelog/data/2025-02-19--0001-credentials-data.xml"/>
|
||||||
<include file="db.changelog/data/2025-02-19--0001-pass-data.xml"/>
|
<include file="db.changelog/data/2025-02-19--0001-pass-data.xml"/>
|
||||||
<include file="db.changelog/data/2025-02-19--0001-code-data.xml"/>
|
<include file="db.changelog/data/2025-02-19--0001-code-data.xml"/>
|
||||||
<include file="db.changelog/data/2025-02-19--0001-terminal-data.xml"/>
|
<include file="db.changelog/data/2025-02-19--0001-terminal-data.xml"/>
|
||||||
|
<include file="db.changelog/data/2025-02-19--0001-pass-users-data.xml"/>
|
||||||
|
<include file="db.changelog/data/2025-02-19--0001-pass-terminal-data.xml"/>
|
||||||
|
<include file="db.changelog/data/2025-02-19--0001-code-terminal-data.xml"/>
|
||||||
|
|
||||||
|
<include file="db.changelog/1.0/2025-02-19--0001-users-is-card-blocked.xml"/>
|
||||||
|
<include file="db.changelog/data/2025-02-19--0001-users-is-card-blocked-data.xml"/>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
Loading…
x
Reference in New Issue
Block a user