Search in sources :

Example 6 with Budget

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();
    }
}
Also used : Budget(com.tony.billing.entity.Budget) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 7 with Budget

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;
}
Also used : CommonValidateService(com.tony.billing.service.api.CommonValidateService) Date(java.util.Date) HashMap(java.util.HashMap) UserIdContainer(com.tony.billing.util.UserIdContainer) StringUtils(org.apache.commons.lang3.StringUtils) BudgetTagMapper(com.tony.billing.dao.mapper.BudgetTagMapper) EnumDeleted(com.tony.billing.constants.enums.EnumDeleted) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) 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) TagInfoService(com.tony.billing.service.api.TagInfoService) TagInfo(com.tony.billing.entity.TagInfo) EnumOwnershipCheckTables(com.tony.billing.constraints.enums.EnumOwnershipCheckTables) Resource(javax.annotation.Resource) TagCostRef(com.tony.billing.entity.TagCostRef) Collectors(java.util.stream.Collectors) List(java.util.List) CostTagMapper(com.tony.billing.dao.mapper.CostTagMapper) Budget(com.tony.billing.entity.Budget) Preconditions(com.google.common.base.Preconditions) BudgetMapper(com.tony.billing.dao.mapper.BudgetMapper) TagBudgetRef(com.tony.billing.entity.TagBudgetRef) TagInfoDTO(com.tony.billing.dto.TagInfoDTO) TagInfo(com.tony.billing.entity.TagInfo) Budget(com.tony.billing.entity.Budget) Date(java.util.Date)

Aggregations

Budget (com.tony.billing.entity.Budget)7 BudgetDTO (com.tony.billing.dto.BudgetDTO)3 TagInfo (com.tony.billing.entity.TagInfo)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Preconditions (com.google.common.base.Preconditions)2 BudgetMapper (com.tony.billing.dao.mapper.BudgetMapper)2 TagInfoMapper (com.tony.billing.dao.mapper.TagInfoMapper)2 BudgetReportItemDTO (com.tony.billing.dto.BudgetReportItemDTO)2 TagCostInfoDTO (com.tony.billing.dto.TagCostInfoDTO)2 TagInfoDTO (com.tony.billing.dto.TagInfoDTO)2 CostRecord (com.tony.billing.entity.CostRecord)2 TagInfoToDtoListSupplier (com.tony.billing.functions.TagInfoToDtoListSupplier)2 BudgetReportModel (com.tony.billing.model.BudgetReportModel)2 AbstractServiceImpl (com.tony.billing.service.base.AbstractServiceImpl)2 UserIdContainer (com.tony.billing.util.UserIdContainer)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 CollectionUtils (org.apache.commons.collections.CollectionUtils)2