Skip to content
Extraits de code Groupes Projets
Valider 8e651558 rédigé par anas elhaddad's avatar anas elhaddad
Parcourir les fichiers

add pagination, sort and search for deleted sale session

parent ca9c81d2
Branches
1 requête de fusion!113MYD-628/add pagination, sort and search for deleted sale session
Pipeline #11942 réussi avec les étapes
in 1 minute et 2 secondes
## [1.0.72-RELEASE]
### Added
- MYD-628/add pagination, sort and search for deleted sale session
### Changed
- Changes in existing functionality.
### Deprecated
- Soon-to-be removed features.
### Removed
- Features that have been removed.
### Fixed
- fix item count
### Security
- Any security improvements.
## [1.0.71-RELEASE] ## [1.0.71-RELEASE]
### Added ### Added
- MYD-628/add pagination, sort and search for sale ssesion - MYD-628/add pagination, sort and search for sale session
### Changed ### Changed
- Changes in existing functionality. - Changes in existing functionality.
......
...@@ -29,4 +29,6 @@ public class Paths { ...@@ -29,4 +29,6 @@ public class Paths {
public static final String THEORETICAL_AMOUNT = "/theoretical-amount"; public static final String THEORETICAL_AMOUNT = "/theoretical-amount";
public static final String SALE_SESSION_PAGE = "/page"; public static final String SALE_SESSION_PAGE = "/page";
public static final String COUNT_TYPE_SALE_SESSION = "/count-type"; public static final String COUNT_TYPE_SALE_SESSION = "/count-type";
public static final String DELETED_SALE_SESSION_PAGE = "/deleted/page";
public static final String DELETED_COUNT_TYPE_SALE_SESSION = "/deleted/count-type";
} }
...@@ -169,5 +169,33 @@ public class SaleSessionController { ...@@ -169,5 +169,33 @@ public class SaleSessionController {
return saleSessionService.getTypeCount(name, type, startDate, endDate); return saleSessionService.getTypeCount(name, type, startDate, endDate);
} }
@GetMapping(Paths.DELETED_SALE_SESSION_PAGE)
@PreAuthorize("@securityCustomExpressions.isClientTrusted(#requestAuthorization)")
public Page<SaleSessionDTO> getDeletedSaleSessionsPage(
@RequestParam(required = false) String name,
@RequestParam(required = false) String type,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date startDate,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date endDate,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(defaultValue = "id") String sortBy,
@RequestParam(defaultValue = "ASC") String sortDir,
@RequestHeader String requestAuthorization) {
return saleSessionService.getDeletedSaleSessionsPage(name, type, startDate, endDate, page, size, sortBy, sortDir);
}
@GetMapping(Paths.DELETED_COUNT_TYPE_SALE_SESSION)
@PreAuthorize("@securityCustomExpressions.isClientTrusted(#requestAuthorization)")
public List<String[]> getDeletedStatusCount(
@RequestParam(required = false) String name,
@RequestParam(required = false) String type,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date startDate,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date endDate,
@RequestHeader String requestAuthorization) {
return saleSessionService.getDeletedTypeCount(name, type, startDate, endDate);
}
} }
...@@ -93,4 +93,28 @@ public interface SaleSessionRepository extends JpaRepository<SaleSession, Long> ...@@ -93,4 +93,28 @@ public interface SaleSessionRepository extends JpaRepository<SaleSession, Long>
@Param("name") String name , @Param("name") String name ,
@Param("startDate") Date startDate , @Param("startDate") Date startDate ,
@Param("endDate") Date endDate); @Param("endDate") Date endDate);
@Query("SELECT sl FROM SaleSession sl WHERE " +
"(:name IS NULL OR :name = '' OR LOWER(sl.name) LIKE LOWER(CONCAT('%', :name, '%'))) " +
"AND (:type IS NULL OR :type = '' OR LOWER(sl.type) like LOWER(CONCAT('%', :type,'%')))" +
"AND ( CAST(:startDate as string) IS NULL OR CAST(sl.startedDate as date) BETWEEN :startDate AND :endDate)" +
"AND sl.status = 'DELETED' ")
Page<SaleSession> getSaleSessionsDeletedPage(@Param("type") String type,
@Param("name") String name ,
@Param("startDate") Date startDate ,
@Param("endDate") Date endDate ,
Pageable pageable);
@Query("SELECT sl.type, COUNT(sl) FROM SaleSession sl WHERE " +
"(:name IS NULL OR :name = '' OR LOWER(sl.name) LIKE LOWER(CONCAT('%', :name, '%'))) " +
"AND (:type IS NULL OR :type = '' OR LOWER(sl.type) like LOWER(CONCAT('%', :type,'%')))" +
"AND ( CAST(:startDate as string) IS NULL OR CAST(sl.startedDate as date) BETWEEN :startDate AND :endDate)" +
"AND sl.status = 'DELETED' " +
"GROUP BY sl.type")
List<Object[]> getDeletedTypeCount(@Param("type") String type,
@Param("name") String name ,
@Param("startDate") Date startDate ,
@Param("endDate") Date endDate);
} }
...@@ -34,4 +34,8 @@ public interface SaleSessionService { ...@@ -34,4 +34,8 @@ public interface SaleSessionService {
Page<SaleSessionDTO> getSaleSessionsPage(String name , String type, Date startDate, Date endDate, Page<SaleSessionDTO> getSaleSessionsPage(String name , String type, Date startDate, Date endDate,
int page, int size, String sortBy, String order); int page, int size, String sortBy, String order);
List<String[]> getTypeCount(String name , String type, Date startDate, Date endDate); List<String[]> getTypeCount(String name , String type, Date startDate, Date endDate);
Page<SaleSessionDTO> getDeletedSaleSessionsPage(String name , String type, Date startDate, Date endDate,
int page, int size, String sortBy, String order);
List<String[]> getDeletedTypeCount(String name , String type, Date startDate, Date endDate);
} }
...@@ -262,6 +262,23 @@ public class SaleSessionServiceImp implements SaleSessionService { ...@@ -262,6 +262,23 @@ public class SaleSessionServiceImp implements SaleSessionService {
return convertObjectListToStringList(saleSessionRepository.getTypeCount(type, name, startDate, endDate)); return convertObjectListToStringList(saleSessionRepository.getTypeCount(type, name, startDate, endDate));
} }
@Override
public Page<SaleSessionDTO> getDeletedSaleSessionsPage(String name, String type, Date startDate, Date endDate, int page, int size, String sortBy, String sortDir) {
if("createdAt".equals(sortBy))
sortBy = "id";
Sort.Direction direction = Sort.Direction.fromString(sortDir);
Pageable pageable = PageRequest.of(page, size, Sort.by(direction, sortBy));
return saleSessionRepository.getSaleSessionsDeletedPage(type,name,startDate,endDate,pageable)
.map(saleSessionMapper::toDTO);
}
@Override
public List<String[]> getDeletedTypeCount(String name, String type, Date startDate, Date endDate) {
return convertObjectListToStringList(saleSessionRepository.getDeletedTypeCount(type, name, startDate, endDate));
}
private List<String[]> convertObjectListToStringList(List<Object[]> objectList) { private List<String[]> convertObjectListToStringList(List<Object[]> objectList) {
if (objectList == null) { if (objectList == null) {
return new ArrayList<>(); return new ArrayList<>();
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter