| | |
| | | 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; |
| | |
| | | @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); |