use of com.tony.billing.entity.Budget in project BillingDubbo by TonyJiangWJ.
the class BudgetController method updateBudget.
@PostMapping("/budget/update")
public BaseResponse updateBudget(@ModelAttribute("request") @Validated BudgetUpdateRequest request) {
Budget updateInfo = new Budget();
updateInfo.setId(request.getId());
updateInfo.setBudgetName(request.getName());
updateInfo.setVersion(request.getVersion());
updateInfo.setBudgetMoney(request.getAmount());
Budget oldBudgetInfo = budgetService.getById(request.getId());
updateInfo.setBelongMonth(oldBudgetInfo.getBelongMonth());
updateInfo.setBelongYear(oldBudgetInfo.getBelongYear());
if (budgetService.updateBudget(updateInfo)) {
return ResponseUtil.success();
} else {
return ResponseUtil.error();
}
}
use of com.tony.billing.entity.Budget in project BillingDubbo by TonyJiangWJ.
the class TagInfoServiceImpl method insertTagBudgetRef.
@Override
public Long insertTagBudgetRef(TagBudgetRef budgetRef) {
Preconditions.checkNotNull(budgetRef.getBudgetId());
Preconditions.checkNotNull(budgetRef.getTagId());
budgetRef.setCreateTime(new Date());
budgetRef.setModifyTime(new Date());
if (budgetTagMapper.countByBudgetIdAndTagId(budgetRef.getBudgetId(), budgetRef.getTagId()) > 0) {
logger.error("tag:{} 已经绑定到当前预算 budget:{}", budgetRef.getTagId(), budgetRef.getBudgetId());
return -3L;
}
budgetRef.setIsDeleted(EnumDeleted.NOT_DELETED.val());
TagInfo tagInfo = mapper.getTagInfoById(budgetRef.getTagId());
Budget budget = budgetMapper.getById(budgetRef.getBudgetId(), UserIdContainer.getUserId());
if (tagInfo != null && budget != null && tagInfo.getUserId().equals(UserIdContainer.getUserId())) {
List<Long> boundTagsToThisMonth = mapper.listTagIdsByBudgetMonth(budget.getBelongYear(), budget.getBelongMonth(), UserIdContainer.getUserId(), budget.getId());
if (CollectionUtils.isNotEmpty(boundTagsToThisMonth) && boundTagsToThisMonth.stream().anyMatch(tagId -> tagId.equals(tagInfo.getId()))) {
logger.error("tag:{} 已经绑定到当月其他预算", tagInfo.getId());
return -2L;
}
if (mapper.insertTagBudgetRef(budgetRef) > 0) {
return budgetRef.getId();
}
}
return -1L;
}
Aggregations