Search in sources :

Example 1 with FlashItemsQuery

use of com.actionworks.flashsale.app.model.query.FlashItemsQuery in project flash-sale by ThoughtsBeta.

the class FlashItemController method getOnlineFlashItems.

@GetMapping(value = "/activities/{activityId}/flash-items/online")
@SentinelResource("GetOnlineFlashItems")
public MultiResponse<FlashItemResponse> getOnlineFlashItems(@RequestAttribute Long userId, @PathVariable Long activityId, @RequestParam Integer pageSize, @RequestParam Integer pageNumber, @RequestParam(required = false) String keyword) {
    FlashItemsQuery flashItemsQuery = new FlashItemsQuery().setKeyword(keyword).setPageSize(pageSize).setPageNumber(pageNumber).setStatus(FlashItemStatus.ONLINE.getCode());
    AppMultiResult<FlashItemDTO> flashItemsResult = flashItemAppService.getFlashItems(userId, activityId, flashItemsQuery);
    if (!flashItemsResult.isSuccess() || flashItemsResult.getData() == null) {
        return ResponseBuilder.withMulti(flashItemsResult);
    }
    return MultiResponse.of(toFlashItemsResponse(flashItemsResult.getData()), flashItemsResult.getTotal());
}
Also used : FlashItemDTO(com.actionworks.flashsale.app.model.dto.FlashItemDTO) FlashItemsQuery(com.actionworks.flashsale.app.model.query.FlashItemsQuery) GetMapping(org.springframework.web.bind.annotation.GetMapping) SentinelResource(com.alibaba.csp.sentinel.annotation.SentinelResource)

Example 2 with FlashItemsQuery

use of com.actionworks.flashsale.app.model.query.FlashItemsQuery in project flash-sale by ThoughtsBeta.

the class FlashItemController method getFlashItems.

@GetMapping(value = "/activities/{activityId}/flash-items")
@SentinelResource("GetFlashItems")
public MultiResponse<FlashItemDTO> getFlashItems(@RequestAttribute Long userId, @PathVariable Long activityId, @RequestParam Integer pageSize, @RequestParam Integer pageNumber, @RequestParam(required = false) String keyword) {
    FlashItemsQuery flashItemsQuery = new FlashItemsQuery().setKeyword(keyword).setPageSize(pageSize).setPageNumber(pageNumber);
    AppMultiResult<FlashItemDTO> flashItemsResult = flashItemAppService.getFlashItems(userId, activityId, flashItemsQuery);
    return ResponseBuilder.withMulti(flashItemsResult);
}
Also used : FlashItemDTO(com.actionworks.flashsale.app.model.dto.FlashItemDTO) FlashItemsQuery(com.actionworks.flashsale.app.model.query.FlashItemsQuery) GetMapping(org.springframework.web.bind.annotation.GetMapping) SentinelResource(com.alibaba.csp.sentinel.annotation.SentinelResource)

Aggregations

FlashItemDTO (com.actionworks.flashsale.app.model.dto.FlashItemDTO)2 FlashItemsQuery (com.actionworks.flashsale.app.model.query.FlashItemsQuery)2 SentinelResource (com.alibaba.csp.sentinel.annotation.SentinelResource)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2