add report
This commit is contained in:
parent
c96cf40dee
commit
353639c22f
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@ -40,9 +40,11 @@ public class EmployeeController {
|
||||
return new EmployeeDTO(employeeService.addWorker(new EmployeeDTO(Employee)));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public EmployeeDTO updateWorker(@PathVariable Long id,@RequestBody EmployeeDTO employeeDTO) {
|
||||
return new EmployeeDTO(employeeService.updateReportWorker(id, employeeDTO));
|
||||
@PutMapping("/update")
|
||||
public EmployeeDTO updateWorker(@RequestParam("id") Long id, @RequestParam("name") String name) {
|
||||
var emp = employeeService.findWorker(id);
|
||||
emp.setFio(name);
|
||||
return new EmployeeDTO(employeeService.updateReportWorker(id, new EmployeeDTO(emp)));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@ -56,10 +58,12 @@ public class EmployeeController {
|
||||
return employeeService.findAllRequestsOfEmployee(employee);
|
||||
}
|
||||
|
||||
@GetMapping("/postId={postId}")
|
||||
public List<Employee> getListOfWorkers(@RequestParam("postId") Long id) {
|
||||
@GetMapping("/postid={id}")
|
||||
public List<Employee> getListOfWorkers(@PathVariable Long id) {
|
||||
final Appointment appointment = appointmentService.findAppointment(id);
|
||||
return employeeService.findWorkerByPost(appointment);
|
||||
var res = employeeService.findWorkerByPost(appointment);
|
||||
return res;
|
||||
|
||||
//return new ArrayList<Employee>();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ import com.example.demo.speaker.service.EmployeeService;
|
||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -34,17 +37,15 @@ public class RequestForCooperationController {
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public RequestForCooperation createRequest(@PathVariable Long nameCompany,
|
||||
@PathVariable String comment,
|
||||
@PathVariable Integer isActive,
|
||||
@PathVariable Long sort,
|
||||
@PathVariable Long type
|
||||
){
|
||||
public RequestForCooperation createRequest(@RequestParam Long nameCompany,
|
||||
@RequestParam String comment
|
||||
) throws ParseException {
|
||||
|
||||
//@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);
|
||||
var emp = employeeService.findWorker(1L);
|
||||
DateFormat form = new SimpleDateFormat("yyyy-MM-dd");
|
||||
var request = new RequestForCooperation(656656L, company, form.parse("2023-06-13"), TypeOfRequestEnum.DEVELOP, comment, emp);
|
||||
return requestForCooperationService.addRequest(new RequestForCooperationDTO(request));
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,13 @@ public class RequestForCooperation {
|
||||
this.typeSotr = type;
|
||||
this.id = r.nextLong();
|
||||
}
|
||||
public RequestForCooperation(Long id, Company name, Date createDate, TypeOfRequestEnum type, String text) {
|
||||
public RequestForCooperation(Long id, Company name, Date createDate, TypeOfRequestEnum type, String text, Employee emp) {
|
||||
this.nameCompany = name;
|
||||
this.createDate = createDate;
|
||||
this.comment = text;
|
||||
this.typeSotr = type;
|
||||
this.id = id;
|
||||
this.sotr = emp;
|
||||
}
|
||||
|
||||
public Company getName()
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.data.repository.query.Param;
|
||||
import java.util.List;
|
||||
|
||||
public interface IEmployeeRepository extends JpaRepository<Employee, Long> {
|
||||
@Query("SELECT DISTINCT p.fio FROM Employee p where :appointment = p.appointment")
|
||||
@Query("SELECT DISTINCT p FROM Employee p where :appointment = p.appointment")
|
||||
List<Employee> getEmployeeByAppointment(@Param("appointment") Appointment appointment);
|
||||
|
||||
@Query("SELECT DISTINCT p FROM RequestForCooperation p where :employee = p.sotr")
|
||||
|
@ -35,7 +35,7 @@ private final IAppointmentRepository appointmentRepository;
|
||||
@Transactional(readOnly = true)
|
||||
public Appointment findAppointment(Long id) {
|
||||
final Optional<Appointment> appointment = appointmentRepository.findById(id);
|
||||
return appointment.orElseThrow(()->new AppointmentNotFoundException(id));
|
||||
return appointment.get();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user