| | |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.service.ICustomerService; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | @Slf4j |
| | | public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements ICustomerService { |
| | | private CustomerMapper customerMapper; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public List<Customer> selectCustomerList(Customer customer) { |
| | | return customerMapper.selectList(new LambdaQueryWrapper<>()); |
| | | LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (customer.getCustomerName() != null && !customer.getCustomerName().isEmpty()) { |
| | | queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName()); |
| | | } |
| | | List<Customer> customerList = customerMapper.selectList(queryWrapper); |
| | | return customerList; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int insertCustomer(Customer customer) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Integer tenantId = loginUser.getTenantId(); |
| | | customer.setTenantId(Long.valueOf(tenantId)); |
| | | return customerMapper.insert(customer); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public int updateCustomer(Customer customer) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Integer tenantId = loginUser.getTenantId(); |
| | | customer.setTenantId(Long.valueOf(tenantId)); |
| | | return customerMapper.updateById(customer); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public int deleteCustomerByIds(Long[] ids) { |
| | | return customerMapper.deleteCustomerByIds(ids); |
| | | List<Long> idList = Arrays.asList(ids); |
| | | return customerMapper.deleteBatchIds(idList); |
| | | } |
| | | |
| | | /** |
| | | * 删除客户档案信息 |
| | | * |
| | | * @param id 客户档案主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteCustomerById(Long id) { |
| | | return customerMapper.deleteById(id); |
| | | public List<Customer> selectCustomerListByIds(Long[] ids) { |
| | | LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(Customer::getId, Arrays.asList(ids)); |
| | | return customerMapper.selectList(queryWrapper); |
| | | } |
| | | } |