package cn.flightfeather.supervision.lightshare.repository.impl
|
|
import cn.flightfeather.supervision.domain.entity.MeetingComment
|
import cn.flightfeather.supervision.domain.entity.MeetingInfo
|
import cn.flightfeather.supervision.domain.entity.MeetingMaterial
|
import cn.flightfeather.supervision.domain.entity.Participant
|
import cn.flightfeather.supervision.domain.mapper.*
|
import cn.flightfeather.supervision.infrastructure.utils.FileUtil
|
import cn.flightfeather.supervision.infrastructure.utils.GsonUtils
|
import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator
|
import cn.flightfeather.supervision.lightshare.repository.MeetingParticipantRepository
|
import cn.flightfeather.supervision.lightshare.repository.MeetingRepository
|
import cn.flightfeather.supervision.websocket.MeetingMsgVo
|
import com.github.pagehelper.PageHelper
|
import com.google.gson.Gson
|
import com.google.gson.JsonParser
|
import org.springframework.stereotype.Repository
|
import org.springframework.web.multipart.MultipartFile
|
import tk.mybatis.mapper.entity.Example
|
import java.util.*
|
import javax.servlet.http.HttpServletResponse
|
|
/**
|
* @author riku
|
* Date: 2019/11/19
|
*/
|
@Repository
|
class MeetingRepositoryImpl(
|
val meetingInfoMapper: MeetingInfoMapper,
|
val vmRoomMapper: VMRoomMapper,
|
val meetingMaterialMapper: MeetingMaterialMapper,
|
val meetingCommentMapper: MeetingCommentMapper,
|
val meetParticipantMapper: ParticipantMapper
|
) : MeetingRepository {
|
|
override fun getAllMeeting(userId: String, page: Int, perPage: Int, response: HttpServletResponse): List<MeetingInfo> {
|
|
val counts = meetingInfoMapper.selectCountByExample(Example(MeetingInfo::class.java))
|
val totalPage = Math.ceil(counts.toDouble() / perPage.toDouble()).toInt()
|
response.setIntHeader("totalPage", totalPage)
|
response.setIntHeader("currentPage", page)
|
|
val offset = perPage.times(page - 1)
|
PageHelper.offsetPage<MeetingInfo>(offset, perPage)
|
|
val resultList = mutableListOf<MeetingInfo>()
|
val meetingList = meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miIsrelease", true)
|
and(
|
createCriteria().orNotEqualTo("miExtension2", "deleted")
|
.orIsNull("miExtension2")
|
)
|
orderBy("miBegindate").desc()
|
})
|
|
meetingList.forEach {
|
//针对 “工作部署” 、“专项培训”类型的会议,只有创建者和参与者可在“会议广场”查看
|
if (it.miType == 2.toByte() || it.miType == 3.toByte()) {
|
val b1 = meetParticipantMapper.selectByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpParticipantid", userId)
|
.andEqualTo("mpMguid", it.miGuid)
|
}).isNotEmpty()
|
val b2 = it.miCreatorid == userId
|
if (b1 || b2) {
|
resultList.add(it)
|
}
|
} else {
|
resultList.add(it)
|
}
|
}
|
|
return resultList
|
}
|
|
override fun getMeeting(meetingId: String): MeetingInfo? {
|
return meetingInfoMapper.selectByPrimaryKey(meetingId)
|
}
|
|
override fun getMeetingUserJoined(userId: String, status: Int, page: Int, perPage: Int, response: HttpServletResponse): List<MeetingInfo> {
|
//fixme 暂时先强制不分页,只有一页
|
if (page > 1) {
|
return emptyList()
|
}
|
//fixme 需要修改查找方法
|
val result = mutableListOf<MeetingInfo>()
|
meetParticipantMapper.selectByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpParticipantid", userId)
|
}).forEach {
|
val t = meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miGuid", it.mpMguid)
|
.andEqualTo("miIsend", false)
|
.andEqualTo("miIsrelease", true)
|
and(
|
createCriteria().orNotEqualTo("miExtension2", "deleted")
|
.orIsNull("miExtension2")
|
)
|
orderBy("miBegindate").desc()
|
})
|
result.addAll(t)
|
}
|
meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miCreatorid", userId)
|
.andEqualTo("miIsrelease", true)
|
.andEqualTo("miIsend", false)
|
orderBy("miBegindate").desc()
|
}).forEach breaking@{
|
for (i in 0 until result.size) {
|
if (result[i].miGuid == it.miGuid) {
|
return@breaking
|
}
|
}
|
result.add(it)
|
}
|
|
return result
|
|
}
|
|
override fun getMyMeetingUnReleased(userId: String, status: Int, page: Int, perPage: Int, response: HttpServletResponse): List<MeetingInfo> {
|
|
val counts = meetingInfoMapper.selectCountByExample(Example(MeetingInfo::class.java))
|
val totalPage = Math.ceil(counts.toDouble() / perPage.toDouble()).toInt()
|
response.setIntHeader("totalPage", totalPage)
|
response.setIntHeader("currentPage", page)
|
|
val offset = perPage.times(page - 1)
|
PageHelper.offsetPage<MeetingInfo>(offset, perPage)
|
|
return meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miCreatorid", userId)
|
.andEqualTo("miIsrelease", false)
|
.andEqualTo("miIsend", false)
|
and(
|
createCriteria().orNotEqualTo("miExtension2", "deleted")
|
.orIsNull("miExtension2")
|
)
|
orderBy("miBegindate").desc()
|
})
|
}
|
|
override fun getMyMeetingReleased(userId: String, status: Int, page: Int, perPage: Int, response: HttpServletResponse): List<MeetingInfo> {
|
|
val counts = meetingInfoMapper.selectCountByExample(Example(MeetingInfo::class.java))
|
val totalPage = Math.ceil(counts.toDouble() / perPage.toDouble()).toInt()
|
response.setIntHeader("totalPage", totalPage)
|
response.setIntHeader("currentPage", page)
|
|
val offset = perPage.times(page - 1)
|
PageHelper.offsetPage<MeetingInfo>(offset, perPage)
|
|
return meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miCreatorid", userId)
|
.andEqualTo("miIsrelease", true)
|
.andEqualTo("miIsend", false)
|
and(
|
createCriteria().orNotEqualTo("miExtension2", "deleted")
|
.orIsNull("miExtension2")
|
)
|
orderBy("miBegindate").desc()
|
})
|
}
|
|
override fun getHistoryMeeting(userId: String, status: Int, page: Int, perPage: Int, response: HttpServletResponse): List<MeetingInfo> {
|
if (page > 1) {
|
return emptyList()
|
}
|
//fixme 需要修改查找方法
|
val result = mutableListOf<MeetingInfo>()
|
meetParticipantMapper.selectByExample(Example(Participant::class.java).apply {
|
createCriteria().andEqualTo("mpParticipantid", userId)
|
}).forEach {
|
val t = meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miGuid", it.mpMguid)
|
.andEqualTo("miIsend", true)
|
.andEqualTo("miIsrelease", true)
|
and(
|
createCriteria().orNotEqualTo("miExtension2", "deleted")
|
.orIsNull("miExtension2")
|
)
|
orderBy("miBegindate").desc()
|
})
|
result.addAll(t)
|
}
|
meetingInfoMapper.selectByExample(Example(MeetingInfo::class.java).apply {
|
createCriteria().andEqualTo("miCreatorid", userId)
|
.andEqualTo("miIsrelease", true)
|
.andEqualTo("miIsend", true)
|
orderBy("miBegindate").desc()
|
}).forEach breaking@{
|
for (i in 0 until result.size) {
|
if (result[i].miGuid == it.miGuid) {
|
return@breaking
|
}
|
}
|
result.add(it)
|
}
|
|
return result
|
}
|
|
override fun addMeetingInfo(meetingInfo: MeetingInfo): Int {
|
return meetingInfoMapper.insert(meetingInfo)
|
}
|
|
override fun updateMeetingInfo(userId: String, meetingInfo: MeetingInfo): Int {
|
return meetingInfoMapper.updateByPrimaryKeySelective(meetingInfo)
|
}
|
|
override fun deleteMeetingInfo(meetingId: String): Int {
|
return meetingInfoMapper.deleteByPrimaryKey(meetingId)
|
}
|
|
override fun updateMeetingStatusDeleted(meetingId: String): Int {
|
val meeting = meetingInfoMapper.selectByPrimaryKey(meetingId)
|
//fixme 2019.12.19 此处暂时借用扩展字段做删除状态的存储
|
meeting.miExtension2 = "deleted"
|
return meetingInfoMapper.updateByPrimaryKey(meeting)
|
}
|
|
override fun saveMeetingRecords(meetingId: String, roomId: String, msgVoList: List<MeetingMsgVo>): Int {
|
var result = 0
|
msgVoList.forEach {
|
result += meetingCommentMapper.insert(MeetingComment().apply {
|
mcMguid = meetingId
|
mcVmroomguid = roomId
|
mcSpoke = Gson().toJson(listOf(it))
|
mcCreatedate = Date()
|
mcUpdatedate = Date()
|
})
|
}
|
return result
|
}
|
|
override fun getMeetingRecords(userId: String, meetingId: String, roomId: String, page: Int, perPage: Int, response: HttpServletResponse): List<MeetingMsgVo> {
|
val example = Example(MeetingComment::class.java).apply {
|
createCriteria().andEqualTo("mcMguid", meetingId)
|
.andEqualTo("mcVmroomguid", roomId)
|
orderBy("mcUpdatedate").desc()
|
}
|
val counts = meetingCommentMapper.selectCountByExample(example)
|
val totalPage = Math.ceil(counts.toDouble() / perPage.toDouble()).toInt()
|
response.setIntHeader("totalPage", totalPage)
|
response.setIntHeader("currentPage", page)
|
|
val offset = perPage.times(page - 1)
|
PageHelper.offsetPage<MeetingComment>(offset, perPage)
|
|
val resultList = mutableListOf<MeetingMsgVo>()
|
meetingCommentMapper.selectByExample(example).forEach {
|
val msgList = GsonUtils.parserJsonToArrayBeans(it.mcSpoke, MeetingMsgVo::class.java)
|
resultList.addAll(msgList)
|
}
|
return resultList
|
}
|
}
|