|
@@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerUserSelectDto;
|
|
|
+import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
import com.fjhx.customer.entity.customer.po.CustomerUser;
|
|
|
import com.fjhx.customer.entity.customer.vo.CustomerUserVo;
|
|
|
import com.fjhx.customer.mapper.customer.CustomerUserMapper;
|
|
|
+import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.customer.service.customer.CustomerUserService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
@@ -22,12 +25,15 @@ import java.util.List;
|
|
|
* 客户用户表 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
+ * @author
|
|
|
* @since 2023-04-04
|
|
|
*/
|
|
|
@Service
|
|
|
public class CustomerUserServiceImpl extends ServiceImpl<CustomerUserMapper, CustomerUser> implements CustomerUserService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CustomerService customerService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<CustomerUserVo> getList(CustomerUserSelectDto dto) {
|
|
|
IWrapper<CustomerUser> wrapper = getWrapper();
|
|
@@ -62,17 +68,25 @@ public class CustomerUserServiceImpl extends ServiceImpl<CustomerUserMapper, Cus
|
|
|
public CustomerUserVo detail(Long id) {
|
|
|
CustomerUser CustomerUser = this.getById(id);
|
|
|
CustomerUserVo result = BeanUtil.toBean(CustomerUser, CustomerUserVo.class);
|
|
|
+ Customer customer = customerService.getById(result.getCustomerId());
|
|
|
+ if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
+ result.setCustomerName(customer.getName());
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void add(CustomerUserDto customerUserDto) {
|
|
|
- if(ObjectUtil.isEmpty(customerUserDto.getCustomerId())){
|
|
|
+ if (ObjectUtil.isEmpty(customerUserDto.getCustomerId())) {
|
|
|
throw new ServiceException("客户id不能为空");
|
|
|
}
|
|
|
- List<CustomerUser> list = this.list(q -> q.eq(CustomerUser::getCustomerId, customerUserDto.getCustomerId()).eq(CustomerUser::getEmail, customerUserDto.getEmail()));
|
|
|
- if(ObjectUtil.isNotEmpty(list)){
|
|
|
- throw new ServiceException("邮箱不能重复");
|
|
|
+ if (ObjectUtil.isNotEmpty(customerUserDto.getEmail())) {
|
|
|
+ List<CustomerUser> list = this.list(q -> q
|
|
|
+ .eq(CustomerUser::getCustomerId, customerUserDto.getCustomerId())
|
|
|
+ .eq(CustomerUser::getEmail, customerUserDto.getEmail()));
|
|
|
+ if (ObjectUtil.isNotEmpty(list)) {
|
|
|
+ throw new ServiceException("邮箱不能重复");
|
|
|
+ }
|
|
|
}
|
|
|
this.save(customerUserDto);
|
|
|
}
|