| | |
| | | package cn.flightfeather.supervision.domain.repository |
| | | |
| | | import cn.flightfeather.supervision.common.exception.ResponseErrorException |
| | | import cn.flightfeather.supervision.common.exception.BizException |
| | | import cn.flightfeather.supervision.domain.entity.PracticalOperation |
| | | import cn.flightfeather.supervision.domain.entity.PracticalOperationRecord |
| | | import cn.flightfeather.supervision.domain.mapper.PracticalOperationMapper |
| | |
| | | * @param stateId 事务的结果状态id(根据每个事务的定义决定) |
| | | */ |
| | | fun executeOperation(userId: String, operationId: Int, stateId: String): PracticalOperationRecord? { |
| | | val userInfo = userInfoRep.getUser(userId) ?: throw ResponseErrorException("用户不存在,无法操作") |
| | | val userInfo = userInfoRep.getUser(userId) ?: throw BizException("用户不存在,无法操作") |
| | | val operation = |
| | | practicalOperationMapper.selectByPrimaryKey(operationId) ?: throw ResponseErrorException("该实操事务不存在") |
| | | practicalOperationMapper.selectByPrimaryKey(operationId) ?: throw BizException("该实操事务不存在") |
| | | val stateRangeIds = operation.poStateRangeId.split(";") |
| | | val stateRangeNames = operation.poStateRange.split(";") |
| | | if (stateRangeIds.size != stateRangeNames.size) throw ResponseErrorException("事务执行结果的可选状态配置错误!") |
| | | if (stateRangeIds.size != stateRangeNames.size) throw BizException("事务执行结果的可选状态配置错误!") |
| | | val index = stateRangeIds.indexOf(stateId) |
| | | if (index == -1) throw ResponseErrorException("事务执行的状态无效") |
| | | if (index == -1) throw BizException("事务执行的状态无效") |
| | | val record = PracticalOperationRecord().apply { |
| | | poId = operationId |
| | | poTitle = operation.poTitle |