mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-05-03 00:27:29 +08:00
player optimize
This commit is contained in:
@@ -103,6 +103,7 @@ const (
|
||||
|
||||
// MysqlDsn mysql服务配置信息 root:root 设置mysql账户的用户名和密码
|
||||
MysqlDsn = "root:root@(192.168.20.5:3601)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
//MysqlDsn = "root:MuBai0916$@(47.254.16.58:3610)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
|
||||
/*
|
||||
redis 配置信息
|
||||
@@ -115,6 +116,10 @@ const (
|
||||
RedisPassword = `root`
|
||||
RedisDBNo = 0
|
||||
|
||||
//RedisAddr = `47.254.16.58:3620`
|
||||
//RedisPassword = `MuBai0916$`
|
||||
//RedisDBNo = 0
|
||||
|
||||
// MysqlDsn docker compose 环境下的链接信息 mysql:3306 为 docker compose 中 mysql服务对应的网络名称和端口
|
||||
//MysqlDsn = "root:root@(mysql:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
|
||||
|
||||
@@ -177,6 +177,7 @@ func DelSlaveMovieInfos(id string) {
|
||||
//}
|
||||
}
|
||||
|
||||
// AddMovieDetailIndex 添加详情表索引
|
||||
func AddMovieDetailIndex() {
|
||||
var m MovieDetail
|
||||
tableName := m.TableName()
|
||||
@@ -184,14 +185,16 @@ func AddMovieDetailIndex() {
|
||||
db.Mdb.Exec(fmt.Sprintf("CREATE UNIQUE INDEX idx_mid ON %s (mid)", tableName))
|
||||
}
|
||||
|
||||
// AddSlaveMovieInfoIndex 添加附属站点信息表索引
|
||||
func AddSlaveMovieInfoIndex() {
|
||||
var s SlaveMovieInfo
|
||||
tableName := s.TableName()
|
||||
// 如果不存在索引则创建对应索引
|
||||
if !db.Mdb.Migrator().HasIndex(&s, "idx_mid") {
|
||||
// 添加索引
|
||||
db.Mdb.Exec(fmt.Sprintf("CREATE INDEX idx_mid ON %s (mid)", tableName))
|
||||
db.Mdb.Exec(fmt.Sprintf("CREATE INDEX idx_dbId ON %s (db_id)", tableName))
|
||||
db.Mdb.Exec(fmt.Sprintf("CREATE INDEX idx_sid ON %s (sid DESC)", tableName))
|
||||
db.Mdb.Exec(fmt.Sprintf("CREATE INDEX idx_mid ON %s (mid DESC)", tableName))
|
||||
db.Mdb.Exec(fmt.Sprintf("CREATE INDEX idx_dbId ON %s (db_id DESC", tableName))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,8 +557,7 @@ func GetDetailByMid(mid int64) MovieDetail {
|
||||
if err != nil {
|
||||
// 如果没有获取到对应值, 则去mysql中进行查找
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if err := db.Mdb.Model(&MovieDetail{}).Select("id, mid, cid, pid, name, sub_title, c_name, state, picture, actor, director,"+
|
||||
" content, remarks, area, year").Where("mid = ?", mid).Find(&m).Error; err != nil {
|
||||
if err := db.Mdb.Where("mid = ?", mid).Find(&m).Error; err != nil {
|
||||
log.Println("Find BasicInfo Failed: ", err)
|
||||
return m
|
||||
}
|
||||
@@ -631,7 +633,7 @@ func GetBasicInfoByIds(ids []int64) []MovieBasicInfo {
|
||||
// 如果存在nil值,则去mysql进行补全
|
||||
if len(newIds) > 0 {
|
||||
if err := db.Mdb.Model(&MovieDetail{}).Select("id, mid, cid, pid, name, sub_title, c_name, state, picture, actor, director,"+
|
||||
" content, remarks, area, year").Where("mid IN (?)", ids).Find(&ml).Error; err != nil {
|
||||
" content, remarks, area, year").Where("mid IN (?)", newIds).Find(&ml).Error; err != nil {
|
||||
log.Println("BatchFind BasicInfo Failed: ", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user