package doumeemes.service.business.impl; 
 | 
  
 | 
import doumeemes.core.model.PageData; 
 | 
import doumeemes.core.model.PageWrap; 
 | 
import doumeemes.core.utils.Utils; 
 | 
import doumeemes.dao.business.CustomerDistributeMapper; 
 | 
import doumeemes.dao.business.model.CustomerDistribute; 
 | 
import doumeemes.service.business.CustomerDistributeService; 
 | 
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 org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.stereotype.Service; 
 | 
import org.springframework.util.CollectionUtils; 
 | 
  
 | 
import java.util.List; 
 | 
  
 | 
/** 
 | 
 * 订单类-客户分配信息表Service实现 
 | 
 * @author 江蹄蹄 
 | 
 * @date 2022/04/20 09:33 
 | 
 */ 
 | 
@Service 
 | 
public class CustomerDistributeServiceImpl implements CustomerDistributeService { 
 | 
  
 | 
    @Autowired 
 | 
    private CustomerDistributeMapper customerDistributeMapper; 
 | 
  
 | 
    @Override 
 | 
    public Integer create(CustomerDistribute customerDistribute) { 
 | 
        customerDistributeMapper.insert(customerDistribute); 
 | 
        return customerDistribute.getId(); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void deleteById(Integer id) { 
 | 
        customerDistributeMapper.deleteById(id); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void delete(CustomerDistribute customerDistribute) { 
 | 
        UpdateWrapper<CustomerDistribute> deleteWrapper = new UpdateWrapper<>(customerDistribute); 
 | 
        customerDistributeMapper.delete(deleteWrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void deleteByIdInBatch(List<Integer> ids) { 
 | 
        if (CollectionUtils.isEmpty(ids)) { 
 | 
            return; 
 | 
        } 
 | 
        customerDistributeMapper.deleteBatchIds(ids); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void updateById(CustomerDistribute customerDistribute) { 
 | 
        customerDistributeMapper.updateById(customerDistribute); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void updateByIdInBatch(List<CustomerDistribute> customerDistributes) { 
 | 
        if (CollectionUtils.isEmpty(customerDistributes)) { 
 | 
            return; 
 | 
        } 
 | 
        for (CustomerDistribute customerDistribute: customerDistributes) { 
 | 
            this.updateById(customerDistribute); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public CustomerDistribute findById(Integer id) { 
 | 
        return customerDistributeMapper.selectById(id); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public CustomerDistribute findOne(CustomerDistribute customerDistribute) { 
 | 
        QueryWrapper<CustomerDistribute> wrapper = new QueryWrapper<>(customerDistribute); 
 | 
        return customerDistributeMapper.selectOne(wrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public List<CustomerDistribute> findList(CustomerDistribute customerDistribute) { 
 | 
        QueryWrapper<CustomerDistribute> wrapper = new QueryWrapper<>(customerDistribute); 
 | 
        return customerDistributeMapper.selectList(wrapper); 
 | 
    } 
 | 
   
 | 
    @Override 
 | 
    public PageData<CustomerDistribute> findPage(PageWrap<CustomerDistribute> pageWrap) { 
 | 
        IPage<CustomerDistribute> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); 
 | 
        QueryWrapper<CustomerDistribute> queryWrapper = new QueryWrapper<>(); 
 | 
        Utils.MP.blankToNull(pageWrap.getModel()); 
 | 
        if (pageWrap.getModel().getId() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getId, pageWrap.getModel().getId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getDeleted() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getDeleted, pageWrap.getModel().getDeleted()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCreateUser() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getCreateUser, pageWrap.getModel().getCreateUser()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCreateTime() != null) { 
 | 
            queryWrapper.lambda().ge(CustomerDistribute::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime())); 
 | 
            queryWrapper.lambda().le(CustomerDistribute::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUpdateUser() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getUpdateUser, pageWrap.getModel().getUpdateUser()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUpdateTime() != null) { 
 | 
            queryWrapper.lambda().ge(CustomerDistribute::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime())); 
 | 
            queryWrapper.lambda().le(CustomerDistribute::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getRemark() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getRemark, pageWrap.getModel().getRemark()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getStatus() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getStatus, pageWrap.getModel().getStatus()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getRootDepartId() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getRootDepartId, pageWrap.getModel().getRootDepartId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getArea() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getArea, pageWrap.getModel().getArea()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getSaleUserId() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getSaleUserId, pageWrap.getModel().getSaleUserId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getDepartId() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getDepartId, pageWrap.getModel().getDepartId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCustomerId() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getCustomerId, pageWrap.getModel().getCustomerId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCategory() != null) { 
 | 
            queryWrapper.lambda().eq(CustomerDistribute::getCategory, pageWrap.getModel().getCategory()); 
 | 
        } 
 | 
        for(PageWrap.SortData sortData: pageWrap.getSorts()) { 
 | 
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { 
 | 
                queryWrapper.orderByDesc(sortData.getProperty()); 
 | 
            } else { 
 | 
                queryWrapper.orderByAsc(sortData.getProperty()); 
 | 
            } 
 | 
        } 
 | 
        return PageData.from(customerDistributeMapper.selectPage(page, queryWrapper)); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public long count(CustomerDistribute customerDistribute) { 
 | 
        QueryWrapper<CustomerDistribute> wrapper = new QueryWrapper<>(customerDistribute); 
 | 
        return customerDistributeMapper.selectCount(wrapper); 
 | 
    } 
 | 
} 
 |