Commit e6501968 authored by 杨林's avatar 杨林

埋点样例类

parent f8bf8f80
package model
/**
* Created with IntelliJ IDEA.
* Class: TrackItem
* Description:
* User: lin
* Date: 2021-07-22
* Time: 16:58
*/
case class TrackItem(
track_id: Long,
distinct_id: String,
lib_detail: String,
lib_version: String,
lib: String,
app_version: String,
lib_method: String,
event_name: String,
`type`: String,
properties: String,
HOST: String,
user_agent: String,
ua_platform: String,
ua_version: String,
ua_language: String,
`connection`: String,
Pragma: String,
cache_control: String,
accept: String,
accept_encoding: String,
ip: String,
ip_info: String,
url: String,
referrer: String,
remark: String,
user_id: String,
created_at: String
)
package tools.gziptools
import java.io.ByteArrayOutputStream
import java.nio.charset.{Charset, StandardCharsets}
import java.util.zip.GZIPOutputStream
/**
* Created with IntelliJ IDEA.
* Class: GzipUtils
* Description: 压缩解压缩工具
* User: lin
* Date: 2021-07-20
* Time: 13:30
*/
object GzipUtils {
/**
* 压缩方法
*
* @param str 要压缩的字符串
* @param charset 字符串编码
* @return 压缩后的字符串
*/
def compress(str: String, charset: Charset): String = {
if (str.isEmpty) {
return ""
}
val out = new ByteArrayOutputStream()
var gzip: GZIPOutputStream = null
try {
gzip = new GZIPOutputStream(out)
gzip.write(str.getBytes(charset))
gzip.close()
} catch {
case exception: Exception => exception.printStackTrace()
}
out.toString(charset)
}
/**
* 默认字符集为UTF_8压缩
*
* @param str 要压缩的字符串
* @return 压缩后的字符串
*/
def compress(str: String): String = {
compress(str, StandardCharsets.UTF_8)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment