-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8debc80
commit 23c45be
Showing
5 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
backend/src/main/java/com/semanaspringreact/dsvendas/dto/SaleSucessDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.semanaspringreact.dsvendas.dto; | ||
|
||
import java.io.Serializable; | ||
|
||
import com.semanaspringreact.dsvendas.entities.Seller; | ||
|
||
public class SaleSucessDTO implements Serializable { | ||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
private String sellerName; | ||
private Long visited; | ||
private Long deals; | ||
|
||
public SaleSucessDTO() { | ||
|
||
} | ||
|
||
public SaleSucessDTO(Seller seller, Long visited, Long deals) { | ||
this.sellerName = seller.getName(); | ||
this.visited = visited; | ||
this.deals = deals; | ||
} | ||
|
||
public String getSellerName() { | ||
return sellerName; | ||
} | ||
|
||
public void setSellerName(String sellerName) { | ||
this.sellerName = sellerName; | ||
} | ||
|
||
public Long getVisited() { | ||
return visited; | ||
} | ||
|
||
public void setVisited(Long visited) { | ||
this.visited = visited; | ||
} | ||
|
||
public Long getDeals() { | ||
return deals; | ||
} | ||
|
||
public void setDeals(Long deals) { | ||
this.deals = deals; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
41 changes: 41 additions & 0 deletions
41
backend/src/main/java/com/semanaspringreact/dsvendas/dto/SaleSumDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.semanaspringreact.dsvendas.dto; | ||
|
||
import java.io.Serializable; | ||
|
||
import com.semanaspringreact.dsvendas.entities.Seller; | ||
|
||
public class SaleSumDTO implements Serializable { | ||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
private String sellerName; | ||
private Double sum; | ||
|
||
public SaleSumDTO() { | ||
|
||
} | ||
|
||
public SaleSumDTO(Seller seller, Double sum) { | ||
this.sellerName = seller.getName(); | ||
this.sum = sum; | ||
} | ||
|
||
public String getSellerName() { | ||
return sellerName; | ||
} | ||
|
||
public void setSellerName(String sellerName) { | ||
this.sellerName = sellerName; | ||
} | ||
|
||
public Double getSum() { | ||
return sum; | ||
} | ||
|
||
public void setSum(Double sum) { | ||
this.sum = sum; | ||
} | ||
|
||
|
||
} |
15 changes: 13 additions & 2 deletions
15
backend/src/main/java/com/semanaspringreact/dsvendas/repositories/SaleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
package com.semanaspringreact.dsvendas.repositories; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import com.semanaspringreact.dsvendas.dto.SaleSucessDTO; | ||
import com.semanaspringreact.dsvendas.dto.SaleSumDTO; | ||
import com.semanaspringreact.dsvendas.entities.Sale; | ||
|
||
public interface SaleRepository extends JpaRepository<Sale, Long>{ | ||
|
||
|
||
|
||
@Query("SELECT new com.semanaspringreact.dsvendas.dto.SaleSumDTO(obj.seller, SUM(obj.amount))" | ||
+ "FROM Sale AS obj GROUP BY obj.seller") | ||
List<SaleSumDTO> amountGroupedBySeller(); | ||
|
||
@Query("SELECT new com.semanaspringreact.dsvendas.dto.SaleSucessDTO(obj.seller, SUM(obj.visited), SUM(obj.deals))" | ||
+ "FROM Sale AS obj GROUP BY obj.seller") | ||
List<SaleSucessDTO> sucessGroupedBySeller(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters