use of com.tony.billing.entity.TagInfo in project BillingDubbo by TonyJiangWJ.
the class TagInfoController method delCostTag.
/**
* 删除账单标签
*
* @param request
* @return
*/
@RequestMapping(value = "/cost/tag/delete")
public BaseResponse delCostTag(@ModelAttribute("request") @Validated CostTagDelRequest 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) {
if (tagInfoService.deleteCostTag(costRecord.getId(), tagInfo.getId())) {
ResponseUtil.success(response);
} else {
ResponseUtil.error(response);
}
} else {
ResponseUtil.paramError(response);
}
} catch (Exception e) {
logger.error("/cost/tag/delete error", e);
ResponseUtil.sysError(response);
}
return response;
}
use of com.tony.billing.entity.TagInfo in project BillingDubbo by TonyJiangWJ.
the class TagInfoServiceImpl method findTagInfoByName.
@Override
public TagInfo findTagInfoByName(String tagName) {
TagInfo tagInfo = new TagInfo();
tagInfo.setTagName(tagName);
tagInfo.setUserId(UserIdContainer.getUserId());
List<TagInfo> tagInfos = mapper.list(tagInfo);
if (!CollectionUtils.isEmpty(tagInfos)) {
return tagInfos.get(0);
} else {
return null;
}
}
use of com.tony.billing.entity.TagInfo 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