供应商增加名称唯一校验

This commit is contained in:
1378012178@qq.com 2026-01-22 15:30:00 +08:00
parent 4d0cc2b85e
commit 66855a182b
3 changed files with 21 additions and 0 deletions

View File

@ -24,4 +24,6 @@ public interface ISuppliersApi {
SuppliersApplyEntity getSupInfoByOpenId(String openId);
IPage<SuppliersOrgAllEntity> getSuppliersAuditLog(Integer pageNo, Integer pageSize, String openId);
boolean nameDuplicateChecked(String suppliersName);
}

View File

@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.CollectionUtils;
import java.util.List;
@ -197,4 +198,16 @@ public class NuBizSuppliersApplyServiceImpl extends ServiceImpl<NuBizSuppliersAp
return list;
}
@Override
public boolean nameDuplicateChecked(String suppliersName) {
QueryWrapper<NuBizSuppliersApply> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("suppliers_name",suppliersName);
List<NuBizSuppliersApply> nuBizSuppliersApplies = baseMapper.selectList(queryWrapper);
if(CollectionUtils.isEmpty(nuBizSuppliersApplies)){
return false;
}else{
return true;
}
}
}

View File

@ -31,6 +31,9 @@ public class SuppliersApi {
*/
@PostMapping(value = "/addSuppliers")
public Result<Object> addSuppliers(@RequestBody SuppliersApplyEntity suppliersApplyEntity) {
if(!suppliersApi.nameDuplicateChecked(suppliersApplyEntity.getSuppliersName())){
return Result.error("供应商名称重复");
}
SuppliersApplyEntity suppliersApplyEntity1 = suppliersApi.addSuppliers(suppliersApplyEntity);
return Result.OK(suppliersApplyEntity);
}
@ -43,6 +46,9 @@ public class SuppliersApi {
*/
@PostMapping(value = "/editSuppliers")
public Result<Object> editSuppliers(@RequestBody SuppliersApplyEntity suppliersApplyEntity) {
if(!suppliersApi.nameDuplicateChecked(suppliersApplyEntity.getSuppliersName())){
return Result.error("供应商名称重复");
}
SuppliersApplyEntity suppliersApplyEntity1 = suppliersApi.editSuppliers(suppliersApplyEntity);
return Result.OK(suppliersApplyEntity);
}