Merge pull request 'develop' (#4) from develop into master
Reviewed-on: #4
This commit is contained in:
commit
26d69afad0
@ -28,6 +28,9 @@ public class App {
|
||||
Если при запуске появляется ошибка связанная с длиной чего-то, то надо тыкнуть на кнопку с надписью App,
|
||||
перейти в Edit Configurations -> modify options -> Shorten command line -> ниже надписи Build and Run
|
||||
будет Shorten command line -> выбираем JAR manifest.
|
||||
|
||||
ipconfig /all
|
||||
Надо искать IPv4-адрес внизу списка
|
||||
*/
|
||||
|
||||
SpringApplication.run(App.class, args);
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.dto.entity.employee.EmployeeCreateDTO;
|
||||
import com.example.nto.dto.entity.employee.EmployeeDTO;
|
||||
import com.example.nto.service.EmployeeService;
|
||||
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
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("api/v1/authorization")
|
||||
public class AuthorizationController {
|
||||
private final EmployeeService employeeService;
|
||||
|
||||
@GetMapping("/login")
|
||||
public ResponseEntity<EmployeeDTO> login(Authentication authentication) {
|
||||
return ResponseEntity.ok(employeeService.getByEmail(authentication.getName()));
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public ResponseEntity<EmployeeDTO> registerEmployee(@RequestBody EmployeeCreateDTO employeeCreateDTO) {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(employeeService.create(employeeCreateDTO));
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.dto.entity.employee.EmployeeDTO;
|
||||
import com.example.nto.dto.entity.employee.EmployeeItemDTO;
|
||||
import com.example.nto.service.EmployeeService;
|
||||
import com.example.nto.service.PhotoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("api/v1/employees")
|
||||
public class EmployeeController {
|
||||
private final EmployeeService employeeService;
|
||||
private final PhotoService photoService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<EmployeeItemDTO>> getAll() {
|
||||
return ResponseEntity.ok(employeeService.getAll());
|
||||
}
|
||||
|
||||
@GetMapping("/working/{isWorking}")
|
||||
public ResponseEntity<List<EmployeeItemDTO>> getAllWorking(@PathVariable boolean isWorking) {
|
||||
return ResponseEntity.ok(employeeService.getWorkingEmployee(isWorking));
|
||||
}
|
||||
|
||||
@GetMapping("/{employeeId}")
|
||||
public ResponseEntity<EmployeeDTO> getEmployeeById(@PathVariable long employeeId) {
|
||||
return ResponseEntity.ok(employeeService.getById(employeeId));
|
||||
}
|
||||
|
||||
@GetMapping("/email/{email}")
|
||||
public ResponseEntity<EmployeeDTO> getEmployeeByEmail(@PathVariable String email) {
|
||||
return ResponseEntity.ok(employeeService.getByEmail(email));
|
||||
}
|
||||
|
||||
@GetMapping("/telephone/{telephone}")
|
||||
public ResponseEntity<EmployeeDTO> getEmployeeByTelephone(@PathVariable String telephone) {
|
||||
return ResponseEntity.ok(employeeService.getByTelephone(telephone));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<EmployeeDTO> updateEmployee(@PathVariable long employeeId, @RequestBody EmployeeDTO employeeDTO) {
|
||||
return ResponseEntity.ok(employeeService.update(employeeId, employeeDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<EmployeeDTO> deleteEmployeeById(@PathVariable long employeeId) {
|
||||
employeeService.delete(employeeId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@PatchMapping("/image/profile/{id}")
|
||||
public ResponseEntity<Void> patchImageProfile(@PathVariable long employeeId, @RequestBody byte[] photo) {
|
||||
String imageUrl = photoService.uploadProfilePhoto(employeeId, photo);
|
||||
employeeService.patchProfileImage(employeeId, imageUrl);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@PatchMapping("/block/{id}/{blockStatus}")
|
||||
public ResponseEntity<Void> patchImageProfile(@PathVariable long employeeId, @PathVariable boolean blockStatus) {
|
||||
employeeService.patchBlockEmployee(employeeId, blockStatus);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.dto.entity.OfficeDTO;
|
||||
import com.example.nto.service.OfficeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("api/v1/offices")
|
||||
public class OfficeController {
|
||||
private final OfficeService officeService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<OfficeDTO>> getAll() {
|
||||
return ResponseEntity.ok(officeService.getAllOffice());
|
||||
}
|
||||
|
||||
@GetMapping("/sorted/distance")
|
||||
public ResponseEntity<List<OfficeDTO>> getAllSortedByDistance(
|
||||
@RequestParam(name = "latitude") double latitude,
|
||||
@RequestParam(name = "longitude") double longitude
|
||||
) {
|
||||
return ResponseEntity.ok(officeService.getAllSortedDistance(latitude, longitude));
|
||||
}
|
||||
|
||||
@GetMapping("/{officeId}")
|
||||
public ResponseEntity<OfficeDTO> getById(@PathVariable long officeId) {
|
||||
return ResponseEntity.ok(officeService.getById(officeId));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<OfficeDTO> createOffice(@RequestBody OfficeDTO officeDTO) {
|
||||
return ResponseEntity.ok(officeService.create(officeDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/{officeId}")
|
||||
public ResponseEntity<OfficeDTO> updateOffice(@PathVariable long officeId, @RequestBody OfficeDTO officeDTO) {
|
||||
return ResponseEntity.ok(officeService.update(officeId, officeDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{officeId}")
|
||||
public ResponseEntity<Void> deleteOffice(@PathVariable long officeId) {
|
||||
officeService.delete(officeId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.dto.entity.TerminalDTO;
|
||||
import com.example.nto.service.TerminalService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("api/v1/terminals")
|
||||
public class TerminalController {
|
||||
private final TerminalService terminalService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<TerminalDTO>> getAll() {
|
||||
return ResponseEntity.ok(terminalService.getAllTerminal());
|
||||
}
|
||||
|
||||
@GetMapping("/{terminalId}")
|
||||
public ResponseEntity<TerminalDTO> getTerminalById(@PathVariable long terminalId) {
|
||||
return ResponseEntity.ok(terminalService.getById(terminalId));
|
||||
}
|
||||
|
||||
@GetMapping("/check/{code}")
|
||||
public ResponseEntity<TerminalDTO> checkCode(@PathVariable String code) {
|
||||
return ResponseEntity.ok(terminalService.checkCode(code));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<TerminalDTO> createTerminal(@RequestBody TerminalDTO terminalDTO) {
|
||||
return ResponseEntity.ok(terminalService.create(terminalDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/{terminalId}")
|
||||
public ResponseEntity<TerminalDTO> updateTerminal(@PathVariable long terminalId, @RequestBody TerminalDTO terminalDTO) {
|
||||
return ResponseEntity.ok(terminalService.update(terminalId, terminalDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{terminalId}")
|
||||
public ResponseEntity<Void> deleteTerminal(@PathVariable long terminalId) {
|
||||
terminalService.delete(terminalId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.example.nto.controller;
|
||||
|
||||
import com.example.nto.dto.entity.VisitDTO;
|
||||
import com.example.nto.service.VisitService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("api/v1/visits")
|
||||
public class VisitController {
|
||||
private final VisitService visitService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<VisitDTO>> getAll() {
|
||||
return ResponseEntity.ok(visitService.getAll());
|
||||
}
|
||||
|
||||
@GetMapping("/employee/{employeeId}")
|
||||
public ResponseEntity<List<VisitDTO>> getAllVisitByEmployee(@PathVariable long employeeId) {
|
||||
return ResponseEntity.ok(visitService.getAllVisitByEmployee(employeeId));
|
||||
}
|
||||
|
||||
@GetMapping("/{visitId}")
|
||||
public ResponseEntity<VisitDTO> getById(@PathVariable long visitId) {
|
||||
return ResponseEntity.ok(visitService.getById(visitId));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{visitId}")
|
||||
public ResponseEntity<Void> delete(@PathVariable long visitId) {
|
||||
visitService.delete(visitId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@PostMapping("/open/{startTerminalId}/{employeeId}/{passageName}")
|
||||
public ResponseEntity<VisitDTO> open(@PathVariable long employeeId, @PathVariable long startTerminalId, @PathVariable String passageName) {
|
||||
return ResponseEntity.ok(visitService.open(employeeId, startTerminalId, passageName));
|
||||
}
|
||||
|
||||
@PostMapping("/exit/{endTerminalId}/{employeeId}")
|
||||
public ResponseEntity<Void> open(@PathVariable long employeeId, @PathVariable long endTerminalId) {
|
||||
visitService.exit(employeeId, endTerminalId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -86,7 +87,7 @@ public class Employee implements UserDetails {
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@OneToMany(mappedBy = "employee")
|
||||
private List<Visit> visits;
|
||||
private List<Visit> visits = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.example.nto.dto.mappers.employee;
|
||||
|
||||
import com.example.nto.domain.entity.Employee;
|
||||
import com.example.nto.domain.entity.Employee;
|
||||
import com.example.nto.domain.entity.Office;
|
||||
import com.example.nto.domain.entity.Position;
|
||||
import com.example.nto.domain.entity.Role;
|
||||
@ -8,6 +8,8 @@ import com.example.nto.dto.entity.employee.EmployeeCreateDTO;
|
||||
import com.example.nto.utils.Utils;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@UtilityClass
|
||||
public class EmployeeCreateMapper {
|
||||
public static Employee convertFromDTO(
|
||||
@ -27,7 +29,7 @@ public class EmployeeCreateMapper {
|
||||
employee.setRole(role);
|
||||
employee.setProfileImageUrl(Utils.getRandomUrlProfileImage());
|
||||
employee.setBlocked(false);
|
||||
|
||||
employee.setCreatedAt(LocalDateTime.now());
|
||||
return employee;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class EmployeeItemMapper {
|
||||
// todo: Протестировать работу!
|
||||
|
||||
List<Visit> visitsLast30Days = Utils.filterDateLast30Days(employee.getVisits());
|
||||
employeeItemDTO.setVisitStatus(visitsLast30Days.stream().anyMatch(visit -> !visit.isFinished()));
|
||||
employeeItemDTO.setVisitStatus(employee.getVisits().stream().anyMatch(visit -> !visit.isFinished()));
|
||||
|
||||
return employeeItemDTO;
|
||||
}
|
||||
|
5
src/main/java/com/example/nto/service/PhotoService.java
Normal file
5
src/main/java/com/example/nto/service/PhotoService.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.example.nto.service;
|
||||
|
||||
public interface PhotoService {
|
||||
String uploadProfilePhoto(long id, byte[] photo);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.example.nto.service.impl;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.model.AmazonS3Exception;
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||
import com.example.nto.aspect.annotation.LogExample;
|
||||
import com.example.nto.config.ObjectStorageConfig;
|
||||
import com.example.nto.service.PhotoService;
|
||||
import com.example.nto.utils.Utils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PhotoServiceImpl implements PhotoService {
|
||||
private final ObjectStorageConfig objectStorageConfig;
|
||||
|
||||
@Override
|
||||
@LogExample
|
||||
public String uploadProfilePhoto(long id, byte[] photo) {
|
||||
final String url;
|
||||
final String bucketName = objectStorageConfig.getBucketName();
|
||||
final AmazonS3 s3Client = objectStorageConfig.createAmazonS3();
|
||||
|
||||
try {
|
||||
String fileName = Utils.profileFileName(id);
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
metadata.setContentLength(photo.length);
|
||||
|
||||
// Загрузка файла в Yandex Object Storage
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(photo);
|
||||
s3Client.putObject(bucketName, fileName, inputStream, metadata);
|
||||
|
||||
// Получение ссылки на загруженный файл
|
||||
url = s3Client.getUrl(bucketName, fileName).toExternalForm();
|
||||
|
||||
} catch (AmazonS3Exception e) {
|
||||
throw new AmazonS3Exception(e.getMessage());
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
@ -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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0001-roles" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="roles"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<createTable tableName="roles">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="role_name" type="VARCHAR(100)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0002-positions" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="positions"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<createTable tableName="positions">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="name" type="VARCHAR(255)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0003-passages" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="passages"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<createTable tableName="passages">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="passage" type="VARCHAR(255)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,89 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0004-offices" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="offices"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<!--
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@Column(name = "name", unique = true)
|
||||
@NotBlank(message = "Название не может быть пустым!")
|
||||
@Size(max = 100, message = "Максимальная длина названия 100 символов!")
|
||||
private String name;
|
||||
|
||||
@Column(name = "description")
|
||||
@NotBlank(message = "Описание не может быть пустым!")
|
||||
@Size(max = 300, message = "Максимальная длина описания 300 символов!")
|
||||
private String description;
|
||||
|
||||
@Column(name = "address")
|
||||
@NotBlank(message = "Адрес не может быть пустым!")
|
||||
@Size(max = 200, message = "Максимальный размер адреса 200 символов!")
|
||||
private String address;
|
||||
|
||||
@Column(name = "latitude")
|
||||
@NotNull(message = "Широта не может быть пустой!")
|
||||
private Double latitude;
|
||||
|
||||
@Column(name = "longitude")
|
||||
@NotNull(message = "Долгота не может быть пустой!")
|
||||
private Double longitude;
|
||||
|
||||
@Column(name = "logo_image_url")
|
||||
@NotBlank(message = "Путь к логотипу не может быть пустой!")
|
||||
@Size(max = 200, message = "Максимальный размер пути к логотипу 200 символов!")
|
||||
private String linkLogo;
|
||||
|
||||
@Column(name = "telephone")
|
||||
@Size(max = 20, message = "Максимальная длина телефонного номера 20 символов!")
|
||||
private String telephone;
|
||||
|
||||
@Column(name = "email")
|
||||
@Size(max = 255, message = "Максимальная длина email 255 символов")
|
||||
@Email(message = "Email адрес должен быть в формате user@example.com!")
|
||||
private String email;
|
||||
|
||||
@OneToMany(mappedBy = "office")
|
||||
private List<Employee> employeeList;
|
||||
|
||||
@OneToMany(mappedBy = "office")
|
||||
private List<Terminal> terminals;
|
||||
-->
|
||||
|
||||
<createTable tableName="offices">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="name" type="VARCHAR(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="description" type="VARCHAR(255)"/>
|
||||
<column name="address" type="VARCHAR(200)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="latitude" type="DOUBLE PRECISION">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="longitude" type="DOUBLE PRECISION">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="logo_image_url" type="VARCHAR(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="telephone" type="VARCHAR(20)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="email" type="VARCHAR(255)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,30 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0005-terminals" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="terminals"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<createTable tableName="terminals">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="name" type="VARCHAR(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="code" type="VARCHAR(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="office_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_terminals_office"
|
||||
referencedTableName="offices"
|
||||
referencedColumnNames="id"
|
||||
deleteCascade="false" />
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,55 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0006-employees" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="employees"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<createTable tableName="employees">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="name" type="VARCHAR(100)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="surname" type="VARCHAR(100)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="patronymic" type="VARCHAR(100)"/>
|
||||
<column name="about_me" type="VARCHAR(300)"/>
|
||||
<column name="telephone" type="VARCHAR(20)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="email" type="VARCHAR(255)">
|
||||
<constraints nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="password" type="VARCHAR(300)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="office_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_employees_office"
|
||||
referencedTableName="offices"
|
||||
referencedColumnNames="id"
|
||||
deleteCascade="false" />
|
||||
</column>
|
||||
<column name="role_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_volunteer_roles"
|
||||
referencedTableName="roles" referencedColumnNames="id" deleteCascade="false"/>
|
||||
</column>
|
||||
<column name="pos_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_employees_positions"
|
||||
referencedTableName="roles" referencedColumnNames="id" deleteCascade="false"/>
|
||||
</column>
|
||||
<column name="profile_image_url" type="VARCHAR(100)"/>
|
||||
|
||||
<column name="is_blocked" type="BOOLEAN">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="created_at" type="DATETIME" valueDate="current_datetime" defaultValueDate="current_datetime"/>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,43 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0007-visits" author="Petr Rudichev">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="visits"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
|
||||
<createTable tableName="visits">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false" unique="true"/>
|
||||
</column>
|
||||
<column name="employee_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_visits_office"
|
||||
referencedTableName="employees"
|
||||
referencedColumnNames="id"
|
||||
deleteCascade="false" />
|
||||
</column>
|
||||
<column name="start_visit" type="DATETIME" valueDate="current_datetime" defaultValueDate="current_datetime"/>
|
||||
<column name="end_visit" type="DATETIME">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="is_finished" type="BOOLEAN">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="start_terminal_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_employees_start_terminals"
|
||||
referencedTableName="terminals" referencedColumnNames="id" deleteCascade="false"/>
|
||||
</column>
|
||||
<column name="end_terminal_id" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_employees_end_terminals"
|
||||
referencedTableName="terminals" referencedColumnNames="id" deleteCascade="false"/>
|
||||
</column>
|
||||
<column name="type_passage" type="BIGINT">
|
||||
<constraints nullable="false" foreignKeyName="fk_employees_passages"
|
||||
referencedTableName="passages" referencedColumnNames="id" deleteCascade="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0001-roles-data" author="Petr Rudichev">
|
||||
<loadData tableName="roles" file="db.changelog/data/csv/2025-02-19--0001-roles-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0002-positions-data" author="Petr Rudichev">
|
||||
<loadData tableName="positions" file="db.changelog/data/csv/2025-02-19--0002-positions-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0003-passages-data" author="Petr Rudichev">
|
||||
<loadData tableName="passages" file="db.changelog/data/csv/2025-02-19--0003-passages-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0004-offices-data" author="Petr Rudichev">
|
||||
<loadData tableName="offices" file="db.changelog/data/csv/2025-02-19--0004-offices-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0005-terminals-data" author="Petr Rudichev">
|
||||
<loadData tableName="terminals" file="db.changelog/data/csv/2025-02-19--0005-terminals-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0006-employees-data" author="Petr Rudichev">
|
||||
<loadData tableName="employees" file="db.changelog/data/csv/2025-02-19--0006-employees-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,9 @@
|
||||
<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.0.xsd">
|
||||
|
||||
<changeSet id="2025-02-19--0007-visits-data" author="Petr Rudichev">
|
||||
<loadData tableName="visits" file="db.changelog/data/csv/2025-02-19--0007-visits-data.csv"
|
||||
separator=";" quotchar="*" encoding="UTF-8"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,3 @@
|
||||
role_name
|
||||
ROLE_USER
|
||||
ROLE_ADMIN
|
|
@ -0,0 +1,4 @@
|
||||
name
|
||||
Директор
|
||||
Разработчик
|
||||
Дизайнер
|
|
@ -0,0 +1,3 @@
|
||||
passage
|
||||
Карта
|
||||
Телефон
|
|
@ -0,0 +1,2 @@
|
||||
name;description;address;latitude;longitude;logo_image_url;telephone;email
|
||||
Офис в Москве;Любимый офис Владимира Путина;г. Москва;54.31207;48.393951;https://storage.yandexcloud.net/spring-boot-final-nto-bacet/standard/profile--1.jpg;+794145546556;limasov_krut@gmail.com
|
|
@ -0,0 +1,2 @@
|
||||
name;code;office_id
|
||||
Первый считыватель в Москве;313123323232312;1
|
|
@ -0,0 +1,2 @@
|
||||
name;surname;patronymic;about_me;telephone;email;password;office_id;pos_id;role_id;profile_image_url;created_at;is_blocked
|
||||
Иван;Иванович;Иванов;Меня зовут Алексей, и я уже несколько лет занимаюсь волонтерской деятельностью.;+79263321231;example1@gmail.com;$2a$04$NybaY71VUlBaqzmyit2VBOFiJjuz0gO519e8WwVGK4eQkIUctLfgy;1;1;2;https://storage.yandexcloud.net/spring-boot-final-nto-bacet/standard/profile--10.jpg;now;false
|
|
@ -0,0 +1,3 @@
|
||||
employee_id;start_visit;end_visit;is_finished;start_terminal_id;end_terminal_id;type_passage
|
||||
1;now;now;true;1;1;2
|
||||
1;now;null;false;1;1;1
|
|
@ -1,4 +1,21 @@
|
||||
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
||||
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0001-roles.xml" />
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0002-positions.xml" />
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0003-passages.xml" />
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0004-offices.xml" />
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0005-terminals.xml" />
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0006-employees.xml" />
|
||||
<include file="db.changelog/0.0.1/2025-02-19--0007-visits.xml" />
|
||||
|
||||
<include file="db.changelog/data/2025-02-19--0001-roles-data.xml" />
|
||||
<include file="db.changelog/data/2025-02-19--0002-positions-data.xml" />
|
||||
<include file="db.changelog/data/2025-02-19--0003-passages-data.xml" />
|
||||
<include file="db.changelog/data/2025-02-19--0004-offices-data.xml" />
|
||||
<include file="db.changelog/data/2025-02-19--0005-terminals-data.xml" />
|
||||
<include file="db.changelog/data/2025-02-19--0006-employees-data.xml" />
|
||||
<include file="db.changelog/data/2025-02-19--0007-visits-data.xml" />
|
||||
|
||||
</databaseChangeLog>
|
Loading…
x
Reference in New Issue
Block a user