| package doumeemes.service.business.impl; | 
|   | 
| import doumeemes.core.model.PageData; | 
| import doumeemes.core.model.PageWrap; | 
| import doumeemes.core.utils.Utils; | 
| import doumeemes.dao.business.UnitDistributeMapper; | 
| import doumeemes.dao.business.model.UnitDistribute; | 
| import doumeemes.service.business.UnitDistributeService; | 
| 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:37 | 
|  */ | 
| @Service | 
| public class UnitDistributeServiceImpl implements UnitDistributeService { | 
|   | 
|     @Autowired | 
|     private UnitDistributeMapper unitDistributeMapper; | 
|   | 
|     @Override | 
|     public Integer create(UnitDistribute unitDistribute) { | 
|         unitDistributeMapper.insert(unitDistribute); | 
|         return unitDistribute.getId(); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteById(Integer id) { | 
|         unitDistributeMapper.deleteById(id); | 
|     } | 
|   | 
|     @Override | 
|     public void delete(UnitDistribute unitDistribute) { | 
|         UpdateWrapper<UnitDistribute> deleteWrapper = new UpdateWrapper<>(unitDistribute); | 
|         unitDistributeMapper.delete(deleteWrapper); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteByIdInBatch(List<Integer> ids) { | 
|         if (CollectionUtils.isEmpty(ids)) { | 
|             return; | 
|         } | 
|         unitDistributeMapper.deleteBatchIds(ids); | 
|     } | 
|   | 
|     @Override | 
|     public void updateById(UnitDistribute unitDistribute) { | 
|         unitDistributeMapper.updateById(unitDistribute); | 
|     } | 
|   | 
|     @Override | 
|     public void updateByIdInBatch(List<UnitDistribute> unitDistributes) { | 
|         if (CollectionUtils.isEmpty(unitDistributes)) { | 
|             return; | 
|         } | 
|         for (UnitDistribute unitDistribute: unitDistributes) { | 
|             this.updateById(unitDistribute); | 
|         } | 
|     } | 
|   | 
|     @Override | 
|     public UnitDistribute findById(Integer id) { | 
|         return unitDistributeMapper.selectById(id); | 
|     } | 
|   | 
|     @Override | 
|     public UnitDistribute findOne(UnitDistribute unitDistribute) { | 
|         QueryWrapper<UnitDistribute> wrapper = new QueryWrapper<>(unitDistribute); | 
|         return unitDistributeMapper.selectOne(wrapper); | 
|     } | 
|   | 
|     @Override | 
|     public List<UnitDistribute> findList(UnitDistribute unitDistribute) { | 
|         QueryWrapper<UnitDistribute> wrapper = new QueryWrapper<>(unitDistribute); | 
|         return unitDistributeMapper.selectList(wrapper); | 
|     } | 
|    | 
|     @Override | 
|     public PageData<UnitDistribute> findPage(PageWrap<UnitDistribute> pageWrap) { | 
|         IPage<UnitDistribute> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         QueryWrapper<UnitDistribute> queryWrapper = new QueryWrapper<>(); | 
|         Utils.MP.blankToNull(pageWrap.getModel()); | 
|         if (pageWrap.getModel().getId() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getId, pageWrap.getModel().getId()); | 
|         } | 
|         if (pageWrap.getModel().getDeleted() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getDeleted, pageWrap.getModel().getDeleted()); | 
|         } | 
|         if (pageWrap.getModel().getCreateUser() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getCreateUser, pageWrap.getModel().getCreateUser()); | 
|         } | 
|         if (pageWrap.getModel().getCreateTime() != null) { | 
|             queryWrapper.lambda().ge(UnitDistribute::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime())); | 
|             queryWrapper.lambda().le(UnitDistribute::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime())); | 
|         } | 
|         if (pageWrap.getModel().getUpdateUser() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getUpdateUser, pageWrap.getModel().getUpdateUser()); | 
|         } | 
|         if (pageWrap.getModel().getUpdateTime() != null) { | 
|             queryWrapper.lambda().ge(UnitDistribute::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime())); | 
|             queryWrapper.lambda().le(UnitDistribute::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime())); | 
|         } | 
|         if (pageWrap.getModel().getRemark() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getRemark, pageWrap.getModel().getRemark()); | 
|         } | 
|         if (pageWrap.getModel().getDepartId() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getDepartId, pageWrap.getModel().getDepartId()); | 
|         } | 
|         if (pageWrap.getModel().getRootDepartId() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getRootDepartId, pageWrap.getModel().getRootDepartId()); | 
|         } | 
|         if (pageWrap.getModel().getUnitId() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getUnitId, pageWrap.getModel().getUnitId()); | 
|         } | 
|         if (pageWrap.getModel().getName() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getName, pageWrap.getModel().getName()); | 
|         } | 
|         if (pageWrap.getModel().getType() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getType, pageWrap.getModel().getType()); | 
|         } | 
|         if (pageWrap.getModel().getStatus() != null) { | 
|             queryWrapper.lambda().eq(UnitDistribute::getStatus, pageWrap.getModel().getStatus()); | 
|         } | 
|         for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|             if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|                 queryWrapper.orderByDesc(sortData.getProperty()); | 
|             } else { | 
|                 queryWrapper.orderByAsc(sortData.getProperty()); | 
|             } | 
|         } | 
|         return PageData.from(unitDistributeMapper.selectPage(page, queryWrapper)); | 
|     } | 
|   | 
|     @Override | 
|     public long count(UnitDistribute unitDistribute) { | 
|         QueryWrapper<UnitDistribute> wrapper = new QueryWrapper<>(unitDistribute); | 
|         return unitDistributeMapper.selectCount(wrapper); | 
|     } | 
| } |