add front
This commit is contained in:
parent
17f2a1e768
commit
4b69a4ff4b
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
1070
data.trace.db
1070
data.trace.db
File diff suppressed because it is too large
Load Diff
@ -18,16 +18,12 @@ public class AppointmentController {
|
|||||||
this.appointmentService = appointmentService;
|
this.appointmentService = appointmentService;
|
||||||
}
|
}
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public AppointmentDTO addAppointment(@RequestBody AppointmentDTO appointmentDTO){
|
public AppointmentDTO addAppointment(String name){
|
||||||
try
|
|
||||||
{
|
Random r = new Random();
|
||||||
return new AppointmentDTO(appointmentService.addAppointment(new AppointmentDTO(new Appointment(appointmentDTO.getName()))));
|
var app = new Appointment(r.nextLong(), name);
|
||||||
|
return new AppointmentDTO(appointmentService.addAppointment(new AppointmentDTO(app)));
|
||||||
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
|
@ -9,7 +9,7 @@ public class AppointmentDTO {
|
|||||||
public AppointmentDTO(Appointment appointment)
|
public AppointmentDTO(Appointment appointment)
|
||||||
{
|
{
|
||||||
this.id = appointment.getId();
|
this.id = appointment.getId();
|
||||||
this.name = appointment.getName();
|
this.name = appointment.getName();;
|
||||||
}
|
}
|
||||||
public AppointmentDTO(){}
|
public AppointmentDTO(){}
|
||||||
|
|
||||||
|
@ -21,12 +21,15 @@ public class CompanyController {
|
|||||||
public CompanyController(CompanyService _companyService) {
|
public CompanyController(CompanyService _companyService) {
|
||||||
this.companyService = _companyService;
|
this.companyService = _companyService;
|
||||||
}
|
}
|
||||||
@PostMapping
|
@PostMapping("/add")
|
||||||
public CompanyDTO addCompany(@RequestBody CompanyDTO companyDTO) {
|
public CompanyDTO addCompany(@RequestParam("name") String name, @RequestParam("legalAdressCompany") String legalAdressCompany,
|
||||||
return new CompanyDTO(companyService.addCompany(companyDTO));
|
@RequestParam("adressCompany") String adressCompany,
|
||||||
|
@RequestParam("contactEmail") String contactEmail) {
|
||||||
|
var company = new Company(name, legalAdressCompany, adressCompany, contactEmail);
|
||||||
|
return new CompanyDTO(companyService.addCompany(new CompanyDTO(company)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public CompanyDTO updateCompany(@PathVariable Long id,@RequestBody CompanyDTO companyDTO) {
|
public CompanyDTO updateCompany(@PathVariable Long id,@RequestBody CompanyDTO companyDTO) {
|
||||||
return new CompanyDTO(companyService.updateCompany(id,companyDTO));
|
return new CompanyDTO(companyService.updateCompany(id,companyDTO));
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class CompanyDTO {
|
|||||||
private String legalAdressCompany;
|
private String legalAdressCompany;
|
||||||
private String adressCompany;
|
private String adressCompany;
|
||||||
private String contactEmail;
|
private String contactEmail;
|
||||||
private List<RequestForCooperationDTO> requests = new ArrayList<>();
|
// private List<RequestForCooperationDTO> requests = new ArrayList<>();
|
||||||
|
|
||||||
public CompanyDTO(Company company)
|
public CompanyDTO(Company company)
|
||||||
{
|
{
|
||||||
@ -24,10 +24,7 @@ public class CompanyDTO {
|
|||||||
this.legalAdressCompany = company.getLegalAdressCompany();
|
this.legalAdressCompany = company.getLegalAdressCompany();
|
||||||
this.adressCompany = company.getAdressCompany();
|
this.adressCompany = company.getAdressCompany();
|
||||||
this.contactEmail = company.getContactEmail();
|
this.contactEmail = company.getContactEmail();
|
||||||
this.requests = company.getList() == null ? null : company.getList()
|
|
||||||
.stream()
|
|
||||||
.map(RequestForCooperationDTO::new)
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
@ -42,5 +39,4 @@ public class CompanyDTO {
|
|||||||
|
|
||||||
public String getLegalAdressCompany() { return legalAdressCompany; }
|
public String getLegalAdressCompany() { return legalAdressCompany; }
|
||||||
|
|
||||||
public List<RequestForCooperationDTO> getRequests() { return requests; }
|
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,10 @@ public class EmployeeController {
|
|||||||
return employeeService.findAllWorkers();
|
return employeeService.findAllWorkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/")
|
@PostMapping("/add")
|
||||||
public EmployeeDTO createWorker(@RequestBody EmployeeDTO emplyeeDTO) {
|
public EmployeeDTO createWorker(@RequestParam("name") String name, @RequestParam("appointmentId") Long appointmentId) {
|
||||||
return new EmployeeDTO(employeeService.addWorker(emplyeeDTO));
|
var Employee = new Employee(name, appointmentService.findAppointment(appointmentId));
|
||||||
|
return new EmployeeDTO(employeeService.addWorker(new EmployeeDTO(Employee)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package com.example.demo.speaker.controller;
|
package com.example.demo.speaker.controller;
|
||||||
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
import com.example.demo.speaker.model.RequestForCooperation;
|
||||||
|
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
||||||
import com.example.demo.speaker.service.CompanyService;
|
import com.example.demo.speaker.service.CompanyService;
|
||||||
|
import com.example.demo.speaker.service.EmployeeService;
|
||||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/request")
|
@RequestMapping("/requests")
|
||||||
public class RequestForCooperationController {
|
public class RequestForCooperationController {
|
||||||
private final RequestForCooperationService requestForCooperationService;
|
private final RequestForCooperationService requestForCooperationService;
|
||||||
private final CompanyService companyService;
|
private final CompanyService companyService;
|
||||||
|
private final EmployeeService employeeService;
|
||||||
|
|
||||||
public RequestForCooperationController(RequestForCooperationService requestForCooperationService, CompanyService companyService) {
|
public RequestForCooperationController(RequestForCooperationService requestForCooperationService, CompanyService companyService, EmployeeService employeeService) {
|
||||||
this.requestForCooperationService = requestForCooperationService;
|
this.requestForCooperationService = requestForCooperationService;
|
||||||
this.companyService = companyService;
|
this.companyService = companyService;
|
||||||
|
this.employeeService = employeeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@ -28,10 +33,19 @@ public class RequestForCooperationController {
|
|||||||
return requestForCooperationService.findAllRequests();
|
return requestForCooperationService.findAllRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/")
|
@PostMapping("/add")
|
||||||
public RequestForCooperation createRequest(@RequestBody RequestForCooperationDTO requestDTO) {
|
public RequestForCooperation createRequest(@PathVariable Long nameCompany,
|
||||||
|
@PathVariable String comment,
|
||||||
|
@PathVariable Integer isActive,
|
||||||
|
@PathVariable Long sort,
|
||||||
|
@PathVariable Long type
|
||||||
|
){
|
||||||
|
|
||||||
return requestForCooperationService.addRequest(requestDTO);
|
//@RequestBody RequestForCooperationDTO requestDTO) {
|
||||||
|
var company = companyService.findCompany(nameCompany);
|
||||||
|
var emp = employeeService.findWorker(sort);
|
||||||
|
var request = new RequestForCooperation(company, new Date(), type == 0 ? TypeOfRequestEnum.DEVELOP : TypeOfRequestEnum.TRACKING, comment);
|
||||||
|
return requestForCooperationService.addRequest(new RequestForCooperationDTO(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
|
@ -11,7 +11,7 @@ import static java.lang.Math.abs;
|
|||||||
public class Appointment {
|
public class Appointment {
|
||||||
private String name;
|
private String name;
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AppointmentService {
|
public class AppointmentService {
|
||||||
@ -21,8 +22,8 @@ private final IAppointmentRepository appointmentRepository;
|
|||||||
public Appointment addAppointment(AppointmentDTO appointmentDTO) {
|
public Appointment addAppointment(AppointmentDTO appointmentDTO) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Appointment appointment = new Appointment(appointmentDTO.getId(), appointmentDTO.getName());
|
Appointment appointment = new Appointment(appointmentDTO.getName());
|
||||||
appointmentRepository.saveAndFlush(appointment);
|
appointmentRepository.save(appointment);
|
||||||
return appointment;
|
return appointment;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user