| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public SysConfigProportionDto create(SysConfigProportion resources) { |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle(resources.getTitle()); |
| | | if(ObjectUtils.isNotEmpty(sysConfigProportion)){ |
| | | throw new BadRequestException("标题已存在"); |
| | | } |
| | | //判断标题是否存在 |
| | | getInfo(resources,null); |
| | | return sysConfigProportionMapper.toDto(sysConfigProportionRepository.save(resources)); |
| | | } |
| | | |
| | |
| | | public void update(SysConfigProportion resources) { |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findById(resources.getId()).orElseGet(SysConfigProportion::new); |
| | | ValidationUtil.isNull( sysConfigProportion.getId(),"SysConfigProportion","id",resources.getId()); |
| | | SysConfigProportion configProportion = sysConfigProportionRepository.findByTitle(resources.getTitle()); |
| | | //判断标题是否存在 |
| | | getInfo(resources,sysConfigProportion); |
| | | sysConfigProportion.copy(resources); |
| | | if(configProportion != null && sysConfigProportion.getId() != configProportion.getId()){ |
| | | throw new BadRequestException("标题已存在"); |
| | | } |
| | | sysConfigProportionRepository.save(sysConfigProportion); |
| | | } |
| | | |
| | | /** |
| | | * 重名验证 |
| | | * @param / |
| | | */ |
| | | public void getInfo(SysConfigProportion resources,SysConfigProportion sysConfigProportion){ |
| | | //根据标题查询比例表 |
| | | SysConfigProportion configProportion = sysConfigProportionRepository.findByTitle(resources.getTitle()); |
| | | if(ObjectUtils.isNotEmpty(resources.getId())){ |
| | | if(configProportion != null && configProportion.getId() != sysConfigProportion.getId()){ |
| | | throw new BadRequestException("标题已存在"); |
| | | } |
| | | }else{ |
| | | if(configProportion != null){ |
| | | throw new BadRequestException("标题已存在"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |