Data changed; Added visitType to Visit entity
This commit is contained in:
parent
6a4676ae11
commit
6aa09857f8
@ -3,6 +3,7 @@ package com.displaynone.acss.components.acs;
|
|||||||
import com.displaynone.acss.components.acs.models.gate.GateModel;
|
import com.displaynone.acss.components.acs.models.gate.GateModel;
|
||||||
import com.displaynone.acss.components.acs.models.gate.service.GateService;
|
import com.displaynone.acss.components.acs.models.gate.service.GateService;
|
||||||
import com.displaynone.acss.components.acs.models.visit.VisitModel;
|
import com.displaynone.acss.components.acs.models.visit.VisitModel;
|
||||||
|
import com.displaynone.acss.components.acs.models.visit.VisitType;
|
||||||
import com.displaynone.acss.components.acs.models.visit.service.VisitService;
|
import com.displaynone.acss.components.acs.models.visit.service.VisitService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -66,10 +67,11 @@ public class ACSComponent {
|
|||||||
visitService.createVisit(visit);
|
visitService.createVisit(visit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createVisit(Long userId, Long gateId) {
|
public void createVisit(Long userId, Long gateId, VisitType visitType) {
|
||||||
VisitModel visit = new VisitModel();
|
VisitModel visit = new VisitModel();
|
||||||
visit.setUserId(userId);
|
visit.setUserId(userId);
|
||||||
visit.setGateId(gateId);
|
visit.setGateId(gateId);
|
||||||
|
visit.setVisitType(visitType);
|
||||||
createVisit(visit);
|
createVisit(visit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,5 @@ public class VisitDTO {
|
|||||||
private Long userId;
|
private Long userId;
|
||||||
private Long gateId;
|
private Long gateId;
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
private VisitType visitType;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ public class VisitMapper {
|
|||||||
dto.setUserId(model.getUserId());
|
dto.setUserId(model.getUserId());
|
||||||
dto.setGateId(model.getGateId());
|
dto.setGateId(model.getGateId());
|
||||||
dto.setCreatedAt(model.getCreatedAt());
|
dto.setCreatedAt(model.getCreatedAt());
|
||||||
|
dto.setVisitType(model.getVisitType());
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,8 @@ public class VisitModel {
|
|||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private VisitType visitType;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.displaynone.acss.components.acs.models.visit;
|
||||||
|
|
||||||
|
public enum VisitType {
|
||||||
|
CARD,
|
||||||
|
APP
|
||||||
|
}
|
@ -6,8 +6,10 @@ import com.displaynone.acss.components.acs.models.gate.GateMapper;
|
|||||||
import com.displaynone.acss.components.acs.models.gate.GateModel;
|
import com.displaynone.acss.components.acs.models.gate.GateModel;
|
||||||
import com.displaynone.acss.components.acs.models.visit.VisitDTO;
|
import com.displaynone.acss.components.acs.models.visit.VisitDTO;
|
||||||
import com.displaynone.acss.components.acs.models.visit.VisitMapper;
|
import com.displaynone.acss.components.acs.models.visit.VisitMapper;
|
||||||
|
import com.displaynone.acss.components.acs.models.visit.VisitType;
|
||||||
import com.displaynone.acss.components.auth.AuthComponent;
|
import com.displaynone.acss.components.auth.AuthComponent;
|
||||||
import com.displaynone.acss.components.auth.models.user.UserModel;
|
import com.displaynone.acss.components.auth.models.user.UserModel;
|
||||||
|
import com.displaynone.acss.exception.generics.BadRequestHTTPException;
|
||||||
import com.displaynone.acss.exception.generics.ForbiddenHTTPException;
|
import com.displaynone.acss.exception.generics.ForbiddenHTTPException;
|
||||||
import com.displaynone.acss.exception.generics.NotFoundHTTPException;
|
import com.displaynone.acss.exception.generics.NotFoundHTTPException;
|
||||||
import com.displaynone.acss.utils.GlobalUtils;
|
import com.displaynone.acss.utils.GlobalUtils;
|
||||||
@ -30,13 +32,18 @@ public class ACSController {
|
|||||||
@PostMapping("/open")
|
@PostMapping("/open")
|
||||||
public ResponseEntity<Void> open(@RequestBody OpenRQB body) {
|
public ResponseEntity<Void> open(@RequestBody OpenRQB body) {
|
||||||
Long code = body.getCode();
|
Long code = body.getCode();
|
||||||
|
VisitType visitType = body.getVisitType();
|
||||||
|
|
||||||
|
if (code == null) throw new BadRequestHTTPException("Code not found");
|
||||||
|
if (visitType == null) throw new BadRequestHTTPException("visitType not found");
|
||||||
|
|
||||||
GateModel gate = acsComponent.getGateByCodeStrict(code);
|
GateModel gate = acsComponent.getGateByCodeStrict(code);
|
||||||
if (gate.isACSBlocked()) throw new ForbiddenHTTPException("Specified gate is blocked");
|
if (gate.isACSBlocked()) throw new ForbiddenHTTPException("Specified gate is blocked");
|
||||||
|
|
||||||
UserModel user = (UserModel) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
UserModel user = (UserModel) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||||
if (user.isACSBlocked()) throw new ForbiddenHTTPException("User is blocked");
|
if (user.isACSBlocked()) throw new ForbiddenHTTPException("User is blocked");
|
||||||
|
|
||||||
acsComponent.createVisit(user.getId(), gate.getId());
|
acsComponent.createVisit(user.getId(), gate.getId(), visitType);
|
||||||
|
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
@ -70,6 +77,7 @@ public class ACSController {
|
|||||||
) {
|
) {
|
||||||
Pageable pageable = PageRequest.of(page, size);
|
Pageable pageable = PageRequest.of(page, size);
|
||||||
if (!acsComponent.isGateExists(gateId)) throw new NotFoundHTTPException("Gate not found");
|
if (!acsComponent.isGateExists(gateId)) throw new NotFoundHTTPException("Gate not found");
|
||||||
|
if (!acsComponent.isGateExists(gateId)) throw new NotFoundHTTPException("Gate not found");
|
||||||
return ResponseEntity.ok(acsComponent.getVisitsByGateIdPaginated(gateId, pageable).map(VisitMapper::convertToDTO));
|
return ResponseEntity.ok(acsComponent.getVisitsByGateIdPaginated(gateId, pageable).map(VisitMapper::convertToDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.displaynone.acss.controllers.acs;
|
package com.displaynone.acss.controllers.acs;
|
||||||
|
|
||||||
|
import com.displaynone.acss.components.acs.models.visit.VisitType;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OpenRQB {
|
public class OpenRQB {
|
||||||
private Long code;
|
private Long code;
|
||||||
|
private VisitType visitType;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
<column name="created_at" type="DATETIME" defaultValueDate="${now}">
|
<column name="created_at" type="DATETIME" defaultValueDate="${now}">
|
||||||
<constraints nullable="false" />
|
<constraints nullable="false" />
|
||||||
</column>
|
</column>
|
||||||
|
<column name="visit_type" type="VARCHAR(100)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addForeignKeyConstraint baseTableName="visits"
|
<addForeignKeyConstraint baseTableName="visits"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
login;name;photo;position;password;is_active;isacsblocked
|
login;name;photo;position;password;is_active;isacsblocked
|
||||||
user;Default User;https://wiki.i-edu.ru/mediawiki/images/thumb/1/19/Иван.png/600px-Иван.png;Software Engineer;$2a$12$CUo06gR1qTWC9JB2o1HnXuTK2U5yLIdCPprVWgY8jdB9l.xhbAoQK;1;0
|
user;Default User;https://wiki.i-edu.ru/mediawiki/images/thumb/1/19/Иван.png/600px-Иван.png;Software Engineer;$2a$12$GYcNHy6K8OGPQgM/sof9JOiKB9rjIIzf5fQIqYUAtAmu5ARd9dypG;1;0
|
||||||
admin;Admin User;https://app2.elevate-holistics.com/assets/no-profile/no-profile-0.jpg;Product Manager;$2a$12$e0djVwP9MBeFd9aZia33W.u1Yiq3gDpVNECXn7I.KgvjPr0eoeWwS;1;0
|
admin;Admin User;https://app2.elevate-holistics.com/assets/no-profile/no-profile-0.jpg;Product Manager;$2a$12$AJaVAsSLFtmdsZbgeJLko.y.SW6EQR3K9Lf9QOWYtJcTsIt4Nn8jK;1;0
|
||||||
bob_jones;Bob Jones;https://png.klev.club/uploads/posts/2024-06/thumbs/png-klev-club-sy5u-p-znachok-devushka-png-20.png;QA Engineer;$2a$12$b//P422i15PDoij6g4SOluIUol7X3E0eFttGMGlGCJuBmZFE6nMw.;1;0
|
bob_jones;Bob Jones;https://png.klev.club/uploads/posts/2024-06/thumbs/png-klev-club-sy5u-p-znachok-devushka-png-20.png;QA Engineer;$2a$12$b//P422i15PDoij6g4SOluIUol7X3E0eFttGMGlGCJuBmZFE6nMw.;1;0
|
||||||
alice_johnson;Alice Johnson;https://wiki.i-edu.ru/mediawiki/images/thumb/1/19/Иван.png/600px-Иван.png;UX Designer;$2a$12$b//P422i15PDoij6g4SOluIUol7X3E0eFttGMGlGCJuBmZFE6nMw.;1;0
|
alice_johnson;Alice Johnson;https://wiki.i-edu.ru/mediawiki/images/thumb/1/19/Иван.png/600px-Иван.png;UX Designer;$2a$12$b//P422i15PDoij6g4SOluIUol7X3E0eFttGMGlGCJuBmZFE6nMw.;1;0
|
||||||
charlie_brown;Charlie Brown;https://png.klev.club/uploads/posts/2024-06/thumbs/png-klev-club-sy5u-p-znachok-devushka-png-20.png;DevOps Engineer;$2a$12$b//P422i15PDoij6g4SOluIUol7X3E0eFttGMGlGCJuBmZFE6nMw.;1;0
|
charlie_brown;Charlie Brown;https://png.klev.club/uploads/posts/2024-06/thumbs/png-klev-club-sy5u-p-znachok-devushka-png-20.png;DevOps Engineer;$2a$12$b//P422i15PDoij6g4SOluIUol7X3E0eFttGMGlGCJuBmZFE6nMw.;1;0
|
||||||
|
|
@ -1,51 +1,51 @@
|
|||||||
user_id;gate_id;created_at
|
user_id;gate_id;created_at;visit_type
|
||||||
1;1;2023-10-01 08:00:00
|
1;1;2023-10-01 08:00:00;APP
|
||||||
2;2;2023-10-01 09:15:00
|
2;2;2023-10-01 09:15:00;CARD
|
||||||
3;3;2023-10-01 10:30:00
|
3;3;2023-10-01 10:30:00;APP
|
||||||
4;4;2023-10-01 11:45:00
|
4;4;2023-10-01 11:45:00;CARD
|
||||||
5;5;2023-10-01 12:00:00
|
5;5;2023-10-01 12:00:00;CARD
|
||||||
1;2;2023-10-01 13:15:00
|
1;2;2023-10-01 13:15:00;APP
|
||||||
2;3;2023-10-01 14:30:00
|
2;3;2023-10-01 14:30:00;APP
|
||||||
3;4;2023-10-01 15:45:00
|
3;4;2023-10-01 15:45:00;CARD
|
||||||
4;5;2023-10-01 16:00:00
|
4;5;2023-10-01 16:00:00;CARD
|
||||||
5;1;2023-10-01 17:15:00
|
5;1;2023-10-01 17:15:00;APP
|
||||||
1;3;2023-10-02 08:30:00
|
1;3;2023-10-02 08:30:00;CARD
|
||||||
2;4;2023-10-02 09:45:00
|
2;4;2023-10-02 09:45:00;CARD
|
||||||
3;5;2023-10-02 10:00:00
|
3;5;2023-10-02 10:00:00;APP
|
||||||
4;1;2023-10-02 11:15:00
|
4;1;2023-10-02 11:15:00;APP
|
||||||
5;2;2023-10-02 12:30:00
|
5;2;2023-10-02 12:30:00;CARD
|
||||||
1;4;2023-10-02 13:45:00
|
1;4;2023-10-02 13:45:00;CARD
|
||||||
2;5;2023-10-02 14:00:00
|
2;5;2023-10-02 14:00:00;APP
|
||||||
3;1;2023-10-02 15:15:00
|
3;1;2023-10-02 15:15:00;APP
|
||||||
4;2;2023-10-02 16:30:00
|
4;2;2023-10-02 16:30:00;APP
|
||||||
5;3;2023-10-02 17:45:00
|
5;3;2023-10-02 17:45:00;CARD
|
||||||
1;5;2023-10-03 08:00:00
|
1;5;2023-10-03 08:00:00;CARD
|
||||||
2;1;2023-10-03 09:15:00
|
2;1;2023-10-03 09:15:00;CARD
|
||||||
3;2;2023-10-03 10:30:00
|
3;2;2023-10-03 10:30:00;CARD
|
||||||
4;3;2023-10-03 11:45:00
|
4;3;2023-10-03 11:45:00;CARD
|
||||||
5;4;2023-10-03 12:00:00
|
5;4;2023-10-03 12:00:00;CARD
|
||||||
1;1;2023-10-03 13:15:00
|
1;1;2023-10-03 13:15:00;APP
|
||||||
2;2;2023-10-03 14:30:00
|
2;2;2023-10-03 14:30:00;APP
|
||||||
3;3;2023-10-03 15:45:00
|
3;3;2023-10-03 15:45:00;APP
|
||||||
4;4;2023-10-03 16:00:00
|
4;4;2023-10-03 16:00:00;APP
|
||||||
5;5;2023-10-03 17:15:00
|
5;5;2023-10-03 17:15:00;APP
|
||||||
1;2;2023-10-04 08:30:00
|
1;2;2023-10-04 08:30:00;CARD
|
||||||
2;3;2023-10-04 09:45:00
|
2;3;2023-10-04 09:45:00;CARD
|
||||||
3;4;2023-10-04 10:00:00
|
3;4;2023-10-04 10:00:00;CARD
|
||||||
4;5;2023-10-04 11:15:00
|
4;5;2023-10-04 11:15:00;CARD
|
||||||
5;1;2023-10-04 12:30:00
|
5;1;2023-10-04 12:30:00;APP
|
||||||
1;3;2023-10-04 13:45:00
|
1;3;2023-10-04 13:45:00;APP
|
||||||
2;4;2023-10-04 14:00:00
|
2;4;2023-10-04 14:00:00;APP
|
||||||
3;5;2023-10-04 15:15:00
|
3;5;2023-10-04 15:15:00;APP
|
||||||
4;1;2023-10-04 16:30:00
|
4;1;2023-10-04 16:30:00;CARD
|
||||||
5;2;2023-10-04 17:45:00
|
5;2;2023-10-04 17:45:00;CARD
|
||||||
1;4;2023-10-05 08:00:00
|
1;4;2023-10-05 08:00:00;APP
|
||||||
2;5;2023-10-05 09:15:00
|
2;5;2023-10-05 09:15:00;APP
|
||||||
3;1;2023-10-05 10:30:00
|
3;1;2023-10-05 10:30:00;APP
|
||||||
4;2;2023-10-05 11:45:00
|
4;2;2023-10-05 11:45:00;CARD
|
||||||
5;3;2023-10-05 12:00:00
|
5;3;2023-10-05 12:00:00;CARD
|
||||||
1;5;2023-10-05 13:15:00
|
1;5;2023-10-05 13:15:00;CARD
|
||||||
2;1;2023-10-05 14:30:00
|
2;1;2023-10-05 14:30:00;APP
|
||||||
3;2;2023-10-05 15:45:00
|
3;2;2023-10-05 15:45:00;APP
|
||||||
4;3;2023-10-05 16:00:00
|
4;3;2023-10-05 16:00:00;APP
|
||||||
5;4;2023-10-05 17:15:00
|
5;4;2023-10-05 17:15:00;APP
|
|
Loading…
x
Reference in New Issue
Block a user