diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java index ac996d4..10e1e7f 100644 --- a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuyuanshen.common.core.domain.model.LoginUser; +import com.fuyuanshen.common.core.utils.StringUtils; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.common.satoken.utils.LoginHelper; import com.fuyuanshen.customer.constant.ArrayConstants; @@ -107,17 +108,27 @@ public class CustomerServiceImpl extends ServiceImpl i /** * 修改客户 * - * @param resources / + * @param customer / */ @Override @Transactional(rollbackFor = Exception.class) - public void updateCustomer(Customer resources) throws Exception { - if (resources.getEnabled()) { - resources.setStatus("0"); - } else { - resources.setStatus("1"); + public void updateCustomer(Customer customer) throws Exception { + + UserQueryCriteria userQueryCriteria = new UserQueryCriteria(); + if (StringUtils.isNotEmpty(customer.getUserName())) { + userQueryCriteria.setCustomerName(customer.getUserName()); + List customers = customerMapper.queryCustomers(userQueryCriteria); + if (!customers.isEmpty()) { + throw new BadRequestException("用户名已存在!!!"); + } } - saveOrUpdate(resources); + + if (customer.getEnabled()) { + customer.setStatus("0"); + } else { + customer.setStatus("1"); + } + saveOrUpdate(customer); }