|
@@ -1,8 +1,10 @@
|
|
|
package com.fjhx.customer.service.customer.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fjhx.area.utils.AreaUtil;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
|
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
import com.fjhx.customer.entity.customer.po.CustomerUser;
|
|
@@ -11,6 +13,7 @@ import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.customer.service.customer.CustomerUserService;
|
|
|
import com.fjhx.customer.utils.code.CodeEnum;
|
|
|
+import com.obs.services.internal.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -20,7 +23,9 @@ import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.rmi.ServerException;
|
|
|
import java.security.Security;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -59,6 +64,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
}
|
|
|
wrapper.orderByDesc(Customer::getCreateTime);
|
|
|
Page<CustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+
|
|
|
+ //复制城市信息
|
|
|
+ List<CustomerVo> records = page.getRecords();
|
|
|
+ AreaUtil.setAreaName(records);
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -68,14 +77,18 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public CustomerDto detail(Long id) {
|
|
|
+ public CustomerVo detail(Long id) {
|
|
|
//查询客户表的信息
|
|
|
Customer Customer = this.getById(id);
|
|
|
- CustomerDto result = BeanUtil.toBean(Customer, CustomerDto.class);
|
|
|
+ CustomerVo result = BeanUtil.toBean(Customer, CustomerVo.class);
|
|
|
+ if (ObjectUtil.isEmpty(result)){
|
|
|
+ throw new ServiceException("没有找到该用户信息");
|
|
|
+ }
|
|
|
//查询客户-联系人表的信息
|
|
|
List<CustomerUser> customerUserList = customerUserService.list(Wrappers.<CustomerUser>lambdaQuery()
|
|
|
.eq(CustomerUser::getCustomerId, result.getId()));
|
|
|
result.setCustomerUserList(customerUserList);
|
|
|
+ AreaUtil.setAreaName(result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -84,6 +97,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
* @param customerDto
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
public void add(CustomerDto customerDto) {
|
|
|
customerDto.setCode(CodeEnum.CUSTOMER.getCode());
|
|
|
this.save(customerDto);
|
|
@@ -95,13 +109,14 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
* 修改客户表的数据
|
|
|
* @param customerDto
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
@Override
|
|
|
public void edit(CustomerDto customerDto) {
|
|
|
//修改客户表的信息
|
|
|
this.updateById(customerDto);
|
|
|
//删除客户-用户表的信息
|
|
|
customerUserService.remove(Wrappers.<CustomerUser>lambdaQuery().eq(CustomerUser::getCustomerId,customerDto.getId()));
|
|
|
- //添加库户-联系人表的信息
|
|
|
+ //添加客户-联系人表的信息
|
|
|
saveCustomerUse(customerDto);
|
|
|
}
|
|
|
|
|
@@ -110,6 +125,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
* @param
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
public void delete(Long id) {
|
|
|
//删除客户表的数据
|
|
|
this.removeById(id);
|
|
@@ -128,7 +144,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
//添加权限(自己看自己)
|
|
|
wrapper.eq(Customer::getUserId, SecurityUtils.getUserId());
|
|
|
wrapper.orderByDesc(Customer::getCreateTime);
|
|
|
- Page<CustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ Page<CustomerVo> page =baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ //复制城市信息
|
|
|
+ List<CustomerVo> records = page.getRecords();
|
|
|
+ AreaUtil.setAreaName(records);
|
|
|
return page;
|
|
|
}
|
|
|
|