Search in sources :

Example 1 with TagInfoDTO

use of com.tony.billing.dto.TagInfoDTO 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 TagInfoDTO

use of com.tony.billing.dto.TagInfoDTO in project BillingDubbo by TonyJiangWJ.

the class TagInfoController method listCostTag.

/**
 * 列出账单赋值的标签
 *
 * @param request
 * @return
 */
@RequestMapping(value = "/cost/tag/list")
public CostTagListResponse listCostTag(@ModelAttribute("request") @Validated CostTagListRequest request) {
    CostTagListResponse response = new CostTagListResponse();
    try {
        List<TagInfo> costTagList = tagInfoService.listTagInfoByTradeNo(request.getTradeNo());
        TagInfoDTO model;
        List<TagInfoDTO> result = new ArrayList<>();
        for (TagInfo entity : costTagList) {
            model = new TagInfoDTO();
            model.setTagName(entity.getTagName());
            model.setTagId(entity.getId());
            result.add(model);
        }
        if (!CollectionUtils.isEmpty(result)) {
            response.setTagInfoModels(result);
            ResponseUtil.success(response);
        } else {
            ResponseUtil.dataNotExisting(response);
        }
    } catch (Exception e) {
        ResponseUtil.sysError(response);
        logger.error("/cost/tag/list error", e);
    }
    return response;
}
Also used : CostTagListResponse(com.tony.billing.response.taginfo.CostTagListResponse) TagInfo(com.tony.billing.entity.TagInfo) ArrayList(java.util.ArrayList) TagInfoDTO(com.tony.billing.dto.TagInfoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with TagInfoDTO

use of com.tony.billing.dto.TagInfoDTO in project BillingDubbo by TonyJiangWJ.

the class CostRecordController method formatDetailModel.

private CostRecordDetailDTO formatDetailModel(CostRecord record) {
    CostRecordDetailDTO model = new CostRecordDetailDTO();
    model.setId(record.getId());
    model.setVersion(record.getVersion());
    model.setCreateTime(record.getCostCreateTime());
    model.setGoodsName(record.getGoodsName());
    model.setInOutType(record.getInOutType());
    model.setIsDeleted(record.getIsDeleted());
    model.setLocation(record.getLocation());
    model.setMemo(record.getMemo());
    model.setMoney(MoneyUtil.fen2Yuan(record.getMoney()));
    model.setModifyTime(record.getCostModifyTime());
    model.setOrderNo(record.getOrderNo());
    model.setOrderStatus(record.getOrderStatus());
    model.setOrderType(record.getOrderType());
    model.setPaidTime(record.getPaidTime());
    model.setRefundMoney(MoneyUtil.fen2Yuan(record.getRefundMoney()));
    model.setServiceCost(MoneyUtil.fen2Yuan(record.getServiceCost()));
    model.setTarget(record.getTarget());
    model.setTradeNo(record.getTradeNo());
    model.setTradeStatus(record.getTradeStatus());
    model.setIsHidden(record.getIsHidden());
    List<TagInfo> tagInfos = tagInfoService.listTagInfoByTradeNo(record.getTradeNo());
    if (!CollectionUtils.isEmpty(tagInfos)) {
        model.setTagInfos(tagInfos.stream().map(tagInfo -> {
            TagInfoDTO tagInfoDTO = new TagInfoDTO();
            tagInfoDTO.setTagId(tagInfo.getId());
            tagInfoDTO.setTagName(tagInfo.getTagName());
            return tagInfoDTO;
        }).collect(Collectors.toList()));
    }
    return model;
}
Also used : TagInfo(com.tony.billing.entity.TagInfo) CostRecordDetailDTO(com.tony.billing.dto.CostRecordDetailDTO) TagInfoDTO(com.tony.billing.dto.TagInfoDTO)

Example 4 with TagInfoDTO

use of com.tony.billing.dto.TagInfoDTO in project BillingDubbo by TonyJiangWJ.

the class TagInfoController method getCostsCommunalTags.

@RequestMapping(value = "/cost/tag/communal/list")
public CostTagListResponse getCostsCommunalTags(@ModelAttribute("request") @Validated CommunalTagsRequest request) {
    List<TagInfoDTO> tagInfoDTOS = tagInfoService.listCommonTagInfos(request.getCostIds());
    CostTagListResponse response = new CostTagListResponse();
    if (!CollectionUtils.isEmpty(tagInfoDTOS)) {
        response.setTagInfoModels(tagInfoDTOS);
        return ResponseUtil.success(response);
    } else {
        return ResponseUtil.dataNotExisting(response);
    }
}
Also used : CostTagListResponse(com.tony.billing.response.taginfo.CostTagListResponse) TagInfoDTO(com.tony.billing.dto.TagInfoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TagInfoDTO (com.tony.billing.dto.TagInfoDTO)4 TagInfo (com.tony.billing.entity.TagInfo)3 CostTagListResponse (com.tony.billing.response.taginfo.CostTagListResponse)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ArrayList (java.util.ArrayList)2 CostRecordDetailDTO (com.tony.billing.dto.CostRecordDetailDTO)1 CostRecord (com.tony.billing.entity.CostRecord)1 TagBudgetRef (com.tony.billing.entity.TagBudgetRef)1 TagCostRef (com.tony.billing.entity.TagCostRef)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