package cn.flightfeather.supervision.lightshare.repository.impl
|
|
import cn.flightfeather.supervision.domain.entity.Participant
|
import cn.flightfeather.supervision.domain.mapper.ParticipantMapper
|
import cn.flightfeather.supervision.lightshare.repository.MeetingParticipantRepository
|
import cn.flightfeather.supervision.lightshare.vo.MeetingUserOnlineStatusVo
|
import cn.flightfeather.supervision.domain.enumeration.ParticipantType
|
import org.springframework.stereotype.Repository
|
import tk.mybatis.mapper.entity.Example
|
|
/**
|
* @author riku
|
* Date: 2019/12/19
|
*/
|
@Repository
|
class MeetingParticipantRepositoryImpl(val participantMapper: ParticipantMapper): MeetingParticipantRepository {
|
override fun deleteAllByMeetingId(meetingId: String): Int {
|
return participantMapper.deleteByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpMguid", meetingId)
|
})
|
}
|
|
override fun addParticipant(participant: Participant): Int {
|
val exitResult = participantMapper.selectByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpMguid", participant.mpMguid)
|
.andEqualTo("mcVmroomguid", participant.mcVmroomguid)
|
.andEqualTo("mpParticipantid", participant.mpParticipantid)
|
})
|
|
//查重
|
return if (exitResult.isNotEmpty()) {
|
0
|
} else {
|
participantMapper.insert(participant)
|
}
|
}
|
|
override fun deleteParticipant(participant: Participant): Int {
|
return participantMapper.delete(participant)
|
}
|
|
override fun getParticipantByType(meetingId: String, roomId: String?, participantType: Int): List<Participant> {
|
return participantMapper.selectByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpMguid", meetingId)
|
.apply {
|
if (roomId != null) {
|
andEqualTo("mcVmroomguid", roomId)
|
}
|
//判断获取的参会人员类型,如果不是全部,则加判定条件
|
if (participantType != ParticipantType.All.value) {
|
andEqualTo("mpPersontype", participantType.toByte())
|
}
|
}
|
})
|
}
|
|
override fun getParticipant(meetingId: String, roomId: String?, participantId: String): Participant? {
|
return participantMapper.selectByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpMguid", meetingId)
|
.apply {
|
if (roomId != null) {
|
andEqualTo("mcVmroomguid", roomId)
|
}
|
}.andEqualTo("mpParticipantid", participantId)
|
})?.takeIf {
|
it.isNotEmpty()
|
}?.get(0)
|
}
|
|
override fun selectAsUserInfo(meetingId: String, roomId: String): List<MeetingUserOnlineStatusVo> {
|
val resultMapList = participantMapper.selectAsUserInfo(meetingId, roomId)
|
return mutableListOf<MeetingUserOnlineStatusVo>().apply {
|
resultMapList.forEach {
|
add(MeetingUserOnlineStatusVo().apply {
|
this.userId = it["userId"].toString()
|
headIconUrl = it["headIconUrl"].toString()
|
acountname = it["realName"].toString()
|
personType = it["personType"].toString().toInt()
|
})
|
}
|
}
|
}
|
}
|