package com.gkhy.safePlatform.specialWork.service.baseService.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.specialWork.entity.MaterialAllocationBaseInfo; import com.gkhy.safePlatform.specialWork.enums.MaterialAllocationBaseStatusEnum; import com.gkhy.safePlatform.specialWork.model.query.MaterialAllocationBaseQuery; import com.gkhy.safePlatform.specialWork.repository.MaterialAllocationBaseInfoRepository; import com.gkhy.safePlatform.specialWork.service.baseService.MaterialAllocationBaseInfoService; import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service("MaterialAllocationBaseInfoService") public class MaterialAllocationBaseInfoServiceImpl extends ServiceImpl implements MaterialAllocationBaseInfoService { @Override public int saveOne(MaterialAllocationBaseInfo materialAllocationBaseInfo) { materialAllocationBaseInfo.setStatus(MaterialAllocationBaseStatusEnum.VALID.getCode()); materialAllocationBaseInfo.setGmtCreate(LocalDateTime.now()); return baseMapper.saveOne(materialAllocationBaseInfo); } @Override public int updateOne(MaterialAllocationBaseInfo materialAllocationBaseInfo) { if(null == materialAllocationBaseInfo.getId()){ throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } materialAllocationBaseInfo.setGmtModified(LocalDateTime.now()); return baseMapper.updateOne(materialAllocationBaseInfo); } @Override public int updateStatus(Long id) { if(null == id){ throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return baseMapper.updateStatus(id,MaterialAllocationBaseStatusEnum.ABANDONED.getCode()); } @Override public int batchUpdateStatus(List ids) { if(CollectionUtils.isEmpty(ids)){ throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return baseMapper.batchUpdateStatus(ids,MaterialAllocationBaseStatusEnum.ABANDONED.getCode()); } @Override public List listByPage(Page page, MaterialAllocationBaseQuery query) { query.setStatus(MaterialAllocationBaseStatusEnum.VALID.getCode()); return baseMapper.listByCondition(page,query); } @Override public List listAll(MaterialAllocationBaseQuery query) { query.setStatus(MaterialAllocationBaseStatusEnum.VALID.getCode()); return baseMapper.listByCondition(query); } @Override public int getCountByWorkTypeOrLevel(MaterialAllocationBaseQuery query) { query.setStatus(MaterialAllocationBaseStatusEnum.VALID.getCode()); return baseMapper.getCountByWorkTypeOrLevel(query); } @Override public MaterialAllocationBaseInfo queryById(Long maId) { return baseMapper.queryById(maId,MaterialAllocationBaseStatusEnum.VALID.getCode()); } }