package com.doumee.service.business.impl; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Constants; import com.doumee.core.utils.Utils; import com.doumee.dao.business.CustomerLogMapper; import com.doumee.dao.business.model.*; import com.doumee.service.business.CustomerLogService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Objects; /** * 客户留资记录信息表Service实现 * @author 江蹄蹄 * @date 2024/07/04 14:40 */ @Service public class CustomerLogServiceImpl implements CustomerLogService { @Autowired private CustomerLogMapper customerLogMapper; @Override public Long create(CustomerLog customerLog) { customerLogMapper.insert(customerLog); return customerLog.getId(); } @Override public void deleteById(Long id) { customerLogMapper.deleteById(id); } @Override public void delete(CustomerLog customerLog) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(customerLog); customerLogMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (CollectionUtils.isEmpty(ids)) { return; } customerLogMapper.deleteBatchIds(ids); } @Override public void updateById(CustomerLog customerLog) { customerLogMapper.updateById(customerLog); } @Override public void updateByIdInBatch(List customerLogs) { if (CollectionUtils.isEmpty(customerLogs)) { return; } for (CustomerLog customerLog: customerLogs) { this.updateById(customerLog); } } @Override public CustomerLog findById(Long id) { return customerLogMapper.selectById(id); } @Override public CustomerLog findOne(CustomerLog customerLog) { QueryWrapper wrapper = new QueryWrapper<>(customerLog); return customerLogMapper.selectOne(wrapper); } @Override public List findList(CustomerLog customerLog) { QueryWrapper wrapper = new QueryWrapper<>(customerLog); return customerLogMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); Utils.MP.blankToNull(pageWrap.getModel()); queryWrapper.selectAll(CustomerLog.class) .leftJoin(Customer.class,Customer::getId,CustomerLog::getCostomerId) .eq(CustomerLog::getIsdeleted, Constants.ZERO) .eq(Objects.nonNull(pageWrap.getModel().getType()),CustomerLog::getType, pageWrap.getModel().getType()) .eq(Objects.nonNull(pageWrap.getModel().getMemberId()),Customer::getMemberId, pageWrap.getModel().getMemberId()); queryWrapper.orderByDesc(CustomerLog::getCreateDate); PageData pageData = PageData.from(customerLogMapper.selectJoinPage(page,CustomerLog.class, queryWrapper)); for (CustomerLog customerLog:pageData.getRecords()) { customerLog.setPhone( customerLog.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2") ); } return pageData; } @Override public long count(CustomerLog customerLog) { QueryWrapper wrapper = new QueryWrapper<>(customerLog); return customerLogMapper.selectCount(wrapper); } }