| | |
| | | package com.ruoyi.oa.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | |
| | | import com.ruoyi.oa.domain.SgReserveIp; |
| | | import com.ruoyi.oa.mapper.SgReserveIpMapper; |
| | | import com.ruoyi.oa.service.ISgReserveIpService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | LambdaQueryWrapper<SgReserveIp> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getIp()), SgReserveIp::getIp, bo.getIp()); |
| | | lqw.eq(bo.getBuildingId() != null, SgReserveIp::getBuildingId, bo.getBuildingId()); |
| | | lqw.eq(SgReserveIp::getSchoolId, bo.getSchoolId()); |
| | | lqw.orderByDesc(SgReserveIp::getUpdateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean insertByBo(SgReserveIpBo bo) { |
| | | List<SgReserveIp> ipList = baseMapper.selectList(new LambdaQueryWrapper<SgReserveIp>() |
| | | .eq(SgReserveIp::getIp, bo.getIp()).eq(SgReserveIp::getSchoolId, bo.getSchoolId())); |
| | | if (ipList.size() > 0) { |
| | | throw new ServiceException("IP地址重复", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | List<SgReserveIp> macList = baseMapper.selectList(new LambdaQueryWrapper<SgReserveIp>() |
| | | .eq(SgReserveIp::getMac, bo.getMac()).eq(SgReserveIp::getSchoolId, bo.getSchoolId())); |
| | | if (macList.size() > 0) { |
| | | throw new ServiceException("MAC地址重复", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | SgReserveIp add = BeanUtil.toBean(bo, SgReserveIp.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = save(add); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean updateByBo(SgReserveIpBo bo) { |
| | | List<SgReserveIp> ipList = baseMapper.selectList(new LambdaQueryWrapper<SgReserveIp>() |
| | | .ne(SgReserveIp::getId, bo.getId()) |
| | | .eq(SgReserveIp::getIp, bo.getIp()) |
| | | .eq(SgReserveIp::getSchoolId, bo.getSchoolId())); |
| | | if (ipList.size() > 0) { |
| | | throw new ServiceException("IP地址重复", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | List<SgReserveIp> macList = baseMapper.selectList(new LambdaQueryWrapper<SgReserveIp>() |
| | | .ne(SgReserveIp::getId, bo.getId()) |
| | | .eq(SgReserveIp::getMac, bo.getMac()) |
| | | .eq(SgReserveIp::getSchoolId, bo.getSchoolId())); |
| | | if (macList.size() > 0) { |
| | | throw new ServiceException("MAC地址重复", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | SgReserveIp update = BeanUtil.toBean(bo, SgReserveIp.class); |
| | | validEntityBeforeSave(update); |
| | | return updateById(update); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if(isValid){ |
| | | //TODO 做一些业务上的校验,判断是否需要校验 |