Search in sources :

Example 1 with BaseRequest

use of com.tony.billing.request.BaseRequest in project BillingDubbo by TonyJiangWJ.

the class TagInfoController method listTag.

/**
 * 列出所有标签
 *
 * @param request
 * @return
 */
@RequestMapping(value = "/tag/list")
public TagInfoListResponse listTag(@ModelAttribute("request") BaseRequest request) {
    TagInfoListResponse response = new TagInfoListResponse();
    TagInfo tagInfo = new TagInfo();
    tagInfo.setUserId(request.getUserId());
    List<TagInfo> tagInfos = tagInfoService.listTagInfo(tagInfo);
    if (!CollectionUtils.isEmpty(tagInfos)) {
        response.setTagInfoList(tagInfos.parallelStream().map(tag -> {
            TagInfoDTO model = new TagInfoDTO();
            model.setTagName(tag.getTagName());
            model.setTagId(tag.getId());
            model.setUsageCount(tagInfoService.countTagUsage(tag.getId(), request.getUserId()));
            return model;
        }).sorted(Comparator.comparing(TagInfoDTO::getUsageCount).reversed()).collect(Collectors.toList()));
    }
    ResponseUtil.success(response);
    return response;
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) BudgetTagAssignableListRequest(com.tony.billing.request.taginfo.BudgetTagAssignableListRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) CostTagListResponse(com.tony.billing.response.taginfo.CostTagListResponse) ArrayList(java.util.ArrayList) ResponseUtil(com.tony.billing.util.ResponseUtil) BaseRequest(com.tony.billing.request.BaseRequest) BaseResponse(com.tony.billing.response.BaseResponse) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) TagInfoToDtoListSupplier(com.tony.billing.functions.TagInfoToDtoListSupplier) CostRecordService(com.tony.billing.service.api.CostRecordService) CostTagBatchOperateRequest(com.tony.billing.request.taginfo.CostTagBatchOperateRequest) TagInfoService(com.tony.billing.service.api.TagInfoService) TagInfo(com.tony.billing.entity.TagInfo) BudgetTagDelRequest(com.tony.billing.request.taginfo.BudgetTagDelRequest) TagInfoPutRequest(com.tony.billing.request.taginfo.TagInfoPutRequest) Validated(org.springframework.validation.annotation.Validated) TagCostRef(com.tony.billing.entity.TagCostRef) Reference(org.apache.dubbo.config.annotation.Reference) BudgetTagPutRequest(com.tony.billing.request.taginfo.BudgetTagPutRequest) TagInfoDelRequest(com.tony.billing.request.taginfo.TagInfoDelRequest) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) CostRecord(com.tony.billing.entity.CostRecord) CostTagListRequest(com.tony.billing.request.taginfo.CostTagListRequest) CommunalTagsRequest(com.tony.billing.request.taginfo.CommunalTagsRequest) List(java.util.List) CollectionUtils(org.springframework.util.CollectionUtils) TagBudgetRef(com.tony.billing.entity.TagBudgetRef) CostTagDelRequest(com.tony.billing.request.taginfo.CostTagDelRequest) Comparator(java.util.Comparator) TagInfoDTO(com.tony.billing.dto.TagInfoDTO) TagInfoListResponse(com.tony.billing.response.taginfo.TagInfoListResponse) CostTagPutRequest(com.tony.billing.request.taginfo.CostTagPutRequest) TagInfoListResponse(com.tony.billing.response.taginfo.TagInfoListResponse) TagInfo(com.tony.billing.entity.TagInfo) TagInfoDTO(com.tony.billing.dto.TagInfoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TagInfoDTO (com.tony.billing.dto.TagInfoDTO)1 CostRecord (com.tony.billing.entity.CostRecord)1 TagBudgetRef (com.tony.billing.entity.TagBudgetRef)1 TagCostRef (com.tony.billing.entity.TagCostRef)1 TagInfo (com.tony.billing.entity.TagInfo)1 TagInfoToDtoListSupplier (com.tony.billing.functions.TagInfoToDtoListSupplier)1 BaseRequest (com.tony.billing.request.BaseRequest)1 BudgetTagAssignableListRequest (com.tony.billing.request.taginfo.BudgetTagAssignableListRequest)1 BudgetTagDelRequest (com.tony.billing.request.taginfo.BudgetTagDelRequest)1 BudgetTagPutRequest (com.tony.billing.request.taginfo.BudgetTagPutRequest)1 CommunalTagsRequest (com.tony.billing.request.taginfo.CommunalTagsRequest)1 CostTagBatchOperateRequest (com.tony.billing.request.taginfo.CostTagBatchOperateRequest)1 CostTagDelRequest (com.tony.billing.request.taginfo.CostTagDelRequest)1 CostTagListRequest (com.tony.billing.request.taginfo.CostTagListRequest)1 CostTagPutRequest (com.tony.billing.request.taginfo.CostTagPutRequest)1 TagInfoDelRequest (com.tony.billing.request.taginfo.TagInfoDelRequest)1 TagInfoPutRequest (com.tony.billing.request.taginfo.TagInfoPutRequest)1 BaseResponse (com.tony.billing.response.BaseResponse)1 CostTagListResponse (com.tony.billing.response.taginfo.CostTagListResponse)1 TagInfoListResponse (com.tony.billing.response.taginfo.TagInfoListResponse)1