Commit cdb07feb authored by 盖献康's avatar 盖献康

bug(70558) - 车企管理,新增、编辑企业名称验重

parent 6791a9bc
...@@ -2,7 +2,9 @@ package com.ruoyi.service.impl; ...@@ -2,7 +2,9 @@ package com.ruoyi.service.impl;
import java.util.List; import java.util.List;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.request.AutomobileEnterpriseListRequest; import com.ruoyi.web.request.AutomobileEnterpriseListRequest;
...@@ -59,6 +61,14 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter ...@@ -59,6 +61,14 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter
@Override @Override
public int insertAutomobileEnterprise(AutomobileEnterprise automobileEnterprise) public int insertAutomobileEnterprise(AutomobileEnterprise automobileEnterprise)
{ {
// 判断企业名称是否重复
if (lambdaQuery()
.eq(AutomobileEnterprise::getEnterpriseName, automobileEnterprise.getEnterpriseName())
.ne(ObjUtil.isNotEmpty(automobileEnterprise.getId()), AutomobileEnterprise::getId, automobileEnterprise.getId())
.exists()
) {
throw new ServiceException("企业名称已存在");
}
automobileEnterprise.setCreateTime(DateUtils.getNowDate()); automobileEnterprise.setCreateTime(DateUtils.getNowDate());
automobileEnterprise.setCreateBy(String.valueOf(SecurityUtils.getUserId())); automobileEnterprise.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
return automobileEnterpriseMapper.insert(automobileEnterprise); return automobileEnterpriseMapper.insert(automobileEnterprise);
...@@ -73,6 +83,14 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter ...@@ -73,6 +83,14 @@ public class AutomobileEnterpriseServiceImpl extends ServiceImpl<AutomobileEnter
@Override @Override
public int updateAutomobileEnterprise(AutomobileEnterprise automobileEnterprise) public int updateAutomobileEnterprise(AutomobileEnterprise automobileEnterprise)
{ {
// 判断企业名称是否重复
if (lambdaQuery()
.eq(AutomobileEnterprise::getEnterpriseName, automobileEnterprise.getEnterpriseName())
.ne(ObjUtil.isNotEmpty(automobileEnterprise.getId()), AutomobileEnterprise::getId, automobileEnterprise.getId())
.exists()
) {
throw new ServiceException("企业名称已存在");
}
automobileEnterprise.setUpdateTime(DateUtils.getNowDate()); automobileEnterprise.setUpdateTime(DateUtils.getNowDate());
automobileEnterprise.setUpdateBy(String.valueOf(SecurityUtils.getUserId())); automobileEnterprise.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
return automobileEnterpriseMapper.updateAutomobileEnterprise(automobileEnterprise); return automobileEnterpriseMapper.updateAutomobileEnterprise(automobileEnterprise);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment