package cn.flightfeather.supervision.lightshare.service.Impl
|
|
import cn.flightfeather.supervision.domain.entity.Law
|
import cn.flightfeather.supervision.domain.entity.LawsRegulations
|
import cn.flightfeather.supervision.domain.enumeration.SceneType
|
import cn.flightfeather.supervision.domain.mapper.BaseInfoMapper
|
import cn.flightfeather.supervision.domain.mapper.LawMapper
|
import cn.flightfeather.supervision.domain.mapper.LawsRegulationsMapper
|
import cn.flightfeather.supervision.domain.mapper.UserinfoMapper
|
import cn.flightfeather.supervision.lightshare.service.LawService
|
import cn.flightfeather.supervision.lightshare.vo.LawVo
|
import cn.flightfeather.supervision.lightshare.vo.LawsRegulationsCondition
|
import com.github.pagehelper.PageHelper
|
import org.springframework.stereotype.Service
|
import tk.mybatis.mapper.entity.Example
|
import javax.servlet.http.HttpServletResponse
|
|
@Service
|
class LawServiceImpl(
|
val lawMapper: LawMapper,
|
val lawsRegulationsMapper: LawsRegulationsMapper,
|
val userinfoMapper: UserinfoMapper,
|
val baseInfoMapper: BaseInfoMapper
|
) : LawService {
|
|
override fun getLaws(page: Int, per_page: Int, response: HttpServletResponse): ArrayList<LawVo> {
|
val counts = lawMapper.selectCountByExample(Example(Law::class.java))
|
val totalPage = Math.ceil(counts.toDouble() / per_page.toDouble()).toInt()
|
response.setIntHeader("totalPage", totalPage)
|
response.setIntHeader("currentPage", page)
|
|
val laws = lawMapper.selectAll()
|
val resultList = ArrayList<LawVo>()
|
laws.forEach {
|
val l = LawVo().apply {
|
id = it.laGuid
|
authorId = it.laAuthorid
|
authorName = it.laAuthorname
|
typeId = it.laTypeid
|
typeName = it.laTypename
|
title = it.laTitle
|
abstract = it.laAbstract
|
picUrl = it.laPicurl
|
bodyUrl = it.laBodyurl
|
}
|
resultList.add(l)
|
}
|
return if (page == 1) {
|
resultList
|
} else {
|
ArrayList()
|
}
|
}
|
|
override fun getLawText(lawId: String): String {
|
val law = lawMapper.selectByPrimaryKey(lawId)
|
return law.laText
|
}
|
|
override fun getLawsRegulations(userId: String,
|
condition: LawsRegulationsCondition, page: Int, per_page: Int, response: HttpServletResponse): List<LawsRegulations> {
|
// val userInfo = userinfoMapper.selectByPrimaryKey(userId)
|
val baseInfo = baseInfoMapper.selectByPrimaryKey(userId)
|
val example = Example(LawsRegulations::class.java).apply {
|
createCriteria().apply {
|
condition.apply {
|
level?.let {
|
andEqualTo("lrResourcelevel", it)
|
}
|
andEqualTo("lrIsforeign", isForeign)
|
category?.let {
|
andEqualTo("lrResourcetypeid", it)
|
}
|
keywords?.let {
|
andLike("lrKeywords", it)
|
}
|
andEqualTo("lrIsopen", isOpen)
|
andEqualTo("lrIsuse", isUsing)
|
fileType?.let {
|
andEqualTo("lrResourcefiletype", it)
|
}
|
}
|
// baseInfo?.biDistrictCode?.let {
|
// andEqualTo("biDistrictCode", it)
|
// }
|
}
|
condition.sceneTypeId?.let {
|
if (it != SceneType.NoType.value) {
|
and(
|
createCriteria().orIsNull("lrExtension1")
|
.orLike("lrExtension1", "%$it%")
|
)
|
}
|
}
|
orderBy("lrPublishdate").desc()
|
}
|
|
val counts = lawsRegulationsMapper.selectCountByExample(example)
|
val totalPage = Math.ceil(counts.toDouble() / per_page.toDouble()).toInt()
|
response.setIntHeader("totalPage", totalPage)
|
response.setIntHeader("currentPage", page)
|
|
val offset = per_page.times(page - 1)
|
PageHelper.offsetPage<LawsRegulations>(offset, per_page)
|
|
return lawsRegulationsMapper.selectByExample(example)
|
}
|
|
override fun getLawsRegulationsWithEachType(condition: LawsRegulationsCondition): List<LawsRegulations> {
|
return lawsRegulationsMapper.getLawsRegulations(condition.level,
|
condition.isForeign, condition.category, condition.keywords,
|
condition.isOpen, condition.isUsing, condition.count, condition.sceneTypeId)
|
}
|
|
override fun getSeries(userId: String, seriesId: String): List<LawsRegulations> {
|
return lawsRegulationsMapper.selectByExample(Example(LawsRegulations::class.java).apply {
|
createCriteria().andEqualTo("lrExtension2", seriesId)
|
orderBy("lrExtension3")
|
})
|
}
|
}
|