唐耀东
2022-05-18 41e8084ef826dc8d98d4d25bf891965ce2af3ad3
ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/SgNvrServiceImpl.java
@@ -1,6 +1,8 @@
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;
@@ -17,6 +19,7 @@
import com.ruoyi.oa.service.ISgNvrService;
import org.springframework.transaction.annotation.Transactional;
import javax.swing.text.html.HTML;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@@ -62,6 +65,12 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean insertByBo(SgNvrBo bo) {
        List<SgNvr> list = baseMapper.selectList(new LambdaQueryWrapper<SgNvr>()
            .eq(SgNvr::getDeploymentName, bo.getDeploymentName())
            .eq(SgNvr::getSchoolId, bo.getSchoolId()));
        if (list.size() > 0) {
            throw new ServiceException("部署名称重复", HttpStatus.HTTP_PARTIAL);
        }
        SgNvr add = BeanUtil.toBean(bo, SgNvr.class);
        validEntityBeforeSave(add);
        boolean flag = save(add);
@@ -74,6 +83,13 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateByBo(SgNvrBo bo) {
        List<SgNvr> list = baseMapper.selectList(new LambdaQueryWrapper<SgNvr>()
            .ne(SgNvr::getId, bo.getId())
            .eq(SgNvr::getDeploymentName, bo.getDeploymentName())
            .eq(SgNvr::getSchoolId, bo.getSchoolId()));
        if (list.size() > 0) {
            throw new ServiceException("部署名称重复", HttpStatus.HTTP_PARTIAL);
        }
        SgNvr update = BeanUtil.toBean(bo, SgNvr.class);
        validEntityBeforeSave(update);
        return updateById(update);