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.LawMapper
|
import cn.flightfeather.supervision.domain.mapper.LawsRegulationsMapper
|
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) : 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(
|
condition: LawsRegulationsCondition, page: Int, per_page: Int, response: HttpServletResponse): List<LawsRegulations> {
|
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)
|
}
|
}
|
}
|
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)
|
}
|
}
|