Search in sources :

Example 1 with TagInfoListResponse

use of com.tony.billing.response.taginfo.TagInfoListResponse 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)

Example 2 with TagInfoListResponse

use of com.tony.billing.response.taginfo.TagInfoListResponse in project BillingDubbo by TonyJiangWJ.

the class TagInfoController method listBudgetAssignableTags.

@RequestMapping("/budget/tag/assignable/list")
public TagInfoListResponse listBudgetAssignableTags(@Validated @ModelAttribute("request") BudgetTagAssignableListRequest request) {
    List<TagInfo> tagInfos = tagInfoService.listAssignableTagsByBudgetId(request.getBudgetId());
    TagInfoListResponse response = new TagInfoListResponse();
    response.setTagInfoList(new TagInfoToDtoListSupplier(tagInfos).get());
    if (CollectionUtils.isEmpty(tagInfos)) {
        return ResponseUtil.dataNotExisting(response);
    }
    return ResponseUtil.success(response);
}
Also used : TagInfoListResponse(com.tony.billing.response.taginfo.TagInfoListResponse) TagInfo(com.tony.billing.entity.TagInfo) TagInfoToDtoListSupplier(com.tony.billing.functions.TagInfoToDtoListSupplier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TagInfo (com.tony.billing.entity.TagInfo)2 TagInfoToDtoListSupplier (com.tony.billing.functions.TagInfoToDtoListSupplier)2 TagInfoListResponse (com.tony.billing.response.taginfo.TagInfoListResponse)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 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 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