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.ApprovalRuleItemStand; import com.gkhy.safePlatform.specialWork.entity.ApprovalRuleItemStandDO; import com.gkhy.safePlatform.specialWork.enums.RuleItemStandStatusEnum; import com.gkhy.safePlatform.specialWork.enums.RuleStatusEnum; import com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleStandListDBQuery; import com.gkhy.safePlatform.specialWork.model.update.EntityStatusBatchUO; import com.gkhy.safePlatform.specialWork.model.query.ApprovalRuleStandListQuery; import com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleStandPageDBQuery; import com.gkhy.safePlatform.specialWork.repository.ApprovalRuleItemStandRepository; import com.gkhy.safePlatform.specialWork.service.baseService.ApprovalRuleStandService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Set; @Service("ApprovalRuleStandService") public class ApprovalRuleStandServiceImpl extends ServiceImpl implements ApprovalRuleStandService { @Autowired private ApprovalRuleItemStandRepository approvalRuleItemStandRepository; @Override public void saveRuleStand(ApprovalRuleItemStand itemStandEntity) { if (itemStandEntity == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = approvalRuleItemStandRepository.insert(itemStandEntity); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_ADD_ERROR); } } @Override public ApprovalRuleItemStandDO getRuleStandDOById(Long ruleStandId) { if (ruleStandId == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return approvalRuleItemStandRepository.getRuleStandDOById(ruleStandId, RuleItemStandStatusEnum.VALID.getCode()); } @Override public void updateRuleStand(ApprovalRuleItemStand itemStandEntity) { if (itemStandEntity == null || itemStandEntity.getId() == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = approvalRuleItemStandRepository.updateById(itemStandEntity); if (i == 0) { throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE); } if (i > 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } @Override public List listRuleStandDO(ApprovalRuleStandListDBQuery dbQuery) { if (dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return approvalRuleItemStandRepository.listRuleStandDO(dbQuery); } @Override public List listRuleStandByPage(Page page, ApprovalRuleStandPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return approvalRuleItemStandRepository.listRuleStandByPage(page,dbQuery); } @Override public void deleteBatch(EntityStatusBatchUO batchDeleteObj) { if (batchDeleteObj == null || batchDeleteObj.getIds() == null || batchDeleteObj.getIds().size() == 0 || batchDeleteObj.getStatus() == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = approvalRuleItemStandRepository.updateStatusBatch(batchDeleteObj); if (i == 0) { throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE); } if (i != batchDeleteObj.getIds().size()) { throw new BusinessException(ResultCodes.SERVER_BATCH_UPDATE_ERROR); } } /** * 获取标准列表 无条件 * @return */ @Override public List listStandId() { return baseMapper.listStandId(RuleItemStandStatusEnum.VALID.getCode()); } @Override public List listItemStandByIds(Set standIds) { if (standIds == null || standIds.size() == 0) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return approvalRuleItemStandRepository.listItemStandByIds(standIds); } }