Коммит на 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.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication()
|
||||
public class App {
|
||||
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.Configuration;
|
||||
@ -18,4 +18,4 @@ public class SwaggerConfig {
|
||||
.paths(PathSelectors.any())
|
||||
.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 org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.support.ErrorPageFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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.web.builders.HttpSecurity;
|
||||
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.password.PasswordEncoder;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
|
||||
|
||||
@Configuration
|
||||
@ -28,16 +25,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.csrf().disable()
|
||||
|
||||
.authorizeRequests()
|
||||
.antMatchers("/h2-console/**").permitAll()
|
||||
.antMatchers("/api/employees/register").permitAll()
|
||||
.antMatchers("/api/employees/{username}").permitAll()
|
||||
.antMatchers("/api/employees/paginated").permitAll()
|
||||
.antMatchers("/api/employees/unoccupied").permitAll()
|
||||
.antMatchers("/api/users/register").permitAll()
|
||||
.antMatchers("/api/users/username/{username}").permitAll()
|
||||
.antMatchers("/api/users/paginated").permitAll()
|
||||
.antMatchers("/api/users/login").permitAll()
|
||||
.antMatchers("/api/authority/").permitAll()
|
||||
.antMatchers("/api/employees/**").hasAnyAuthority("ROLE_USER", "ROLE_ADMIN")
|
||||
.antMatchers("/api/employees/login").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.httpBasic()
|
||||
@ -52,7 +46,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.passwordEncoder(passwordEncoder());
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
@ -1,4 +1,5 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.entity.Authority;
|
||||
import com.example.nto.service.AuthorityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -30,12 +31,12 @@ public class AuthorityController {
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<String> idRole(@PathVariable Long id) {
|
||||
public ResponseEntity<String> login(@PathVariable Long id) {
|
||||
String idn = authorityService.isAdmin(id);
|
||||
if (Objects.equals(idn, "ROLE_ADMIN")) {
|
||||
return ResponseEntity.ok("Является администратором");}
|
||||
return ResponseEntity.ok("is Admin");}
|
||||
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;
|
||||
|
||||
import com.example.nto.entity.Code;
|
||||
import com.example.nto.entity.Employee;
|
||||
import com.example.nto.dto.CodeDTO;
|
||||
import com.example.nto.entity.Users;
|
||||
import com.example.nto.service.CodeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class CodeController {
|
||||
|
||||
private final CodeService codeService;
|
||||
|
||||
@PatchMapping("/api/{username}/open")
|
||||
public Employee update(@PathVariable String username, @RequestBody Code newCode) {
|
||||
// return codeService.openDoor(username, newCode.getValue());
|
||||
return null;
|
||||
//TODO Service доделать и открыть тут коммент
|
||||
@PatchMapping("/api/open")
|
||||
public Optional<Users> update(Authentication authentication, @RequestBody CodeDTO newCode) {
|
||||
String username = authentication.getName();
|
||||
return codeService.openDoor(username, newCode.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
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.TerminalService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
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.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@RestController
|
||||
@ -20,14 +25,29 @@ import java.util.List;
|
||||
public class PassController {
|
||||
|
||||
private final PassService passService;
|
||||
private final UsersRepository usersRepository;
|
||||
|
||||
@GetMapping("/paginated/")
|
||||
public ResponseEntity<List<PassDTO>> getAllPassesAtUser(
|
||||
@RequestParam long userId,
|
||||
@RequestParam(required = false) String username,
|
||||
@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);
|
||||
return ResponseEntity.ok(passService.getAllPassesPaginated(pageable, userId));
|
||||
return ResponseEntity.ok(passService.getAllPassesPaginated(pageable, username));
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.dto.CredentialsDTO;
|
||||
import com.example.nto.dto.TerminalDTO;
|
||||
import com.example.nto.service.CredentialsService;
|
||||
import com.example.nto.service.TerminalService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@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
|
||||
public class AuthorityDTO {
|
||||
|
||||
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
|
||||
public class CredentialsDTO {
|
||||
|
||||
private long id;
|
||||
private String login;
|
||||
private String hashedPassword;
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.example.nto.dto;
|
||||
|
||||
import com.example.nto.entity.Terminal;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class PassDTO {
|
||||
private long id;
|
||||
private long employee;
|
||||
private LocalDateTime localDateTime;
|
||||
private long terminal;
|
||||
private Terminal terminal;
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.example.nto.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class TerminalDTO {
|
||||
private long id;
|
||||
|
@ -8,4 +8,5 @@ public class UserRegisterDTO {
|
||||
private String password;
|
||||
private String name;
|
||||
private String lastname;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,15 +5,14 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class EmployeeDTO {
|
||||
public class UsersDTO {
|
||||
|
||||
private long id;
|
||||
private String username;
|
||||
private String name;
|
||||
private String password;
|
||||
private long authority_id;
|
||||
private long credentials;
|
||||
private String photo;
|
||||
private String position;
|
||||
private Boolean isCardBlocked;
|
||||
private LocalDateTime lastVisit;
|
||||
|
||||
}
|
@ -1,28 +1,19 @@
|
||||
package com.example.nto.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "Authority")
|
||||
@Table(name = "authority")
|
||||
public class Authority implements GrantedAuthority {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@Column(name = "authority")
|
||||
private String authority;
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.example.nto.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -17,6 +18,10 @@ public class Code {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
@ManyToOne
|
||||
@JoinColumn(name="terminal")
|
||||
@JsonIgnore
|
||||
private Terminal terminal;
|
||||
@Column(name = "value")
|
||||
private long value;
|
||||
}
|
||||
|
@ -19,4 +19,7 @@ public class Credentials {
|
||||
@Column(name = "hashed_password")
|
||||
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 lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@ -16,9 +15,9 @@ public class Pass {
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "employee")
|
||||
@JoinColumn(name = "users")
|
||||
@JsonIgnore
|
||||
private Employee employee;
|
||||
private Users users;
|
||||
|
||||
@Column(name = "time")
|
||||
private LocalDateTime time;
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.example.nto.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.example.nto.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
@ -16,11 +13,8 @@ import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "Employee")
|
||||
public class Employee implements UserDetails {
|
||||
@Table(name = "users")
|
||||
public class Users implements UserDetails {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
@ -42,18 +36,20 @@ public class Employee implements UserDetails {
|
||||
private String photo;
|
||||
@Column(name = "position")
|
||||
private String position;
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
private Set<Authority> authorities;
|
||||
@Column(name = "lastVisit")
|
||||
private LocalDateTime lastVisit;
|
||||
@Column(name = "iscardblocked")
|
||||
private Boolean isCardBlocked;
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
@ -74,4 +70,5 @@ public class Employee implements UserDetails {
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,4 +4,4 @@ public class PersonAlreadyExistsException extends RuntimeException {
|
||||
public PersonAlreadyExistsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ public class PersonNotFoundException extends RuntimeException {
|
||||
public PersonNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ public class RoleisNotAdmin extends RuntimeException {
|
||||
public RoleisNotAdmin(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.example.nto.exception.handler;
|
||||
|
||||
|
||||
import com.example.nto.exception.PersonAlreadyExistsException;
|
||||
import com.example.nto.exception.PersonNotFoundException;
|
||||
import com.example.nto.exception.RoleisNotAdmin;
|
||||
@ -11,16 +10,19 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(RoleisNotAdmin.class)
|
||||
public ResponseEntity<String> handleRoleisNotAdmin(RoleisNotAdmin e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(PersonNotFoundException.class)
|
||||
public ResponseEntity<String> handlePersonNotFound(PersonNotFoundException e) {
|
||||
public ResponseEntity<String> handlePersonNotFoundException(PersonNotFoundException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@ExceptionHandler(PersonAlreadyExistsException.class)
|
||||
public ResponseEntity<String> handlePersonAlreadyExists(PersonAlreadyExistsException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_GATEWAY);
|
||||
public ResponseEntity<String> handlePersonAlreadyExistsException(PersonAlreadyExistsException e) {
|
||||
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;
|
||||
|
||||
import com.example.nto.dto.AuthorityDTO;
|
||||
import com.example.nto.entity.Authority;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@ -10,4 +9,4 @@ import java.util.Optional;
|
||||
@Repository
|
||||
public interface AuthorityRepository extends JpaRepository<Authority, Long> {
|
||||
Optional<Authority> findByAuthority(String Authority);
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,15 @@ package com.example.nto.repository;
|
||||
|
||||
import com.example.nto.entity.Code;
|
||||
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 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
|
||||
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;
|
||||
|
||||
import com.example.nto.entity.Pass;
|
||||
import com.example.nto.entity.Terminal;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
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();
|
||||
|
||||
String isAdmin(Long id);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.example.nto.service;
|
||||
|
||||
|
||||
import com.example.nto.entity.Employee;
|
||||
import com.example.nto.entity.Users;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CodeService {
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
import com.example.nto.dto.PassDTO;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public interface PassService {
|
||||
List<PassDTO> getPassAtUser(long id);
|
||||
|
||||
|
||||
List<PassDTO> getAllPassesPaginated(Pageable pageable, long id);
|
||||
List<PassDTO> getAllPassesPaginated(Pageable pageable, String username);
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
|
||||
package com.example.nto.service;
|
||||
|
||||
import com.example.nto.dto.CredentialsDTO;
|
||||
import com.example.nto.dto.TerminalDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface TerminalService {
|
||||
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) {
|
||||
|
||||
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
|
||||
public List<Authority> getAll() {
|
||||
@ -33,4 +35,4 @@ public class AuthorityServiceImpl implements AuthorityService {
|
||||
|
||||
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.repository.CredentialsRepository;
|
||||
import com.example.nto.service.CredentialsService;
|
||||
import com.example.nto.utils.CredentialsMapper;
|
||||
import com.example.nto.util.CredentialsMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -64,4 +64,4 @@ public class CredentialsServiceImpl implements CredentialsService {
|
||||
public void deleteCredentials(Long 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.repository.PassRepository;
|
||||
import com.example.nto.service.PassService;
|
||||
import com.example.nto.utils.PassMapper;
|
||||
import com.example.nto.util.PassMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -22,14 +22,16 @@ public class PassServiceImpl implements PassService {
|
||||
@Override
|
||||
public List<PassDTO> getPassAtUser(long id) {
|
||||
return passRepository.findAll().stream()
|
||||
.filter(pass -> pass.getEmployee().toString().equals(id))
|
||||
.filter(pass -> pass.getUsers().getId() == id)
|
||||
.map(PassMapper::convertDTO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public List<PassDTO> getAllPassesPaginated(Pageable pageable, long id) {
|
||||
return passRepository.findAll(pageable)
|
||||
.filter(pass -> pass.getEmployee().toString().equals(id))
|
||||
.map(PassMapper::convertDTO).toList();
|
||||
public List<PassDTO> getAllPassesPaginated(Pageable pageable, String username) {
|
||||
return passRepository.findAll(pageable).stream()
|
||||
.filter(pass -> Objects.equals(pass.getUsers().getUsername(), username))
|
||||
.map(PassMapper::convertDTO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +1,14 @@
|
||||
package com.example.nto.service.impl;
|
||||
|
||||
import com.example.nto.dto.CredentialsDTO;
|
||||
import com.example.nto.dto.TerminalDTO;
|
||||
import com.example.nto.entity.Credentials;
|
||||
import com.example.nto.entity.Terminal;
|
||||
import com.example.nto.repository.CredentialsRepository;
|
||||
import com.example.nto.repository.TerminalRepository;
|
||||
import com.example.nto.service.CredentialsService;
|
||||
import com.example.nto.service.TerminalService;
|
||||
import com.example.nto.utils.CredentialsMapper;
|
||||
import com.example.nto.utils.TerminalMapper;
|
||||
import com.example.nto.util.TerminalMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.example.nto.service.impl;
|
||||
|
||||
import com.example.nto.entity.Employee;
|
||||
import com.example.nto.repository.EmployeeRepository;
|
||||
import com.example.nto.entity.Users;
|
||||
import com.example.nto.repository.UsersRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@ -14,14 +14,14 @@ import java.util.Optional;
|
||||
@RequiredArgsConstructor
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
private final EmployeeRepository employeeRepository;
|
||||
private final UsersRepository usersRepository;
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
||||
Optional<Employee> optionalUsers = employeeRepository.findByUsername(s);
|
||||
Optional<Users> optionalUsers = usersRepository.findByUsername(s);
|
||||
|
||||
if(optionalUsers.isEmpty()) {
|
||||
throw new UsernameNotFoundException("User not found");
|
||||
}
|
||||
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;
|
||||
import com.example.nto.entity.Authority;
|
||||
package com.example.nto.util;
|
||||
|
||||
import com.example.nto.dto.AuthorityDTO;
|
||||
import com.example.nto.entity.Authority;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class AuthorityMapper {
|
||||
public static AuthorityDTO convertDTO(Authority role) {
|
||||
AuthorityDTO authorityDTO = new AuthorityDTO();
|
||||
authorityDTO.setId(role.getId());
|
||||
authorityDTO.setAuthority(role.getAuthority());
|
||||
return authorityDTO;
|
||||
AuthorityDTO rolesDTO = new AuthorityDTO();
|
||||
rolesDTO.setId(role.getId());
|
||||
rolesDTO.setName(role.getAuthority());
|
||||
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.entity.Authority;
|
||||
import com.example.nto.entity.Credentials;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@ -15,4 +13,4 @@ public class CredentialsMapper {
|
||||
credentialsDTO.setHashedPassword(credentials.getHashedPassword());
|
||||
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 lombok.experimental.UtilityClass;
|
||||
|
||||
|
||||
@UtilityClass
|
||||
public class PassMapper {
|
||||
public static PassDTO convertDTO(Pass pass) {
|
||||
PassDTO passDTO = new PassDTO();
|
||||
passDTO.setId(pass.getId());
|
||||
if (pass.getEmployee() != null) {
|
||||
passDTO.setEmployee(pass.getEmployee().getId());
|
||||
}
|
||||
|
||||
passDTO.setLocalDateTime(pass.getTime());
|
||||
if (pass.getTerminal() != null) {
|
||||
passDTO.setTerminal(pass.getTerminal().getId());
|
||||
passDTO.setTerminal(pass.getTerminal());
|
||||
}
|
||||
|
||||
|
||||
|
||||
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:
|
||||
url: jdbc:h2:mem:testdb
|
||||
|
||||
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
@ -18,9 +17,4 @@ spring:
|
||||
generate-ddl: false
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
show-sql: true
|
||||
|
||||
spring-doc:
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
operationsSorter: method
|
||||
show-sql: true
|
@ -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 name="value" type="INT">
|
||||
</column>
|
||||
<column name="terminal" type="INT">
|
||||
</column>
|
||||
|
||||
</createTable>
|
||||
</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">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="employee" type="INT">
|
||||
<column name="users" type="BIGINT">
|
||||
</column>
|
||||
<column name="time" type="TIMESTAMP">
|
||||
</column>
|
||||
<column name="terminal" type="INT">
|
||||
<column name="terminal" type="BIGINT">
|
||||
</column>
|
||||
|
||||
</createTable>
|
||||
|
@ -6,13 +6,13 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||
|
||||
<changeSet id="2025-02-02--0001-employee-authorities" author="IgraM">
|
||||
<createTable tableName="employee_authorities">
|
||||
<changeSet id="2025-02-02--0001-users-authorities" author="IgraM">
|
||||
<createTable tableName="users_authorities">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="employee_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_userauth_usr" referencedTableName="employee"
|
||||
<column name="users_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_userauth_usr" referencedTableName="users"
|
||||
referencedColumnNames="id"/>
|
||||
</column>
|
||||
<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
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0001-employee" author="IgraM">
|
||||
<createTable tableName="employee">
|
||||
<changeSet id="2025-02-19--0001-users" author="IgraM">
|
||||
<createTable tableName="users">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
@ -23,6 +23,9 @@
|
||||
</column>
|
||||
<column name="last_visit" type="TIMESTAMP">
|
||||
</column>
|
||||
<column name="iscardblocked" type="BOOLEAN">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="username" type="VARCHAR(100)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
@ -5,12 +5,12 @@
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||
<preConditions onFail="WARN">
|
||||
<not>
|
||||
<tableExists tableName="employee_authorities"/>
|
||||
<tableExists tableName="code_terminal"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<changeSet id="2025-02-19--0001-employee-authorities-data" author="IgraM">
|
||||
<loadData tableName="employee_authorities"
|
||||
file="db.changelog/data/csv/2025-02-19--0001-employee-authorities-data.csv"
|
||||
<changeSet id="2025-02-19--0001-code-terminal-data" author="IgraM">
|
||||
<loadData tableName="code_terminal"
|
||||
file="db.changelog/data/csv/2025-02-19--0001-code-terminal-data.csv"
|
||||
separator=";"
|
||||
encoding="UTF-8"/>
|
||||
</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">
|
||||
<preConditions onFail="WARN">
|
||||
<not>
|
||||
<tableExists tableName="code"/>
|
||||
<tableExists tableName="terminal"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<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">
|
||||
<preConditions onFail="WARN">
|
||||
<not>
|
||||
<tableExists tableName="employee"/>
|
||||
<tableExists tableName="users"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<changeSet id="2025-02-19--0001-employee-data" author="IgraM">
|
||||
<loadData tableName="employee"
|
||||
file="db.changelog/data/csv/2025-02-19--0001-employee-data.csv"
|
||||
<changeSet id="2025-02-19--0001-users-data" author="IgraM">
|
||||
<loadData tableName="users"
|
||||
file="db.changelog/data/csv/2025-02-19--0001-users-data.csv"
|
||||
separator=";"
|
||||
encoding="UTF-8"/>
|
||||
</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
|
||||
123456789
|
||||
123456789
|
||||
123456789
|
||||
123456789
|
||||
123456789
|
||||
value;terminal
|
||||
123456789;2
|
||||
1234567891;1
|
||||
1234567892;1
|
||||
1234567893;2
|
||||
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
|
||||
1;2023-05-29T10:15:30
|
||||
2;2021-05-29T10:15:30
|
||||
3;2022-05-29T10:15:30
|
||||
4;2025-05-29T10:15:30
|
||||
users;time;terminal
|
||||
1;2023-05-29T10:15:30;1
|
||||
2;2021-05-29T10:15:30;2
|
||||
3;2022-05-29T10:15:30;2
|
||||
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
|
||||
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-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-code.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-employee-data.xml"/>
|
||||
<include file="db.changelog/data/2025-02-19--0001-users-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-pass-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-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>
|
Loading…
x
Reference in New Issue
Block a user