Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
0eab40fb5c | |||
4f4fdb4917 | |||
a32bff5d3a | |||
e2b185804e | |||
a2ff138e7f | |||
a252b18bcf | |||
1b17c56fa9 | |||
4d64662f16 | |||
98c889a0cc | |||
1fbc4460ad |
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
9
.idea/PutBit.iml
Normal file
9
.idea/PutBit.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/PutBit.iml" filepath="$PROJECT_DIR$/.idea/PutBit.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
10
README.md
10
README.md
@ -1,12 +1,2 @@
|
||||
# PutBit
|
||||
|
||||
# Разработка веб-сервиса для приема абитуриентов в вуз
|
||||
|
||||
Данное приложение представляет из себя веб-сервис, который позволит упростить, ускорить и автоматизировать процесс подачи заявления абитуриетов в вуз
|
||||
|
||||
## Что из себя представляет ?
|
||||
Сайт, через который абитуриенты смогут заполнить о себе информацию и подать заявление на поступление
|
||||
|
||||
## Пример
|
||||
|
||||
Примером можно рассматривать данную [систему](https://ulstu.ru/)
|
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
HELP.md
|
||||
data.mv.db
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
|
19
app/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
19
app/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
wrapperVersion=3.3.2
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
|
27
app/pom.xml
27
app/pom.xml
@ -30,6 +30,13 @@
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
@ -54,22 +61,17 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>angus-mail</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -84,5 +86,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@ -1,11 +1,15 @@
|
||||
package putBit.app;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import putBit.app.Timer.myTimer;
|
||||
import putBit.app.services.OrderService;
|
||||
@SpringBootApplication
|
||||
public class AppApplication {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppApplication.class, args);
|
||||
}
|
||||
|
35
app/src/main/java/putBit/app/Timer/Task.java
Normal file
35
app/src/main/java/putBit/app/Timer/Task.java
Normal file
@ -0,0 +1,35 @@
|
||||
package putBit.app.Timer;
|
||||
|
||||
import jakarta.mail.MessagingException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import putBit.app.models.Order;
|
||||
import putBit.app.services.OrderService;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ComponentScan
|
||||
public class Task extends TimerTask {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println("START");
|
||||
orderService.workWithStudents();
|
||||
} catch (MessagingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
47
app/src/main/java/putBit/app/Timer/myTimer.java
Normal file
47
app/src/main/java/putBit/app/Timer/myTimer.java
Normal file
@ -0,0 +1,47 @@
|
||||
package putBit.app.Timer;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.aspectj.weaver.ast.Or;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import putBit.app.services.OrderService;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
|
||||
@Data
|
||||
public final class myTimer {
|
||||
|
||||
private static myTimer INSTANCE;
|
||||
private boolean closed = false;
|
||||
private LocalDateTime date = LocalDateTime.of(2024, Month.DECEMBER,11, 0,0,0);
|
||||
private OrderService orderService;
|
||||
|
||||
private myTimer(OrderService orderService) {
|
||||
this.orderService = orderService;
|
||||
System.out.println("create timer");
|
||||
|
||||
LocalDateTime later = LocalDateTime.now().plusDays(10);
|
||||
Date LaterAsDate = Date.from(later.atZone(ZoneId.systemDefault()).toInstant());
|
||||
this.date = later;
|
||||
new Timer().schedule(new Task(orderService), LaterAsDate);
|
||||
}
|
||||
|
||||
public static myTimer getInstance(OrderService orderService) {
|
||||
if(INSTANCE == null) {
|
||||
INSTANCE = new myTimer(orderService);
|
||||
}
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
public static myTimer getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
}
|
20
app/src/main/java/putBit/app/WebConfiguraion.java
Normal file
20
app/src/main/java/putBit/app/WebConfiguraion.java
Normal file
@ -0,0 +1,20 @@
|
||||
package putBit.app;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import putBit.app.Timer.Task;
|
||||
import putBit.app.Timer.myTimer;
|
||||
import putBit.app.services.OrderService;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("putBit.app.services")
|
||||
class WebConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.AchievementDto;
|
||||
import putBit.app.controllers.Dto.ExamDto;
|
||||
import putBit.app.services.AchievementService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/achievement")
|
||||
public class AchievementsController {
|
||||
|
||||
private final AchievementService achievementService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<AchievementDto> create(@RequestBody AchievementDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new AchievementDto(achievementService.create(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<AchievementDto> update(@RequestBody AchievementDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new AchievementDto(achievementService.update(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<AchievementDto> delete(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new AchievementDto(achievementService.delete(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<AchievementDto>> getAll() {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(achievementService.findAll().stream().map(AchievementDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<AchievementDto> getById(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new AchievementDto(achievementService.findById(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/forUser/{id}")
|
||||
public ResponseEntity<List<AchievementDto>> getForUser(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(achievementService.findByUser(id).stream().map(AchievementDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forUserNot/{id}")
|
||||
public ResponseEntity<List<AchievementDto>> getForUserNot(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(achievementService.findByUserNot(id).stream().map(AchievementDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
129
app/src/main/java/putBit/app/controllers/BenefitController.java
Normal file
129
app/src/main/java/putBit/app/controllers/BenefitController.java
Normal file
@ -0,0 +1,129 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.AchievementDto;
|
||||
import putBit.app.controllers.Dto.BenefitDto;
|
||||
import putBit.app.services.BenefitService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/benefit")
|
||||
public class BenefitController {
|
||||
|
||||
private final BenefitService benefitService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<BenefitDto> create(@RequestBody BenefitDto examDto) {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(new BenefitDto(benefitService.create(examDto)), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<BenefitDto> update(@RequestBody BenefitDto examDto) {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(new BenefitDto(benefitService.update(examDto)), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<BenefitDto> delete(@PathVariable int id) {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(new BenefitDto(benefitService.delete(id)), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<BenefitDto>> getAll() {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(benefitService.findAll().stream().map(BenefitDto::new).toList(), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<BenefitDto> getById(@PathVariable int id) {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(new BenefitDto(benefitService.findById(id)), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/forUser/{id}")
|
||||
public ResponseEntity<List<BenefitDto>> getForUser(@PathVariable int id) {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(benefitService.findByUser(id).stream().map(BenefitDto::new).toList(), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forUserNot/{id}")
|
||||
public ResponseEntity<List<BenefitDto>> getForUserNot(@PathVariable int id) {
|
||||
try {
|
||||
return new ResponseEntity<>
|
||||
(benefitService.findByUserNot(id).stream().map(BenefitDto::new).toList(), HttpStatus.OK);
|
||||
} catch (ValidationException ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
} catch (Exception ex) {
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
41
app/src/main/java/putBit/app/controllers/DateController.java
Normal file
41
app/src/main/java/putBit/app/controllers/DateController.java
Normal file
@ -0,0 +1,41 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.Timer.myTimer;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/date_close")
|
||||
public class DateController {
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<Long> createUser() {
|
||||
try
|
||||
{
|
||||
LocalDateTime date = myTimer.getInstance().getDate();
|
||||
ZonedDateTime zdt = ZonedDateTime.of(date, ZoneId.systemDefault());
|
||||
return new ResponseEntity<Long>(zdt.toInstant().toEpochMilli(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import lombok.*;
|
||||
import putBit.app.models.Achievement;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AchievementDto {
|
||||
|
||||
private int id;
|
||||
|
||||
|
||||
@NonNull
|
||||
private String title ;
|
||||
|
||||
private int points;
|
||||
|
||||
public AchievementDto(Achievement achievement){
|
||||
this.id = achievement.getId();
|
||||
this.title = achievement.getTitle();
|
||||
this.points = achievement.getPoints();
|
||||
}
|
||||
|
||||
}
|
26
app/src/main/java/putBit/app/controllers/Dto/BenefitDto.java
Normal file
26
app/src/main/java/putBit/app/controllers/Dto/BenefitDto.java
Normal file
@ -0,0 +1,26 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import lombok.*;
|
||||
import putBit.app.models.Achievement;
|
||||
import putBit.app.models.Benefit;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BenefitDto {
|
||||
|
||||
private int id;
|
||||
|
||||
|
||||
@NonNull
|
||||
private String title ;
|
||||
|
||||
public BenefitDto(Benefit benefit){
|
||||
this.id = benefit.getId();
|
||||
this.title = benefit.getTitle();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
28
app/src/main/java/putBit/app/controllers/Dto/ExamDto.java
Normal file
28
app/src/main/java/putBit/app/controllers/Dto/ExamDto.java
Normal file
@ -0,0 +1,28 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.*;
|
||||
import putBit.app.models.Exam;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ExamDto {
|
||||
|
||||
private int id;
|
||||
|
||||
|
||||
@NonNull
|
||||
private String title ;
|
||||
|
||||
public ExamDto(Exam exam){
|
||||
this.id = exam.getId();
|
||||
this.title = exam.getTitle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.ExamResult;
|
||||
import putBit.app.models.User;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ExamResultDto {
|
||||
|
||||
|
||||
private int user ;
|
||||
|
||||
|
||||
private int exam ;
|
||||
|
||||
private String title;
|
||||
|
||||
private int points ;
|
||||
|
||||
|
||||
public ExamResultDto(ExamResult examResult){
|
||||
this.user = examResult.getUser().getId();
|
||||
this.exam = examResult.getExam().getId();
|
||||
this.title = examResult.getExam().getTitle();
|
||||
this.points = examResult.getPoints();
|
||||
}
|
||||
|
||||
}
|
58
app/src/main/java/putBit/app/controllers/Dto/OrderDto.java
Normal file
58
app/src/main/java/putBit/app/controllers/Dto/OrderDto.java
Normal file
@ -0,0 +1,58 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.Benefit;
|
||||
import putBit.app.models.Order;
|
||||
import putBit.app.models.Training;
|
||||
import putBit.app.models.User;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderDto {
|
||||
|
||||
private int user;
|
||||
|
||||
private int training;
|
||||
|
||||
private String name = null;
|
||||
|
||||
private String snils = null;
|
||||
|
||||
private int points = 0;
|
||||
|
||||
private Boolean confirm ;
|
||||
|
||||
private Boolean benefit ;
|
||||
|
||||
public OrderDto(Order order){
|
||||
this.user = order.getUser().getId();
|
||||
this.training = order.getTraining().getId();
|
||||
this.name = order.getUser().getName();
|
||||
this.snils = order.getUser().getSnils();
|
||||
|
||||
int sum = 0;
|
||||
for(var exam: order.getUser().getExams())
|
||||
{
|
||||
for(var examT: order.getTraining().getExams())
|
||||
{
|
||||
if(examT.getExam().getId() == exam.getExam().getId())
|
||||
sum+= exam.getPoints();
|
||||
}
|
||||
}
|
||||
for(var ach : order.getUser().getAchievements())
|
||||
{
|
||||
sum+= ach.getPoints();
|
||||
}
|
||||
this.points = sum;
|
||||
|
||||
this.confirm = order.getConfirm();
|
||||
this.benefit = order.getBenefit();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.Training;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TrainingDto {
|
||||
|
||||
private int id;
|
||||
|
||||
private String num ;
|
||||
|
||||
private String title ;
|
||||
|
||||
private String desc ;
|
||||
|
||||
private String prof ;
|
||||
|
||||
private List<String> exams = new ArrayList<>();
|
||||
|
||||
private int basic_places ;
|
||||
|
||||
private int benefit_places ;
|
||||
|
||||
public TrainingDto(Training training){
|
||||
this.id = training.getId();
|
||||
this.title = training.getTitle();
|
||||
this.num = training.getNum();
|
||||
this.desc = training.getDesc();
|
||||
|
||||
if(training.getExams() != null){
|
||||
for(var exam: training.getExams())
|
||||
{
|
||||
this.exams.add(exam.getExam().getTitle() + " (" + exam.getPoints() + "б.)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.prof = training.getProf();
|
||||
this.basic_places = training.getBasic_places();
|
||||
this.benefit_places = training.getBenefit_places();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.TrainingExam;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TrainingExamDto {
|
||||
|
||||
private int training ;
|
||||
|
||||
|
||||
private int exam ;
|
||||
|
||||
private String title = null;
|
||||
|
||||
private int points ;
|
||||
|
||||
public TrainingExamDto(TrainingExam trainingExam){
|
||||
this.training = trainingExam.getTraining().getId();
|
||||
this.exam = trainingExam.getExam().getId();
|
||||
this.title = trainingExam.getExam().getTitle();
|
||||
this.points = trainingExam.getPoints();
|
||||
}
|
||||
|
||||
}
|
41
app/src/main/java/putBit/app/controllers/Dto/UserDto.java
Normal file
41
app/src/main/java/putBit/app/controllers/Dto/UserDto.java
Normal file
@ -0,0 +1,41 @@
|
||||
package putBit.app.controllers.Dto;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.models.enums.Role;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserDto {
|
||||
|
||||
private int id ;
|
||||
|
||||
private String role ;
|
||||
|
||||
private String email;
|
||||
|
||||
private String password ;
|
||||
|
||||
private String againPassword ;
|
||||
|
||||
private String phone ;
|
||||
|
||||
private String name ;
|
||||
|
||||
private String snils ;
|
||||
|
||||
|
||||
public UserDto(User user){
|
||||
this.id = user.getId();
|
||||
this.role = user.getRole().name();
|
||||
this.email = user.getEmail();
|
||||
this.password = user.getPassword();
|
||||
this.phone = user.getPhone();
|
||||
this.name = user.getName();
|
||||
this.snils = user.getSnils();
|
||||
}
|
||||
|
||||
}
|
165
app/src/main/java/putBit/app/controllers/ExamController.java
Normal file
165
app/src/main/java/putBit/app/controllers/ExamController.java
Normal file
@ -0,0 +1,165 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.ExamDto;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.services.ExamService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/exam")
|
||||
public class ExamController {
|
||||
|
||||
private final ExamService examService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<ExamDto> create(@RequestBody ExamDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamDto(examService.create(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<ExamDto> update(@RequestBody ExamDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamDto(examService.update(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<ExamDto> delete(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamDto(examService.delete(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<ExamDto>> getAll() {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(examService.findAll().stream().map(ExamDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ExamDto> getById(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamDto(examService.findById(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forTraining/{id}")
|
||||
public ResponseEntity<List<ExamDto>> getForTraining(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(examService.findNotTraining(id).stream().map(ExamDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forUser/{id}")
|
||||
public ResponseEntity<List<ExamDto>> getForUser(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(examService.findNotUser(id).stream().map(ExamDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.ExamDto;
|
||||
import putBit.app.controllers.Dto.ExamResultDto;
|
||||
import putBit.app.models.ExamResult;
|
||||
import putBit.app.services.ExamResultService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/exam_result")
|
||||
public class ExamResultController {
|
||||
private final ExamResultService examResultService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<ExamResultDto> create(@RequestBody ExamResultDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamResultDto(examResultService.create(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<ExamResultDto> update(@RequestBody ExamResultDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamResultDto(examResultService.update(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{userId}/{examId}")
|
||||
public ResponseEntity<ExamResultDto> delete(@PathVariable int userId, @PathVariable int examId) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamResultDto(examResultService.delete(userId,examId)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/{userId}/{examId}")
|
||||
public ResponseEntity<ExamResultDto> getById(@PathVariable int userId, @PathVariable int examId) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new ExamResultDto(examResultService.findById(userId, examId)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forUser/{id}")
|
||||
public ResponseEntity<List<ExamResultDto>> getForUser(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(examResultService.findByUser(id).stream().map(ExamResultDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
142
app/src/main/java/putBit/app/controllers/OrderController.java
Normal file
142
app/src/main/java/putBit/app/controllers/OrderController.java
Normal file
@ -0,0 +1,142 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.ExamDto;
|
||||
import putBit.app.controllers.Dto.OrderDto;
|
||||
import putBit.app.services.OrderService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/order")
|
||||
public class OrderController {
|
||||
private final OrderService orderService;
|
||||
|
||||
@PostMapping("/{userID}/{trainingId}")
|
||||
public ResponseEntity<OrderDto> create(@PathVariable int userID, @PathVariable int trainingId) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new OrderDto(orderService.create(userID,trainingId)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{userId}")
|
||||
public ResponseEntity<OrderDto> delete(@PathVariable int userId) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new OrderDto(orderService.delete(userId)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/benefit/{id}")
|
||||
public ResponseEntity<List<OrderDto>> getOrderForBenefit(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(orderService.findForBenefit(id).stream().map(OrderDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/basic/{id}")
|
||||
public ResponseEntity<List<OrderDto>> getOrderOfBasic(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(orderService.findForBasic(id).stream().map(OrderDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/search/{id}/{value}")
|
||||
public ResponseEntity<List<OrderDto>> getSearch(@PathVariable int id,@PathVariable String value) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(orderService.findByNameOrSnils(id,value).stream().map(OrderDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forUser/{id}")
|
||||
public ResponseEntity<OrderDto> getByUser(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new OrderDto(orderService.findByUser(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
148
app/src/main/java/putBit/app/controllers/TrainingController.java
Normal file
148
app/src/main/java/putBit/app/controllers/TrainingController.java
Normal file
@ -0,0 +1,148 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.ExamDto;
|
||||
import putBit.app.controllers.Dto.TrainingDto;
|
||||
import putBit.app.services.TrainingService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/training")
|
||||
public class TrainingController {
|
||||
|
||||
private final TrainingService trainingService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<TrainingDto> create(@RequestBody TrainingDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingDto(trainingService.create(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<TrainingDto> update(@RequestBody TrainingDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingDto(trainingService.update(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<TrainingDto> delete(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingDto(trainingService.delete(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<TrainingDto>> getAll() {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(trainingService.findAll().stream().map(TrainingDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<TrainingDto> getById(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingDto(trainingService.findById(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/search/{title}")
|
||||
public ResponseEntity<List<TrainingDto>> search(@PathVariable String title) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(trainingService.findByTitle(title).stream().map(TrainingDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.ExamResultDto;
|
||||
import putBit.app.controllers.Dto.TrainingExamDto;
|
||||
import putBit.app.services.TrainingExamService;
|
||||
import putBit.app.services.TrainingService;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/training_exam")
|
||||
public class TrainingExamController {
|
||||
|
||||
private final TrainingExamService trainingExamService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<TrainingExamDto> create(@RequestBody TrainingExamDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingExamDto(trainingExamService.create(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<TrainingExamDto> update(@RequestBody TrainingExamDto examDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingExamDto(trainingExamService.update(examDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/{trainingId}/{examId}")
|
||||
public ResponseEntity<TrainingExamDto> delete(@PathVariable int trainingId, @PathVariable int examId) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingExamDto(trainingExamService.delete(trainingId,examId)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/{trainingId}/{examId}")
|
||||
public ResponseEntity<TrainingExamDto> getById(@PathVariable int trainingId, @PathVariable int examId) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new TrainingExamDto(trainingExamService.findById(trainingId, examId)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/forTraining/{id}")
|
||||
public ResponseEntity<List<TrainingExamDto>> getForTraining(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(trainingExamService.findByTraining(id).stream().map(TrainingExamDto::new).toList(), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
198
app/src/main/java/putBit/app/controllers/UserController.java
Normal file
198
app/src/main/java/putBit/app/controllers/UserController.java
Normal file
@ -0,0 +1,198 @@
|
||||
package putBit.app.controllers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.services.*;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@CrossOrigin(origins = "http://localhost:8081")
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<UserDto> createUser(@RequestBody UserDto userDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.create(userDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/achievement/{user}/{achievement}")
|
||||
public ResponseEntity<UserDto> addAchievement(@PathVariable int user, @PathVariable int achievement) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.addAchievement(user,achievement)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/benefit/{user}/{benefit}")
|
||||
public ResponseEntity<UserDto> addBenefit(@PathVariable int user, @PathVariable int benefit) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.addBenefit(user,benefit)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/achievement/{user}/{achievement}")
|
||||
public ResponseEntity<UserDto> removeAchievement(@PathVariable int user, @PathVariable int achievement) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.removeAchievement(user,achievement)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/benefit/{user}/{benefit}")
|
||||
public ResponseEntity<UserDto> removeBenefit(@PathVariable int user, @PathVariable int benefit) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.removeBenefit(user,benefit)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/{email}/{password}")
|
||||
public ResponseEntity<UserDto> auth(@PathVariable String email, @PathVariable String password) {
|
||||
try
|
||||
{
|
||||
UserDto userDto = UserDto.builder()
|
||||
.email(email)
|
||||
.password(password)
|
||||
.build();
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.auth(userDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException | EntityNotFoundException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PutMapping("/")
|
||||
public ResponseEntity<UserDto> update(@RequestBody UserDto userDto) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.update(userDto)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<UserDto> getById(@PathVariable int id) {
|
||||
try
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(new UserDto(userService.findById(id)), HttpStatus.OK);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseEntity<>
|
||||
(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
31
app/src/main/java/putBit/app/models/Achievement.java
Normal file
31
app/src/main/java/putBit/app/models/Achievement.java
Normal file
@ -0,0 +1,31 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "achievements")
|
||||
public class Achievement {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
|
||||
|
||||
@Column(name = "title", unique = true, nullable = false, length = 20)
|
||||
private String title ;
|
||||
|
||||
@Column(name = "points", nullable = false, length = 3)
|
||||
private int points ;
|
||||
|
||||
@ManyToMany(mappedBy = "achievements")
|
||||
List<User> users;
|
||||
}
|
28
app/src/main/java/putBit/app/models/Benefit.java
Normal file
28
app/src/main/java/putBit/app/models/Benefit.java
Normal file
@ -0,0 +1,28 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "benefits")
|
||||
public class Benefit {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
|
||||
|
||||
@Column(name = "title", unique = true,nullable = false, length = 20)
|
||||
private String title ;
|
||||
|
||||
@ManyToMany(mappedBy = "benefits")
|
||||
List<User> users;
|
||||
}
|
32
app/src/main/java/putBit/app/models/Exam.java
Normal file
32
app/src/main/java/putBit/app/models/Exam.java
Normal file
@ -0,0 +1,32 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "exams")
|
||||
public class Exam {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
|
||||
|
||||
@Column(name = "title", unique = true, nullable = false, length = 20)
|
||||
private String title ;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.REMOVE, mappedBy = "exam")
|
||||
List<ExamResult> users;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.REMOVE, mappedBy = "exam")
|
||||
List<TrainingExam> trainings;
|
||||
}
|
31
app/src/main/java/putBit/app/models/ExamResult.java
Normal file
31
app/src/main/java/putBit/app/models/ExamResult.java
Normal file
@ -0,0 +1,31 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.PrimaryKey.ExamResultPK;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@IdClass(ExamResultPK.class)
|
||||
@Entity(name = "exam_results")
|
||||
public class ExamResult {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private User user ;
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "exam_id", nullable = false)
|
||||
private Exam exam ;
|
||||
|
||||
@Column(name = "points", nullable = false,unique = false, length = 3)
|
||||
private int points ;
|
||||
|
||||
}
|
35
app/src/main/java/putBit/app/models/Order.java
Normal file
35
app/src/main/java/putBit/app/models/Order.java
Normal file
@ -0,0 +1,35 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import putBit.app.models.PrimaryKey.OrderPK;
|
||||
import putBit.app.models.PrimaryKey.TrainingExamPK;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@IdClass(OrderPK.class)
|
||||
@Entity(name = "orders")
|
||||
public class Order {
|
||||
|
||||
@Id
|
||||
@OneToOne
|
||||
@JoinColumn(name = "user_id", unique = true,nullable = false)
|
||||
private User user;
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "training_id",nullable = false)
|
||||
private Training training;
|
||||
|
||||
@Column(name = "confirm", columnDefinition = "boolean",nullable = false)
|
||||
private Boolean confirm ;
|
||||
|
||||
@Column(name = "benefit", columnDefinition = "boolean",nullable = false)
|
||||
private Boolean benefit ;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package putBit.app.models.PrimaryKey;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ExamResultPK implements Serializable {
|
||||
|
||||
private int user;
|
||||
|
||||
private int exam;
|
||||
|
||||
|
||||
}
|
21
app/src/main/java/putBit/app/models/PrimaryKey/OrderPK.java
Normal file
21
app/src/main/java/putBit/app/models/PrimaryKey/OrderPK.java
Normal file
@ -0,0 +1,21 @@
|
||||
package putBit.app.models.PrimaryKey;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderPK implements Serializable {
|
||||
|
||||
private int user;
|
||||
|
||||
private int training;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package putBit.app.models.PrimaryKey;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.Training;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TrainingExamPK implements Serializable {
|
||||
|
||||
private int training;
|
||||
|
||||
private int exam;
|
||||
|
||||
|
||||
}
|
47
app/src/main/java/putBit/app/models/Training.java
Normal file
47
app/src/main/java/putBit/app/models/Training.java
Normal file
@ -0,0 +1,47 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "trainings")
|
||||
public class Training {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
|
||||
@Column(name = "num", unique = true, nullable = false, length = 11)
|
||||
private String num ;
|
||||
|
||||
@Column(name = "title", unique = true, nullable = false, length = 50)
|
||||
private String title ;
|
||||
|
||||
@Column(name = "desc", nullable = false, length = 300)
|
||||
private String desc ;
|
||||
|
||||
@Column(name = "prof", nullable = false, length = 300)
|
||||
private String prof ;
|
||||
|
||||
@Column(name = "basic_places", nullable = false, length = 3)
|
||||
private int basic_places ;
|
||||
|
||||
@Column(name = "benefit_places", nullable = false, length = 3)
|
||||
private int benefit_places ;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.REMOVE, mappedBy = "training")
|
||||
List<TrainingExam> exams;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, mappedBy = "training")
|
||||
List<Order> orders;
|
||||
|
||||
}
|
32
app/src/main/java/putBit/app/models/TrainingExam.java
Normal file
32
app/src/main/java/putBit/app/models/TrainingExam.java
Normal file
@ -0,0 +1,32 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.PrimaryKey.TrainingExamPK;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@IdClass(TrainingExamPK.class)
|
||||
@Entity(name = "training_exams")
|
||||
public class TrainingExam {
|
||||
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "training_id", nullable = false)
|
||||
private Training training ;
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "exam_id", nullable = false)
|
||||
private Exam exam ;
|
||||
|
||||
@Column(name = "points", nullable = false, length = 3)
|
||||
private int points ;
|
||||
|
||||
}
|
100
app/src/main/java/putBit/app/models/User.java
Normal file
100
app/src/main/java/putBit/app/models/User.java
Normal file
@ -0,0 +1,100 @@
|
||||
package putBit.app.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.enums.Role;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "users")
|
||||
public class User {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "role", nullable = false)
|
||||
private Role role;
|
||||
|
||||
@Column(name = "email", nullable = false)
|
||||
private String email;
|
||||
|
||||
@Column(name = "password", nullable = false, length = 20)
|
||||
private String password;
|
||||
|
||||
@Column(name = "phone", length = 12)
|
||||
private String phone;
|
||||
|
||||
|
||||
@Column(name = "name", nullable = false, length = 80)
|
||||
private String name;
|
||||
|
||||
@Column(name = "snils", unique = true, length = 11)
|
||||
private String snils;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name = "user_achievements",
|
||||
joinColumns = @JoinColumn(name = "user_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "achievements_id"))
|
||||
Set<Achievement> achievements;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name = "user_benefits",
|
||||
joinColumns = @JoinColumn(name = "user_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "benefits_id"))
|
||||
Set<Benefit> benefits;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.REMOVE, mappedBy = "user")
|
||||
List<ExamResult> exams;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER,cascade = CascadeType.PERSIST, mappedBy = "user" )
|
||||
Order order;
|
||||
|
||||
public void addAchievement(Achievement achievement){
|
||||
achievements.add(achievement);
|
||||
}
|
||||
public boolean deleteAchievement(Achievement achievement){
|
||||
for(Achievement ach:
|
||||
achievements)
|
||||
{
|
||||
if (ach.getId() == achievement.getId()) {
|
||||
achievements.remove(ach);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addBenefit(Benefit benefit){
|
||||
benefits.add(benefit);
|
||||
}
|
||||
public boolean deleteBenefit(Benefit benefit){
|
||||
for(Benefit ben:
|
||||
benefits)
|
||||
{
|
||||
if (ben.getId() == benefit.getId()) {
|
||||
benefits.remove(ben);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
6
app/src/main/java/putBit/app/models/enums/Role.java
Normal file
6
app/src/main/java/putBit/app/models/enums/Role.java
Normal file
@ -0,0 +1,6 @@
|
||||
package putBit.app.models.enums;
|
||||
|
||||
public enum Role {
|
||||
USER,
|
||||
ADMIN,
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import putBit.app.models.Achievement;
|
||||
import putBit.app.models.Benefit;
|
||||
import putBit.app.models.ExamResult;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface AchievementRepository extends JpaRepository<Achievement, Integer> {
|
||||
|
||||
@Query(value = "select a.* from achievements a " +
|
||||
"where a.id in (select ua.achievements_id from USER_ACHIEVEMENTS ua " +
|
||||
"where ua.user_id = :id)", nativeQuery = true)
|
||||
List<Achievement> findAchievementsByUsersId(@Param("id") int userId);
|
||||
|
||||
|
||||
|
||||
@Query(value = "select a.* from achievements a " +
|
||||
"where a.id not in (select ua.achievements_id from USER_ACHIEVEMENTS ua " +
|
||||
"where ua.user_id = :id)", nativeQuery = true)
|
||||
List<Achievement> findAchievementsByUsersIdNot(@Param("id") int userId);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import putBit.app.models.Benefit;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface BenefitRepository extends JpaRepository<Benefit, Integer> {
|
||||
|
||||
@Query(value = "select b.* from benefits b " +
|
||||
"where b.id in (select ub.benefits_id from USER_BENEFITS ub " +
|
||||
"where ub.user_id = :id)", nativeQuery = true)
|
||||
List<Benefit> findBenefitsByUsersId(@Param("id") int userId);
|
||||
|
||||
|
||||
@Query(value = "select b.* from benefits b " +
|
||||
"where b.id not in (select ub.benefits_id from USER_BENEFITS ub " +
|
||||
"where ub.user_id = :id)", nativeQuery = true)
|
||||
List<Benefit> findBenefitsByUsersIdNot(@Param("id") int userId);
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ExamRepository extends JpaRepository<Exam, Integer> {
|
||||
|
||||
@Query(value = "select e.* from exams e " +
|
||||
"where e.id not in (select er.exam_id from exam_results er " +
|
||||
"where er.user_id = :id )", nativeQuery = true)
|
||||
List<Exam> findByUserIdNot(@Param("id") int id);
|
||||
|
||||
@Query(value = "select e.* from exams e " +
|
||||
"where e.id not in (select te.exam_id from training_exams te " +
|
||||
"where te.training_id = :id )", nativeQuery = true)
|
||||
List<Exam> findByTrainingIdNot(@Param("id") int id);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.ExamResult;
|
||||
import putBit.app.models.PrimaryKey.ExamResultPK;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ExamResultRepository extends JpaRepository<ExamResult, ExamResultPK> {
|
||||
|
||||
Optional<ExamResult> findByUserAndExam(User user, Exam exam);
|
||||
|
||||
List<ExamResult> findAllByUser(User user);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import putBit.app.models.Order;
|
||||
import putBit.app.models.PrimaryKey.OrderPK;
|
||||
import putBit.app.models.Training;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface OrderRepository extends JpaRepository<Order, OrderPK> {
|
||||
@Query(value = "select o.* from orders o " +
|
||||
" where o.training_id = :id and " +
|
||||
" o.user_id in (select u.id from users u where " +
|
||||
" LOWER(u.name) LIKE CONCAT('%',LOWER(:value),'%') or LOWER(u.snils) like CONCAT('%',LOWER(:value),'%'))" , nativeQuery = true)
|
||||
List<Order> findByUserInfo(@Param("value") String value, @Param("id") int id);
|
||||
|
||||
|
||||
List<Order> findAllByBenefitAndTraining(Boolean benefit, Training training);
|
||||
|
||||
Optional<Order> findByUser(User user);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "delete from orders o where " +
|
||||
"o.user_id = :user" , nativeQuery = true)
|
||||
void deleteByUser(@Param("user") int userId);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import putBit.app.models.*;
|
||||
import putBit.app.models.PrimaryKey.TrainingExamPK;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface TrainingExamRepository extends JpaRepository<TrainingExam, TrainingExamPK> {
|
||||
|
||||
List<TrainingExam> findAllByTraining(Training training);
|
||||
|
||||
|
||||
Optional<TrainingExam> findByTrainingAndExam(Training training, Exam exam);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import putBit.app.models.Training;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface TrainingRepository extends JpaRepository<Training, Integer> {
|
||||
|
||||
List<Training> findAllByTitleContainingIgnoreCase(String title);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package putBit.app.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import putBit.app.models.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Integer> {
|
||||
|
||||
@Query(value = "select u.* from users u " +
|
||||
"where u.id in (select ua.user_id from USER_ACHIEVEMENTS ua " +
|
||||
"where ua.achievements_id = :id)", nativeQuery = true)
|
||||
List<User> findUsersByAchievementsId(@Param("id")int AchievementId);
|
||||
|
||||
@Query(value = "select u.* from users u " +
|
||||
"where u.id in (select ub.user_id from USER_BENEFITS ub " +
|
||||
"where ub.benefits_id = :id)", nativeQuery = true)
|
||||
List<User> findUsersByBenefitsId(@Param("id")int AchievementId);
|
||||
|
||||
Optional<User> findByEmailAndPassword(String email, String password);
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.AchievementDto;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.models.Achievement;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.repositories.AchievementRepository;
|
||||
import putBit.app.repositories.UserRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AchievementService {
|
||||
|
||||
private final AchievementRepository achievementRepository;
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public Achievement create(AchievementDto achievement){
|
||||
|
||||
if(achievement.getTitle().isEmpty() || (achievement.getTitle().length() < 3 || achievement.getTitle().length() > 20 ) )
|
||||
throw new ValidationException("Неверные данные");
|
||||
if(achievement.getPoints() > 10 || achievement.getPoints() < 0 )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
Achievement newAchievement = Achievement.builder()
|
||||
.title(achievement.getTitle())
|
||||
.points(achievement.getPoints())
|
||||
.build();
|
||||
return achievementRepository.save(newAchievement);
|
||||
}
|
||||
|
||||
public Achievement findById(int id){
|
||||
return achievementRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Достижение не найдено"));
|
||||
}
|
||||
|
||||
public Achievement update(AchievementDto achievement)
|
||||
{
|
||||
if(achievement.getTitle().isEmpty() || (achievement.getTitle().length() < 3 || achievement.getTitle().length() > 20 ) )
|
||||
throw new ValidationException("Неверные данные");
|
||||
if(achievement.getPoints() > 10 || achievement.getPoints() < 0 )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
Achievement currentAchievement = findById(achievement.getId());
|
||||
|
||||
currentAchievement.setTitle(achievement.getTitle());
|
||||
currentAchievement.setPoints(achievement.getPoints());
|
||||
return achievementRepository.save(currentAchievement);
|
||||
}
|
||||
|
||||
public Achievement delete(int id){
|
||||
Achievement currentAchievement = findById(id);
|
||||
List<User> users = userRepository.findUsersByAchievementsId(id);
|
||||
for(User user:
|
||||
users){
|
||||
user.deleteAchievement(currentAchievement);
|
||||
userRepository.save(user);
|
||||
}
|
||||
achievementRepository.delete(currentAchievement);
|
||||
return currentAchievement;
|
||||
}
|
||||
|
||||
public List<Achievement> findAll(){
|
||||
return achievementRepository.findAll();
|
||||
}
|
||||
|
||||
public List<Achievement> findByUser(int id){
|
||||
return achievementRepository.findAchievementsByUsersId(id);
|
||||
}
|
||||
|
||||
public List<Achievement> findByUserNot(int id){
|
||||
return achievementRepository.findAchievementsByUsersIdNot(id);
|
||||
}
|
||||
}
|
76
app/src/main/java/putBit/app/services/BenefitService.java
Normal file
76
app/src/main/java/putBit/app/services/BenefitService.java
Normal file
@ -0,0 +1,76 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.BenefitDto;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.models.Achievement;
|
||||
import putBit.app.models.Benefit;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.repositories.BenefitRepository;
|
||||
import putBit.app.repositories.UserRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BenefitService {
|
||||
|
||||
private final BenefitRepository benefitRepository;
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public Benefit create(BenefitDto benefit){
|
||||
|
||||
if(benefit.getTitle().isEmpty() || (benefit.getTitle().length() < 3 || benefit.getTitle().length() > 20 ) )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
Benefit newBenefit = Benefit.builder()
|
||||
.title(benefit.getTitle())
|
||||
.build();
|
||||
return benefitRepository.save(newBenefit);
|
||||
}
|
||||
|
||||
public Benefit findById(int id){
|
||||
return benefitRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Льгота не найдена"));
|
||||
}
|
||||
|
||||
public Benefit update(BenefitDto benefit)
|
||||
{
|
||||
if(benefit.getTitle().isEmpty() || (benefit.getTitle().length() < 3 || benefit.getTitle().length() > 20 ) )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
Benefit currentBenefit = findById(benefit.getId());
|
||||
currentBenefit.setTitle(benefit.getTitle());
|
||||
return benefitRepository.save(currentBenefit);
|
||||
}
|
||||
|
||||
public Benefit delete(int id ){
|
||||
Benefit currentBenefit = findById(id);
|
||||
List<User> users = userRepository.findUsersByBenefitsId(id);
|
||||
for(User user:
|
||||
users){
|
||||
user.deleteBenefit(currentBenefit);
|
||||
userRepository.save(user);
|
||||
}
|
||||
benefitRepository.delete(currentBenefit);
|
||||
return currentBenefit;
|
||||
}
|
||||
|
||||
public List<Benefit> findAll(){
|
||||
return benefitRepository.findAll();
|
||||
}
|
||||
|
||||
public List<Benefit> findByUser(int id){
|
||||
return benefitRepository.findBenefitsByUsersId(id);
|
||||
}
|
||||
|
||||
public List<Benefit> findByUserNot(int id){
|
||||
return benefitRepository.findBenefitsByUsersIdNot(id);
|
||||
}
|
||||
|
||||
}
|
67
app/src/main/java/putBit/app/services/ExamResultService.java
Normal file
67
app/src/main/java/putBit/app/services/ExamResultService.java
Normal file
@ -0,0 +1,67 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.ExamResultDto;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.ExamResult;
|
||||
import putBit.app.models.PrimaryKey.ExamResultPK;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.repositories.ExamResultRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ExamResultService {
|
||||
|
||||
private final ExamResultRepository examResultRepository;
|
||||
private final UserService userService;
|
||||
private final ExamService examService;
|
||||
|
||||
public ExamResult create(ExamResultDto examResult){
|
||||
|
||||
|
||||
User user = userService.findById(examResult.getUser());
|
||||
Exam exam = examService.findById(examResult.getExam());
|
||||
ExamResult newExam = ExamResult.builder()
|
||||
.user(user)
|
||||
.exam(exam)
|
||||
.points(examResult.getPoints())
|
||||
.build();
|
||||
return examResultRepository.save(newExam);
|
||||
}
|
||||
|
||||
public ExamResult findById(int userId, int examId){
|
||||
User user = userService.findById(userId);
|
||||
Exam exam = examService.findById(examId);
|
||||
ExamResultPK pk = new ExamResultPK(user.getId(),exam.getId());
|
||||
return examResultRepository.findById(pk)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Экзамен не найден"));
|
||||
}
|
||||
|
||||
public ExamResult update(ExamResultDto examResult)
|
||||
{
|
||||
if(examResult.getPoints() > 100 || examResult.getPoints() < 0 )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
ExamResult currentExam = findById(examResult.getUser(),examResult.getExam());
|
||||
|
||||
currentExam.setPoints(examResult.getPoints());
|
||||
return examResultRepository.save(currentExam);
|
||||
}
|
||||
|
||||
public ExamResult delete(int userId, int examId){
|
||||
ExamResult currentExam = findById( userId, examId);
|
||||
examResultRepository.delete(currentExam);
|
||||
return currentExam;
|
||||
}
|
||||
public List<ExamResult> findByUser(int id){
|
||||
User currentUser = userService.findById(id);
|
||||
return examResultRepository.findAllByUser(currentUser);
|
||||
}
|
||||
}
|
69
app/src/main/java/putBit/app/services/ExamService.java
Normal file
69
app/src/main/java/putBit/app/services/ExamService.java
Normal file
@ -0,0 +1,69 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.ExamDto;
|
||||
import putBit.app.controllers.Dto.TrainingDto;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.Training;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.models.enums.Role;
|
||||
import putBit.app.repositories.ExamRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ExamService {
|
||||
private final ExamRepository examRepository;
|
||||
|
||||
public Exam create(ExamDto exam){
|
||||
|
||||
if(exam.getTitle().isEmpty() || (exam.getTitle().length() < 3 || exam.getTitle().length() > 20 ) )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
Exam newExam = Exam.builder()
|
||||
.title(exam.getTitle())
|
||||
.build();
|
||||
return examRepository.save(newExam);
|
||||
}
|
||||
|
||||
public Exam findById(int id){
|
||||
return examRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Экзамен не найден"));
|
||||
}
|
||||
|
||||
public Exam update(ExamDto exam)
|
||||
{
|
||||
if(exam.getTitle().isEmpty() || (exam.getTitle().length() < 3 || exam.getTitle().length() > 20 ) )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
Exam currentExam = findById(exam.getId());
|
||||
|
||||
currentExam.setTitle(exam.getTitle());
|
||||
return examRepository.save(currentExam);
|
||||
}
|
||||
|
||||
public Exam delete(int id){
|
||||
Exam currentExam = findById(id);
|
||||
examRepository.delete(currentExam);
|
||||
return currentExam;
|
||||
}
|
||||
|
||||
public List<Exam> findAll(){
|
||||
return examRepository.findAll();
|
||||
}
|
||||
|
||||
public List<Exam> findNotUser(int id){
|
||||
return examRepository.findByUserIdNot(id);
|
||||
}
|
||||
|
||||
public List<Exam> findNotTraining(int id){
|
||||
return examRepository.findByTrainingIdNot(id);
|
||||
}
|
||||
|
||||
}
|
184
app/src/main/java/putBit/app/services/OrderService.java
Normal file
184
app/src/main/java/putBit/app/services/OrderService.java
Normal file
@ -0,0 +1,184 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import jakarta.mail.MessagingException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.aspectj.weaver.ast.Or;
|
||||
import org.hibernate.service.NullServiceException;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import putBit.app.Timer.myTimer;
|
||||
import putBit.app.controllers.Dto.OrderDto;
|
||||
import putBit.app.models.*;
|
||||
import putBit.app.models.PrimaryKey.OrderPK;
|
||||
import putBit.app.repositories.OrderRepository;
|
||||
import putBit.app.repositories.TrainingRepository;
|
||||
import putBit.app.repositories.UserRepository;
|
||||
import putBit.app.services.WorkEmail.EmailWork;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
import putBit.app.services.help.OrderPoints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class OrderService {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final TrainingService trainingService;
|
||||
|
||||
private final OrderRepository orderRepository;
|
||||
|
||||
private final EmailWork emailWork;
|
||||
|
||||
public OrderService(
|
||||
UserService userService,
|
||||
TrainingService trainingService,
|
||||
OrderRepository orderRepository){
|
||||
this.userService=userService;
|
||||
this.trainingService = trainingService;
|
||||
this.orderRepository = orderRepository;
|
||||
this.emailWork = new EmailWork();
|
||||
myTimer timer = myTimer.getInstance(this);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Order create(int userID, int trainingId){
|
||||
User user = userService.findById(userID);
|
||||
Training training = trainingService.findById(trainingId);
|
||||
int limit = 0;
|
||||
for(TrainingExam exam:
|
||||
training.getExams())
|
||||
{
|
||||
boolean check = false;
|
||||
for(ExamResult result:
|
||||
user.getExams())
|
||||
{
|
||||
if(result.getExam().getId() == exam.getExam().getId() && result.getPoints() >= exam.getPoints())
|
||||
{
|
||||
check = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!check)
|
||||
throw new ValidationException("Нет нужных экзаменов");
|
||||
|
||||
}
|
||||
for(TrainingExam exam:
|
||||
training.getExams())
|
||||
{
|
||||
limit+=exam.getPoints();
|
||||
}
|
||||
int userPoints=0;
|
||||
for(ExamResult result:
|
||||
user.getExams())
|
||||
{
|
||||
userPoints+= result.getPoints();
|
||||
}
|
||||
if(limit>userPoints)
|
||||
return null;
|
||||
|
||||
Order newOrder = Order.builder()
|
||||
.user(user)
|
||||
.training(training)
|
||||
.benefit(user.getBenefits() != null && !user.getBenefits().isEmpty())
|
||||
.confirm(false)
|
||||
.build();
|
||||
|
||||
return orderRepository.save(newOrder);
|
||||
}
|
||||
|
||||
public Order findById(int userId, int trainId){
|
||||
OrderPK pk = new OrderPK(userId,trainId);
|
||||
return orderRepository.findById(pk)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Заявка не найдена"));
|
||||
}
|
||||
@Transactional
|
||||
public Order delete(int userId){
|
||||
User user = userService.findById(userId);
|
||||
Order currentOrder = orderRepository.findByUser(user).orElseThrow();
|
||||
orderRepository.deleteByUser(userId);
|
||||
return currentOrder;
|
||||
|
||||
}
|
||||
|
||||
public List<Order> findForBenefit(int id){
|
||||
Training training = trainingService.findById(id);
|
||||
return orderRepository.findAllByBenefitAndTraining(true, training);
|
||||
}
|
||||
|
||||
public List<Order> findForBasic(int id){
|
||||
Training training = trainingService.findById(id);
|
||||
return orderRepository.findAllByBenefitAndTraining(false, training);
|
||||
}
|
||||
|
||||
public List<Order> findByNameOrSnils(int id, String text){
|
||||
return orderRepository.findByUserInfo(text, id);
|
||||
}
|
||||
|
||||
public Order findByUser(int id){
|
||||
User user = userService.findById(id);
|
||||
return orderRepository.findByUser(user)
|
||||
.orElseThrow(() -> new EntityNotFoundException("У этого челика нет заявления"));
|
||||
}
|
||||
|
||||
public void emailSend() throws MessagingException {
|
||||
List<Order> orders = orderRepository.findAll();
|
||||
for(var order: orders){
|
||||
String email = order.getUser().getEmail();
|
||||
if(order.getConfirm())
|
||||
emailWork.sendMessage(email, "Поздравляем, вы поступили");
|
||||
else
|
||||
emailWork.sendMessage(email, "Сожалеем, вы не поступили");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void workWithStudents() throws MessagingException {
|
||||
List<Training> trainings = trainingService.findAll();
|
||||
for(Training training: trainings)
|
||||
{
|
||||
System.out.println(training.getId() + " or:" + training.getOrders().size());
|
||||
if(training.getOrders().isEmpty())
|
||||
continue;
|
||||
|
||||
List<OrderPoints> orders_benefits = new ArrayList<>(findForBenefit(training.getId()).stream().map(or -> new OrderPoints(or)).toList());
|
||||
List<OrderPoints> orders_basic = new ArrayList<>(findForBasic(training.getId()).stream().map(or -> new OrderPoints(or)).toList());
|
||||
|
||||
orders_benefits.sort(Collections.reverseOrder());
|
||||
orders_basic.sort(Collections.reverseOrder());
|
||||
|
||||
List<Order> orderToUpdate = new ArrayList<>();
|
||||
|
||||
System.out.println(orders_basic.size());
|
||||
|
||||
System.out.println(orders_benefits.size());
|
||||
|
||||
int i = 0;
|
||||
for(var order: orders_benefits)
|
||||
{
|
||||
if(i == training.getBenefit_places())
|
||||
break;
|
||||
order.getOrder().setConfirm(true);
|
||||
orderToUpdate.add(order.getOrder());
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for(var order: orders_basic)
|
||||
{
|
||||
if(i == training.getBasic_places())
|
||||
break;
|
||||
order.getOrder().setConfirm(true);
|
||||
orderToUpdate.add(order.getOrder());
|
||||
i++;
|
||||
}
|
||||
orderRepository.saveAll(orderToUpdate);
|
||||
}
|
||||
emailSend();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.TrainingDto;
|
||||
import putBit.app.controllers.Dto.TrainingExamDto;
|
||||
import putBit.app.models.*;
|
||||
import putBit.app.models.PrimaryKey.TrainingExamPK;
|
||||
import putBit.app.repositories.TrainingExamRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TrainingExamService {
|
||||
private final TrainingExamRepository trainingExamRepository;
|
||||
private final ExamService examService;
|
||||
private final TrainingService trainingService;
|
||||
|
||||
public TrainingExam create(TrainingExamDto trainingExam){
|
||||
|
||||
|
||||
|
||||
Training training = trainingService.findById(trainingExam.getTraining());
|
||||
Exam exam = examService.findById(trainingExam.getExam());
|
||||
TrainingExam newExam = TrainingExam.builder()
|
||||
.training(training)
|
||||
.exam(exam)
|
||||
.points(trainingExam.getPoints())
|
||||
.build();
|
||||
return trainingExamRepository.save(newExam);
|
||||
}
|
||||
|
||||
public TrainingExam findById(int trainId, int examId){
|
||||
TrainingExamPK pk = new TrainingExamPK(trainId,examId);
|
||||
return trainingExamRepository.findById(pk)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Экзамен не найден"));
|
||||
}
|
||||
|
||||
public TrainingExam update(TrainingExamDto trainingExam)
|
||||
{
|
||||
if(trainingExam.getPoints() > 100 || trainingExam.getPoints() < 0 )
|
||||
throw new ValidationException("Неверные данные");
|
||||
|
||||
TrainingExam currentExam = findById(trainingExam.getTraining(),trainingExam.getExam());
|
||||
|
||||
currentExam.setPoints(trainingExam.getPoints());
|
||||
return trainingExamRepository.save(currentExam);
|
||||
}
|
||||
|
||||
public TrainingExam delete(int trainId, int examId){
|
||||
TrainingExam currentExam = findById( trainId, examId);
|
||||
trainingExamRepository.delete(currentExam);
|
||||
return currentExam;
|
||||
}
|
||||
public List<TrainingExam> findByTraining(int id){
|
||||
Training currentTraining = trainingService.findById(id);
|
||||
return trainingExamRepository.findAllByTraining(currentTraining);
|
||||
}
|
||||
|
||||
}
|
93
app/src/main/java/putBit/app/services/TrainingService.java
Normal file
93
app/src/main/java/putBit/app/services/TrainingService.java
Normal file
@ -0,0 +1,93 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.TrainingDto;
|
||||
import putBit.app.models.Exam;
|
||||
import putBit.app.models.Training;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.repositories.TrainingRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TrainingService {
|
||||
private final TrainingRepository trainingRepository;
|
||||
|
||||
public Training create(TrainingDto training){
|
||||
System.out.println(training.getNum());
|
||||
if(training.getTitle().isEmpty() || (training.getTitle().length() < 2 || training.getTitle().length() > 50 ) )
|
||||
throw new ValidationException("Неверное название");
|
||||
if(training.getNum().isEmpty() || (training.getNum().length() < 8 || training.getNum().length() > 11 ) )
|
||||
throw new ValidationException("Неверный номер");
|
||||
if(training.getDesc().isEmpty() || (training.getDesc().length() < 10 || training.getDesc().length() > 300 ) )
|
||||
throw new ValidationException("Неверное описание");
|
||||
if(training.getProf().isEmpty() || (training.getProf().length() < 5 || training.getProf().length() > 300 ) )
|
||||
throw new ValidationException("Неверные профессии");
|
||||
if(training.getBasic_places() > 999 || training.getBasic_places() < 10 )
|
||||
throw new ValidationException("Неверные базовые места");
|
||||
if(training.getBenefit_places() > 999 || training.getBenefit_places() < 10 )
|
||||
throw new ValidationException("Неверные льготные места");
|
||||
|
||||
|
||||
Training newTraining = Training.builder()
|
||||
.title(training.getTitle())
|
||||
.num(training.getNum())
|
||||
.desc(training.getDesc())
|
||||
.prof(training.getProf())
|
||||
.basic_places(training.getBasic_places())
|
||||
.benefit_places(training.getBenefit_places())
|
||||
.build();
|
||||
return trainingRepository.save(newTraining);
|
||||
}
|
||||
|
||||
public Training findById(int id){
|
||||
return trainingRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Направление не найдено"));
|
||||
}
|
||||
|
||||
public Training update(TrainingDto training)
|
||||
{
|
||||
|
||||
if(training.getTitle().isEmpty() || (training.getTitle().length() < 2 || training.getTitle().length() > 50 ) )
|
||||
throw new ValidationException("Неверное название");
|
||||
if(training.getNum().isEmpty() || (training.getNum().length() < 8 || training.getNum().length() > 11 ) )
|
||||
throw new ValidationException("Неверный номер");
|
||||
if(training.getDesc().isEmpty() || (training.getDesc().length() < 10 || training.getDesc().length() > 300 ) )
|
||||
throw new ValidationException("Неверное описание");
|
||||
if(training.getProf().isEmpty() || (training.getProf().length() < 5 || training.getProf().length() > 300 ) )
|
||||
throw new ValidationException("Неверные профессии");
|
||||
if(training.getBasic_places() > 999 || training.getBasic_places() < 10 )
|
||||
throw new ValidationException("Неверные базовые места");
|
||||
if(training.getBenefit_places() > 999 || training.getBenefit_places() < 10 )
|
||||
throw new ValidationException("Неверные льготные места");
|
||||
|
||||
Training currentTraining = findById(training.getId());
|
||||
|
||||
currentTraining.setTitle(training.getTitle());
|
||||
currentTraining.setNum(training.getNum());
|
||||
currentTraining.setDesc(training.getDesc());
|
||||
currentTraining.setProf(training.getProf());
|
||||
currentTraining.setBasic_places(training.getBasic_places());
|
||||
currentTraining.setBenefit_places(training.getBenefit_places());
|
||||
return trainingRepository.save(currentTraining);
|
||||
}
|
||||
|
||||
public Training delete(int id){
|
||||
Training currentTraining = findById(id);
|
||||
trainingRepository.delete(currentTraining);
|
||||
return currentTraining;
|
||||
}
|
||||
|
||||
public List<Training> findAll(){
|
||||
return trainingRepository.findAll();
|
||||
}
|
||||
|
||||
public List<Training> findByTitle(String title){
|
||||
return trainingRepository.findAllByTitleContainingIgnoreCase(title);
|
||||
}
|
||||
}
|
128
app/src/main/java/putBit/app/services/UserService.java
Normal file
128
app/src/main/java/putBit/app/services/UserService.java
Normal file
@ -0,0 +1,128 @@
|
||||
package putBit.app.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.hibernate.sql.exec.ExecutionException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import putBit.app.controllers.Dto.AchievementDto;
|
||||
import putBit.app.controllers.Dto.BenefitDto;
|
||||
import putBit.app.controllers.Dto.UserDto;
|
||||
import putBit.app.models.Achievement;
|
||||
import putBit.app.models.Benefit;
|
||||
import putBit.app.models.User;
|
||||
import putBit.app.models.enums.Role;
|
||||
import putBit.app.repositories.UserRepository;
|
||||
import putBit.app.services.exceptions.EntityNotFoundException;
|
||||
import putBit.app.services.exceptions.ValidationException;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
private final BenefitService benefitService;
|
||||
private final AchievementService achievementService;
|
||||
|
||||
|
||||
public static boolean patternMatches(String emailAddress) {
|
||||
return Pattern
|
||||
.compile("^(?=.{1,64}@)[A-Za-z0-9_-]+(\\\\.[A-Za-z0-9_-]+)*@[^-][A-Za-z0-9-]+(\\\\.[A-Za-z0-9-]+)*(\\\\.[A-Za-z]{2,})$")
|
||||
.matcher(emailAddress)
|
||||
.matches();
|
||||
}
|
||||
|
||||
public User create(UserDto user){
|
||||
System.out.println(user);
|
||||
if(patternMatches(user.getEmail()) )
|
||||
throw new ValidationException("Неверная почта");
|
||||
if(user.getName().isEmpty() || (user.getName().length() < 3 || user.getName().length() > 80 ) )
|
||||
throw new ValidationException("Неверное ФИО");
|
||||
if(user.getSnils().length() != 11)
|
||||
throw new ValidationException("Неверный снилс");
|
||||
if(user.getPassword().isEmpty() || (user.getPassword().length() < 6 || user.getPassword().length() > 20 ) )
|
||||
throw new ValidationException("Неверный пароль");
|
||||
if(user.getPhone().length() != 11)
|
||||
throw new ValidationException("Неверный номер телефона");
|
||||
|
||||
|
||||
User newUser = User.builder()
|
||||
.email(user.getEmail())
|
||||
.password(user.getPassword())
|
||||
.phone(user.getPhone())
|
||||
.role(Role.USER)
|
||||
.name(user.getName())
|
||||
.snils(user.getSnils())
|
||||
.build();
|
||||
return userRepository.save(newUser);
|
||||
}
|
||||
|
||||
public User findById(int id){
|
||||
return userRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Пользователь не найден"));
|
||||
}
|
||||
|
||||
public User auth(UserDto user)
|
||||
{
|
||||
return userRepository.findByEmailAndPassword(user.getEmail(), user.getPassword())
|
||||
.orElseThrow(() -> new EntityNotFoundException("Пользователь не найден"));
|
||||
}
|
||||
|
||||
public User update(UserDto user)
|
||||
{
|
||||
if(user.getEmail().isEmpty() )
|
||||
throw new ValidationException("Неверная почта");
|
||||
if(user.getName().isEmpty() || (user.getName().length() < 3 || user.getName().length() > 80 ) )
|
||||
throw new ValidationException("Неверное ФИО");
|
||||
if(user.getSnils().length() != 11)
|
||||
throw new ValidationException("Неверный снилс");
|
||||
if(user.getPassword().isEmpty() || (user.getPassword().length() < 6 || user.getPassword().length() > 20 ) )
|
||||
throw new ValidationException("Неверный пароль");
|
||||
if(user.getPhone().length() > 12 || user.getPhone().length() < 11)
|
||||
throw new ValidationException("Неверный номер телефона");
|
||||
|
||||
|
||||
User currentUser = findById(user.getId());
|
||||
|
||||
if(!user.getName().isEmpty() && !currentUser.getName().equals(user.getName()))
|
||||
currentUser.setName(user.getName());
|
||||
if(!user.getEmail().isEmpty() && !currentUser.getEmail().equals(user.getEmail()))
|
||||
currentUser.setName(user.getEmail());
|
||||
if(!user.getPassword().isEmpty() && !currentUser.getPassword().equals(user.getPassword()))
|
||||
currentUser.setPassword(user.getPassword());
|
||||
if(!user.getPhone().isEmpty() && !currentUser.getPhone().equals(user.getPhone()))
|
||||
currentUser.setPhone(user.getPhone());
|
||||
if(!user.getSnils().isEmpty() && !currentUser.getSnils().equals(user.getSnils()))
|
||||
currentUser.setSnils(user.getSnils());
|
||||
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
public User addAchievement(int userId, int achId){
|
||||
User currentUser = findById(userId);
|
||||
Achievement newAch = achievementService.findById(achId);
|
||||
currentUser.addAchievement(newAch);
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
public User addBenefit(int userId, int benId){
|
||||
User currentUser = findById(userId);
|
||||
Benefit newBen = benefitService.findById(benId);
|
||||
currentUser.addBenefit(newBen);
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
|
||||
public User removeAchievement(int userId, int achId){
|
||||
User currentUser = findById(userId);
|
||||
Achievement newAch = achievementService.findById(achId);
|
||||
if (!currentUser.deleteAchievement(newAch))
|
||||
throw new RuntimeException("нет такой ачивки у этого человека");
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
|
||||
public User removeBenefit(int userId, int benId){
|
||||
User currentUser = findById(userId);
|
||||
Benefit newBen = benefitService.findById(benId);
|
||||
if (!currentUser.deleteBenefit(newBen))
|
||||
throw new RuntimeException("нет такой ачивки у этого человека");
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package putBit.app.services.WorkEmail;
|
||||
|
||||
import jakarta.mail.*;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class EmailWork {
|
||||
|
||||
private Properties prop;
|
||||
|
||||
private final String username = "labrpp89@gmail.com";
|
||||
|
||||
private final String password = "wfhb szlu vibt jkae";
|
||||
|
||||
public EmailWork(){
|
||||
prop = new Properties();
|
||||
prop.put("mail.smtp.auth", true);
|
||||
prop.put("mail.smtp.starttls.enable", "true");
|
||||
prop.put("mail.smtp.host", "smtp.gmail.com");
|
||||
prop.put("mail.smtp.port", "587");
|
||||
prop.put("mail.smtp.ssl.trust", "smtp.gmail.com");
|
||||
|
||||
}
|
||||
|
||||
public void sendMessage(String emailTo, String text) throws MessagingException {
|
||||
Session session = Session.getInstance(prop, new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress("from@gmail.com"));
|
||||
message.setRecipients(
|
||||
Message.RecipientType.TO, InternetAddress.parse(emailTo));
|
||||
message.setSubject("Ваш любимый вуз");
|
||||
|
||||
String msg = text;
|
||||
|
||||
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
||||
mimeBodyPart.setContent(msg, "text/html; charset=utf-8");
|
||||
|
||||
Multipart multipart = new MimeMultipart();
|
||||
multipart.addBodyPart(mimeBodyPart);
|
||||
|
||||
message.setContent(multipart);
|
||||
|
||||
Transport.send(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package putBit.app.services.exceptions;
|
||||
|
||||
public class EntityNotFoundException extends RuntimeException {
|
||||
public EntityNotFoundException(String text) {
|
||||
super(String.format(text));
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package putBit.app.services.exceptions;
|
||||
|
||||
public class ValidationException extends RuntimeException {
|
||||
public ValidationException(String text) {
|
||||
super(String.format(text));
|
||||
}
|
||||
}
|
40
app/src/main/java/putBit/app/services/help/OrderPoints.java
Normal file
40
app/src/main/java/putBit/app/services/help/OrderPoints.java
Normal file
@ -0,0 +1,40 @@
|
||||
package putBit.app.services.help;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import putBit.app.models.Order;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderPoints implements Comparable<OrderPoints>{
|
||||
private Order order;
|
||||
private int points;
|
||||
|
||||
public OrderPoints(Order order){
|
||||
this.order = order;
|
||||
int sum = 0;
|
||||
for(var exam: order.getUser().getExams())
|
||||
{
|
||||
for(var examT: order.getTraining().getExams())
|
||||
{
|
||||
if(examT.getExam().getId() == exam.getExam().getId())
|
||||
sum+= exam.getPoints();
|
||||
}
|
||||
}
|
||||
for(var ach : order.getUser().getAchievements())
|
||||
{
|
||||
sum+= ach.getPoints();
|
||||
}
|
||||
this.points = sum;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(OrderPoints o) {
|
||||
return Integer.compare(points,o.points);
|
||||
}
|
||||
}
|
@ -1 +1,12 @@
|
||||
spring.application.name=app
|
||||
spring.main.banner-mode=off
|
||||
#server.port=8081
|
||||
spring.datasource.url=jdbc:h2:file:./data
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=password
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.settings.trace=false
|
||||
spring.h2.console.settings.web-allow-others=false
|
@ -1,13 +1,522 @@
|
||||
package putBit.app;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import putBit.app.controllers.Dto.*;
|
||||
import putBit.app.models.*;
|
||||
import putBit.app.models.enums.Role;
|
||||
import putBit.app.repositories.*;
|
||||
import putBit.app.services.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class AppApplicationTests {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
ExamService examService;
|
||||
|
||||
@Autowired
|
||||
ExamResultService examResultService;
|
||||
|
||||
@Autowired
|
||||
BenefitService benefitService;
|
||||
|
||||
@Autowired
|
||||
AchievementService achievementService;
|
||||
|
||||
@Autowired
|
||||
TrainingService trainingService;
|
||||
|
||||
@Autowired
|
||||
TrainingExamService trainingExamService;
|
||||
|
||||
@Autowired
|
||||
OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
ExamRepository examRepository;
|
||||
|
||||
@Autowired
|
||||
ExamResultRepository examResultRepository;
|
||||
|
||||
@Autowired
|
||||
AchievementRepository achievementRepository;
|
||||
|
||||
@Autowired
|
||||
BenefitRepository benefitRepository;
|
||||
|
||||
@Autowired
|
||||
TrainingRepository trainingRepository;
|
||||
|
||||
@Autowired
|
||||
TrainingExamRepository trainingExamRepository;
|
||||
|
||||
@Autowired
|
||||
OrderRepository orderRepository;
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
@org.junit.jupiter.api.Order(1)
|
||||
void Integate_CreateUser() {
|
||||
|
||||
User us1 = User.builder()
|
||||
.email("email1")
|
||||
.password("12345678")
|
||||
.phone("88005553535")
|
||||
.role(Role.USER)
|
||||
.name("Vova Morozov")
|
||||
.snils("33322233344")
|
||||
.build();
|
||||
User us2 = User.builder()
|
||||
.email("email2")
|
||||
.password("12345678")
|
||||
.phone("88005553535")
|
||||
.role(Role.USER)
|
||||
.name("Dima Redov")
|
||||
.snils("11122233344")
|
||||
.build();
|
||||
User res1 = userService.create(new UserDto(us1));
|
||||
User res2 = userService.create(new UserDto(us2));
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(2)
|
||||
void Integate_CreateExam(){
|
||||
Exam ex1 = Exam.builder()
|
||||
.title("Математика")
|
||||
.build();
|
||||
Exam ex2 = Exam.builder()
|
||||
.title("Русский язык")
|
||||
.build();
|
||||
Exam ex3 = Exam.builder()
|
||||
.title("Физика")
|
||||
.build();
|
||||
Exam ex4 = Exam.builder()
|
||||
.title("Информатика")
|
||||
.build();
|
||||
|
||||
Exam res1 = examService.create(new ExamDto(ex1));
|
||||
Exam res2 = examService.create(new ExamDto(ex2));
|
||||
Exam res3 = examService.create(new ExamDto(ex3));
|
||||
Exam res4 = examService.create(new ExamDto(ex4));
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
Assertions.assertNotNull(res3);
|
||||
Assertions.assertNotNull(res4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(3)
|
||||
void Integate_CreateBenefit(){
|
||||
Benefit bf1 = Benefit.builder()
|
||||
.title("Инвалидность I")
|
||||
.build();
|
||||
Benefit bf2 = Benefit.builder()
|
||||
.title("Инвалидность II")
|
||||
.build();
|
||||
Benefit bf3 = Benefit.builder()
|
||||
.title("Инвалидность III")
|
||||
.build();
|
||||
|
||||
Benefit res1 = benefitService.create(new BenefitDto(bf1));
|
||||
Benefit res2 = benefitService.create(new BenefitDto(bf2));
|
||||
Benefit res3 = benefitService.create(new BenefitDto(bf3));
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
Assertions.assertNotNull(res3);
|
||||
}
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(4)
|
||||
void Integate_CreateAchievements(){
|
||||
Achievement ac1 = Achievement.builder()
|
||||
.title("ГТО 1 степени")
|
||||
.points(5)
|
||||
.build();
|
||||
Achievement ac2 = Achievement.builder()
|
||||
.title("ГТО 2 степени")
|
||||
.points(3)
|
||||
.build();
|
||||
Achievement ac3 = Achievement.builder()
|
||||
.title("Красный диплом")
|
||||
.points(7)
|
||||
.build();
|
||||
|
||||
Achievement res1 = achievementService.create(new AchievementDto(ac1));
|
||||
Achievement res2 = achievementService.create(new AchievementDto(ac2));
|
||||
Achievement res3 = achievementService.create(new AchievementDto(ac3));
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
Assertions.assertNotNull(res3);
|
||||
}
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(5)
|
||||
void Integate_CreateExamResult(){
|
||||
|
||||
User us1 = userService.findById(1);
|
||||
User us2 = userService.findById(2);
|
||||
|
||||
Exam ex1 = examService.findById(1);
|
||||
Exam ex2 = examService.findById(2);
|
||||
Exam ex3 = examService.findById(3);
|
||||
|
||||
ExamResult er1 = ExamResult.builder()
|
||||
.user(us1)
|
||||
.exam(ex1)
|
||||
.points(30)
|
||||
.build();
|
||||
ExamResult er2 = ExamResult.builder()
|
||||
.user(us1)
|
||||
.exam(ex2)
|
||||
.points(30)
|
||||
.build();
|
||||
|
||||
ExamResult er3 = ExamResult.builder()
|
||||
.user(us2)
|
||||
.exam(ex2)
|
||||
.points(50)
|
||||
.build();
|
||||
ExamResult er4 = ExamResult.builder()
|
||||
.user(us2)
|
||||
.exam(ex3)
|
||||
.points(60)
|
||||
.build();
|
||||
|
||||
var res1 = examResultService.create(new ExamResultDto(er1));
|
||||
var res2 = examResultService.create(new ExamResultDto(er2));
|
||||
var res3 = examResultService.create(new ExamResultDto(er3));
|
||||
var res4 = examResultService.create(new ExamResultDto(er4));
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
Assertions.assertNotNull(res3);
|
||||
Assertions.assertNotNull(res4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(6)
|
||||
void Integate_CreateTraining() {
|
||||
Training tr1 = Training.builder()
|
||||
.title("ПИбд")
|
||||
.num("09.09.01.01")
|
||||
.desc("Типо программисты")
|
||||
.prof("бэкендер, фронтендер, аналитикffff")
|
||||
.basic_places(100)
|
||||
.benefit_places(10)
|
||||
.build();
|
||||
Training tr2 = Training.builder()
|
||||
.title("ИВТ")
|
||||
.num("09.09.02")
|
||||
.desc("Типо программисты-инженеры")
|
||||
.prof("на заваод")
|
||||
.basic_places(120)
|
||||
.benefit_places(12)
|
||||
.build();
|
||||
Training tr3 = Training.builder()
|
||||
.title("ИСЭ")
|
||||
.num("09.09.03")
|
||||
.desc("Типо программисты-инженеры")
|
||||
.prof("цифровой экономист")
|
||||
.basic_places(120)
|
||||
.benefit_places(12)
|
||||
.build();
|
||||
|
||||
var res1 = trainingService.create(new TrainingDto(tr1));
|
||||
var res2 = trainingService.create(new TrainingDto(tr2));
|
||||
var res3 = trainingService.create(new TrainingDto(tr3));
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
Assertions.assertNotNull(res3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(7)
|
||||
void Integate_CreateTrainingExam(){
|
||||
|
||||
Training tr1 = trainingService.findById(1);
|
||||
Training tr2 = trainingService.findById(2);
|
||||
|
||||
Exam ex1 = examService.findById(1);
|
||||
Exam ex2 = examService.findById(2);
|
||||
Exam ex3 = examService.findById(3);
|
||||
|
||||
TrainingExam te1 = TrainingExam.builder()
|
||||
.training(tr1)
|
||||
.exam(ex1)
|
||||
.points(30)
|
||||
.build();
|
||||
TrainingExam te2 = TrainingExam.builder()
|
||||
.training(tr1)
|
||||
.exam(ex2)
|
||||
.points(30)
|
||||
.build();
|
||||
TrainingExam te3 = TrainingExam.builder()
|
||||
.training(tr2)
|
||||
.exam(ex2)
|
||||
.points(5)
|
||||
.build();
|
||||
TrainingExam te4 = TrainingExam.builder()
|
||||
.training(tr2)
|
||||
.exam(ex3)
|
||||
.points(66)
|
||||
.build();
|
||||
|
||||
var res1 = trainingExamService.create(new TrainingExamDto(te1));
|
||||
var res2 = trainingExamService.create(new TrainingExamDto(te2));
|
||||
var res3 = trainingExamService.create(new TrainingExamDto(te3));
|
||||
var res4 = trainingExamService.create(new TrainingExamDto(te4));
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
Assertions.assertNotNull(res2);
|
||||
Assertions.assertNotNull(res3);
|
||||
Assertions.assertNotNull(res4);
|
||||
|
||||
}
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(8)
|
||||
void Integate_CreateOrder(){
|
||||
Training tr1 = trainingService.findById(1);
|
||||
Training tr2 = trainingService.findById(3);
|
||||
|
||||
User us1 = userService.findById(2);
|
||||
User us2 = userService.findById(2);
|
||||
|
||||
Order o1 = Order.builder()
|
||||
.user(us1)
|
||||
.training(tr1)
|
||||
.build();
|
||||
Order o2 = Order.builder()
|
||||
.user(us2)
|
||||
.training(tr2)
|
||||
.build();
|
||||
|
||||
var res1 = orderService.create(1,1);
|
||||
|
||||
Assertions.assertNotNull(res1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(9)
|
||||
void Integate_updateUser(){
|
||||
User us1 = userService.findById(1);
|
||||
String oldName = us1.getName();
|
||||
us1.setName(oldName + "Upd");
|
||||
var res = userService.update(new UserDto(us1));
|
||||
Assertions.assertNotNull(res);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(10)
|
||||
void Integate_updateUserAddBenefit(){
|
||||
User us1 = userService.findById(1);
|
||||
Achievement ach1 = achievementService.findById(1);
|
||||
Achievement ach2 = achievementService.findById(2);
|
||||
List<User> res = new ArrayList<>();
|
||||
res.add(userService.addAchievement(us1.getId(), ach2.getId()));
|
||||
res.add(userService.addAchievement(us1.getId(), ach1.getId()));
|
||||
|
||||
User us2 = userService.findById(1);
|
||||
Benefit b1 = benefitService.findById(1);
|
||||
Benefit b2 = benefitService.findById(2);
|
||||
|
||||
res.add(userService.addAchievement(us2.getId(), ach2.getId()));
|
||||
res.add(userService.addBenefit(us2.getId(), b2.getId()));
|
||||
res.add(userService.addBenefit(us1.getId(),b2.getId()));
|
||||
Assertions.assertEquals(res.size(),res.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(11)
|
||||
void Integate_updateUserRemoveBenefit(){
|
||||
User us1 = userService.findById(1);
|
||||
Benefit b1 = benefitService.findById(2);
|
||||
int countB = us1.getBenefits().size();
|
||||
us1 = userService.removeBenefit(us1.getId(),b1.getId());
|
||||
Assertions.assertEquals(us1.getBenefits().size(),us1.getBenefits().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(12)
|
||||
void Integate_updateExam(){
|
||||
Exam ex = examService.findById(1);
|
||||
String oldName = ex.getTitle();
|
||||
ex.setTitle(ex.getTitle() + "UPD");
|
||||
var res = examService.update(new ExamDto(ex));
|
||||
Assertions.assertEquals(oldName + "UPD", res.getTitle());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(13)
|
||||
void Integate_updateExamResult(){
|
||||
ExamResult er = examResultService.findById(1,1);
|
||||
er.setPoints(100);
|
||||
var res = examResultService.update(new ExamResultDto(er));
|
||||
Assertions.assertEquals(100,res.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(14)
|
||||
void Integate_updateBenefit(){
|
||||
Benefit b = benefitService.findById(1);
|
||||
String oldName = b.getTitle();
|
||||
b.setTitle(b.getTitle() + "UPD");
|
||||
var res = benefitService.update(new BenefitDto(b));
|
||||
Assertions.assertEquals(oldName + "UPD", res.getTitle());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(15)
|
||||
void Integate_updateAchievement(){
|
||||
Achievement b = achievementService.findById(1);
|
||||
String oldName = b.getTitle();
|
||||
b.setTitle(b.getTitle() + "UPD");
|
||||
var res = achievementService.update(new AchievementDto(b));
|
||||
Assertions.assertEquals(oldName + "UPD", res.getTitle());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(16)
|
||||
void Integate_updateTraining(){
|
||||
Training b = trainingService.findById(1);
|
||||
String oldName = b.getTitle();
|
||||
b.setTitle(b.getTitle() + "UPD");
|
||||
var res = trainingService.update(new TrainingDto(b));
|
||||
Assertions.assertEquals(oldName + "UPD", res.getTitle());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(17)
|
||||
void Integate_updateTrainigExam(){
|
||||
TrainingExam er = trainingExamService.findById(1,1);
|
||||
er.setPoints(90);
|
||||
var res = trainingExamService.update(new TrainingExamDto(er));
|
||||
Assertions.assertEquals(90,res.getPoints());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(18)
|
||||
void Integate_deleteExam(){
|
||||
int countBefore = examService.findAll().size();
|
||||
Exam ex = examService.findById(3);
|
||||
examService.delete(ex.getId());
|
||||
int countAfter = examService.findAll().size();
|
||||
Assertions.assertEquals(countBefore-1,countAfter);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(19)
|
||||
void Integate_deleteBenefit(){
|
||||
int countBefore = benefitService.findAll().size();
|
||||
Benefit ex = benefitService.findById(3);
|
||||
benefitService.delete(ex.getId());
|
||||
int countAfter = benefitService.findAll().size();
|
||||
Assertions.assertEquals(countBefore-1,countAfter);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(20)
|
||||
void Integate_deleteAchievement(){
|
||||
int countBefore = achievementService.findAll().size();
|
||||
Achievement ex = achievementService.findById(3);
|
||||
achievementService.delete(ex.getId());
|
||||
int countAfter = achievementService.findAll().size();
|
||||
Assertions.assertEquals(countBefore-1,countAfter);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(21)
|
||||
void Integate_deleteExamResult(){
|
||||
var res = examResultService.delete(1,1);
|
||||
Assertions.assertEquals(1,res.getUser().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(22)
|
||||
void Integate_deleteTraining(){
|
||||
int countBefore = trainingService.findAll().size();
|
||||
Training ex = trainingService.findById(3);
|
||||
trainingService.delete(ex.getId());
|
||||
int countAfter = trainingService.findAll().size();
|
||||
Assertions.assertEquals(countBefore-1,countAfter);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(23)
|
||||
void Integate_deleteTrainingExam(){
|
||||
var res = trainingExamService.delete(1,1);
|
||||
Assertions.assertEquals(1,res.getTraining().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(24)
|
||||
void Integrate_deleteOrder(){
|
||||
var res = orderService.delete(1);
|
||||
System.out.println(res.getUser().getName());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(25)
|
||||
void Integrate_findUser(){
|
||||
var res = userService.findById(1);
|
||||
Assertions.assertNotNull(res);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(26)
|
||||
void Integrate_findExam(){
|
||||
var res = examService.findById(1);
|
||||
Assertions.assertNotNull(res);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(27)
|
||||
void Integrate_findTraining(){
|
||||
var res = trainingService.findById(1);
|
||||
Assertions.assertNotNull(res);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(28)
|
||||
void Integrate_findBenefit(){
|
||||
var res = benefitService.findById(1);
|
||||
Assertions.assertNotNull(res);
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Order(29)
|
||||
void Integrate_findAchievement(){
|
||||
var res = achievementService.findById(1);
|
||||
Assertions.assertNotNull(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
23
front/.gitignore
vendored
Normal file
23
front/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
24
front/README.md
Normal file
24
front/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# frontvid
|
||||
|
||||
## Project setup
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
npm run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
npm run lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
5
front/babel.config.js
Normal file
5
front/babel.config.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
19
front/jsconfig.json
Normal file
19
front/jsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "esnext",
|
||||
"baseUrl": "./",
|
||||
"moduleResolution": "node",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
}
|
||||
}
|
12719
front/package-lock.json
generated
Normal file
12719
front/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
52
front/package.json
Normal file
52
front/package.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "frontvid",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.4.0",
|
||||
"bootstrap": "^4.6.0",
|
||||
"core-js": "^3.8.3",
|
||||
"jquery": "^3.6.4",
|
||||
"popper.js": "^1.16.1",
|
||||
"vue": "^3.2.13",
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.16",
|
||||
"@babel/eslint-parser": "^7.12.16",
|
||||
"@vue/cli-plugin-babel": "~5.0.0",
|
||||
"@vue/cli-plugin-eslint": "~5.0.0",
|
||||
"@vue/cli-service": "~5.0.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-vue": "^8.0.3",
|
||||
"node-sass": "^9.0.0",
|
||||
"sass-loader": "^16.0.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/vue3-essential",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"parser": "@babel/eslint-parser"
|
||||
},
|
||||
"rules": {
|
||||
"vue/multi-word-component-names": 0
|
||||
}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not dead",
|
||||
"not ie 11"
|
||||
]
|
||||
}
|
BIN
front/public/favicon.ico
Normal file
BIN
front/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
18
front/public/index.html
Normal file
18
front/public/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
50
front/src/App.vue
Normal file
50
front/src/App.vue
Normal file
@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div id="app" class="my">
|
||||
<div>
|
||||
<router-view />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserSevice from './services/UserSevice';
|
||||
|
||||
export default {
|
||||
|
||||
name: "app",
|
||||
created() {
|
||||
if(localStorage.getItem('user') != "" && localStorage.getItem('user') != null){
|
||||
UserSevice.get(localStorage.getItem('user')).then(response =>{
|
||||
if(response.data.role == "USER"){
|
||||
this.$router.push('/profile')
|
||||
}else{
|
||||
this.$router.push('/trains')
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
localStorage.clear()
|
||||
this.$router.push("/login")
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.my
|
||||
{
|
||||
position:relative ;
|
||||
top:0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
min-height: calc(108vh - 3em - 10px);
|
||||
background-image:
|
||||
linear-gradient(#ffbb768f, #ffbb768f),
|
||||
url("./assets/mainBackground.jpg");
|
||||
background-repeat: repeat-y;
|
||||
|
||||
}
|
||||
</style>
|
BIN
front/src/assets/backgroundAuthReg.jpg
Normal file
BIN
front/src/assets/backgroundAuthReg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
BIN
front/src/assets/logo.gif
Normal file
BIN
front/src/assets/logo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 KiB |
BIN
front/src/assets/logo.png
Normal file
BIN
front/src/assets/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
front/src/assets/mainBackground.jpg
Normal file
BIN
front/src/assets/mainBackground.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 892 KiB |
25
front/src/components/LayoutDiv.vue
Normal file
25
front/src/components/LayoutDiv.vue
Normal file
@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="container2">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'LayoutDiv',
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.container2 {
|
||||
position: fixed;
|
||||
top:0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-image: url("../assets/backgroundAuthReg.jpg");
|
||||
background-size: cover;
|
||||
}
|
||||
</style>
|
195
front/src/components/ModalCreateTraining.vue
Normal file
195
front/src/components/ModalCreateTraining.vue
Normal file
@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Номер
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="num"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="title"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="title"
|
||||
name="title"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="basic"
|
||||
class="form-label">Базовые места
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
id="basic"
|
||||
name="basic"
|
||||
v-model="basic"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="benefits"
|
||||
class="form-label">Льготные места
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
id="benefits"
|
||||
name="benefits"
|
||||
v-model="benefits"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="desc"
|
||||
class="form-label">Описание
|
||||
</label>
|
||||
<textarea
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="desc"
|
||||
name="desc"
|
||||
v-model="desc"
|
||||
></textarea>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="prof"
|
||||
class="form-label">Возможные профессии
|
||||
</label>
|
||||
<textarea
|
||||
type="prof"
|
||||
class="form-control"
|
||||
id="prof"
|
||||
name="prof"
|
||||
v-model="prof"
|
||||
></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Добавить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TrainingSevice from '@/services/TrainingSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
num:'',
|
||||
title:'',
|
||||
desc:'',
|
||||
prof: '',
|
||||
basic:0,
|
||||
benefits:0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.num=''
|
||||
this.title =''
|
||||
this.desc=''
|
||||
this.prof= ''
|
||||
this.basic=0
|
||||
this.benefits=0
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:null,
|
||||
num:this.num,
|
||||
title:this.title,
|
||||
desc:this.desc,
|
||||
prof: this.prof,
|
||||
basic_places: this.basic,
|
||||
benefit_places: this.benefits
|
||||
}
|
||||
console.log(data)
|
||||
TrainingSevice.create(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
140
front/src/components/ModalTraining.vue
Normal file
140
front/src/components/ModalTraining.vue
Normal file
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow " @click.self="closeModal">
|
||||
<div class="container row ">
|
||||
<div class="col col-lg-5 rounded-card addScroll">
|
||||
<H3>Направления</H3>
|
||||
<div>
|
||||
<div class="rounded-card" v-for="row in trainings" :key="row.id" style="min-width:max-content;" @click="clickOnCard(row)">
|
||||
<h4>{{ row.num }}</h4>
|
||||
<h5>{{ row.title }}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col rounded-card">
|
||||
<div class="mt-3" >
|
||||
<label for="num" style="color: black;font-weight: bold;">Номер:</label>
|
||||
<span v-if="currentTraining"> {{ currentTraining.num }}</span>
|
||||
</div>
|
||||
<div class="mt-3" >
|
||||
<label for="title" style="color: black;font-weight: bold;">Название:</label>
|
||||
<span v-if="currentTraining"> {{ currentTraining.title }}</span>
|
||||
</div>
|
||||
<div class="mt-3" >
|
||||
<label for="desc" style="color: black;font-weight: bold;">Описание:</label>
|
||||
<span v-if="currentTraining"> {{ currentTraining.desc }}</span>
|
||||
</div>
|
||||
<div class="mt-3" >
|
||||
<label for="prof" style="color: black;font-weight: bold;">Возможные профессии:</label>
|
||||
<span v-if="currentTraining"> {{ currentTraining.prof }}</span>
|
||||
</div>
|
||||
<div class="mt-3" v-if="currentTraining">
|
||||
<label for="exams" style="color: black;font-weight: bold;">Экзамены:</label><p></p>
|
||||
<span v-for="exam in currentTraining.exams" :key="exam">{{ exam }} <p></p></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row rounded-card">
|
||||
<button class="btn-success" @click="sendOrder" :disabled="isSelected">Отправить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrderSevice from '@/services/OrderSevice';
|
||||
import TrainingSevice from '@/services/TrainingSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
trainings: [],
|
||||
currentTraining:null,
|
||||
isSelected:true
|
||||
|
||||
}
|
||||
},
|
||||
beforeCreate(){
|
||||
TrainingSevice.getAll().then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
},
|
||||
sendOrder(){
|
||||
OrderSevice.create(localStorage.getItem('user'), this.currentTraining.id).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
},
|
||||
clickOnCard(data){
|
||||
this.currentTraining = data;
|
||||
this.isSelected = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: max-content;
|
||||
min-height: 70%;
|
||||
max-height: fit-content;
|
||||
|
||||
padding: 3%;
|
||||
margin: 3%;
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
|
||||
.addScroll{
|
||||
overflow-y:auto;
|
||||
height: 400px;
|
||||
}
|
||||
</style>
|
190
front/src/components/ModalUpdTraining.vue
Normal file
190
front/src/components/ModalUpdTraining.vue
Normal file
@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="name"
|
||||
class="form-label">Номер
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
name="name"
|
||||
v-model="num"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="phone"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
name="phone"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="phone"
|
||||
class="form-label">Базовые места
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
name="phone"
|
||||
v-model="basic"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="phone"
|
||||
class="form-label">Льготные места
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
name="phone"
|
||||
v-model="benefits"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="snils"
|
||||
class="form-label">Описание
|
||||
</label>
|
||||
<textarea
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="snils"
|
||||
name="snils"
|
||||
v-model="desc"
|
||||
></textarea>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="email"
|
||||
class="form-label">Возможные профессии
|
||||
</label>
|
||||
<textarea
|
||||
type="email"
|
||||
class="form-control"
|
||||
id="email"
|
||||
name="email"
|
||||
v-model="prof"
|
||||
></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="updateTraining()"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Обновить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TrainingSevice from '@/services/TrainingSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:-1,
|
||||
num:'',
|
||||
title:'',
|
||||
desc:'',
|
||||
prof: '',
|
||||
basic:0,
|
||||
benefits:0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
},
|
||||
updateTraining(){
|
||||
let data = {
|
||||
id:this.id,
|
||||
num:this.num,
|
||||
title:this.title,
|
||||
desc:this.desc,
|
||||
prof: this.prof,
|
||||
basic_places: this.basic,
|
||||
benefit_places: this.benefits
|
||||
}
|
||||
console.log(data)
|
||||
TrainingSevice.update(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -60%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
177
front/src/components/ModalUser.vue
Normal file
177
front/src/components/ModalUser.vue
Normal file
@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="name"
|
||||
class="form-label">ФИО
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
name="name"
|
||||
v-model="name"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="phone"
|
||||
class="form-label">Телефон
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
name="phone"
|
||||
v-model="phone"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="snils"
|
||||
class="form-label">СНИЛС
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="snils"
|
||||
name="snils"
|
||||
v-model="snils"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="email"
|
||||
class="form-label">Почта
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
class="form-control"
|
||||
id="email"
|
||||
name="email"
|
||||
v-model="email"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="password"
|
||||
class="form-label">Пароль
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
id="password"
|
||||
name="password"
|
||||
v-model="password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="updateUser()"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Обновить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserSevice from '@/services/UserSevice';
|
||||
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
name:'',
|
||||
email:'',
|
||||
password:'',
|
||||
phone: '',
|
||||
snils: '',
|
||||
AgainPassword:'',
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
},
|
||||
updateUser(){
|
||||
let data = {
|
||||
id: localStorage.getItem('user'),
|
||||
role: "",
|
||||
name:this.name,
|
||||
email: this.email,
|
||||
phone: this.phone,
|
||||
snils: this.snils,
|
||||
password: this.password,
|
||||
againPassword: ""
|
||||
}
|
||||
console.log(data)
|
||||
UserSevice.update(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -105%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
134
front/src/components/achCreate.vue
Normal file
134
front/src/components/achCreate.vue
Normal file
@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="benefits"
|
||||
class="form-label">Баллы
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="10"
|
||||
class="form-control"
|
||||
id="benefits"
|
||||
name="benefits"
|
||||
v-model="points"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Добавить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AchievementSevice from '@/services/AchievementSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:'',
|
||||
title:'',
|
||||
points:0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.num=''
|
||||
this.title =''
|
||||
this.points=0
|
||||
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:null,
|
||||
num:this.num,
|
||||
title:this.title,
|
||||
points:this.points
|
||||
}
|
||||
console.log(data)
|
||||
AchievementSevice.create(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
132
front/src/components/achUpd.vue
Normal file
132
front/src/components/achUpd.vue
Normal file
@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="benefits"
|
||||
class="form-label">Баллы
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
id="benefits"
|
||||
name="benefits"
|
||||
v-model="points"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Обновить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AchievementSevice from '@/services/AchievementSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:'',
|
||||
title:'',
|
||||
points:0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.num=''
|
||||
this.title =''
|
||||
this.points=0
|
||||
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:this.id,
|
||||
num:this.num,
|
||||
title:this.title,
|
||||
points:this.points
|
||||
}
|
||||
console.log(data)
|
||||
AchievementSevice.update(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
106
front/src/components/achievements.vue
Normal file
106
front/src/components/achievements.vue
Normal file
@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<AdminHeader />
|
||||
<div>
|
||||
<div class="container m-3">
|
||||
|
||||
<div class="rounded-card row">
|
||||
<H1>Достижения</H1>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<div class="row">
|
||||
<button class="btn-success border border-transparent rounded shadow-sm " @click="showCreate">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Номер</td>
|
||||
<td>Названией</td>
|
||||
<td>Баллы</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr v-for="(row, index) in achievements" :key="index" style="min-width:max-content;" >
|
||||
<td @click="showUpd(row.id,row.title,row.points)">{{ index+1 }}</td>
|
||||
<td @click="showUpd(row.id,row.title,row.points)">{{ row.title }}</td>
|
||||
<td @click="showUpd(row.id,row.title,row.points)">{{ row.points }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteAch(row.id)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<achCreate ref="modalCreate"></achCreate>
|
||||
<achUpd ref="modalUpdate"></achUpd>
|
||||
|
||||
</template>
|
||||
<script scoped>
|
||||
import AchievementSevice from '@/services/AchievementSevice';
|
||||
import AdminHeader from '@/elemets/adminHeader.vue';
|
||||
import achCreate from './achCreate.vue';
|
||||
import achUpd from './achUpd.vue';
|
||||
export default{
|
||||
name:"achievements",
|
||||
data(){
|
||||
return{
|
||||
achievements: [],
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AdminHeader,
|
||||
achCreate,
|
||||
achUpd
|
||||
},
|
||||
beforeCreate(){
|
||||
AchievementSevice.getAll().then(response =>{
|
||||
this.achievements = response.data
|
||||
})
|
||||
|
||||
},
|
||||
methods:{
|
||||
showUpd(id,title,points) {
|
||||
this.$refs.modalUpdate.show = true;
|
||||
this.$refs.modalUpdate.id = id
|
||||
this.$refs.modalUpdate.title = title
|
||||
this.$refs.modalUpdate.points = points
|
||||
|
||||
},
|
||||
showCreate() {
|
||||
this.$refs.modalCreate.show = true;
|
||||
|
||||
},
|
||||
deleteAch(id){
|
||||
AchievementSevice.delete(id).then(response =>{
|
||||
console.log(response.data)
|
||||
AchievementSevice.getAll().then(response =>{
|
||||
this.achievements = response.data
|
||||
})
|
||||
}).catch(e => {
|
||||
console.log(e.data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:absolute ;
|
||||
min-width:calc(205vh);
|
||||
background-color: #6ec0d9e9 ;
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:12px;
|
||||
align-items: center;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
113
front/src/components/benCreate.vue
Normal file
113
front/src/components/benCreate.vue
Normal file
@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Добавить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BenefitSevice from '@/services/BenefitSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:'',
|
||||
title:'',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.title =''
|
||||
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:null,
|
||||
title:this.title,
|
||||
}
|
||||
console.log(data)
|
||||
BenefitSevice.create(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
114
front/src/components/benUpd.vue
Normal file
114
front/src/components/benUpd.vue
Normal file
@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Обновить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BenefitSevice from '@/services/BenefitSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:'',
|
||||
title:'',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.title =''
|
||||
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:this.id,
|
||||
title:this.title,
|
||||
}
|
||||
console.log(data)
|
||||
BenefitSevice.update(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
104
front/src/components/benefits.vue
Normal file
104
front/src/components/benefits.vue
Normal file
@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<AdminHeader />
|
||||
<div>
|
||||
<div class="container m-3">
|
||||
|
||||
<div class="rounded-card row">
|
||||
<H1>Льготы</H1>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<div class="row">
|
||||
<button class="btn-success border border-transparent rounded shadow-sm " @click="showCreate">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Номер</td>
|
||||
<td>Названией</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr v-for="(row, index) in benefits" :key="index" style="min-width:max-content;" >
|
||||
<td @click="showUpd(row.id,row.title)">{{ index+1 }}</td>
|
||||
<td @click="showUpd(row.id,row.title)">{{ row.title }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteAch(row.id)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<benCreate ref="modalCreate"></benCreate>
|
||||
<benUpd ref="modalUpdate"></benUpd>
|
||||
|
||||
</template>
|
||||
|
||||
<script scoped>
|
||||
import BenefitSevice from '@/services/BenefitSevice';
|
||||
import AdminHeader from '@/elemets/adminHeader.vue';
|
||||
import benCreate from './benCreate.vue';
|
||||
import benUpd from './benUpd.vue';
|
||||
export default{
|
||||
name:"benefits",
|
||||
data(){
|
||||
return{
|
||||
benefits: [],
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AdminHeader,
|
||||
benCreate,
|
||||
benUpd
|
||||
},
|
||||
beforeCreate(){
|
||||
BenefitSevice.getAll().then(response =>{
|
||||
this.benefits = response.data
|
||||
})
|
||||
|
||||
},
|
||||
methods:{
|
||||
showUpd(id,title) {
|
||||
this.$refs.modalUpdate.show = true;
|
||||
this.$refs.modalUpdate.id = id
|
||||
this.$refs.modalUpdate.title = title
|
||||
|
||||
},
|
||||
showCreate() {
|
||||
this.$refs.modalCreate.show = true;
|
||||
|
||||
},
|
||||
deleteAch(id){
|
||||
BenefitSevice.delete(id).then(response =>{
|
||||
console.log(response.data)
|
||||
BenefitSevice.getAll().then(response =>{
|
||||
this.benefits = response.data
|
||||
})
|
||||
}).catch(e => {
|
||||
console.log(e.data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:absolute ;
|
||||
min-width:calc(205vh);
|
||||
background-color: #6ec0d9e9 ;
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:12px;
|
||||
align-items: center;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
113
front/src/components/examCreate.vue
Normal file
113
front/src/components/examCreate.vue
Normal file
@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Добавить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ExamSevice from '@/services/ExamSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:'',
|
||||
title:'',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.title =''
|
||||
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:null,
|
||||
title:this.title,
|
||||
}
|
||||
console.log(data)
|
||||
ExamSevice.create(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
114
front/src/components/examUpd.vue
Normal file
114
front/src/components/examUpd.vue
Normal file
@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div v-if="show" class="modal-shadow" @click.self="closeModal">
|
||||
<div class="container">
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="num"
|
||||
class="form-label">Название
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="num"
|
||||
name="num"
|
||||
v-model="title"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
@click="create"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Обновить
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ExamSevice from '@/services/ExamSevice';
|
||||
export default {
|
||||
name: "ModalWindow",
|
||||
data: function () {
|
||||
return {
|
||||
show: false,
|
||||
id:'',
|
||||
title:'',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.show = false
|
||||
this.title =''
|
||||
|
||||
},
|
||||
create(){
|
||||
let data = {
|
||||
id:this.id,
|
||||
title:this.title,
|
||||
}
|
||||
console.log(data)
|
||||
ExamSevice.update(data).then(res => {
|
||||
console.log(res.data)
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.modal-shadow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
padding: 50px ;
|
||||
background: rgba(0, 0, 0, 0.39);
|
||||
}
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
min-width: 100px;
|
||||
height: fit-content;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 1%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
|
||||
|
||||
}
|
||||
.modal-close {
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: #2a4cc7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 7px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #0971c7;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
</style>
|
104
front/src/components/exams.vue
Normal file
104
front/src/components/exams.vue
Normal file
@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<AdminHeader />
|
||||
<div>
|
||||
<div class="container m-3">
|
||||
|
||||
<div class="rounded-card row">
|
||||
<H1>Экзамены</H1>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<div class="row">
|
||||
<button class="btn-success border border-transparent rounded shadow-sm " @click="showCreate">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Номер</td>
|
||||
<td>Название</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr v-for="(row, index) in exams" :key="index" style="min-width:max-content;" >
|
||||
<td @click="showUpd(row.id,row.title)">{{ index+1 }}</td>
|
||||
<td @click="showUpd(row.id,row.title)">{{ row.title }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteAch(row.id)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<examCreate ref="modalCreate"></examCreate>
|
||||
<examUpd ref="modalUpdate"></examUpd>
|
||||
|
||||
</template>
|
||||
|
||||
<script scoped>
|
||||
import ExamSevice from '@/services/ExamSevice';
|
||||
import AdminHeader from '@/elemets/adminHeader.vue';
|
||||
import examUpd from './examUpd.vue';
|
||||
import examCreate from './examCreate.vue';
|
||||
export default{
|
||||
name:"benefits",
|
||||
data(){
|
||||
return{
|
||||
exams: [],
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AdminHeader,
|
||||
examCreate,
|
||||
examUpd
|
||||
},
|
||||
beforeCreate(){
|
||||
ExamSevice.getAll().then(response =>{
|
||||
this.exams = response.data
|
||||
})
|
||||
|
||||
},
|
||||
methods:{
|
||||
showUpd(id,title) {
|
||||
this.$refs.modalUpdate.show = true;
|
||||
this.$refs.modalUpdate.id = id
|
||||
this.$refs.modalUpdate.title = title
|
||||
|
||||
},
|
||||
showCreate() {
|
||||
this.$refs.modalCreate.show = true;
|
||||
|
||||
},
|
||||
deleteAch(id){
|
||||
ExamSevice.delete(id).then(response =>{
|
||||
console.log(response.data)
|
||||
ExamSevice.getAll().then(response =>{
|
||||
this.exams = response.data
|
||||
})
|
||||
}).catch(e => {
|
||||
console.log(e.data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:absolute ;
|
||||
min-width:calc(205vh);
|
||||
background-color: #6ec0d9e9 ;
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:12px;
|
||||
align-items: center;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
100
front/src/components/login.vue
Normal file
100
front/src/components/login.vue
Normal file
@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<layout-div>
|
||||
<div class="row justify-content-md-center mt-5">
|
||||
<div class="col-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title mb-4">Вход</h5>
|
||||
<form>
|
||||
<p v-if="Object.keys(validationErrors).length != 0" class='text-center '><small class='text-danger'>Incorrect Email or Password</small></p>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="email"
|
||||
class="form-label">
|
||||
Почта
|
||||
</label>
|
||||
<input
|
||||
v-model="email"
|
||||
type="email"
|
||||
class="form-control"
|
||||
id="email"
|
||||
name="email"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="password"
|
||||
class="form-label">Пароль
|
||||
</label>
|
||||
<input
|
||||
v-model="password"
|
||||
type="password"
|
||||
class="form-control"
|
||||
id="password"
|
||||
name="password"
|
||||
/>
|
||||
</div>
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
:disabled="isSubmitting"
|
||||
@click="loginAction()"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Войти</button>
|
||||
<p class="text-center">Еще не зарегистрированы?
|
||||
<router-link to="/register">Зарегистрироваться </router-link>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</layout-div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserService from '../services/UserSevice';
|
||||
import LayoutDiv from './LayoutDiv.vue';
|
||||
|
||||
export default {
|
||||
name: 'LoginPage',
|
||||
components: {
|
||||
LayoutDiv,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
email:'',
|
||||
password:'',
|
||||
validationErrors:{},
|
||||
isSubmitting:false,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if(localStorage.getItem('user') != "" && localStorage.getItem('user') != null){
|
||||
this.$router.push('/profile')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loginAction(){
|
||||
this.isSubmitting = true
|
||||
UserService.auth(this.email, this.password)
|
||||
.then(response => {
|
||||
localStorage.setItem('user', response.data.id)
|
||||
if(response.data.role == 'USER'){
|
||||
this.$router.push('/profile')
|
||||
}
|
||||
else{
|
||||
this.$router.push('/trains')
|
||||
}
|
||||
return response.data
|
||||
})
|
||||
.catch(error => {
|
||||
this.isSubmitting = false
|
||||
console.log(error);
|
||||
return error
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
196
front/src/components/orders.vue
Normal file
196
front/src/components/orders.vue
Normal file
@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<HeaderUser />
|
||||
<div class="container">
|
||||
<div class="rounded-card row">
|
||||
<H1>Заявления</H1>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
placeholder="Название направления"
|
||||
name="name"
|
||||
v-model="search_value"
|
||||
/>
|
||||
<button class="btn-secondary border border-transparent rounded shadow-sm " @click="search">Поиск</button>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<h2>Льготные места</h2>
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Место</td>
|
||||
<td>ФИО</td>
|
||||
<td>СНИЛС</td>
|
||||
<td>Баллы</td>
|
||||
<td>Поступление</td>
|
||||
</tr>
|
||||
<tr v-for="row in benefits" :key="row.id_table" style="min-width:max-content;">
|
||||
<td>{{ row.id_table}}</td>
|
||||
<td>{{ row.name }}</td>
|
||||
<td>{{ row.snils }}</td>
|
||||
<td>{{ row.points }}</td>
|
||||
<td>
|
||||
<p v-if="row.confirm">+</p>
|
||||
<p v-else>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<h2>Базовые места</h2>
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Место</td>
|
||||
<td>ФИО</td>
|
||||
<td>СНИЛС</td>
|
||||
<td>Баллы</td>
|
||||
<td>Поступление</td>
|
||||
</tr>
|
||||
<tr v-for="row in basics" :key="row.id_table" style="min-width:max-content;">
|
||||
<td>{{ row.id_table}}</td>
|
||||
<td>{{ row.name }}</td>
|
||||
<td>{{ row.snils }}</td>
|
||||
<td>{{ row.points }}</td>
|
||||
<td>
|
||||
<p v-if="row.confirm">+</p>
|
||||
<p v-else>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script scoped>
|
||||
import HeaderUser from '@/elemets/headerUser.vue';
|
||||
import OrderSevice from '@/services/OrderSevice';
|
||||
|
||||
export default {
|
||||
name: 'Page2',
|
||||
data () {
|
||||
return {
|
||||
id: 0,
|
||||
num: "",
|
||||
title:"",
|
||||
basics:[],
|
||||
benefits:[],
|
||||
search_value:"",
|
||||
}
|
||||
},
|
||||
components: {
|
||||
HeaderUser,
|
||||
},
|
||||
created() {
|
||||
this.id = this.$route.params.id;
|
||||
OrderSevice.getBasic(this.id).then(response =>{
|
||||
this.basics = response.data;
|
||||
this.basics.sort(function(a,b){
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
}
|
||||
if (a.points < b.points) {
|
||||
return 1;
|
||||
}
|
||||
// a должно быть равным b
|
||||
return 0;
|
||||
})
|
||||
let id = 1;
|
||||
this.basics.forEach((val) =>{
|
||||
val.id_table = id;
|
||||
id++;
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
OrderSevice.getBenefit(this.id).then(response =>{
|
||||
this.benefits = response.data;
|
||||
this.benefits.sort(function(a,b){
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
}
|
||||
if (a.points < b.points) {
|
||||
return 1;
|
||||
}
|
||||
// a должно быть равным b
|
||||
return 0;
|
||||
})
|
||||
let id = 1;
|
||||
this.benefits.forEach((val) =>{
|
||||
val.id_table = id;
|
||||
id++;
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
search(){
|
||||
if(this.search_value.length > 0) {
|
||||
this.basics = this.basics.filter((place) => place.name.toUpperCase().indexOf(this.search_value.toUpperCase())>-1)
|
||||
this.benefits = this.benefits.filter((place) => place.name.toUpperCase().indexOf(this.search_value.toUpperCase())>-1)
|
||||
}else{
|
||||
OrderSevice.getBasic(this.id).then(response =>{
|
||||
this.basics = response.data;
|
||||
this.basics.sort(function(a,b){
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
}
|
||||
if (a.points < b.points) {
|
||||
return 1;
|
||||
}
|
||||
// a должно быть равным b
|
||||
return 0;
|
||||
})
|
||||
let id = 1;
|
||||
this.basics.forEach((val) =>{
|
||||
val.id_table = id;
|
||||
id++;
|
||||
})
|
||||
})
|
||||
OrderSevice.getBenefit(this.id).then(response =>{
|
||||
this.benefits = response.data;
|
||||
this.benefits.sort(function(a,b){
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
}
|
||||
if (a.points < b.points) {
|
||||
return 1;
|
||||
}
|
||||
// a должно быть равным b
|
||||
return 0;
|
||||
})
|
||||
let id = 1;
|
||||
this.benefits.forEach((val) =>{
|
||||
val.id_table = id;
|
||||
id++;
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:absolute ;
|
||||
min-width:calc(205vh);
|
||||
background-color: #6ec0d9e9 ;
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:12px;
|
||||
align-items: center;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
409
front/src/components/profile.vue
Normal file
409
front/src/components/profile.vue
Normal file
@ -0,0 +1,409 @@
|
||||
|
||||
<script>
|
||||
import HeaderUser from '@/elemets/headerUser.vue';
|
||||
import UserSevice from '@/services/UserSevice';
|
||||
import AchievementSevice from '@/services/AchievementSevice';
|
||||
import BenefitSevice from '@/services/BenefitSevice';
|
||||
import ExamResultSevice from '@/services/ExamResultSevice';
|
||||
import ExamSevice from '@/services/ExamSevice';
|
||||
import ModalUser from './ModalUser.vue';
|
||||
export default {
|
||||
name: "user",
|
||||
components: {
|
||||
HeaderUser,
|
||||
ModalUser
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentUser: null,
|
||||
myExams:[],
|
||||
exams:[],
|
||||
myAchievements:[],
|
||||
achievements:[],
|
||||
myBenefits:[],
|
||||
benefits:[],
|
||||
selectedExam:null,
|
||||
selectedAchievement: null,
|
||||
selectedBenefit:null,
|
||||
ExamPoints:0,
|
||||
message: ''
|
||||
};
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("user") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
UserSevice.get(localStorage.getItem("user"))
|
||||
.then(response => {
|
||||
this.currentUser = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
AchievementSevice.getForUser(localStorage.getItem("user"))
|
||||
.then(response =>{
|
||||
this.myAchievements = response.data;
|
||||
console.log("myAch");
|
||||
console.log(response.data);
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
AchievementSevice.getForUserNot(localStorage.getItem("user"))
|
||||
.then(response =>{
|
||||
this.achievements = response.data;
|
||||
if (this.achievements.length > 0){
|
||||
this.selectedAchievement = this.achievements[0];
|
||||
}else{
|
||||
this.selectedAchievement = {id:-1};
|
||||
}
|
||||
console.log("allAch");
|
||||
console.log(response.data);
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
BenefitSevice.getForUser(localStorage.getItem("user"))
|
||||
.then(response =>{
|
||||
this.myBenefits = response.data;
|
||||
console.log("myBen");
|
||||
console.log(response.data);
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
BenefitSevice.getForUserNot(localStorage.getItem("user"))
|
||||
.then(response =>{
|
||||
this.benefits = response.data;
|
||||
if(this.benefits.length >0){
|
||||
this.selectedBenefit = this.benefits[0];
|
||||
}else{
|
||||
this.selectedBenefit = {id:-1};
|
||||
}
|
||||
console.log(response.data);
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
ExamResultSevice.getForUser(localStorage.getItem("user"))
|
||||
.then(response =>{
|
||||
this.myExams = response.data;
|
||||
console.log(response.data);
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
ExamSevice.getForUser(localStorage.getItem("user"))
|
||||
.then(response =>{
|
||||
this.exams = response.data;
|
||||
if(this.exams.length > 0)
|
||||
{
|
||||
this.selectedExam = this.exams[0];
|
||||
}else{
|
||||
this.selectedExam = {id:-1};
|
||||
}
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getUser(id) {
|
||||
UserSevice.get(id)
|
||||
.then(response => {
|
||||
this.currentUser = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
showModal() {
|
||||
this.$refs.modal.show = true;
|
||||
this.$refs.modal.name = this.currentUser.name;
|
||||
this.$refs.modal.email = this.currentUser.email;
|
||||
this.$refs.modal.password = this.currentUser.password;
|
||||
this.$refs.modal.phone = this.currentUser.phone;
|
||||
this.$refs.modal.snils = this.currentUser.snils;
|
||||
this.$refs.modal.AgainPassword = this.currentUser.AgainPassword;
|
||||
},
|
||||
|
||||
handleChange(e)
|
||||
{
|
||||
if (+e.target.value > 100) {
|
||||
e.target.value = 100;
|
||||
} else if (+e.target.value < 0) {
|
||||
e.target.value = 0;
|
||||
}
|
||||
if(+e.target.value == ""){
|
||||
e.target.value = 0;
|
||||
}
|
||||
},
|
||||
addExam(){
|
||||
let data = {
|
||||
user: localStorage.getItem("user"),
|
||||
exam: this.selectedExam.id,
|
||||
points:this.ExamPoints,
|
||||
}
|
||||
ExamResultSevice.create(data).then(otver =>{
|
||||
ExamResultSevice.getForUser(localStorage.getItem("user")).then(res =>{
|
||||
console.log(otver.data)
|
||||
this.myExams = res.data;
|
||||
ExamSevice.getForUser(localStorage.getItem("user")).then(response =>{
|
||||
this.exams = response.data;
|
||||
if(this.exams.length > 0)
|
||||
{
|
||||
this.selectedExam = this.exams[0];
|
||||
}
|
||||
else{
|
||||
this.selectedExam = {id:-1};
|
||||
}
|
||||
this.ExamPoints = 0;
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
addAchievement(){
|
||||
UserSevice.addAchievement(localStorage.getItem("user"), this.selectedAchievement.id)
|
||||
.then(value => {
|
||||
console.log(value);
|
||||
this.achievements = []
|
||||
this.myAchievements = [];
|
||||
AchievementSevice.getForUser(localStorage.getItem("user")).then(response =>
|
||||
{
|
||||
this.myAchievements = response.data;
|
||||
AchievementSevice.getForUserNot(localStorage.getItem("user")).then(result =>{
|
||||
this.achievements = result.data
|
||||
if(this.achievements.length > 0){
|
||||
this.selectedAchievement = this.achievements[0];
|
||||
}else
|
||||
{
|
||||
this.selectedAchievement = {id:-1};
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
console.log('add achievement')
|
||||
},
|
||||
deleteAchievement(id){
|
||||
UserSevice.removeAchievement(localStorage.getItem("user"), id).then(response => {
|
||||
console.log(response.data)
|
||||
AchievementSevice.getForUser(localStorage.getItem("user")).then(response =>
|
||||
{
|
||||
this.myAchievements = response.data;
|
||||
AchievementSevice.getForUserNot(localStorage.getItem("user")).then(result =>{
|
||||
this.achievements = result.data
|
||||
if(this.achievements.length > 0){
|
||||
this.selectedAchievement = this.achievements[0];
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
console.log('remove achievement')
|
||||
},
|
||||
|
||||
|
||||
addBenefit(){
|
||||
UserSevice.addBenefit(localStorage.getItem("user"), this.selectedBenefit.id)
|
||||
.then(value => {
|
||||
console.log(value);
|
||||
this.benefits = []
|
||||
this.myBenefits = [];
|
||||
BenefitSevice.getForUser(localStorage.getItem("user")).then(response =>
|
||||
{
|
||||
this.myBenefits = response.data;
|
||||
BenefitSevice.getForUserNot(localStorage.getItem("user")).then(result =>{
|
||||
this.benefits = result.data
|
||||
if(this.benefits.length > 0){
|
||||
this.selectedBenefit = this.benefits[0];
|
||||
}else{
|
||||
this.selectedBenefit = {id:-1};
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
console.log('add benefit')
|
||||
},
|
||||
deleteBenefit(id){
|
||||
UserSevice.removeBenefit(localStorage.getItem("user"), id).then(response => {
|
||||
console.log(response.data)
|
||||
BenefitSevice.getForUser(localStorage.getItem("user")).then(response =>
|
||||
{
|
||||
this.myBenefits = response.data;
|
||||
BenefitSevice.getForUserNot(localStorage.getItem("user")).then(result =>{
|
||||
this.benefits = result.data
|
||||
if(this.benefits.length > 0){
|
||||
this.selectedBenefit = this.benefits[0];
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
console.log('remove achievement')
|
||||
},
|
||||
|
||||
deletexam(id)
|
||||
{
|
||||
ExamResultSevice.delete(localStorage.getItem("user"),id).then(response =>{
|
||||
console.log(response.data)
|
||||
this.myExams = [];
|
||||
ExamResultSevice.getForUser(localStorage.getItem("user")).then(res => {
|
||||
this.myExams = res.data;
|
||||
ExamSevice.getForUser(localStorage.getItem("user")).then(es => {
|
||||
this.exams = es.data;
|
||||
if(this.exams.length > 0){
|
||||
this.selectedExam = this.exams[0];
|
||||
}else{
|
||||
this.selectedExam = {id:-1};
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
logout() {
|
||||
localStorage.removeItem('user');
|
||||
this.$router.push("/login");
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:relative ;
|
||||
top:0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
min-width: calc(205vh);;
|
||||
background-color: #6ec0d9e9 ;
|
||||
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
}
|
||||
.table
|
||||
{
|
||||
background-color: #fecb98;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<HeaderUser />
|
||||
<div class="container p-1 m-1" id="allInfo">
|
||||
|
||||
<div id="textInfo" class="rounded-card">
|
||||
<label for="profile" style="color: black;font-weight:bolder;">Профиль</label>
|
||||
<div class="mt-3" >
|
||||
<label for="nickName" style="color: black;font-weight: bold;">ФИО:</label>
|
||||
<span> {{ currentUser.name }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="email" style="color: black;font-weight: bold;">Почта:</label>
|
||||
<span> {{ currentUser.email }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="snils" style="color: black;font-weight: bold;">СНИЛС:</label>
|
||||
<span> {{ currentUser.snils }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="phone" style="color: black;font-weight: bold;">Телефон:</label>
|
||||
<span> {{ currentUser.phone }}</span>
|
||||
</div>
|
||||
<div >
|
||||
<button class="btn btn-warning m-5" @click="showModal">Обновить данные</button>
|
||||
<button class="btn btn-warning" @click="logout">Выйти</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="textExams" class="rounded-card justify m-5" style="min-width:auto; gap: 80px; ">
|
||||
<label for="exams" style="color: black;font-weight:bolder;">Экзамены</label>
|
||||
<div style="min-width:max-content; display: flex; align-items: center; gap: 80px;">
|
||||
<select style="min-width: 200px;" v-model="selectedExam">
|
||||
<option v-for="exam in exams" :key="exam.id" v-bind:value="exam">{{exam.title}}</option>
|
||||
</select>
|
||||
<input type="number" min="0" max="100" class="justify" v-model="ExamPoints" placeholder="Введите баллы" required @change="(e) => handleChange(e)">
|
||||
<button class="btn-warning border border-transparent rounded shadow-sm " @click="addExam">Добавить</button>
|
||||
</div>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr v-for="row in myExams" :key="row.exam" style="min-width:max-content;">
|
||||
<td>{{ row.title }}</td>
|
||||
<td>{{ row.points }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deletexam(row.exam)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="textAchievements" class="rounded-card justify m-5" style="min-width:auto; gap: 80px; ">
|
||||
<label for="achievements" style="color: black;font-weight:bolder;">Достижения</label>
|
||||
<div style="min-width:max-content; display: flex; align-items: center; gap: 80px;">
|
||||
<select style="min-width: 200px;" v-model="selectedAchievement">
|
||||
<option v-for="achievement in achievements" :key="achievement.id" v-bind:value="achievement">{{achievement.title}}</option>
|
||||
</select>
|
||||
<button class="btn-warning border border-transparent rounded shadow-sm " @click="addAchievement">Добавить</button>
|
||||
</div>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr v-for="row in myAchievements" :key="row.id" style="min-width:max-content;">
|
||||
<td>{{ row.title }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteAchievement(row.id)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="textBenefits" class="rounded-card justify m-5" style="min-width:auto; gap: 80px; ">
|
||||
<label for="benefit" style="color: black;font-weight:bolder;">Льготы</label>
|
||||
<div style="min-width:max-content; display: flex; align-items: center; gap: 80px;">
|
||||
<select style="min-width: 200px;" v-model="selectedBenefit">
|
||||
<option v-for="benefit in benefits" :key="benefit.id" v-bind:value="benefit">{{benefit.title}}</option>
|
||||
</select>
|
||||
<Button class="btn-warning border border-transparent rounded shadow-sm " @click="addBenefit">Добавить</Button>
|
||||
</div>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr v-for="row in myBenefits" :key="row.id" style="min-width:max-content;">
|
||||
<td>{{ row.title }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteBenefit(row.id)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ModalUser ref="modal"></ModalUser>
|
||||
</template>
|
||||
|
||||
|
189
front/src/components/register.vue
Normal file
189
front/src/components/register.vue
Normal file
@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<layout-div>
|
||||
<div class="row justify-content-md-center mt-5">
|
||||
<div class="col-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title mb-4">Регистрация</h5>
|
||||
<form >
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="name"
|
||||
class="form-label">ФИО
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
name="name"
|
||||
v-model="name"
|
||||
/>
|
||||
<div v-if="validationErrors.name" class="flex flex-col">
|
||||
<small class="text-danger">
|
||||
{{validationErrors?.name[0]}}
|
||||
</small >
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="phone"
|
||||
class="form-label">Телефон
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
name="phone"
|
||||
v-model="phone"
|
||||
/>
|
||||
<div v-if="validationErrors.phone" class="flex flex-col">
|
||||
<small class="text-danger">
|
||||
{{validationErrors?.phone[0]}}
|
||||
</small >
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="snils"
|
||||
class="form-label">СНИЛС
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="snils"
|
||||
name="snils"
|
||||
v-model="snils"
|
||||
/>
|
||||
<div v-if="validationErrors.snils" class="flex flex-col">
|
||||
<small class="text-danger">
|
||||
{{validationErrors?.snils[0]}}
|
||||
</small >
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="email"
|
||||
class="form-label">Почта
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
class="form-control"
|
||||
id="email"
|
||||
name="email"
|
||||
v-model="email"
|
||||
/>
|
||||
<div v-if="validationErrors.email" class="flex flex-col">
|
||||
<small class="text-danger">
|
||||
{{validationErrors?.email[0]}}
|
||||
</small >
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="password"
|
||||
class="form-label">Пароль
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
id="password"
|
||||
name="password"
|
||||
v-model="password"
|
||||
/>
|
||||
<div v-if="validationErrors.password" class="flex flex-col">
|
||||
<small class="text-danger">
|
||||
{{validationErrors?.password[0]}}
|
||||
</small >
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label
|
||||
htmlFor="confirm_password"
|
||||
class="form-label">Подтверждение пароля
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
id="AgainPassword"
|
||||
name="AgainPassword"
|
||||
v-model="AgainPassword"
|
||||
/>
|
||||
</div>
|
||||
<div class="d-grid gap-2">
|
||||
<button
|
||||
:disabled="isSubmitting"
|
||||
@click="registerAction()"
|
||||
type="button"
|
||||
class="btn btn-primary btn-block">Зарегистрироваться
|
||||
</button>
|
||||
<p
|
||||
class="text-center">Уже зарегистрированы? <router-link to="/login">Войти</router-link>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</layout-div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserService from '../services/UserSevice';
|
||||
import LayoutDiv from './LayoutDiv.vue';
|
||||
|
||||
export default {
|
||||
name: 'RegisterPage',
|
||||
components: {
|
||||
LayoutDiv,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
id:null,
|
||||
role: null,
|
||||
name:'',
|
||||
email:'',
|
||||
password:'',
|
||||
phone: '',
|
||||
snils: '',
|
||||
AgainPassword:'',
|
||||
validationErrors:{},
|
||||
isSubmitting:false,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if(localStorage.getItem('user') != "" && localStorage.getItem('user') != null){
|
||||
this.$router.push('/profile')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
registerAction(){
|
||||
this.isSubmitting = true
|
||||
let payload = {
|
||||
id: 0,
|
||||
role: "",
|
||||
name:this.name,
|
||||
email: this.email,
|
||||
phone: this.phone,
|
||||
snils: this.snils,
|
||||
password: this.password,
|
||||
againPassword: this.AgainPassword
|
||||
}
|
||||
UserService.create(payload)
|
||||
.then(response => {
|
||||
localStorage.setItem('user', response.data)
|
||||
localStorage.setItem('role', response.data.role)
|
||||
this.$router.push('/profile')
|
||||
return response
|
||||
})
|
||||
.catch(error => {
|
||||
this.isSubmitting = false
|
||||
if (error.response.data.errors != undefined) {
|
||||
this.validationErrors = error.response.data.errors
|
||||
}
|
||||
return error
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
230
front/src/components/training.vue
Normal file
230
front/src/components/training.vue
Normal file
@ -0,0 +1,230 @@
|
||||
|
||||
<template>
|
||||
<AdminHeader />
|
||||
<div class="container p-1 m-1" id="allInfo">
|
||||
|
||||
<div id="textInfo" class="rounded-card">
|
||||
<label for="profile" style="color: black;font-weight:bolder;">Направление</label>
|
||||
<div class="mt-3" >
|
||||
<label for="nickName" style="color: black;font-weight: bold;">Номер:</label>
|
||||
<span> {{ currentTraining.num }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="email" style="color: black;font-weight: bold;">Название:</label>
|
||||
<span> {{ currentTraining.title }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="email" style="color: black;font-weight: bold;">Базовые места:</label>
|
||||
<span> {{ currentTraining.basic_places }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="email" style="color: black;font-weight: bold;">Льготные места:</label>
|
||||
<span> {{ currentTraining.benefit_places }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="snils" style="color: black;font-weight: bold;">Описание:</label>
|
||||
<span> {{ currentTraining.desc }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label for="phone" style="color: black;font-weight: bold;">Профессии:</label>
|
||||
<span> {{ currentTraining.prof }}</span>
|
||||
</div>
|
||||
<div >
|
||||
<button class="btn btn-warning m-5" @click="showModal">Обновить данные</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="textExams" class="rounded-card justify m-5" style="min-width:auto; gap: 80px; ">
|
||||
<label for="exams" style="color: black;font-weight:bolder;">Экзамены</label>
|
||||
<div style="min-width:max-content; display: flex; align-items: center; gap: 80px;">
|
||||
<select style="min-width: 200px;" v-model="selectedExam">
|
||||
<option v-for="exam in exams" :key="exam.id" v-bind:value="exam">{{exam.title}}</option>
|
||||
</select>
|
||||
<input type="number" min="0" max="100" class="justify" v-model="ExamPoints" placeholder="Введите баллы" required @change="(e) => handleChange(e)">
|
||||
<button class="btn-warning border border-transparent rounded shadow-sm " @click="addExam">Добавить</button>
|
||||
</div>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr v-for="row in myExams" :key="row.exam" style="min-width:max-content;">
|
||||
<td>{{ row.title }}</td>
|
||||
<td>{{ row.points }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deletexam(row.exam)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<ModalUpdTraining ref="modal"></ModalUpdTraining>
|
||||
</template>
|
||||
|
||||
<script scoped>
|
||||
import AdminHeader from '@/elemets/adminHeader.vue';
|
||||
import TrainingSevice from '@/services/TrainingSevice';
|
||||
import TrainingExamSevice from '@/services/TrainingExamSevice';
|
||||
import ExamSevice from '@/services/ExamSevice';
|
||||
import ModalUpdTraining from './ModalUpdTraining.vue';
|
||||
export default {
|
||||
name: "user",
|
||||
components: {
|
||||
AdminHeader,
|
||||
ModalUpdTraining
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
id:0,
|
||||
currentTraining: null,
|
||||
myExams:[],
|
||||
exams:[],
|
||||
selectedExam:null,
|
||||
ExamPoints:0,
|
||||
message: ''
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if (localStorage.getItem("user") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
this.id = this.$route.params.id;
|
||||
TrainingSevice.get(this.id)
|
||||
.then(response => {
|
||||
this.currentTraining = response.data;
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
|
||||
TrainingExamSevice.getForTraining(this.id)
|
||||
.then(response =>{
|
||||
this.myExams = response.data;
|
||||
console.log(response.data);
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
ExamSevice.getForTraining(this.id)
|
||||
.then(response =>{
|
||||
this.exams = response.data;
|
||||
if(this.exams.length > 0)
|
||||
{
|
||||
this.selectedExam = this.exams[0];
|
||||
}else{
|
||||
this.selectedExam = {id:-1};
|
||||
}
|
||||
} ) .catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
||||
showModal() {
|
||||
this.$refs.modal.show = true;
|
||||
this.$refs.modal.id = this.id;
|
||||
this.$refs.modal.title = this.currentTraining.title;
|
||||
this.$refs.modal.num = this.currentTraining.num;
|
||||
this.$refs.modal.desc = this.currentTraining.desc;
|
||||
this.$refs.modal.prof = this.currentTraining.prof;
|
||||
this.$refs.modal.basic = this.currentTraining.basic_places;
|
||||
this.$refs.modal.benefits = this.currentTraining.benefit_places;
|
||||
},
|
||||
|
||||
handleChange(e)
|
||||
{
|
||||
if (+e.target.value > 100) {
|
||||
e.target.value = 100;
|
||||
} else if (+e.target.value < 0) {
|
||||
e.target.value = 0;
|
||||
}
|
||||
if(+e.target.value == ""){
|
||||
e.target.value = 0;
|
||||
}
|
||||
},
|
||||
addExam(){
|
||||
let data = {
|
||||
training: this.id,
|
||||
exam: this.selectedExam.id,
|
||||
title: "",
|
||||
points:this.ExamPoints,
|
||||
}
|
||||
TrainingExamSevice.create(data).then(otver =>{
|
||||
TrainingExamSevice.getForTraining(this.id).then(res =>{
|
||||
console.log(otver.data)
|
||||
this.myExams = res.data;
|
||||
ExamSevice.getForTraining(this.id).then(response =>{
|
||||
this.exams = response.data;
|
||||
if(this.exams.length > 0)
|
||||
{
|
||||
this.selectedExam = this.exams[0];
|
||||
}
|
||||
else{
|
||||
this.selectedExam = {id:-1};
|
||||
}
|
||||
this.ExamPoints = 0;
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
deletexam(id)
|
||||
{
|
||||
TrainingExamSevice.delete(this.id,id).then(response =>{
|
||||
console.log(response.data)
|
||||
this.myExams = [];
|
||||
TrainingExamSevice.getForTraining(this.id).then(res => {
|
||||
this.myExams = res.data;
|
||||
ExamSevice.getForTraining(this.id).then(es => {
|
||||
this.exams = es.data;
|
||||
if(this.exams.length > 0){
|
||||
this.selectedExam = this.exams[0];
|
||||
}else{
|
||||
this.selectedExam = {id:-1};
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:relative ;
|
||||
top:0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
min-width: calc(205vh);;
|
||||
background-color: #6ec0d9e9 ;
|
||||
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
}
|
||||
.table
|
||||
{
|
||||
background-color: #fecb98;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
141
front/src/components/trainings.vue
Normal file
141
front/src/components/trainings.vue
Normal file
@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<HeaderUser />
|
||||
<div>
|
||||
<div class="container m-3">
|
||||
<div class="rounded-card">
|
||||
<H1>Мое заявление</H1>
|
||||
<div v-if="myOrder">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Номер</td>
|
||||
<td>Название</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr style="min-width:max-content;">
|
||||
<td>{{ myOrder.num }}</td>
|
||||
<td>{{ myOrder.title }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteOrder">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-else><h2>Вы еще не подали заявление</h2>
|
||||
<button class="btn-secondary" @click="showModal">Подать заявление</button></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="rounded-card row">
|
||||
<H1>Заявления</H1>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
placeholder="Название направления"
|
||||
name="name"
|
||||
v-model="search_value"
|
||||
/>
|
||||
<button class="btn-secondary border border-transparent rounded shadow-sm " @click="search">Поиск</button>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Номер</td>
|
||||
<td>Зазвание</td>
|
||||
<td>Места обычные</td>
|
||||
<td>Места льготные</td>
|
||||
</tr>
|
||||
<tr v-for="row in trainings" :key="row.id" style="min-width:max-content;" @click="clickOnTraining(row.id)">
|
||||
<td>{{ row.num }}</td>
|
||||
<td>{{ row.title }}</td>
|
||||
<td>{{ row.basic_places }}</td>
|
||||
<td>{{ row.benefit_places }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<ModalTraining ref="modal"></ModalTraining>
|
||||
</template>
|
||||
<script scoped>
|
||||
import TrainingSevice from '@/services/TrainingSevice';
|
||||
import OrderSevice from '@/services/OrderSevice';
|
||||
import HeaderUser from '@/elemets/headerUser.vue';
|
||||
import ModalTraining from './ModalTraining.vue';
|
||||
|
||||
export default{
|
||||
name:"trainings",
|
||||
data(){
|
||||
return{
|
||||
trainings: [],
|
||||
myOrder: null,
|
||||
search_value: ""
|
||||
}
|
||||
},
|
||||
components: {
|
||||
HeaderUser,
|
||||
ModalTraining
|
||||
},
|
||||
beforeCreate(){
|
||||
TrainingSevice.getAll().then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
OrderSevice.getForUser(localStorage.getItem('user')).then(response =>{
|
||||
if(response.data){
|
||||
TrainingSevice.get(response.data.training).then(res => {
|
||||
this.myOrder = res.data
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
methods:{
|
||||
search(){
|
||||
if(this.search_value.length > 0){
|
||||
TrainingSevice.search(this.search_value).then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
}else{
|
||||
TrainingSevice.getAll().then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
showModal(){
|
||||
this.$refs.modal.show = true;
|
||||
},
|
||||
deleteOrder(){
|
||||
OrderSevice.delete(localStorage.getItem('user')).then(res => {
|
||||
console.log(res.data)
|
||||
this.myOrder = null;
|
||||
})
|
||||
},
|
||||
clickOnTraining(id){
|
||||
this.$router.push({ name: 'orders', params: { id: id} })
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:absolute ;
|
||||
min-width:calc(205vh);
|
||||
background-color: #6ec0d9e9 ;
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:12px;
|
||||
align-items: center;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
123
front/src/components/trains.vue
Normal file
123
front/src/components/trains.vue
Normal file
@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<AdminHeader />
|
||||
<div>
|
||||
<div class="container m-3">
|
||||
|
||||
<div class="rounded-card row">
|
||||
<H1>Направления</H1>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
placeholder="Название направления"
|
||||
name="name"
|
||||
v-model="search_value"
|
||||
/>
|
||||
<button class="btn-secondary border border-transparent rounded shadow-sm " @click="search">Поиск</button>
|
||||
<div style="min-width:max-content;" class="m-2">
|
||||
<div class="row">
|
||||
<button class="btn-success border border-transparent rounded shadow-sm " @click="showModal">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Номер</td>
|
||||
<td>Зазвание</td>
|
||||
<td>Места обычные</td>
|
||||
<td>Места льготные</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr v-for="row in trainings" :key="row.id" style="min-width:max-content;" >
|
||||
<td @click="clickOnTraining(row.id)">{{ row.num }}</td>
|
||||
<td @click="clickOnTraining(row.id)">{{ row.title }}</td>
|
||||
<td @click="clickOnTraining(row.id)">{{ row.basic_places }}</td>
|
||||
<td @click="clickOnTraining(row.id)">{{ row.benefit_places }}</td>
|
||||
<td><button class="btn btn-outline-danger" @click="deleteTrain(row.id)">Удалить</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<ModalCreateTraining ref="modal"></ModalCreateTraining>
|
||||
</template>
|
||||
<script scoped>
|
||||
import TrainingSevice from '@/services/TrainingSevice';
|
||||
import AdminHeader from '@/elemets/adminHeader.vue';
|
||||
import ModalCreateTraining from './ModalCreateTraining.vue';
|
||||
export default{
|
||||
name:"trainings",
|
||||
data(){
|
||||
return{
|
||||
trainings: [],
|
||||
myOrder: null,
|
||||
search_value: ""
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AdminHeader,
|
||||
ModalCreateTraining
|
||||
},
|
||||
beforeCreate(){
|
||||
TrainingSevice.getAll().then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
|
||||
},
|
||||
methods:{
|
||||
search(){
|
||||
if(this.search_value.length > 0){
|
||||
TrainingSevice.search(this.search_value).then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
}else{
|
||||
TrainingSevice.getAll().then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
clickOnTraining(id){
|
||||
this.$router.push({ name: 'training', params: { id: id} })
|
||||
},
|
||||
showModal() {
|
||||
this.$refs.modal.show = true;
|
||||
|
||||
},
|
||||
deleteTrain(id){
|
||||
TrainingSevice.delete(id).then(response =>{
|
||||
console.log(response.data)
|
||||
TrainingSevice.getAll().then(response =>{
|
||||
this.trainings = response.data
|
||||
})
|
||||
}).catch(e => {
|
||||
console.log(e.data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.container
|
||||
{
|
||||
position:absolute ;
|
||||
min-width:calc(205vh);
|
||||
background-color: #6ec0d9e9 ;
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:12px;
|
||||
align-items: center;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
.rounded-card{
|
||||
border: 5px solid #3f8ba2;
|
||||
padding:6px;
|
||||
margin:6px;
|
||||
border-radius:8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
41
front/src/elemets/adminHeader.vue
Normal file
41
front/src/elemets/adminHeader.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<script scoped>
|
||||
import UserSevice from '@/services/UserSevice';
|
||||
export default {
|
||||
name: "admHeader",
|
||||
methods:{
|
||||
logout(){
|
||||
UserSevice.logout()
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div >
|
||||
<nav class="navbar navbar-expand navbar-dark">
|
||||
<div class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<router-link to="/trains" class="nav-link" style="color: black;font-weight: bold;">Направления</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/benefits" class="nav-link" style="color: black;font-weight: bold;">Льготы</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/achievements" class="nav-link" style="color: black;font-weight: bold;">Достижения</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/exams" class="nav-link" style="color: black;font-weight: bold;">Экзамены</router-link>
|
||||
</li>
|
||||
<li class="nav-item" >
|
||||
<Button class="btn-secondary nav-link" @click="logout">Выйти</Button>
|
||||
</li>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
.navbar{
|
||||
background-color: #6EC0D9;
|
||||
}
|
||||
|
||||
</style>
|
20
front/src/elemets/headerUser.vue
Normal file
20
front/src/elemets/headerUser.vue
Normal file
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div >
|
||||
<nav class="navbar navbar-expand navbar-dark">
|
||||
<div class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<router-link to="/profile" class="nav-link" style="color: black;font-weight: bold;">Профиль</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/trainings" class="nav-link" style="color: black;font-weight: bold;">Направления</router-link>
|
||||
</li>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
.navbar{
|
||||
background-color: #6EC0D9;
|
||||
}
|
||||
|
||||
</style>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user