package com.gk.hotwork.specialWork.service.baseService.impl;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gk.hotwork.Domain.Enum.ResultCodes;
|
import com.gk.hotwork.Domain.Exception.BusinessException;
|
import com.gk.hotwork.specialWork.entity.ApprovalRuleItemStand;
|
import com.gk.hotwork.specialWork.entity.ApprovalRuleItemStandDO;
|
import com.gk.hotwork.specialWork.enums.RuleItemStandStatusEnum;
|
import com.gk.hotwork.specialWork.model.query.db.ApprovalRuleStandListDBQuery;
|
import com.gk.hotwork.specialWork.model.query.db.ApprovalRuleStandPageDBQuery;
|
import com.gk.hotwork.specialWork.model.update.EntityStatusBatchUO;
|
import com.gk.hotwork.specialWork.repository.ApprovalRuleItemStandRepository;
|
import com.gk.hotwork.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<ApprovalRuleItemStandRepository, ApprovalRuleItemStand> 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<ApprovalRuleItemStandDO> listRuleStandDO(ApprovalRuleStandListDBQuery dbQuery) {
|
if (dbQuery == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return approvalRuleItemStandRepository.listRuleStandDO(dbQuery);
|
}
|
|
@Override
|
public List<ApprovalRuleItemStand> listRuleStandByPage(Page<ApprovalRuleItemStand> 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<Long> listStandId() {
|
return baseMapper.listStandId(RuleItemStandStatusEnum.VALID.getCode());
|
}
|
|
@Override
|
public List<ApprovalRuleItemStandDO> listItemStandByIds(Set<Long> standIds) {
|
if (standIds == null || standIds.size() == 0) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return approvalRuleItemStandRepository.listItemStandByIds(standIds);
|
}
|
}
|