package cn.flightfeather.supervision.lightshare.service.Impl
|
|
import cn.flightfeather.supervision.domain.entity.Version
|
import cn.flightfeather.supervision.domain.mapper.VersionMapper
|
import cn.flightfeather.supervision.infrastructure.utils.FileUtil
|
import cn.flightfeather.supervision.lightshare.service.VersionService
|
import cn.flightfeather.supervision.lightshare.vo.VersionVo
|
import org.springframework.stereotype.Service
|
import org.springframework.web.multipart.MultipartFile
|
import tk.mybatis.mapper.entity.Example
|
|
@Service
|
class VersionServiceImpl(val versionMapper: VersionMapper): VersionService {
|
|
override fun save(version: Version): Int = versionMapper.insert(version)
|
|
override fun update(version: Version): Int = versionMapper.updateByPrimaryKey(version)
|
|
override fun delete(id: String): Int =versionMapper.deleteByPrimaryKey(id)
|
|
override fun getLatestVersion(): Version? {
|
val example = Example(Version::class.java)
|
example.createCriteria().andEqualTo("enable", true)
|
example.orderBy("versionCode").desc()
|
val versionlist = versionMapper.selectByExample(example)
|
if (versionlist != null && versionlist.size > 0) {
|
return versionlist[0]
|
}
|
return null
|
}
|
|
override fun upLoadCrashInfo(userId: String, files: Array<MultipartFile>): Boolean {
|
if (files.isNotEmpty()) {
|
val file = files[0]
|
val fileName = files[0].originalFilename
|
val basePath = "D:/02product/05ledger/files/"
|
val path = "crash/"
|
try {
|
//调用文件保存方法
|
FileUtil.uploadFile(file.bytes, basePath + path, fileName!!)
|
return true
|
} catch (e: Exception) {
|
e.printStackTrace()
|
return false
|
}
|
} else {
|
return false
|
}
|
}
|
}
|