Search in sources :

Example 1 with CostRecordDTO

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

the class CostRecordController method formatModelList.

private List<CostRecordDTO> formatModelList(List<CostRecord> list, boolean showTags) {
    if (!CollectionUtils.isEmpty(list)) {
        List<CostRecordDTO> models = new ArrayList<>();
        CostRecordDTO model;
        List<TagInfo> tagInfos;
        for (CostRecord entity : list) {
            model = new CostRecordDTO();
            model.setId(entity.getId());
            model.setCreateTime(entity.getCostCreateTime());
            model.setGoodsName(entity.getGoodsName());
            model.setInOutType(entity.getInOutType());
            model.setIsDeleted(entity.getIsDeleted());
            model.setMoney(MoneyUtil.fen2Yuan(entity.getMoney()));
            model.setLocation(entity.getLocation());
            model.setOrderStatus(entity.getOrderStatus());
            model.setOrderType(entity.getOrderType());
            model.setTradeNo(entity.getTradeNo());
            model.setTarget(entity.getTarget());
            model.setMemo(entity.getMemo());
            model.setIsHidden(entity.getIsHidden());
            if (showTags) {
                tagInfos = tagInfoService.listTagInfoByTradeNo(entity.getTradeNo());
                if (!CollectionUtils.isEmpty(tagInfos)) {
                    model.setTags(tagInfos.stream().map(TagInfo::getTagName).collect(Collectors.toList()));
                }
            }
            models.add(model);
        }
        return models;
    } else {
        return null;
    }
}
Also used : CostRecord(com.tony.billing.entity.CostRecord) TagInfo(com.tony.billing.entity.TagInfo) ArrayList(java.util.ArrayList) CostRecordDTO(com.tony.billing.dto.CostRecordDTO)

Aggregations

CostRecordDTO (com.tony.billing.dto.CostRecordDTO)1 CostRecord (com.tony.billing.entity.CostRecord)1 TagInfo (com.tony.billing.entity.TagInfo)1 ArrayList (java.util.ArrayList)1