package com.gkhy.safePlatform.specialWork.service.baseService.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.ApprovalRule; import com.gkhy.safePlatform.specialWork.enums.RuleStatusEnum; import com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleListDbQuery; import com.gkhy.safePlatform.specialWork.repository.ApprovalRuleRepository; import com.gkhy.safePlatform.specialWork.service.baseService.ApprovalRuleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service("ApprovalRuleService") public class ApprovalRuleServiceImpl extends ServiceImpl implements ApprovalRuleService { @Autowired private ApprovalRuleRepository approvalRuleRepository; /** * 规则新增 * @param rule * @return */ @Override public int saveOneRule(ApprovalRule rule) { rule.setStatus(RuleStatusEnum.VALID.getCode()); rule.setGmtCreate(LocalDateTime.now()); return baseMapper.insert(rule); } /** * 更新 * @param rule * @return */ @Override public int updateRule(ApprovalRule rule) { rule.setGmtModified(LocalDateTime.now()); return baseMapper.updateById(rule); } /** * 逻辑删除 批量删除 */ @Override public int updateStutsByRuleIds(List ruleIds) { return baseMapper.updateStutsByRuleIds(ruleIds,RuleStatusEnum.ABANDONED.getCode()); } /** * 删除-单条 */ @Override public int updateStutsByRuleId(Long ruleId) { return baseMapper.updateStutsByRuleId(ruleId,RuleStatusEnum.ABANDONED.getCode()); } /** * 条件查询 * @param query * @return */ @Override public List listRule(ApprovalRuleListDbQuery query) { query.setStatus(RuleStatusEnum.VALID.getCode()); List approvalRuleList = baseMapper.listByConditions(query); return approvalRuleList; } @Override public List listRuleByPage(Page page, ApprovalRuleListDbQuery query) { query.setStatus(RuleStatusEnum.VALID.getCode()); List approvalRuleList = baseMapper.listByConditions(page,query); return approvalRuleList; } @Override public ApprovalRule getApprovalRuleInfo(Long depId, Byte workType, Byte workLevel) { if (depId == null || workLevel == null || workType == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return approvalRuleRepository.selectOne(new LambdaQueryWrapper() // 部门id .eq(ApprovalRule::getDepId,depId) // 作业等级 .eq(ApprovalRule::getWorkLevel,workLevel) // 作业类型 .eq(ApprovalRule::getWorkType,workType) // 状态 .eq(ApprovalRule::getStatus,RuleStatusEnum.VALID.getCode())); } }