From abf42fe39ac654b56e6ca95cb07509b75cfa0970 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 18 Sep 2019 19:21:50 +0300 Subject: [PATCH 01/17] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B5=D1=89=D0=B5=20=D0=BE=D0=B4=D0=BD=D0=BE=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=20=D1=81=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8?= =?UTF-8?q?=D0=BB=D1=8F=D0=BC=D0=B8=20=D0=B2=20=D1=81=D0=BE=D1=86=D1=81?= =?UTF-8?q?=D0=B5=D1=82=D1=8F=D1=85!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ewp/crm/models/dto/ClientDto.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/ewp/crm/models/dto/ClientDto.java b/src/main/java/com/ewp/crm/models/dto/ClientDto.java index 9fce8f147..b1e8757cf 100644 --- a/src/main/java/com/ewp/crm/models/dto/ClientDto.java +++ b/src/main/java/com/ewp/crm/models/dto/ClientDto.java @@ -1,5 +1,10 @@ package com.ewp.crm.models.dto; +import com.ewp.crm.models.SocialProfile; + +import java.util.ArrayList; +import java.util.List; + public class ClientDto { private long id; @@ -12,6 +17,8 @@ public class ClientDto { private String email; + private List socialProfiles = new ArrayList<>(); + public ClientDto() { } @@ -23,6 +30,15 @@ public ClientDto(long id, String name, String lastName, String phoneNumber, Stri this.email = email; } + public ClientDto(long id, String name, String lastName, String phoneNumber, String email, List socialProfiles) { + this.id = id; + this.name = name; + this.lastName = lastName; + this.phoneNumber = phoneNumber; + this.email = email; + this.socialProfiles = socialProfiles; + } + public long getId() { return id; } @@ -63,6 +79,14 @@ public void setEmail(String email) { this.email = email; } + public List getSocialProfiles() { + return socialProfiles; + } + + public void setSocialProfiles(List socialProfiles) { + this.socialProfiles = socialProfiles; + } + public static interface ClientTransformer { long getClient_id(); From c10f509293fe8e31ee828786c30ef6d9338bcad1 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 18 Sep 2019 20:28:27 +0300 Subject: [PATCH 02/17] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D0=BB=20=D0=BD=D0=B0=20=D0=BC=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B0=20=D1=81=D0=B2=D0=BE=D0=B8!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ewp/crm/models/dto/ClientDto.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/main/java/com/ewp/crm/models/dto/ClientDto.java b/src/main/java/com/ewp/crm/models/dto/ClientDto.java index b1e8757cf..9fce8f147 100644 --- a/src/main/java/com/ewp/crm/models/dto/ClientDto.java +++ b/src/main/java/com/ewp/crm/models/dto/ClientDto.java @@ -1,10 +1,5 @@ package com.ewp.crm.models.dto; -import com.ewp.crm.models.SocialProfile; - -import java.util.ArrayList; -import java.util.List; - public class ClientDto { private long id; @@ -17,8 +12,6 @@ public class ClientDto { private String email; - private List socialProfiles = new ArrayList<>(); - public ClientDto() { } @@ -30,15 +23,6 @@ public ClientDto(long id, String name, String lastName, String phoneNumber, Stri this.email = email; } - public ClientDto(long id, String name, String lastName, String phoneNumber, String email, List socialProfiles) { - this.id = id; - this.name = name; - this.lastName = lastName; - this.phoneNumber = phoneNumber; - this.email = email; - this.socialProfiles = socialProfiles; - } - public long getId() { return id; } @@ -79,14 +63,6 @@ public void setEmail(String email) { this.email = email; } - public List getSocialProfiles() { - return socialProfiles; - } - - public void setSocialProfiles(List socialProfiles) { - this.socialProfiles = socialProfiles; - } - public static interface ClientTransformer { long getClient_id(); From b7507d4211deb21dcf875a8d9fefe24096204876 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 18 Sep 2019 21:11:32 +0300 Subject: [PATCH 03/17] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D1=8B=20=D1=81=D0=BE=20=D1=81=D1=82=D1=83=D0=B4?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=D0=BC=D0=B8=20=D0=BD=D0=B0=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20"=D0=92=D1=81?= =?UTF-8?q?=D0=B5=20=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D1=8B"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClientDtoForAllStudentsDto.java | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java new file mode 100644 index 000000000..bee4f9da0 --- /dev/null +++ b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java @@ -0,0 +1,96 @@ +package com.ewp.crm.models.dto.for_page_all_student; + +import com.ewp.crm.models.SocialProfile; +import com.ewp.crm.models.Status; + +import java.util.ArrayList; +import java.util.List; + +public class ClientDtoForAllStudentsDto { + + private long id; + + private String name; + + private String lastName; + + private String phoneNumber; + + private Status status; + + private String email; + + private List socialProfiles = new ArrayList<>(); + + public ClientDtoForAllStudentsDto() { + } + + public ClientDtoForAllStudentsDto(long id, String name, String lastName, String phoneNumber, String email, List socialProfiles) { + this.id = id; + this.name = name; + this.lastName = lastName; + this.phoneNumber = phoneNumber; + this.email = email; + this.socialProfiles = socialProfiles; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getSocialProfiles() { + return socialProfiles; + } + + public void setSocialProfiles(List socialProfiles) { + this.socialProfiles = socialProfiles; + } + + public static interface ClientTransformerDto { + + long getClient_id(); + + String getFirst_name(); + + String getLast_name(); + + String getClient_email(); + } + +} From 9f854686d247fb7351db19898915885a55a55091 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 18 Sep 2019 21:12:25 +0300 Subject: [PATCH 04/17] =?UTF-8?q?=D0=A1=D0=BE=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=B8=D0=BB=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=D1=81?= =?UTF-8?q?=D0=BE=20=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=D0=BE=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B5=D0=B9=20"=D0=92=D1=81=D0=B5=20=D1=81=D1=82=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D0=BD=D1=82=D1=8B"!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudentDtoForAllStudentDto.java | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java new file mode 100644 index 000000000..8c8697e20 --- /dev/null +++ b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java @@ -0,0 +1,195 @@ +package com.ewp.crm.models.dto.for_page_all_student; + +import com.ewp.crm.models.Student; +import com.ewp.crm.models.StudentStatus; +import com.ewp.crm.models.dto.ClientDto; +import com.ewp.crm.models.dto.StatusDto; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * Данный класс предназначен для отображения информации о студенитах на вкладке "Все студенты" + */ +public class StudentDtoForAllStudentDto { + + private long id; + private ClientDtoForAllStudentsDto clientDtoForAllStudentsDto; + private StatusDto statusDto; + private String notes; + private String color; + private LocalDateTime trialEndDate; + private LocalDateTime nextPaymentDate; + private BigDecimal price; + private BigDecimal paymentAmount; + private BigDecimal payLater; + private boolean notifyEmail = false; + private boolean notifySMS = false; + private boolean notifyVK = false; + private boolean notifySlack = false; + private StudentStatus studentStatus; + + public StudentDtoForAllStudentDto() { + } + + public StudentDtoForAllStudentDto(long id, + ClientDtoForAllStudentsDto clientDtoForAllStudentsDto, + StatusDto statusDto, + String notes, + String color, + LocalDateTime trialEndDate, + LocalDateTime nextPaymentDate, + BigDecimal price, + BigDecimal paymentAmount, + BigDecimal payLater, + boolean notifyEmail, + boolean notifySMS, + boolean notifyVK, + boolean notifySlack, + StudentStatus studentStatus) { + this.id = id; + this.clientDtoForAllStudentsDto = clientDtoForAllStudentsDto; + this.statusDto = statusDto; + this.notes = notes; + this.color = color; + this.trialEndDate = trialEndDate; + this.nextPaymentDate = nextPaymentDate; + this.price = price; + this.paymentAmount = paymentAmount; + this.payLater = payLater; + this.notifyEmail = notifyEmail; + this.notifySMS = notifySMS; + this.notifyVK = notifyVK; + this.notifySlack = notifySlack; + this.studentStatus = studentStatus; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public ClientDtoForAllStudentsDto getClientDtoForAllStudentsDto() { + return clientDtoForAllStudentsDto; + } + + public void setClientDtoForAllStudentsDto(ClientDtoForAllStudentsDto clientDtoForAllStudentsDto) { + this.clientDtoForAllStudentsDto = clientDtoForAllStudentsDto; + } + + public StatusDto getStatusDto() { + return statusDto; + } + + public void setStatusDto(StatusDto statusDto) { + this.statusDto = statusDto; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public LocalDateTime getTrialEndDate() { + return trialEndDate; + } + + public void setTrialEndDate(LocalDateTime trialEndDate) { + this.trialEndDate = trialEndDate; + } + + public LocalDateTime getNextPaymentDate() { + return nextPaymentDate; + } + + public void setNextPaymentDate(LocalDateTime nextPaymentDate) { + this.nextPaymentDate = nextPaymentDate; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public BigDecimal getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(BigDecimal paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public BigDecimal getPayLater() { + return payLater; + } + + public void setPayLater(BigDecimal payLater) { + this.payLater = payLater; + } + + public boolean isNotifyEmail() { + return notifyEmail; + } + + public void setNotifyEmail(boolean notifyEmail) { + this.notifyEmail = notifyEmail; + } + + public boolean isNotifySMS() { + return notifySMS; + } + + public void setNotifySMS(boolean notifySMS) { + this.notifySMS = notifySMS; + } + + public boolean isNotifyVK() { + return notifyVK; + } + + public void setNotifyVK(boolean notifyVK) { + this.notifyVK = notifyVK; + } + + public boolean isNotifySlack() { + return notifySlack; + } + + public void setNotifySlack(boolean notifySlack) { + this.notifySlack = notifySlack; + } + + public StudentStatus getStudentStatus() { + return studentStatus; + } + + public void setStudentStatus(StudentStatus studentStatus) { + this.studentStatus = studentStatus; + } + + public static StudentDtoForAllStudentDto getStudentDtoForAllStudentDto(Student student) { + StudentDtoForAllStudentDto studentDtoForAllStudentDto = new StudentDtoForAllStudentDto(); + + studentDtoForAllStudentDto.id = student.getId(); + + + return studentDtoForAllStudentDto; + } +} From ec59ab6252bacc3c36197a8e20f91e5747d39c40 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 18 Sep 2019 21:23:19 +0300 Subject: [PATCH 05/17] =?UTF-8?q?=D0=93=D0=BB=D0=B0=D0=B2=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81,=20=D0=BA=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D1=8B=D0=B9=20=D0=B8=20=D0=B1=D1=83=D0=B4=D0=B5?= =?UTF-8?q?=D1=82=20=D1=8F=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=D0=B9=20=D0=B8=20=D0=B2=D1=81=D1=8F=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B?= =?UTF-8?q?=20"=D0=92=D1=81=D0=B5=20=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D1=8B"!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/for_page_all_student/AllStudentsDto.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java new file mode 100644 index 000000000..a002350be --- /dev/null +++ b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java @@ -0,0 +1,13 @@ +package com.ewp.crm.models.dto.for_page_all_student; + + +import com.ewp.crm.models.dto.StatusDto; + +/*** + * Данный класс предназначен для отображения всех студентов во вкладке "Все студенты" + */ +public class AllStudentsDto { + private StudentDtoForAllStudentDto studentDtoForAllStudentDto; + private StatusDto statusDto; + +} From c71526ca33a0d642895befeb835bd04f214ce90a Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 18 Sep 2019 22:05:59 +0300 Subject: [PATCH 06/17] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=D0=B0=D0=BC=D0=B8!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClientDtoForAllStudentsDto.java | 35 ++++++++++++ .../StudentDtoForAllStudentDto.java | 57 +++++++++++++++---- 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java index bee4f9da0..9cf4bed46 100644 --- a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java +++ b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java @@ -1,10 +1,14 @@ package com.ewp.crm.models.dto.for_page_all_student; +import com.ewp.crm.models.Client; import com.ewp.crm.models.SocialProfile; import com.ewp.crm.models.Status; +import com.ewp.crm.util.Constants; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; public class ClientDtoForAllStudentsDto { @@ -93,4 +97,35 @@ public static interface ClientTransformerDto { String getClient_email(); } + /** + * Данный метод получает клиента и на выходе дает его же, необходим для работы с - StudentDtoForAllStudentsDto.java, + * @param client - получаемый клиент, + * @return - возвращаемый клиент. + */ + public static ClientDtoForAllStudentsDto getClientDtoForAllStudent(Client client) { + ClientDtoForAllStudentsDto clientDtoForAllStudentsDto = new ClientDtoForAllStudentsDto(); + + clientDtoForAllStudentsDto.id = client.getId(); + clientDtoForAllStudentsDto.name = client.getName(); + clientDtoForAllStudentsDto.lastName = client.getLastName(); + + Optional emailOptional = client.getEmail(); + clientDtoForAllStudentsDto.email = emailOptional.orElse(Constants.EMPTY_STRING); + Optional phoneNumberOptional = client.getPhoneNumber(); + clientDtoForAllStudentsDto.phoneNumber = phoneNumberOptional.orElse(Constants.EMPTY_STRING); + + clientDtoForAllStudentsDto.socialProfiles = client.getSocialProfiles(); + clientDtoForAllStudentsDto.status = client.getStatus(); + + return clientDtoForAllStudentsDto; + } + + public static List getListClientDtoForAllStudentDto(List clients) { + return clients + .stream() + .map(ClientDtoForAllStudentsDto::getClientDtoForAllStudent) + .collect(Collectors.toList()); + } + + } diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java index 8c8697e20..83e1839f1 100644 --- a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java +++ b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java @@ -7,6 +7,8 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; /** * Данный класс предназначен для отображения информации о студенитах на вкладке "Все студенты" @@ -15,7 +17,7 @@ public class StudentDtoForAllStudentDto { private long id; private ClientDtoForAllStudentsDto clientDtoForAllStudentsDto; - private StatusDto statusDto; +// private StatusDto statusDto; private String notes; private String color; private LocalDateTime trialEndDate; @@ -34,7 +36,7 @@ public StudentDtoForAllStudentDto() { public StudentDtoForAllStudentDto(long id, ClientDtoForAllStudentsDto clientDtoForAllStudentsDto, - StatusDto statusDto, +// StatusDto statusDto, String notes, String color, LocalDateTime trialEndDate, @@ -49,7 +51,7 @@ public StudentDtoForAllStudentDto(long id, StudentStatus studentStatus) { this.id = id; this.clientDtoForAllStudentsDto = clientDtoForAllStudentsDto; - this.statusDto = statusDto; +// this.statusDto = statusDto; this.notes = notes; this.color = color; this.trialEndDate = trialEndDate; @@ -80,13 +82,13 @@ public void setClientDtoForAllStudentsDto(ClientDtoForAllStudentsDto clientDtoFo this.clientDtoForAllStudentsDto = clientDtoForAllStudentsDto; } - public StatusDto getStatusDto() { - return statusDto; - } - - public void setStatusDto(StatusDto statusDto) { - this.statusDto = statusDto; - } +// public StatusDto getStatusDto() { +// return statusDto; +// } +// +// public void setStatusDto(StatusDto statusDto) { +// this.statusDto = statusDto; +// } public String getNotes() { return notes; @@ -184,12 +186,45 @@ public void setStudentStatus(StudentStatus studentStatus) { this.studentStatus = studentStatus; } + /** + * Данный класс предназначен для работы со страницей "Все студенты" + * @param student - принимаемый студент, + * @return - возвращаемый студент. + */ public static StudentDtoForAllStudentDto getStudentDtoForAllStudentDto(Student student) { StudentDtoForAllStudentDto studentDtoForAllStudentDto = new StudentDtoForAllStudentDto(); studentDtoForAllStudentDto.id = student.getId(); - + studentDtoForAllStudentDto.clientDtoForAllStudentsDto = + ClientDtoForAllStudentsDto.getClientDtoForAllStudent(student.getClient()); +// studentDtoForAllStudentDto.statusDto = StatusDto.getStatusDto(...); + studentDtoForAllStudentDto.notes = student.getNotes(); + studentDtoForAllStudentDto.color = student.getColor(); + studentDtoForAllStudentDto.trialEndDate = student.getTrialEndDate(); + studentDtoForAllStudentDto.nextPaymentDate = student.getNextPaymentDate(); + studentDtoForAllStudentDto.price = student.getPrice(); + studentDtoForAllStudentDto.paymentAmount = student.getPaymentAmount(); + studentDtoForAllStudentDto.payLater = student.getPayLater(); + studentDtoForAllStudentDto.notifyEmail = student.isNotifyEmail(); + studentDtoForAllStudentDto.notifySMS = student.isNotifySMS(); + studentDtoForAllStudentDto.notifyVK = student.isNotifyVK(); + studentDtoForAllStudentDto.notifySlack = student.isNotifySlack(); + studentDtoForAllStudentDto.studentStatus = student.getStatus(); return studentDtoForAllStudentDto; } + + public static List getStudentDtoForAllStudentDto(List students) { + return students + .stream() + .map(StudentDtoForAllStudentDto::getStudentDtoForAllStudentDto) + .collect(Collectors.toList()); + } + + /** + * todo Все что выделено в комментарии, связанные со статусом + * надо будет посмотреть, работает ли без него и могу ли я получить + * имя статуса по StudentStatus заместо StatusDto. + * Мне кажется, что это одно и тоже в данном случае! + */ } From 115a1dba0b8fb3dada46190e15b759f225519218 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Fri, 20 Sep 2019 20:41:06 +0300 Subject: [PATCH 07/17] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BB=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B=20?= =?UTF-8?q?=D0=94=D0=A2=D0=9E=20=D0=B8=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BD=D0=B5=D0=BD=D1=83=D0=B6=D0=BD=D1=8B=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClientDtoForAllStudentsPage.java} | 78 +++++----- .../StudentDto.java} | 140 +++++++++--------- .../for_page_all_student/AllStudentsDto.java | 13 -- 3 files changed, 110 insertions(+), 121 deletions(-) rename src/main/java/com/ewp/crm/models/dto/{for_page_all_student/ClientDtoForAllStudentsDto.java => all_students_page/ClientDtoForAllStudentsPage.java} (51%) rename src/main/java/com/ewp/crm/models/dto/{for_page_all_student/StudentDtoForAllStudentDto.java => all_students_page/StudentDto.java} (50%) delete mode 100644 src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java similarity index 51% rename from src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java rename to src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java index 9cf4bed46..664d37f19 100644 --- a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/ClientDtoForAllStudentsDto.java +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java @@ -1,8 +1,8 @@ -package com.ewp.crm.models.dto.for_page_all_student; +package com.ewp.crm.models.dto.all_students_page; import com.ewp.crm.models.Client; import com.ewp.crm.models.SocialProfile; -import com.ewp.crm.models.Status; +import com.ewp.crm.models.dto.StatusDto; import com.ewp.crm.util.Constants; import java.util.ArrayList; @@ -10,30 +10,37 @@ import java.util.Optional; import java.util.stream.Collectors; -public class ClientDtoForAllStudentsDto { +/** + * Этот класс нужен для страницы "Все страницы", чтобы собрать необходимую информацию о клиенте. + * Поля клиента, которые используются в all-students-table.html: + * a) status + * b) name + * c) lastName + * d) email + * e) phoneNumber + * f) socialProfiles + * g) id + */ +public class ClientDtoForAllStudentsPage { private long id; - private String name; - private String lastName; - private String phoneNumber; - - private Status status; - + private StatusDto statusDto; private String email; - private List socialProfiles = new ArrayList<>(); - public ClientDtoForAllStudentsDto() { + + public ClientDtoForAllStudentsPage() { } - public ClientDtoForAllStudentsDto(long id, String name, String lastName, String phoneNumber, String email, List socialProfiles) { + public ClientDtoForAllStudentsPage(long id, String name, String lastName, String phoneNumber, StatusDto statusDto, String email, List socialProfiles) { this.id = id; this.name = name; this.lastName = lastName; this.phoneNumber = phoneNumber; + this.statusDto = statusDto; this.email = email; this.socialProfiles = socialProfiles; } @@ -78,6 +85,14 @@ public void setEmail(String email) { this.email = email; } + public StatusDto getStatusDto() { + return statusDto; + } + + public void setStatusDto(StatusDto statusDto) { + this.statusDto = statusDto; + } + public List getSocialProfiles() { return socialProfiles; } @@ -86,46 +101,33 @@ public void setSocialProfiles(List socialProfiles) { this.socialProfiles = socialProfiles; } - public static interface ClientTransformerDto { - - long getClient_id(); - - String getFirst_name(); - - String getLast_name(); - - String getClient_email(); - } - /** - * Данный метод получает клиента и на выходе дает его же, необходим для работы с - StudentDtoForAllStudentsDto.java, + * Данный метод получает клиента и на выходе дает его же, необходим для работы с - StudentDto.java, * @param client - получаемый клиент, * @return - возвращаемый клиент. */ - public static ClientDtoForAllStudentsDto getClientDtoForAllStudent(Client client) { - ClientDtoForAllStudentsDto clientDtoForAllStudentsDto = new ClientDtoForAllStudentsDto(); + public static ClientDtoForAllStudentsPage getClientDtoForAllStudentsPage(Client client) { + ClientDtoForAllStudentsPage clientDtoForAllStudentsPage = new ClientDtoForAllStudentsPage(); - clientDtoForAllStudentsDto.id = client.getId(); - clientDtoForAllStudentsDto.name = client.getName(); - clientDtoForAllStudentsDto.lastName = client.getLastName(); + clientDtoForAllStudentsPage.id = client.getId(); + clientDtoForAllStudentsPage.name = client.getName(); + clientDtoForAllStudentsPage.lastName = client.getLastName(); Optional emailOptional = client.getEmail(); - clientDtoForAllStudentsDto.email = emailOptional.orElse(Constants.EMPTY_STRING); + clientDtoForAllStudentsPage.email = emailOptional.orElse(Constants.EMPTY_STRING); Optional phoneNumberOptional = client.getPhoneNumber(); - clientDtoForAllStudentsDto.phoneNumber = phoneNumberOptional.orElse(Constants.EMPTY_STRING); + clientDtoForAllStudentsPage.phoneNumber = phoneNumberOptional.orElse(Constants.EMPTY_STRING); - clientDtoForAllStudentsDto.socialProfiles = client.getSocialProfiles(); - clientDtoForAllStudentsDto.status = client.getStatus(); + clientDtoForAllStudentsPage.socialProfiles = client.getSocialProfiles(); + clientDtoForAllStudentsPage.statusDto = StatusDto.getStatusDto(client.getStatus()); - return clientDtoForAllStudentsDto; + return clientDtoForAllStudentsPage; } - public static List getListClientDtoForAllStudentDto(List clients) { + public static List getListClientDtoForAllStudentsPage(List clients) { return clients .stream() - .map(ClientDtoForAllStudentsDto::getClientDtoForAllStudent) + .map(ClientDtoForAllStudentsPage::getClientDtoForAllStudentsPage) .collect(Collectors.toList()); } - - } diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java similarity index 50% rename from src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java rename to src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java index 83e1839f1..367c037b5 100644 --- a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/StudentDtoForAllStudentDto.java +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java @@ -1,9 +1,7 @@ -package com.ewp.crm.models.dto.for_page_all_student; +package com.ewp.crm.models.dto.all_students_page; import com.ewp.crm.models.Student; import com.ewp.crm.models.StudentStatus; -import com.ewp.crm.models.dto.ClientDto; -import com.ewp.crm.models.dto.StatusDto; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -12,12 +10,32 @@ /** * Данный класс предназначен для отображения информации о студенитах на вкладке "Все студенты" + * Поля, которые есть в all-students-table.html: + * * 1. id + * * 2. color + * * 3. client: + * * a) status + * * b) name + * * c) lastName + * * d) email + * * e) phoneNumber + * * f) socialProfiles + * * g) id + * * 4. trialEndDate + * * 5. nextPaymentDate + * * 6. price + * * 7. paymentAmount + * * 8. payLater + * * 9. notifyEmail + * * 10. notifySms + * * 11. notifyVK + * * 12. notifySlack + * * 13. notes */ -public class StudentDtoForAllStudentDto { +public class StudentDto { private long id; - private ClientDtoForAllStudentsDto clientDtoForAllStudentsDto; -// private StatusDto statusDto; + private ClientDtoForAllStudentsPage clientDtoForAllStudentsPage; private String notes; private String color; private LocalDateTime trialEndDate; @@ -31,27 +49,25 @@ public class StudentDtoForAllStudentDto { private boolean notifySlack = false; private StudentStatus studentStatus; - public StudentDtoForAllStudentDto() { - } - - public StudentDtoForAllStudentDto(long id, - ClientDtoForAllStudentsDto clientDtoForAllStudentsDto, -// StatusDto statusDto, - String notes, - String color, - LocalDateTime trialEndDate, - LocalDateTime nextPaymentDate, - BigDecimal price, - BigDecimal paymentAmount, - BigDecimal payLater, - boolean notifyEmail, - boolean notifySMS, - boolean notifyVK, - boolean notifySlack, - StudentStatus studentStatus) { + public StudentDto() { + } + + public StudentDto(long id, + ClientDtoForAllStudentsPage clientDtoForAllStudentsPage, + String notes, + String color, + LocalDateTime trialEndDate, + LocalDateTime nextPaymentDate, + BigDecimal price, + BigDecimal paymentAmount, + BigDecimal payLater, + boolean notifyEmail, + boolean notifySMS, + boolean notifyVK, + boolean notifySlack, + StudentStatus studentStatus) { this.id = id; - this.clientDtoForAllStudentsDto = clientDtoForAllStudentsDto; -// this.statusDto = statusDto; + this.clientDtoForAllStudentsPage = clientDtoForAllStudentsPage; this.notes = notes; this.color = color; this.trialEndDate = trialEndDate; @@ -74,22 +90,14 @@ public void setId(long id) { this.id = id; } - public ClientDtoForAllStudentsDto getClientDtoForAllStudentsDto() { - return clientDtoForAllStudentsDto; + public ClientDtoForAllStudentsPage getClientDtoForAllStudentsPage() { + return clientDtoForAllStudentsPage; } - public void setClientDtoForAllStudentsDto(ClientDtoForAllStudentsDto clientDtoForAllStudentsDto) { - this.clientDtoForAllStudentsDto = clientDtoForAllStudentsDto; + public void setClientDtoForAllStudentsPage(ClientDtoForAllStudentsPage clientDtoForAllStudentsPage) { + this.clientDtoForAllStudentsPage = clientDtoForAllStudentsPage; } -// public StatusDto getStatusDto() { -// return statusDto; -// } -// -// public void setStatusDto(StatusDto statusDto) { -// this.statusDto = statusDto; -// } - public String getNotes() { return notes; } @@ -191,40 +199,32 @@ public void setStudentStatus(StudentStatus studentStatus) { * @param student - принимаемый студент, * @return - возвращаемый студент. */ - public static StudentDtoForAllStudentDto getStudentDtoForAllStudentDto(Student student) { - StudentDtoForAllStudentDto studentDtoForAllStudentDto = new StudentDtoForAllStudentDto(); - - studentDtoForAllStudentDto.id = student.getId(); - studentDtoForAllStudentDto.clientDtoForAllStudentsDto = - ClientDtoForAllStudentsDto.getClientDtoForAllStudent(student.getClient()); -// studentDtoForAllStudentDto.statusDto = StatusDto.getStatusDto(...); - studentDtoForAllStudentDto.notes = student.getNotes(); - studentDtoForAllStudentDto.color = student.getColor(); - studentDtoForAllStudentDto.trialEndDate = student.getTrialEndDate(); - studentDtoForAllStudentDto.nextPaymentDate = student.getNextPaymentDate(); - studentDtoForAllStudentDto.price = student.getPrice(); - studentDtoForAllStudentDto.paymentAmount = student.getPaymentAmount(); - studentDtoForAllStudentDto.payLater = student.getPayLater(); - studentDtoForAllStudentDto.notifyEmail = student.isNotifyEmail(); - studentDtoForAllStudentDto.notifySMS = student.isNotifySMS(); - studentDtoForAllStudentDto.notifyVK = student.isNotifyVK(); - studentDtoForAllStudentDto.notifySlack = student.isNotifySlack(); - studentDtoForAllStudentDto.studentStatus = student.getStatus(); - - return studentDtoForAllStudentDto; - } - - public static List getStudentDtoForAllStudentDto(List students) { + public static StudentDto getStudentDtoForAllStudentDto(Student student) { + StudentDto studentDto = new StudentDto(); + + studentDto.id = student.getId(); + studentDto.clientDtoForAllStudentsPage = + ClientDtoForAllStudentsPage.getClientDtoForAllStudentsPage(student.getClient()); + studentDto.notes = student.getNotes(); + studentDto.color = student.getColor(); + studentDto.trialEndDate = student.getTrialEndDate(); + studentDto.nextPaymentDate = student.getNextPaymentDate(); + studentDto.price = student.getPrice(); + studentDto.paymentAmount = student.getPaymentAmount(); + studentDto.payLater = student.getPayLater(); + studentDto.notifyEmail = student.isNotifyEmail(); + studentDto.notifySMS = student.isNotifySMS(); + studentDto.notifyVK = student.isNotifyVK(); + studentDto.notifySlack = student.isNotifySlack(); + studentDto.studentStatus = student.getStatus(); + + return studentDto; + } + + public static List getStudentDtoForAllStudentDto(List students) { return students .stream() - .map(StudentDtoForAllStudentDto::getStudentDtoForAllStudentDto) + .map(StudentDto::getStudentDtoForAllStudentDto) .collect(Collectors.toList()); } - - /** - * todo Все что выделено в комментарии, связанные со статусом - * надо будет посмотреть, работает ли без него и могу ли я получить - * имя статуса по StudentStatus заместо StatusDto. - * Мне кажется, что это одно и тоже в данном случае! - */ } diff --git a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java b/src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java deleted file mode 100644 index a002350be..000000000 --- a/src/main/java/com/ewp/crm/models/dto/for_page_all_student/AllStudentsDto.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ewp.crm.models.dto.for_page_all_student; - - -import com.ewp.crm.models.dto.StatusDto; - -/*** - * Данный класс предназначен для отображения всех студентов во вкладке "Все студенты" - */ -public class AllStudentsDto { - private StudentDtoForAllStudentDto studentDtoForAllStudentDto; - private StatusDto statusDto; - -} From f01fd9733b6864c12e51a25aab941a95d3aba2ce Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Sat, 21 Sep 2019 22:15:59 +0300 Subject: [PATCH 08/17] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=20StudentRepositoryImpl.java=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D0=B9=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4,=20=D1=81?= =?UTF-8?q?=D0=B2=D1=8F=D0=B7=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=81=20?= =?UTF-8?q?=D0=94=D0=A2=D0=9E=20=D0=B8=20sql-=D0=B2=D1=8B=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/StudentRepositoryImpl.java | 50 +++++++++++++++++++ .../interfaces/StudentRepositoryCustom.java | 3 ++ 2 files changed, 53 insertions(+) diff --git a/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java b/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java index 0ebf66a6c..2de920260 100644 --- a/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java +++ b/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java @@ -2,6 +2,8 @@ import com.ewp.crm.models.SocialProfile.SocialNetworkType; import com.ewp.crm.models.Student; +import com.ewp.crm.models.dto.all_students_page.ClientDtoForAllStudentsPage; +import com.ewp.crm.models.dto.all_students_page.StudentDto; import com.ewp.crm.repository.interfaces.StudentRepositoryCustom; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,10 +12,13 @@ import org.springframework.transaction.annotation.Transactional; import javax.persistence.EntityManager; +import javax.persistence.Tuple; +import java.math.BigDecimal; import java.math.BigInteger; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZonedDateTime; +import java.util.ArrayList; import java.util.List; @Repository @@ -100,4 +105,49 @@ public void detach(Student student) { public void resetColors() { entityManager.createQuery("UPDATE Student s SET s.color = null WHERE s.color IS NOT null").executeUpdate(); } + + @Override + public List getStudentDtoForAllStudentsPage() { + + List result = new ArrayList<>(); + + List tupleStudents = entityManager.createNativeQuery( + "SELECT s.id AS id, s.notes AS notes, s.color AS color, s.end_trial AS trialEndDate," + + "s.next_pay AS nextPaymentDate, s.price AS price, s.amount AS payment_amount," + + "s.later AS payLater, s.notify_email AS notifyEmail, s.notify_sms AS notifySms," + + "s.notify_vk AS notifyVK, s.notify_slack AS notifySlack, s.status_id AS studentStatusID," + + "c.client_id AS client_id, c.first_name AS first_name, c.last_name AS last_name," + + "c.phone_number AS phoneNumber, c.email AS clientEmail, " + + "ss.status AS studentStatusName," + + "st.status_id AS statusID , st.status_name AS statusName " + + "FROM student s, student_status ss, client c, status st, status_clients sc " + + "WHERE s.client_id = c.client_id " + + "AND s.status_id = ss.id " + + "AND st.status_id = sc.status_id " + + "AND c.client_id = sc.user_id;", + + Tuple.class).getResultList(); + /** + * todo надо завершить выборку и проверить, как она работает! + */ + + for (Tuple tuple : tupleStudents) { + long statusId = ((BigInteger) tuple.get("id")).longValue(); + String notes = tuple.get("notes") == null ? "" : (String) tuple.get("notes"); + String color = tuple.get("color") == null ? "" : (String) tuple.get("color"); + LocalDateTime trialEndDate = ((LocalDateTime) tuple.get("trialEndDate")); + LocalDateTime nextPaymentDate = ((LocalDateTime) tuple.get("nextPaymentDate")); + BigDecimal price = ((BigDecimal) tuple.get("price")); + BigDecimal paymentAmount = ((BigDecimal) tuple.get("payment_amount")); + BigDecimal payLater = ((BigDecimal) tuple.get("payLater")); + boolean notifyEmail = (boolean) tuple.get("notifyEmail"); + boolean notifySms = (boolean) tuple.get("notifySms"); + boolean notifyVK = (boolean) tuple.get("notifyVK"); + boolean notifySlack = (boolean) tuple.get("notifySlack"); + + + } + + return result; + } } diff --git a/src/main/java/com/ewp/crm/repository/interfaces/StudentRepositoryCustom.java b/src/main/java/com/ewp/crm/repository/interfaces/StudentRepositoryCustom.java index 4aaa54f8c..fbd498a4a 100644 --- a/src/main/java/com/ewp/crm/repository/interfaces/StudentRepositoryCustom.java +++ b/src/main/java/com/ewp/crm/repository/interfaces/StudentRepositoryCustom.java @@ -2,6 +2,7 @@ import com.ewp.crm.models.SocialProfile.SocialNetworkType; import com.ewp.crm.models.Student; +import com.ewp.crm.models.dto.all_students_page.StudentDto; import java.time.ZonedDateTime; import java.util.List; @@ -17,4 +18,6 @@ public interface StudentRepositoryCustom { void detach(Student student); void resetColors(); + + List getStudentDtoForAllStudentsPage(); } From 927e642c7f1448cb086c6774d2308f61b27bc9d2 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Sat, 21 Sep 2019 23:12:51 +0300 Subject: [PATCH 09/17] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= =?UTF-8?q?!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ewp/crm/models/dto/all_students_page/StudentDto.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java index 367c037b5..1aa13b775 100644 --- a/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java @@ -199,7 +199,7 @@ public void setStudentStatus(StudentStatus studentStatus) { * @param student - принимаемый студент, * @return - возвращаемый студент. */ - public static StudentDto getStudentDtoForAllStudentDto(Student student) { + public static StudentDto getStudentDtoForAllStudentsPage(Student student) { StudentDto studentDto = new StudentDto(); studentDto.id = student.getId(); @@ -221,10 +221,10 @@ public static StudentDto getStudentDtoForAllStudentDto(Student student) { return studentDto; } - public static List getStudentDtoForAllStudentDto(List students) { + public static List getStudentDtoForAllStudentsPage(List students) { return students .stream() - .map(StudentDto::getStudentDtoForAllStudentDto) + .map(StudentDto::getStudentDtoForAllStudentsPage) .collect(Collectors.toList()); } } From 4db71328be930f624627b1d7244be1e985b5a782 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Sun, 22 Sep 2019 19:59:16 +0300 Subject: [PATCH 10/17] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/all_students_page/ClientDtoForAllStudentsPage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java index 664d37f19..7ea280516 100644 --- a/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java @@ -102,7 +102,7 @@ public void setSocialProfiles(List socialProfiles) { } /** - * Данный метод получает клиента и на выходе дает его же, необходим для работы с - StudentDto.java, + * Данный метод получает клиента и на выходе дает DTO этого клиента, необходим для работы с - StudentDto.java, * @param client - получаемый клиент, * @return - возвращаемый клиент. */ From 618b09cfe1d777cc2d9dc5f36090f833260806dc Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Sun, 22 Sep 2019 22:02:03 +0300 Subject: [PATCH 11/17] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=D1=81=D0=B5=D1=85=20?= =?UTF-8?q?=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D0=BE=D0=B2!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ewp/crm/controllers/rest/StudentRestController.java | 7 +++++++ .../java/com/ewp/crm/service/impl/StudentServiceImpl.java | 7 +++++++ .../com/ewp/crm/service/interfaces/StudentService.java | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java b/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java index fe34008a8..79a27bab3 100644 --- a/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java +++ b/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java @@ -61,6 +61,8 @@ public class StudentRestController { private final ClientStatusChangingHistoryService clientStatusChangingHistoryService; + + @Autowired public StudentRestController(StudentService studentService, ClientService clientService, ClientHistoryService clientHistoryService, StudentStatusService studentStatusService, @@ -273,4 +275,9 @@ private void updateNotification(boolean status, Long id, User userFromSession, H studentService.update(current); clientService.updateClient(client); } + + @GetMapping("/all") + public ResponseEntity getStudentDtoForPageOfAll() { + return ResponseEntity.ok(studentService.getStudentDtoForAllStudentsPage()); + } } diff --git a/src/main/java/com/ewp/crm/service/impl/StudentServiceImpl.java b/src/main/java/com/ewp/crm/service/impl/StudentServiceImpl.java index 71081e751..25c7619b5 100644 --- a/src/main/java/com/ewp/crm/service/impl/StudentServiceImpl.java +++ b/src/main/java/com/ewp/crm/service/impl/StudentServiceImpl.java @@ -4,6 +4,7 @@ import com.ewp.crm.models.SocialProfile.SocialNetworkType; import com.ewp.crm.models.Student; import com.ewp.crm.models.StudentStatus; +import com.ewp.crm.models.dto.all_students_page.StudentDto; import com.ewp.crm.repository.interfaces.StudentRepository; import com.ewp.crm.repository.interfaces.StudentRepositoryCustom; import com.ewp.crm.service.interfaces.ProjectPropertiesService; @@ -109,4 +110,10 @@ public Student getStudentByEmail(String email) { return studentRepository.getStudentByEmail(email); } + @Override + public List getStudentDtoForAllStudentsPage() { + return studentRepositoryCustom.getStudentDtoForAllStudentsPage(); + } + + } diff --git a/src/main/java/com/ewp/crm/service/interfaces/StudentService.java b/src/main/java/com/ewp/crm/service/interfaces/StudentService.java index e7dd664f4..2c58ef62e 100644 --- a/src/main/java/com/ewp/crm/service/interfaces/StudentService.java +++ b/src/main/java/com/ewp/crm/service/interfaces/StudentService.java @@ -3,6 +3,7 @@ import com.ewp.crm.models.Client; import com.ewp.crm.models.SocialProfile.SocialNetworkType; import com.ewp.crm.models.Student; +import com.ewp.crm.models.dto.all_students_page.StudentDto; import java.time.ZonedDateTime; import java.util.List; @@ -30,4 +31,5 @@ public interface StudentService extends CommonService { Student getStudentByEmail(String email); + List getStudentDtoForAllStudentsPage(); } From 703052f6c2758935bc7291514713462dcaf5dfb5 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Sun, 22 Sep 2019 22:37:02 +0300 Subject: [PATCH 12/17] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B5=D1=89=D0=B5=20=D0=BE=D0=B4=D0=BD=D1=83=20=D0=94=D0=A2?= =?UTF-8?q?=D0=9E=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=D0=BE=20=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=BE=D0=BC!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/all_students_page/StudentDto.java | 16 +++---- .../all_students_page/StudentStatusDto.java | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/ewp/crm/models/dto/all_students_page/StudentStatusDto.java diff --git a/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java index 1aa13b775..57c597b56 100644 --- a/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentDto.java @@ -47,7 +47,7 @@ public class StudentDto { private boolean notifySMS = false; private boolean notifyVK = false; private boolean notifySlack = false; - private StudentStatus studentStatus; + private StudentStatusDto studentStatusDto; public StudentDto() { } @@ -65,7 +65,7 @@ public StudentDto(long id, boolean notifySMS, boolean notifyVK, boolean notifySlack, - StudentStatus studentStatus) { + StudentStatusDto studentStatusDto) { this.id = id; this.clientDtoForAllStudentsPage = clientDtoForAllStudentsPage; this.notes = notes; @@ -79,7 +79,7 @@ public StudentDto(long id, this.notifySMS = notifySMS; this.notifyVK = notifyVK; this.notifySlack = notifySlack; - this.studentStatus = studentStatus; + this.studentStatusDto = studentStatusDto; } public long getId() { @@ -186,12 +186,12 @@ public void setNotifySlack(boolean notifySlack) { this.notifySlack = notifySlack; } - public StudentStatus getStudentStatus() { - return studentStatus; + public StudentStatusDto getStudentStatusDto() { + return studentStatusDto; } - public void setStudentStatus(StudentStatus studentStatus) { - this.studentStatus = studentStatus; + public void setStudentStatusDto(StudentStatus studentStatus) { + this.studentStatusDto = studentStatusDto; } /** @@ -216,7 +216,7 @@ public static StudentDto getStudentDtoForAllStudentsPage(Student student) { studentDto.notifySMS = student.isNotifySMS(); studentDto.notifyVK = student.isNotifyVK(); studentDto.notifySlack = student.isNotifySlack(); - studentDto.studentStatus = student.getStatus(); + studentDto.studentStatusDto = StudentStatusDto.getStudentStatusDto(student.getStatus()); return studentDto; } diff --git a/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentStatusDto.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentStatusDto.java new file mode 100644 index 000000000..3fe0b7129 --- /dev/null +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/StudentStatusDto.java @@ -0,0 +1,42 @@ +package com.ewp.crm.models.dto.all_students_page; + +import com.ewp.crm.models.Status; +import com.ewp.crm.models.StudentStatus; + +public class StudentStatusDto { + private long id; + private String status; + + public StudentStatusDto() { + } + + public StudentStatusDto(long id, String status) { + this.id = id; + this.status = status; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public static StudentStatusDto getStudentStatusDto(StudentStatus studentStatus) { + StudentStatusDto studentStatusDto = new StudentStatusDto(); + + studentStatusDto.id = studentStatus.getId(); + studentStatusDto.status = studentStatus.getStatus(); + + return studentStatusDto; + } +} From a348a60b1b9a87bc1f187eb5cc5f2e68db2fbc51 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Sun, 22 Sep 2019 22:55:45 +0300 Subject: [PATCH 13/17] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B5=D1=89=D0=B5=20=D0=BE=D0=B4=D0=BD=D1=83=20=D0=94=D0=A2?= =?UTF-8?q?=D0=9E=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=D0=BE=20=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D0=BC=D0=B8!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClientDtoForAllStudentsPage.java | 16 ++--- .../all_students_page/SocialNetworkDto.java | 63 +++++++++++++++++++ 2 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/ewp/crm/models/dto/all_students_page/SocialNetworkDto.java diff --git a/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java index 7ea280516..1f4656aef 100644 --- a/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/ClientDtoForAllStudentsPage.java @@ -29,20 +29,20 @@ public class ClientDtoForAllStudentsPage { private String phoneNumber; private StatusDto statusDto; private String email; - private List socialProfiles = new ArrayList<>(); + private List socialNetworkDtos = new ArrayList<>(); public ClientDtoForAllStudentsPage() { } - public ClientDtoForAllStudentsPage(long id, String name, String lastName, String phoneNumber, StatusDto statusDto, String email, List socialProfiles) { + public ClientDtoForAllStudentsPage(long id, String name, String lastName, String phoneNumber, StatusDto statusDto, String email, List socialNetworkDtos) { this.id = id; this.name = name; this.lastName = lastName; this.phoneNumber = phoneNumber; this.statusDto = statusDto; this.email = email; - this.socialProfiles = socialProfiles; + this.socialNetworkDtos = socialNetworkDtos; } public long getId() { @@ -93,12 +93,12 @@ public void setStatusDto(StatusDto statusDto) { this.statusDto = statusDto; } - public List getSocialProfiles() { - return socialProfiles; + public List getSocialProfilesDto() { + return socialNetworkDtos; } - public void setSocialProfiles(List socialProfiles) { - this.socialProfiles = socialProfiles; + public void setSocialProfiles(List socialNetworkDtos) { + this.socialNetworkDtos = socialNetworkDtos; } /** @@ -118,7 +118,7 @@ public static ClientDtoForAllStudentsPage getClientDtoForAllStudentsPage(Client Optional phoneNumberOptional = client.getPhoneNumber(); clientDtoForAllStudentsPage.phoneNumber = phoneNumberOptional.orElse(Constants.EMPTY_STRING); - clientDtoForAllStudentsPage.socialProfiles = client.getSocialProfiles(); + clientDtoForAllStudentsPage.socialNetworkDtos = SocialNetworkDto.getSocialNetworkDtos(client.getSocialProfiles()); clientDtoForAllStudentsPage.statusDto = StatusDto.getStatusDto(client.getStatus()); return clientDtoForAllStudentsPage; diff --git a/src/main/java/com/ewp/crm/models/dto/all_students_page/SocialNetworkDto.java b/src/main/java/com/ewp/crm/models/dto/all_students_page/SocialNetworkDto.java new file mode 100644 index 000000000..3f375301d --- /dev/null +++ b/src/main/java/com/ewp/crm/models/dto/all_students_page/SocialNetworkDto.java @@ -0,0 +1,63 @@ +package com.ewp.crm.models.dto.all_students_page; + +import com.ewp.crm.models.SocialProfile; + +import java.util.List; +import java.util.stream.Collectors; + +public class SocialNetworkDto { + private long id; + private String socialId; + private SocialProfile.SocialNetworkType socialNetworkType; + + public SocialNetworkDto() { + } + + public SocialNetworkDto(long id, String socialId, SocialProfile.SocialNetworkType socialNetworkType) { + this.id = id; + this.socialId = socialId; + this.socialNetworkType = socialNetworkType; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getSocialId() { + return socialId; + } + + public void setSocialId(String socialId) { + this.socialId = socialId; + } + + public SocialProfile.SocialNetworkType getSocialNetworkType() { + return socialNetworkType; + } + + public void setSocialNetworkType(SocialProfile.SocialNetworkType socialNetworkType) { + this.socialNetworkType = socialNetworkType; + } + + public static SocialNetworkDto getSocialNetworkDto(SocialProfile socialProfile) { + SocialNetworkDto socialNetworkDto = new SocialNetworkDto(); + + socialNetworkDto.id = socialProfile.getId(); + socialNetworkDto.socialId = socialProfile.getSocialId(); + socialNetworkDto.socialNetworkType = socialProfile.getSocialNetworkType(); + + return socialNetworkDto; + } + + public static List getSocialNetworkDtos(List socialProfiles) { + return socialProfiles + .stream() + .map(SocialNetworkDto::getSocialNetworkDto) + .collect(Collectors.toList()); + + } +} From 227ad51c99ed35610b452c4cd6b28f978f079886 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Wed, 25 Sep 2019 19:41:08 +0300 Subject: [PATCH 14/17] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4,=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D1=83=20=D0=BD=D0=B0=20null!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ewp/crm/controllers/rest/StudentRestController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java b/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java index 79a27bab3..860e33099 100644 --- a/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java +++ b/src/main/java/com/ewp/crm/controllers/rest/StudentRestController.java @@ -278,6 +278,9 @@ private void updateNotification(boolean status, Long id, User userFromSession, H @GetMapping("/all") public ResponseEntity getStudentDtoForPageOfAll() { + if (studentService.getStudentDtoForAllStudentsPage() == null) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } return ResponseEntity.ok(studentService.getStudentDtoForAllStudentsPage()); } } From 273476149ebeaa52b48fd93656e65d430ca50300 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Thu, 26 Sep 2019 17:03:13 +0300 Subject: [PATCH 15/17] =?UTF-8?q?=D0=A3=D1=87=D0=B0=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=BA=D0=BE=D0=B4=D0=B0,=20=D0=BA=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=8B=D0=B9=20=D0=BD=D0=B0=D0=B4=D0=BE=20=D0=B1=D1=83?= =?UTF-8?q?=D0=B4=D0=B5=D1=82=20=D0=B7=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C,=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=B2=D1=81=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=20=D1=80=D0=B5=D1=81=D1=82-=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ewp/crm/controllers/StudentController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ewp/crm/controllers/StudentController.java b/src/main/java/com/ewp/crm/controllers/StudentController.java index 3a669ca92..854fdffe9 100644 --- a/src/main/java/com/ewp/crm/controllers/StudentController.java +++ b/src/main/java/com/ewp/crm/controllers/StudentController.java @@ -44,10 +44,11 @@ public ModelAndView showAllStudents(@AuthenticationPrincipal User userFromSessio } else { modelAndView.addObject("defaultStatusForRejectedStudent", ""); } - modelAndView.addObject("students", studentService.getAll()); + modelAndView.addObject("students", studentService.getAll()); //Надо закомментировать, так как будет использоваться рест! modelAndView.addObject("statuses", statusService.getAll()); modelAndView.addObject("emailTmpl", messageTemplateService.getAll()); modelAndView.addObject("slackWorkspaceUrl", slackService.getSlackWorkspaceUrl()); return modelAndView; } + } From c0ed619822919747d2daa8657f1d64db5599c913 Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Thu, 26 Sep 2019 18:27:56 +0300 Subject: [PATCH 16/17] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4,=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D0=B9=20=D0=B2=D1=8B=D1=82?= =?UTF-8?q?=D0=B0=D1=81=D0=BA=D0=B8=D0=B2=D0=B0=D0=B5=D1=82=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=D1=85=20=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=B2,=20=D0=BA=D0=B0=D0=BA=20=D0=94=D0=A2=D0=9E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/StudentRepositoryImpl.java | 122 +++++++++++++++--- 1 file changed, 103 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java b/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java index 2de920260..094dbffc8 100644 --- a/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java +++ b/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java @@ -1,10 +1,17 @@ package com.ewp.crm.repository.impl; +import com.ewp.crm.models.SocialProfile; import com.ewp.crm.models.SocialProfile.SocialNetworkType; import com.ewp.crm.models.Student; +import com.ewp.crm.models.StudentStatus; +import com.ewp.crm.models.dto.StatusDto; import com.ewp.crm.models.dto.all_students_page.ClientDtoForAllStudentsPage; +import com.ewp.crm.models.dto.all_students_page.SocialNetworkDto; import com.ewp.crm.models.dto.all_students_page.StudentDto; +import com.ewp.crm.models.dto.all_students_page.StudentStatusDto; import com.ewp.crm.repository.interfaces.StudentRepositoryCustom; +import org.apache.poi.poifs.crypt.dsig.services.TimeStampService; +import org.apache.poi.poifs.crypt.dsig.services.TimeStampServiceValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +22,7 @@ import javax.persistence.Tuple; import java.math.BigDecimal; import java.math.BigInteger; +import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZonedDateTime; @@ -112,31 +120,37 @@ public List getStudentDtoForAllStudentsPage() { List result = new ArrayList<>(); List tupleStudents = entityManager.createNativeQuery( - "SELECT s.id AS id, s.notes AS notes, s.color AS color, s.end_trial AS trialEndDate," + - "s.next_pay AS nextPaymentDate, s.price AS price, s.amount AS payment_amount," + - "s.later AS payLater, s.notify_email AS notifyEmail, s.notify_sms AS notifySms," + - "s.notify_vk AS notifyVK, s.notify_slack AS notifySlack, s.status_id AS studentStatusID," + - "c.client_id AS client_id, c.first_name AS first_name, c.last_name AS last_name," + - "c.phone_number AS phoneNumber, c.email AS clientEmail, " + - "ss.status AS studentStatusName," + - "st.status_id AS statusID , st.status_name AS statusName " + - "FROM student s, student_status ss, client c, status st, status_clients sc " + - "WHERE s.client_id = c.client_id " + + "SELECT s.id AS id, s.notes AS notes, s.color AS color, s.end_trial AS trialEndDate, " + + "s.next_pay AS nextPaymentDate, s.price AS price, s.amount AS payment_amount, " + + "s.later AS payLater, s.notify_email AS notifyEmail, s.notify_sms AS notifySms, " + + "s.notify_vk AS notifyVK, s.notify_slack AS notifySlack, " + + //Поля для клиента + "c.client_id AS client_id, c.first_name AS first_name, c.last_name AS last_name, " + + "c.phone_number AS phoneNumber, c.email AS clientEmail, " + + "ss.id AS studentStatusId, ss.status AS studentStatusName, " + + // Поля для статуса + "st.status_id AS statusID, st.status_name AS statusName " + + + "FROM student s, " + + "student_status ss, " + + "client c, " + + "status st, " + + "status_clients sc " + + + "WHERE s.client_id = c.client_id " + "AND s.status_id = ss.id " + "AND st.status_id = sc.status_id " + - "AND c.client_id = sc.user_id;", + "AND c.client_id = sc.user_id;" - Tuple.class).getResultList(); - /** - * todo надо завершить выборку и проверить, как она работает! - */ + , Tuple.class).getResultList(); for (Tuple tuple : tupleStudents) { - long statusId = ((BigInteger) tuple.get("id")).longValue(); + //Поля для StudentDto + long studentID = ((BigInteger) tuple.get("id")).longValue(); String notes = tuple.get("notes") == null ? "" : (String) tuple.get("notes"); String color = tuple.get("color") == null ? "" : (String) tuple.get("color"); - LocalDateTime trialEndDate = ((LocalDateTime) tuple.get("trialEndDate")); - LocalDateTime nextPaymentDate = ((LocalDateTime) tuple.get("nextPaymentDate")); + LocalDateTime trialEndDate = ((Timestamp) tuple.get("trialEndDate")).toLocalDateTime(); + LocalDateTime nextPaymentDate = ((Timestamp) tuple.get("nextPaymentDate")).toLocalDateTime(); BigDecimal price = ((BigDecimal) tuple.get("price")); BigDecimal paymentAmount = ((BigDecimal) tuple.get("payment_amount")); BigDecimal payLater = ((BigDecimal) tuple.get("payLater")); @@ -144,10 +158,80 @@ public List getStudentDtoForAllStudentsPage() { boolean notifySms = (boolean) tuple.get("notifySms"); boolean notifyVK = (boolean) tuple.get("notifyVK"); boolean notifySlack = (boolean) tuple.get("notifySlack"); + long studentStatusId = ((BigInteger) tuple.get("studentStatusId")).longValue(); + String studentStatusName = tuple.get("studentStatusName") == null ? "" : (String) tuple.get("studentStatusName"); + //Создать StudentStatus по имени studentStatusName и добавить студенту. + + //Поля для ClientDtoForAllStudentsPage + long clientId = ((BigInteger) tuple.get("client_id")).longValue(); + String firstName = tuple.get("first_name") == null ? "" : (String) tuple.get("first_name"); + String lastName = tuple.get("last_name") == null ? "" : (String) tuple.get("last_name"); + String phoneNumber = tuple.get("phoneNumber") == null ? "" : (String) tuple.get("phoneNumber"); + String email = tuple.get("clientEmail") == null ? "" : (String) tuple.get("clientEmail"); + long statusID = ((BigInteger) tuple.get("statusID")).longValue(); + String statusName = tuple.get("statusName") == null ? "" : (String) tuple.get("statusName"); + + List profiles = getStudentProfiles(clientId); + + + ClientDtoForAllStudentsPage clientDtoForAllStudentsPage = + new ClientDtoForAllStudentsPage( + clientId, + firstName, + lastName, + phoneNumber, + new StatusDto(statusID, statusName), + email, + profiles + ); + //Конец создания клиента. + + //StudentDTO + StudentDto studentDto = new StudentDto( + studentID, + clientDtoForAllStudentsPage, + notes, + color, + trialEndDate, + nextPaymentDate, + price, + paymentAmount, + payLater, + notifyEmail, + notifySms, + notifyVK, + notifySlack, + new StudentStatusDto(studentStatusId, studentStatusName) + ); + //End + + result.add(studentDto); + } + return result; + } + private List getStudentProfiles(long clientId) { + List profiles = new ArrayList<>(); + List socialProfiles = entityManager.createNativeQuery( + "SELECT sn.id AS trueSocialID," + + " sn.social_id AS socialID," + + " sn.social_network_type AS networkType " + + + "FROM social_network sn," + + " client_social_network csn " + + + "WHERE " + clientId + " = csn.client_id " + + " AND csn.social_network_id = sn.id;" + , Tuple.class).getResultList(); + + for (Tuple studentProfile : socialProfiles) { + long trueSocialId = ((BigInteger) studentProfile.get("trueSocialId")).longValue(); + String socialId = studentProfile.get("socialID") == null ? "" : (String) studentProfile.get("socialID"); + String socialNetworkType = studentProfile.get("networkType") == null ? "" : (String) studentProfile.get("networkType"); + profiles.add(new SocialNetworkDto(trueSocialId, socialId, SocialNetworkType.valueOf(socialNetworkType))); } - return result; + return profiles; } } From 64c371568b77b7e7e57629e9a14861526c01438f Mon Sep 17 00:00:00 2001 From: boofoonazail Date: Thu, 26 Sep 2019 20:21:21 +0300 Subject: [PATCH 17/17] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=BA=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=83!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ewp/crm/repository/impl/StudentRepositoryImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java b/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java index ea0440678..a53ffb635 100644 --- a/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java +++ b/src/main/java/com/ewp/crm/repository/impl/StudentRepositoryImpl.java @@ -180,6 +180,12 @@ public List getStudentDtoForAllStudentsPage() { return result; } + /** + * Если id соц.сети не нужны, то можно удалить ДТО соц.сети и использовать + * непосредственно сам класс SocialProfile.java + * @param clientId - получаем при прогонке по циклу студентов в методе getStudentDtoForAllStudentsPage(). + * @return + */ private List getStudentProfiles(long clientId) { List profiles = new ArrayList<>(); List socialProfiles = entityManager.createNativeQuery(