appolli
5 months ago
8 changed files with 104 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||
package entity |
|||
|
|||
type Keyword struct { |
|||
Id uint `gorm:"column:id;primaryKey;autoIncrement"` |
|||
Region string `gorm:"column:region;type:varchar(255);not null"` |
|||
Word string `gorm:"column:word;type:varchar(255);not null"` |
|||
} |
|||
|
|||
func (Keyword) TableName() string { |
|||
return "Keyword" |
|||
} |
@ -0,0 +1,17 @@ |
|||
package entity |
|||
|
|||
type Srtfile struct { |
|||
Id uint `gorm:"column:id;primaryKey;autoIncrement"` |
|||
VideoId string `gorm:"column:videoId;type:varchar(255);not null"` |
|||
ChannelId string `gorm:"column:channelId;type:varchar(255);not null"` |
|||
Ordinal int `gorm:"column:ordinal;type:int(11);not null"` |
|||
SrtStartTime string `gorm:"column:srtStartTime;type:varchar(255);not null"` |
|||
SrtEndTime string `gorm:"column:srtEndTime;type:varchar(255);not null"` |
|||
SrtText string `gorm:"column:srtText;type:varchar(255);not null"` |
|||
IsScan int `gorm:"column:isScan;type:int(11);default:null"` |
|||
} |
|||
|
|||
// TableName sets the insert table name for this struct type
|
|||
func (Srtfile) TableName() string { |
|||
return "Srtfile" |
|||
} |
@ -0,0 +1,16 @@ |
|||
package entity |
|||
|
|||
type WorldResultSet struct { |
|||
Id uint `gorm:"column:id;primaryKey;autoIncrement"` |
|||
KeyWordId int `gorm:"column:keyWordId"` |
|||
WordText string `gorm:"column:wordText"` |
|||
SrtId int `gorm:"column:srtId"` |
|||
SrtOrdinal int `gorm:"column:srtOrdinal"` |
|||
SrtText string `gorm:"column:srtText"` |
|||
VideoId string `gorm:"column:videoId"` |
|||
} |
|||
|
|||
// TableName 设置 WorldResultSet 表名
|
|||
func (WorldResultSet) TableName() string { |
|||
return "World_Result_Set" |
|||
} |
@ -0,0 +1,20 @@ |
|||
package keywordanalyse |
|||
|
|||
import ( |
|||
"main_program/config" |
|||
service "main_program/service" |
|||
) |
|||
|
|||
type keywordAnalyse struct{} |
|||
|
|||
var KeywordAnalyseService keywordAnalyse |
|||
|
|||
func (m *keywordAnalyse) Start() { |
|||
config.Logger.Info("开始逐句解析...") |
|||
videoId, err := service.SrtFileService.QueryOneNotScanVideoId() |
|||
if err != nil { |
|||
config.Logger.Info("没有需要解析的SrtFile...") |
|||
} |
|||
config.Logger.Infof("VideoId:%s", videoId) |
|||
|
|||
} |
@ -0,0 +1,5 @@ |
|||
package service |
|||
|
|||
type keywordService struct{} |
|||
|
|||
var KeywordService keywordService |
@ -0,0 +1,23 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"errors" |
|||
"main_program/common" |
|||
"main_program/entity" |
|||
|
|||
"gorm.io/gorm" |
|||
) |
|||
|
|||
type srtFileService struct{} |
|||
|
|||
var SrtFileService srtFileService |
|||
|
|||
func (srt *srtFileService) QueryOneNotScanVideoId() (videoId string, err error) { |
|||
var srtFile entity.Srtfile |
|||
result := common.MysqlDB.Where(&entity.Srtfile{IsScan: 0}).First(&srtFile) |
|||
if errors.Is(result.Error, gorm.ErrRecordNotFound) { |
|||
return "", errors.New("no srtFile") |
|||
} else { |
|||
return srtFile.VideoId, nil |
|||
} |
|||
} |
Loading…
Reference in new issue