use of com.tony.billing.dto.BudgetDTO 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());
}
use of com.tony.billing.dto.BudgetDTO in project BillingDubbo by TonyJiangWJ.
the class BudgetController method getBudgetInfo.
@RequestMapping("/budget/get")
public BaseResponse getBudgetInfo(@ModelAttribute("request") @Validated BudgetDetailRequest request) {
Budget budget = budgetService.getById(request.getId());
if (budget != null) {
BudgetDetailResponse response = ResponseUtil.success(new BudgetDetailResponse());
BudgetDTO budgetDTO = new BudgetDTO();
budgetDTO.setId(budget.getId());
budgetDTO.setYearMonth(YearMonth.of(Integer.parseInt(budget.getBelongYear()), budget.getBelongMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM")));
budgetDTO.setBudgetName(budget.getBudgetName());
budgetDTO.setBudgetMoney(MoneyUtil.fen2Yuan(budget.getBudgetMoney()));
budgetDTO.setVersion(budget.getVersion());
budgetDTO.setTagInfos(budgetService.getTagInfosByBudgetId(budget.getId(), request.getUserId()));
response.setBudgetInfo(budgetDTO);
return response;
}
return ResponseUtil.dataNotExisting();
}
use of com.tony.billing.dto.BudgetDTO in project BillingDubbo by TonyJiangWJ.
the class BudgetController method listBudget.
@RequestMapping("/budget/list")
public BudgetListResponse listBudget(@ModelAttribute("request") @Validated BudgetListRequest request) {
BudgetListResponse response = new BudgetListResponse();
try {
Budget query = new Budget();
query.setBelongMonth(request.getMonth());
query.setBelongYear(request.getYear());
query.setUserId(request.getUserId());
List<BudgetDTO> budgets = budgetService.queryBudgetsByCondition(query);
if (CollectionUtils.isNotEmpty(budgets)) {
response.setBudgetList(budgets);
ResponseUtil.success(response);
} else {
ResponseUtil.dataNotExisting(response);
}
} catch (Exception e) {
logger.error("/budget/list error", e);
ResponseUtil.sysError(response);
}
return response;
}
Aggregations