Ласт точка на 19.02.2025. Добавлено: Basic Spring Security, Liquibase. Осталось доделать: пагинация, вход по хеадеру
This commit is contained in:
parent
96a39edcbe
commit
4f17ffeca8
6
pom.xml
6
pom.xml
@ -25,7 +25,11 @@
|
|||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.liquibase</groupId>
|
||||||
|
<artifactId>liquibase-core</artifactId>
|
||||||
|
<version>4.27.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
@ -28,10 +28,11 @@ 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/employees/register").permitAll()
|
||||||
.antMatchers("/api/employees/{login}").permitAll()
|
.antMatchers("/api/employees/{username}").permitAll()
|
||||||
.antMatchers("/api/employees/paginated").permitAll()
|
.antMatchers("/api/employees/paginated").permitAll()
|
||||||
.antMatchers("/api/employees/unoccupied").permitAll()
|
.antMatchers("/api/employees/unoccupied").permitAll()
|
||||||
.antMatchers("/api/authority/").permitAll()
|
.antMatchers("/api/authority/").permitAll()
|
||||||
|
@ -12,9 +12,9 @@ public class CodeController {
|
|||||||
|
|
||||||
private final CodeService codeService;
|
private final CodeService codeService;
|
||||||
|
|
||||||
@PatchMapping("/api/{login}/open")
|
@PatchMapping("/api/{username}/open")
|
||||||
public Employee update(@PathVariable String login, @RequestBody Code newCode) {
|
public Employee update(@PathVariable String username, @RequestBody Code newCode) {
|
||||||
// return codeService.openDoor(login, newCode.getValue());
|
// return codeService.openDoor(username, newCode.getValue());
|
||||||
return null;
|
return null;
|
||||||
//TODO Service доделать и открыть тут коммент
|
//TODO Service доделать и открыть тут коммент
|
||||||
}
|
}
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
package com.example.nto.controller;
|
|
||||||
|
|
||||||
import com.example.nto.dto.CredentialsDTO;
|
|
||||||
import com.example.nto.service.CredentialsService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/credentials")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class CredentialsController {
|
|
||||||
|
|
||||||
private final CredentialsService credentialsService;
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public List<CredentialsDTO> getAllCredentials() {
|
|
||||||
return credentialsService.getAllCredentials();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public ResponseEntity<CredentialsDTO> getCredentialsById(@PathVariable long id) {
|
|
||||||
return ResponseEntity.ok(credentialsService.getCredentialsById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
public ResponseEntity<CredentialsDTO> createCredentials(@RequestBody CredentialsDTO dto) {
|
|
||||||
return ResponseEntity.ok(credentialsService.createCredentials(dto));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public ResponseEntity<CredentialsDTO> updateCredentials(@PathVariable long id, @RequestBody CredentialsDTO dto) {
|
|
||||||
return ResponseEntity.ok(credentialsService.updateCredentials(id, dto));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public ResponseEntity<Void> deleteCredentials(@PathVariable long id) {
|
|
||||||
credentialsService.deleteCredentials(id);
|
|
||||||
return ResponseEntity.noContent().build();
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,10 +19,10 @@ public class EmployeeController {
|
|||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{login}")
|
@GetMapping("/{username}")
|
||||||
@ResponseStatus(HttpStatus.OK)
|
@ResponseStatus(HttpStatus.OK)
|
||||||
public ResponseEntity<String> findByLogin(@PathVariable String login) {
|
public ResponseEntity<String> findByUsername(@PathVariable String username) {
|
||||||
if (employeeService.findExistByLogin(login)) {
|
if (employeeService.findExistByUsername(username)) {
|
||||||
return ResponseEntity.ok("Done");
|
return ResponseEntity.ok("Done");
|
||||||
} else return ResponseEntity.badRequest().body("User is not found");
|
} else return ResponseEntity.badRequest().body("User is not found");
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import java.time.LocalDateTime;
|
|||||||
@Data
|
@Data
|
||||||
public class EmployeeDTO {
|
public class EmployeeDTO {
|
||||||
private long id;
|
private long id;
|
||||||
private String login;
|
private String username;
|
||||||
private String name;
|
private String name;
|
||||||
private String password;
|
private String password;
|
||||||
private long authority_id;
|
private long authority_id;
|
||||||
|
@ -4,7 +4,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class UserRegisterDTO {
|
public class UserRegisterDTO {
|
||||||
private String login;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
private String name;
|
private String name;
|
||||||
private String lastname;
|
private String lastname;
|
||||||
|
@ -24,8 +24,8 @@ public class Employee implements UserDetails {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private long id;
|
private long id;
|
||||||
@Column(name = "login")
|
@Column(name = "username")
|
||||||
private String login;
|
private String username;
|
||||||
@Column(name = "name")
|
@Column(name = "name")
|
||||||
private String name;
|
private String name;
|
||||||
@Column(name = "password")
|
@Column(name = "password")
|
||||||
|
@ -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 login);
|
Optional<Credentials> findByLogin(String username);
|
||||||
}
|
}
|
@ -10,11 +10,8 @@ import java.util.Optional;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
||||||
|
|
||||||
@Query("select e from Employee e where e.login = ?1")
|
Optional<Employee> findByUsername(String username);
|
||||||
Optional<Employee> findByLogin(String login);
|
|
||||||
@Query("select e from Employee e where e.id = ?1")
|
|
||||||
Employee findById(long id);
|
Employee findById(long id);
|
||||||
@Query("select count(e) = 1 from Employee e where login = ?1")
|
Boolean findExistByUsername(String username);
|
||||||
Boolean findExistByLogin(String login);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ import java.util.Optional;
|
|||||||
public interface CodeService {
|
public interface CodeService {
|
||||||
|
|
||||||
Boolean findExistByValue(Long value);
|
Boolean findExistByValue(Long value);
|
||||||
Optional<Employee> openDoor(String login, Long value);
|
Optional<Employee> openDoor(String username, Long value);
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,15 @@ import java.util.Optional;
|
|||||||
public interface EmployeeService {
|
public interface EmployeeService {
|
||||||
|
|
||||||
Employee updateEmployee(long id, Employee newEmployee);
|
Employee updateEmployee(long id, Employee newEmployee);
|
||||||
Optional<Employee> findByLogin(String login);
|
Optional<Employee> findByUsername(String username);
|
||||||
|
|
||||||
EmployeeDTO findById(Long id);
|
EmployeeDTO findById(Long id);
|
||||||
|
|
||||||
boolean findExistByLogin(String login);
|
boolean findExistByUsername(String username);
|
||||||
|
|
||||||
EmployeeDTO createUser(UserRegisterDTO dto);
|
EmployeeDTO createUser(UserRegisterDTO dto);
|
||||||
|
|
||||||
EmployeeDTO getUserByUsername(String login);
|
EmployeeDTO getUserByUsername(String username);
|
||||||
|
|
||||||
EmployeeDTO get(String name);
|
EmployeeDTO get(String name);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class EmployeeCodeServiceImpl implements EmployeeService, CodeService {
|
|||||||
|
|
||||||
Employee employee = optionalEmployee.get();
|
Employee employee = optionalEmployee.get();
|
||||||
employee.setName(newEmployee.getName());
|
employee.setName(newEmployee.getName());
|
||||||
employee.setLogin(newEmployee.getUsername());
|
employee.setUsername(newEmployee.getUsername());
|
||||||
employee.setPhoto(newEmployee.getPhoto());
|
employee.setPhoto(newEmployee.getPhoto());
|
||||||
employee.setPosition(newEmployee.getPosition());
|
employee.setPosition(newEmployee.getPosition());
|
||||||
employee.setLastVisit(newEmployee.getLastVisit());
|
employee.setLastVisit(newEmployee.getLastVisit());
|
||||||
@ -50,11 +50,11 @@ public class EmployeeCodeServiceImpl implements EmployeeService, CodeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Employee> findByLogin(String login) {
|
public Optional<Employee> findByUsername(String username) {
|
||||||
if (employeeRepository.findExistByLogin(login))
|
if (employeeRepository.findExistByUsername(username))
|
||||||
return employeeRepository.findByLogin(login);
|
return employeeRepository.findByUsername(username);
|
||||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
||||||
"There is no account with login " + login + " or it is incorrect");
|
"There is no account with login " + username + " or it is incorrect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,17 +67,17 @@ public class EmployeeCodeServiceImpl implements EmployeeService, CodeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean findExistByLogin(String login) {
|
public boolean findExistByUsername(String username) {
|
||||||
if (employeeRepository.findExistByLogin(login))
|
if (employeeRepository.findExistByUsername(username))
|
||||||
throw new ResponseStatusException(HttpStatus.OK, "Login is existing, processing");
|
throw new ResponseStatusException(HttpStatus.OK, "Login is existing, processing");
|
||||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
||||||
"There is no account with login " + login + " or it is incorrect");
|
"There is no account with login " + username + " or it is incorrect");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Employee> openDoor(String login, Long value) {
|
public Optional<Employee> openDoor(String username, Long value) {
|
||||||
// if (findByLogin(login) != null && findExistByValue(value)) {
|
// if (findByLogin(login) != null && findExistByValue(value)) {
|
||||||
// Optional<Employee> employee = findByLogin(login);
|
// Optional<Employee> employee = findByLogin(login);
|
||||||
// employee.ifPresent(employee1 -> employee1.setLastVisit(LocalDateTime.now()));
|
// employee.ifPresent(employee1 -> employee1.setLastVisit(LocalDateTime.now()));
|
||||||
@ -106,11 +106,11 @@ public class EmployeeCodeServiceImpl implements EmployeeService, CodeService {
|
|||||||
|
|
||||||
if (roleUser.isEmpty()) throw new RuntimeException("Roles not found");
|
if (roleUser.isEmpty()) throw new RuntimeException("Roles not found");
|
||||||
Credentials credentials = new Credentials();
|
Credentials credentials = new Credentials();
|
||||||
credentials.setLogin(dto.getLogin());
|
credentials.setLogin(dto.getUsername());
|
||||||
credentials.setHashedPassword(passwordEncoder.encode(dto.getPassword()));
|
credentials.setHashedPassword(passwordEncoder.encode(dto.getPassword()));
|
||||||
Credentials credentialSave = credentialsRepository.save(credentials);
|
Credentials credentialSave = credentialsRepository.save(credentials);
|
||||||
Employee employee = new Employee();
|
Employee employee = new Employee();
|
||||||
employee.setLogin(dto.getLogin());
|
employee.setUsername(dto.getUsername());
|
||||||
employee.setName(dto.getName());
|
employee.setName(dto.getName());
|
||||||
employee.setPassword(passwordEncoder.encode(dto.getPassword()));
|
employee.setPassword(passwordEncoder.encode(dto.getPassword()));
|
||||||
employee.setCredentials(credentials);
|
employee.setCredentials(credentials);
|
||||||
@ -122,12 +122,12 @@ public class EmployeeCodeServiceImpl implements EmployeeService, CodeService {
|
|||||||
return EmployeeMapper.convertDTO(savedUser);
|
return EmployeeMapper.convertDTO(savedUser);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public EmployeeDTO getUserByUsername(String login) {
|
public EmployeeDTO getUserByUsername(String username) {
|
||||||
System.out.println(login);
|
System.out.println(username);
|
||||||
Optional<Employee> optionalUsers = employeeRepository.findByLogin(login);
|
Optional<Employee> optionalUsers = employeeRepository.findByUsername(username);
|
||||||
System.out.println(optionalUsers);
|
System.out.println(optionalUsers);
|
||||||
if (optionalUsers.isEmpty()) {
|
if (optionalUsers.isEmpty()) {
|
||||||
throw new PersonNotFoundException("User with username " + login + "not found");
|
throw new PersonNotFoundException("User with username " + username + "not found");
|
||||||
}
|
}
|
||||||
return EmployeeMapper.convertDTO(optionalUsers.get());
|
return EmployeeMapper.convertDTO(optionalUsers.get());
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
private final EmployeeRepository employeeRepository;
|
private final EmployeeRepository employeeRepository;
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
||||||
Optional<Employee> optionalUsers = employeeRepository.findByLogin(s);
|
Optional<Employee> optionalUsers = employeeRepository.findByUsername(s);
|
||||||
|
|
||||||
if(optionalUsers.isEmpty()) {
|
if(optionalUsers.isEmpty()) {
|
||||||
throw new UsernameNotFoundException("User not found");
|
throw new UsernameNotFoundException("User not found");
|
||||||
|
@ -10,7 +10,7 @@ public class EmployeeMapper {
|
|||||||
public static EmployeeDTO convertDTO(Employee user) {
|
public static EmployeeDTO convertDTO(Employee user) {
|
||||||
EmployeeDTO employeeDTO = new EmployeeDTO();
|
EmployeeDTO employeeDTO = new EmployeeDTO();
|
||||||
employeeDTO.setId(user.getId());
|
employeeDTO.setId(user.getId());
|
||||||
employeeDTO.setLogin(user.getLogin());
|
employeeDTO.setUsername(user.getUsername());
|
||||||
employeeDTO.setName(user.getName());
|
employeeDTO.setName(user.getName());
|
||||||
if (user.getAuthority() != null) {
|
if (user.getAuthority() != null) {
|
||||||
employeeDTO.setAuthority_id(user.getAuthority().getId());
|
employeeDTO.setAuthority_id(user.getAuthority().getId());
|
||||||
|
@ -1,27 +1,25 @@
|
|||||||
spring:
|
spring:
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:h2:mem:testdb
|
url: jdbc:h2:mem:testdb
|
||||||
|
|
||||||
|
|
||||||
h2:
|
h2:
|
||||||
console:
|
console:
|
||||||
#enabled: false
|
|
||||||
enabled: true
|
enabled: true
|
||||||
|
path: /h2-console
|
||||||
|
settings:
|
||||||
|
web-allow-others: true
|
||||||
|
|
||||||
|
liquibase:
|
||||||
|
enabled: true
|
||||||
|
change-log: classpath:db.changelog/db.changelog-master.xml
|
||||||
|
|
||||||
jpa:
|
jpa:
|
||||||
#generate-ddl: false
|
generate-ddl: false
|
||||||
generate-ddl: true
|
|
||||||
|
|
||||||
hibernate:
|
hibernate:
|
||||||
#ddl-auto: none
|
ddl-auto: none
|
||||||
ddl-auto: create-drop
|
|
||||||
|
|
||||||
# Показываем запросы
|
|
||||||
show-sql: true
|
show-sql: true
|
||||||
|
|
||||||
# Своевременный запуск data.sql
|
|
||||||
defer-datasource-initialization: true
|
|
||||||
|
|
||||||
spring-doc:
|
spring-doc:
|
||||||
swagger-ui:
|
swagger-ui:
|
||||||
path: /swagger-ui.html
|
path: /swagger-ui.html
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
INSERT into credentials (login, hashed_password)
|
|
||||||
VALUES
|
|
||||||
('pivanov','$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e'),
|
|
||||||
('ipetrov','$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e'),
|
|
||||||
('asemenov','$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e'),
|
|
||||||
('afedorov','$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e');
|
|
||||||
INSERT INTO employee (login, credentials, name, password, photo, position, last_visit)
|
|
||||||
VALUES
|
|
||||||
('pivanov', 1, 'Иванов Петр Федорович', '$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e', 'https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg', 'Разработчик', '2024-02-12T08:30'),
|
|
||||||
('ipetrov', 2, 'Петров Иван Константинович', '$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e', 'https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg', 'Аналитик', '2024-02-13T08:35'),
|
|
||||||
('asemenov', 3, 'Семенов Анатолий Анатольевич', '$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e', 'https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg', 'Разработчик', '2024-02-13T08:31'),
|
|
||||||
('afedorov', 4, 'Федоров Александр Сергеевич', '$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e', 'https://funnyducks.ru/upload/iblock/0cd/0cdeb7ec3ed6fddda0f90fccee05557d.jpg', 'Тестировщик', '2024-02-12T08:36');
|
|
||||||
|
|
||||||
INSERT INTO code (value)
|
|
||||||
VALUES
|
|
||||||
(1234567890123456789),
|
|
||||||
(9223372036854775807),
|
|
||||||
(1122334455667788990),
|
|
||||||
(998877665544332211),
|
|
||||||
(5566778899001122334);
|
|
||||||
|
|
||||||
INSERT into authority (authority)
|
|
||||||
VALUES
|
|
||||||
('ROlE_USER'),
|
|
||||||
('ROLE_ADMIN');
|
|
||||||
|
|
||||||
UPDATE employee SET authority_id = (1);
|
|
||||||
|
|
||||||
|
|
||||||
INSERT into terminal (type, name)
|
|
||||||
VALUES
|
|
||||||
('qr', 'name1'),
|
|
||||||
('nfc', 'name2');
|
|
||||||
INSERT into pass (employee, time)
|
|
||||||
VALUES
|
|
||||||
('1', '2023-05-29T10:15:30'),
|
|
||||||
('2', '2021-05-29T10:15:30'),
|
|
||||||
('3', '2022-05-29T10:15:30'),
|
|
||||||
('4', '2025-05-29T10:15:30');
|
|
||||||
|
|
||||||
UPDATE pass SET terminal = (1);
|
|
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<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-authority" author="IgraM">
|
||||||
|
<createTable tableName="authority">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="authority" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<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" author="IgraM">
|
||||||
|
<createTable tableName="code">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="value" type="INT">
|
||||||
|
</column>
|
||||||
|
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<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-credentials" author="IgraM">
|
||||||
|
<createTable tableName="credentials">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="login" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="hashed_password" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</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-02--0001-employee-authorities" author="IgraM">
|
||||||
|
<createTable tableName="employee_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"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="authorities_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_userauth_authority" referencedTableName="authority"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<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-employee" author="IgraM">
|
||||||
|
<createTable tableName="employee">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="authority_id" type="INT">
|
||||||
|
</column>
|
||||||
|
<column name="credentials" type="INT">
|
||||||
|
</column>
|
||||||
|
<column name="name" type="VARCHAR(100)">
|
||||||
|
</column>
|
||||||
|
<column name="photo" type="VARCHAR(100)">
|
||||||
|
</column>
|
||||||
|
<column name="position" type="VARCHAR(100)">
|
||||||
|
</column>
|
||||||
|
<column name="last_visit" type="TIMESTAMP">
|
||||||
|
</column>
|
||||||
|
<column name="username" type="VARCHAR(100)">
|
||||||
|
<constraints nullable="false" unique="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="password" type="VARCHAR(100)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<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" author="IgraM">
|
||||||
|
<createTable tableName="pass">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="employee" type="INT">
|
||||||
|
</column>
|
||||||
|
<column name="time" type="TIMESTAMP">
|
||||||
|
</column>
|
||||||
|
<column name="terminal" type="INT">
|
||||||
|
</column>
|
||||||
|
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<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-terminal" author="IgraM">
|
||||||
|
<createTable tableName="terminal">
|
||||||
|
<column name="id" type="BIGINT" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="type" type="VARCHAR(100)">
|
||||||
|
</column>
|
||||||
|
<column name="name" type="VARCHAR(100)">
|
||||||
|
</column>
|
||||||
|
|
||||||
|
</createTable>
|
||||||
|
</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="authority"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-authority-data" author="IgraM">
|
||||||
|
<loadData tableName="authority"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-authority-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="code"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-code-data" author="IgraM">
|
||||||
|
<loadData tableName="code"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-code-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="credentials"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-credentials-data" author="IgraM">
|
||||||
|
<loadData tableName="credentials"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-credentials-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="employee_authorities"/>
|
||||||
|
</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"
|
||||||
|
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="employee"/>
|
||||||
|
</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"
|
||||||
|
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"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-pass-data" author="IgraM">
|
||||||
|
<loadData tableName="pass"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-pass-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="code"/>
|
||||||
|
</not>
|
||||||
|
</preConditions>
|
||||||
|
<changeSet id="2025-02-19--0001-terminal-data" author="IgraM">
|
||||||
|
<loadData tableName="terminal"
|
||||||
|
file="db.changelog/data/csv/2025-02-19--0001-terminal-data.csv"
|
||||||
|
separator=";"
|
||||||
|
encoding="UTF-8"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,3 @@
|
|||||||
|
authority
|
||||||
|
ROLE_USER
|
||||||
|
ROLE_ADMIN
|
|
@ -0,0 +1,6 @@
|
|||||||
|
value
|
||||||
|
123456789
|
||||||
|
123456789
|
||||||
|
123456789
|
||||||
|
123456789
|
||||||
|
123456789
|
|
@ -0,0 +1,5 @@
|
|||||||
|
login;hashed_password
|
||||||
|
pivanov;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e
|
||||||
|
ipetrov;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e
|
||||||
|
asemenov;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e
|
||||||
|
afedorov;$2a$10$mq/UrB0MPG6.Fw2h.4gRauGYa7Zy37dveEU3U1mn22oHxCK7km24e
|
|
@ -0,0 +1,5 @@
|
|||||||
|
employee_id;authorities_id
|
||||||
|
1;1
|
||||||
|
2;1
|
||||||
|
3;1
|
||||||
|
4;2
|
|
@ -0,0 +1,5 @@
|
|||||||
|
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;Тестировщик
|
|
@ -0,0 +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
|
|
@ -0,0 +1,3 @@
|
|||||||
|
type;name
|
||||||
|
qr;name1
|
||||||
|
nfc;name2
|
|
24
src/main/resources/db.changelog/db.changelog-master.xml
Normal file
24
src/main/resources/db.changelog/db.changelog-master.xml
Normal file
@ -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.8.xsd">
|
||||||
|
|
||||||
|
<include file="db.changelog/1.0/2025-02-19--0001-employee.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-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/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-employee-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"/>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
Loading…
x
Reference in New Issue
Block a user