Search in sources :

Example 6 with TagInfo

use of com.tony.billing.entity.TagInfo in project BillingDubbo by TonyJiangWJ.

the class TagInfoController method putCostTag.

/**
 * 添加账单标签
 *
 * @param request
 * @return
 */
@RequestMapping(value = "/cost/tag/put")
public BaseResponse putCostTag(@ModelAttribute("request") @Validated CostTagPutRequest request) {
    BaseResponse response = new BaseResponse();
    try {
        CostRecord costRecord = costRecordService.findByTradeNo(request.getTradeNo(), request.getUserId());
        TagInfo tagInfo = tagInfoService.getTagInfoById(request.getTagId());
        if (costRecord != null && tagInfo != null) {
            TagCostRef ref = new TagCostRef();
            ref.setCostId(costRecord.getId());
            ref.setTagId(tagInfo.getId());
            if (tagInfoService.insertTagCostRef(ref) > 0) {
                ResponseUtil.success(response);
            } else {
                ResponseUtil.error(response);
            }
        } else {
            ResponseUtil.paramError(response);
        }
    } catch (Exception e) {
        logger.error("/cost/tag/put error", e);
        ResponseUtil.sysError(response);
    }
    return response;
}
Also used : BaseResponse(com.tony.billing.response.BaseResponse) CostRecord(com.tony.billing.entity.CostRecord) TagInfo(com.tony.billing.entity.TagInfo) TagCostRef(com.tony.billing.entity.TagCostRef) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with TagInfo

use of com.tony.billing.entity.TagInfo in project BillingDubbo by TonyJiangWJ.

the class TagInfoController method putTag.

/**
 * 添加标签
 *
 * @param request
 * @return
 */
@RequestMapping(value = "/tag/put")
public BaseResponse putTag(@ModelAttribute("request") @Validated TagInfoPutRequest request) {
    BaseResponse response = new BaseResponse();
    try {
        TagInfo tagInfo = new TagInfo();
        tagInfo.setTagName(request.getTagName());
        tagInfo.setUserId(request.getUserId());
        if (tagInfoService.putTagInfo(tagInfo) > 0) {
            ResponseUtil.success(response);
        } else {
            ResponseUtil.error(response);
        }
    } catch (Exception e) {
        logger.error("/tag/put error", e);
        ResponseUtil.sysError(response);
    }
    return response;
}
Also used : BaseResponse(com.tony.billing.response.BaseResponse) TagInfo(com.tony.billing.entity.TagInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with TagInfo

use of com.tony.billing.entity.TagInfo 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)

Example 9 with TagInfo

use of com.tony.billing.entity.TagInfo 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)

Example 10 with TagInfo

use of com.tony.billing.entity.TagInfo 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)

Aggregations

TagInfo (com.tony.billing.entity.TagInfo)13 CostRecord (com.tony.billing.entity.CostRecord)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 TagInfoDTO (com.tony.billing.dto.TagInfoDTO)5 TagInfoToDtoListSupplier (com.tony.billing.functions.TagInfoToDtoListSupplier)5 ArrayList (java.util.ArrayList)5 BaseResponse (com.tony.billing.response.BaseResponse)4 Budget (com.tony.billing.entity.Budget)3 TagCostRef (com.tony.billing.entity.TagCostRef)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Preconditions (com.google.common.base.Preconditions)2 BudgetMapper (com.tony.billing.dao.mapper.BudgetMapper)2 TagInfoMapper (com.tony.billing.dao.mapper.TagInfoMapper)2 BudgetReportItemDTO (com.tony.billing.dto.BudgetReportItemDTO)2 TagCostInfoDTO (com.tony.billing.dto.TagCostInfoDTO)2 TagBudgetRef (com.tony.billing.entity.TagBudgetRef)2 BudgetReportModel (com.tony.billing.model.BudgetReportModel)2 CostTagListResponse (com.tony.billing.response.taginfo.CostTagListResponse)2 TagInfoListResponse (com.tony.billing.response.taginfo.TagInfoListResponse)2