package cn.flightfeather.supervision.lightshare.service.Impl
|
|
import cn.flightfeather.supervision.domain.entity.PracticalOperation
|
import cn.flightfeather.supervision.domain.entity.PracticalOperationRecord
|
import cn.flightfeather.supervision.domain.mapper.PracticalOperationRecordMapper
|
import cn.flightfeather.supervision.domain.repository.PracticalOperationRep
|
import cn.flightfeather.supervision.domain.repository.UserConfigRep
|
import cn.flightfeather.supervision.lightshare.service.OperationService
|
import cn.flightfeather.supervision.lightshare.vo.PracticalOperationVo
|
import org.springframework.stereotype.Service
|
|
@Service
|
class OperationServiceImpl(
|
private val userConfigRep: UserConfigRep,
|
private val practicalOperationRep: PracticalOperationRep,
|
) : OperationService {
|
|
override fun getOperations(userId: String): List<PracticalOperation?> {
|
val res = mutableListOf<PracticalOperation?>()
|
// 先查询是否有特定属于该用户的事务
|
val r = practicalOperationRep.getOperation(userId)
|
res.addAll(r)
|
// 如果用户没有特定为其定制的事务,则使用通用的事务
|
if (res.isEmpty()) {
|
val configIds = mutableListOf<Int>()
|
userConfigRep.getUserConfig(userId).forEach { it?.let { configIds.add(it.ucId) } }
|
val r1 = practicalOperationRep.getOperation(configIds)
|
res.addAll(r1)
|
}
|
return res
|
}
|
|
override fun executeOperation(
|
userId: String,
|
operationId: Int,
|
stateId: String,
|
): PracticalOperationRecord? {
|
return practicalOperationRep.executeOperation(userId, operationId, stateId)
|
}
|
|
override fun getOperationRecord(userId: String): List<PracticalOperationVo?> {
|
val result = mutableListOf<PracticalOperationVo>()
|
val operations = getOperations(userId)
|
operations.forEach {
|
it?.let {
|
val vo = PracticalOperationVo()
|
vo.operation = it
|
val records = practicalOperationRep.getRecords(userId, it.poId, perPage = 1)
|
if (records.isNotEmpty()) {
|
vo.record = records[0]
|
}
|
result.add(vo)
|
}
|
}
|
return result
|
}
|
}
|