|
@@ -0,0 +1,76 @@
|
|
|
+package org.dromara.customerManagement.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.customerManagement.domain.Customer;
|
|
|
+import org.dromara.customerManagement.domain.bo.CustomerBo;
|
|
|
+import org.dromara.customerManagement.domain.vo.CustomerVo;
|
|
|
+import org.dromara.customerManagement.mapper.CustomerMapper;
|
|
|
+import org.dromara.customerManagement.service.CustomerService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class CustomerServiceImpl implements CustomerService {
|
|
|
+ private final CustomerMapper customerMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询客户对象分页查询客户数据
|
|
|
+ * @param customersBo 客户Bo对象
|
|
|
+ * @param pageQuery 查询条件
|
|
|
+ * @return 分页结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<CustomerVo> selectPageCustomerList(CustomerBo customersBo, PageQuery pageQuery){
|
|
|
+ QueryWrapper<Customer> qw = new QueryWrapper<>();
|
|
|
+ qw.eq(StringUtils.isNotBlank(customersBo.getUsername()),"username",customersBo.getUsername());
|
|
|
+ qw.eq(StringUtils.isNotBlank(customersBo.getMobile()),"mobile",customersBo.getMobile());
|
|
|
+ Page<CustomerVo>page= customerMapper.selectVoPage(pageQuery.build(), qw);
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增客户
|
|
|
+ * @param customerBo 客户Bo对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertCustomer(CustomerBo customerBo){
|
|
|
+ Customer customer = MapstructUtils.convert(customerBo, Customer.class);
|
|
|
+ return customerMapper.insert(customer);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改客户
|
|
|
+ * @param customerBo 客户Bo对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateCustomer(CustomerBo customerBo){
|
|
|
+ Customer customer = MapstructUtils.convert(customerBo, Customer.class);
|
|
|
+ QueryWrapper<Customer> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("id",customerBo.getId());
|
|
|
+ return customerMapper.updateById(customer);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除客户
|
|
|
+ * @param customerId 客户ID
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteCustomerById(Long customerId){
|
|
|
+ return customerMapper.deleteById(customerId);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public List<Customer> selectList() {
|
|
|
+ return customerMapper.selectList();
|
|
|
+ }
|
|
|
+}
|