use of com.tony.billing.entity.TagBudgetRef in project BillingDubbo by TonyJiangWJ.
the class TagInfoController method putBudgetTag.
@RequestMapping("/budget/tag/put")
public BaseResponse putBudgetTag(@Validated @ModelAttribute("request") BudgetTagPutRequest request) {
TagBudgetRef ref = new TagBudgetRef();
ref.setTagId(request.getTagId());
ref.setBudgetId(request.getBudgetId());
return tagInfoService.insertTagBudgetRef(ref) > 0 ? ResponseUtil.success() : ResponseUtil.error();
}
use of com.tony.billing.entity.TagBudgetRef 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