e1040e69cd
2.重构数据字段结构, 使数据合理性提高. 3.测试通过openrec获取数据完整性. TODO: 测试时区问题.
89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
package intimate
|
|
|
|
import (
|
|
"database/sql"
|
|
"reflect"
|
|
|
|
"github.com/474420502/hunter"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
type GetSet struct {
|
|
}
|
|
|
|
type Streamer struct {
|
|
Uid int64 //
|
|
Platform string //
|
|
UserId string //
|
|
UserName string //
|
|
LiveUrl sql.NullString //
|
|
Channel sql.NullString //
|
|
LatestLogUid int64
|
|
Ext interface{} //
|
|
UpdateTime sql.NullTime //
|
|
}
|
|
|
|
// Get Simple Value
|
|
func (ai *Streamer) Get(field string) interface{} {
|
|
return reflect.ValueOf(ai).Elem().FieldByName(field).Interface()
|
|
}
|
|
|
|
// Set Simple Value
|
|
func (ai *Streamer) Set(field string, value interface{}) {
|
|
reflect.ValueOf(ai).Elem().FieldByName(field).Set(reflect.ValueOf(value))
|
|
}
|
|
|
|
type CollectLog struct {
|
|
LogUid int64 // 日志id
|
|
StreamerUid int64 // StreamerId 表id与
|
|
|
|
Platform string //
|
|
UserId string // 平台的UserId
|
|
IsLiveStreaming int32 //
|
|
IsError int32 //
|
|
Followers sql.NullInt64 //
|
|
Views sql.NullInt64 //
|
|
Giver interface{} //
|
|
Gratuity sql.NullInt64 //
|
|
LiveTitle sql.NullString //
|
|
LiveStartTime sql.NullTime //
|
|
LiveEndTime sql.NullTime //
|
|
UpdateTime sql.NullTime //
|
|
Tags interface{}
|
|
Ext interface{} //
|
|
ErrorMsg sql.NullString //
|
|
}
|
|
|
|
// Get Simple Value
|
|
func (cl *CollectLog) Get(field string) interface{} {
|
|
return reflect.ValueOf(cl).Elem().FieldByName(field).Interface()
|
|
}
|
|
|
|
// Set Simple Value
|
|
func (cl *CollectLog) Set(field string, value interface{}) {
|
|
reflect.ValueOf(cl).Elem().FieldByName(field).Set(reflect.ValueOf(value))
|
|
}
|
|
|
|
type ExtractorSource struct {
|
|
source gjson.Result
|
|
extractor *hunter.Extractor
|
|
}
|
|
|
|
func NewExtractorSource(gr gjson.Result) *ExtractorSource {
|
|
es := &ExtractorSource{}
|
|
es.source = gr
|
|
return es
|
|
}
|
|
|
|
func (es *ExtractorSource) CreateExtractor() {
|
|
es.extractor = hunter.NewExtractor([]byte(es.source.Str))
|
|
}
|
|
|
|
func (es *ExtractorSource) GetSource() gjson.Result {
|
|
return es.source
|
|
}
|
|
|
|
func (es *ExtractorSource) GetExtractor() *hunter.Extractor {
|
|
return es.extractor
|
|
}
|