Search in sources :

Example 1 with TagInfoToDtoListSupplier

use of com.tony.billing.functions.TagInfoToDtoListSupplier in project BillingDubbo by TonyJiangWJ.

the class BudgetServiceImpl method queryBudgetsByCondition.

@Override
public List<BudgetDTO> queryBudgetsByCondition(Budget condition) {
    Preconditions.checkNotNull(condition.getUserId(), "userId must not be null");
    Preconditions.checkNotNull(condition.getBelongMonth(), "month must not be null");
    Preconditions.checkNotNull(condition.getBelongYear(), "year must not be null");
    List<Budget> budgets = mapper.findByYearMonth(condition);
    return budgets.stream().map((budget) -> {
        BudgetDTO dto = new BudgetDTO();
        dto.setId(budget.getId());
        dto.setBudgetName(budget.getBudgetName());
        dto.setBudgetMoney(MoneyUtil.fen2Yuan(budget.getBudgetMoney()));
        dto.setYearMonth(YearMonth.of(Integer.parseInt(budget.getBelongYear()), budget.getBelongMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM")));
        List<TagInfo> tagInfos = tagInfoMapper.listTagInfoByBudgetId(budget.getId(), budget.getUserId());
        dto.setTagInfos(new TagInfoToDtoListSupplier(tagInfos).get());
        return dto;
    }).collect(Collectors.toList());
}
Also used : RedisUtils(com.tony.billing.util.RedisUtils) LoggerFactory(org.slf4j.LoggerFactory) UserIdContainer(com.tony.billing.util.UserIdContainer) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) BudgetService(com.tony.billing.service.api.BudgetService) CollectionUtils(org.apache.commons.collections.CollectionUtils) CostRecordMapper(com.tony.billing.dao.mapper.CostRecordMapper) MoneyUtil(com.tony.billing.util.MoneyUtil) TagInfoToDtoListSupplier(com.tony.billing.functions.TagInfoToDtoListSupplier) AbstractServiceImpl(com.tony.billing.service.base.AbstractServiceImpl) Service(org.apache.dubbo.config.annotation.Service) TagInfoMapper(com.tony.billing.dao.mapper.TagInfoMapper) TagCostInfoDTO(com.tony.billing.dto.TagCostInfoDTO) BudgetReportModel(com.tony.billing.model.BudgetReportModel) TagInfo(com.tony.billing.entity.TagInfo) Logger(org.slf4j.Logger) Resource(javax.annotation.Resource) BudgetDTO(com.tony.billing.dto.BudgetDTO) Collectors(java.util.stream.Collectors) TimeConstants(com.tony.billing.constants.timing.TimeConstants) CostRecord(com.tony.billing.entity.CostRecord) Objects(java.util.Objects) List(java.util.List) Budget(com.tony.billing.entity.Budget) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) BudgetReportItemDTO(com.tony.billing.dto.BudgetReportItemDTO) NumberUtils(org.apache.commons.lang3.math.NumberUtils) YearMonth(java.time.YearMonth) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) BudgetMapper(com.tony.billing.dao.mapper.BudgetMapper) Comparator(java.util.Comparator) TagInfoDTO(com.tony.billing.dto.TagInfoDTO) Collections(java.util.Collections) Budget(com.tony.billing.entity.Budget) ArrayList(java.util.ArrayList) List(java.util.List) TagInfoToDtoListSupplier(com.tony.billing.functions.TagInfoToDtoListSupplier) BudgetDTO(com.tony.billing.dto.BudgetDTO)

Example 2 with TagInfoToDtoListSupplier

use of com.tony.billing.functions.TagInfoToDtoListSupplier in project BillingDubbo by TonyJiangWJ.

the class TagInfoServiceImpl method listCommonTagInfos.

@Override
public List<TagInfoDTO> listCommonTagInfos(List<Long> recordIds) {
    Preconditions.checkState(CollectionUtils.isNotEmpty(recordIds));
    List<TagInfo> commonTags = mapper.listCommonTagInfos(recordIds, recordIds.size());
    return new TagInfoToDtoListSupplier(commonTags).get();
}
Also used : TagInfo(com.tony.billing.entity.TagInfo) TagInfoToDtoListSupplier(com.tony.billing.functions.TagInfoToDtoListSupplier)

Example 3 with TagInfoToDtoListSupplier

use of com.tony.billing.functions.TagInfoToDtoListSupplier 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)3 TagInfoToDtoListSupplier (com.tony.billing.functions.TagInfoToDtoListSupplier)3 Preconditions (com.google.common.base.Preconditions)1 TimeConstants (com.tony.billing.constants.timing.TimeConstants)1 BudgetMapper (com.tony.billing.dao.mapper.BudgetMapper)1 CostRecordMapper (com.tony.billing.dao.mapper.CostRecordMapper)1 TagInfoMapper (com.tony.billing.dao.mapper.TagInfoMapper)1 BudgetDTO (com.tony.billing.dto.BudgetDTO)1 BudgetReportItemDTO (com.tony.billing.dto.BudgetReportItemDTO)1 TagCostInfoDTO (com.tony.billing.dto.TagCostInfoDTO)1 TagInfoDTO (com.tony.billing.dto.TagInfoDTO)1 Budget (com.tony.billing.entity.Budget)1 CostRecord (com.tony.billing.entity.CostRecord)1 BudgetReportModel (com.tony.billing.model.BudgetReportModel)1 TagInfoListResponse (com.tony.billing.response.taginfo.TagInfoListResponse)1 BudgetService (com.tony.billing.service.api.BudgetService)1 AbstractServiceImpl (com.tony.billing.service.base.AbstractServiceImpl)1 MoneyUtil (com.tony.billing.util.MoneyUtil)1 RedisUtils (com.tony.billing.util.RedisUtils)1 UserIdContainer (com.tony.billing.util.UserIdContainer)1