package cn.flightfeather.supervision.lightshare.service.impl
|
|
import cn.flightfeather.supervision.domain.ds1.entity.Version
|
import cn.flightfeather.supervision.domain.ds1.mapper.VersionMapper
|
import cn.flightfeather.supervision.common.utils.Constant
|
import cn.flightfeather.supervision.common.utils.FileUtil
|
import cn.flightfeather.supervision.lightshare.service.VersionService
|
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.orderBy("versionCode").desc()
|
val versionlist = versionMapper.selectByExample(example)
|
if (versionlist != null && versionlist.size > 0) {
|
return versionlist[0]
|
}
|
return Version()
|
}
|
|
override fun upLoadCrashInfo(userId: String, files: Array<MultipartFile>): Boolean {
|
if (files.isNotEmpty()) {
|
val file = files[0]
|
val fileName = files[0].originalFilename
|
val basePath = Constant.DEFAULT_FILE_PATH + "/files/"
|
val path = "crash/"
|
try {
|
//调用文件保存方法
|
FileUtil().uploadFile(file.bytes, basePath + path, fileName!!)
|
return true
|
} catch (e: Exception) {
|
e.printStackTrace()
|
return false
|
}
|
} else {
|
return false
|
}
|
}
|
}
|