hot_fix_004.go 972 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package hot_fix
  2. import (
  3. "github.com/ChineseSubFinder/ChineseSubFinder/internal/dao"
  4. "github.com/ChineseSubFinder/ChineseSubFinder/internal/models"
  5. "github.com/sirupsen/logrus"
  6. )
  7. /*
  8. 字幕服务器在判断字幕是否包含中文的时候,没有进行 UTF8 的转换,导致故障丢气大量正确字幕
  9. */
  10. type HotFix004 struct {
  11. log *logrus.Logger
  12. }
  13. func NewHotFix004(log *logrus.Logger) *HotFix004 {
  14. return &HotFix004{log: log}
  15. }
  16. func (h HotFix004) GetKey() string {
  17. return "004"
  18. }
  19. func (h HotFix004) Process() (interface{}, error) {
  20. defer func() {
  21. h.log.Infoln("Hotfix", h.GetKey(), "End")
  22. }()
  23. h.log.Infoln("Hotfix", h.GetKey(), "Start...")
  24. return h.process()
  25. }
  26. func (h HotFix004) process() (bool, error) {
  27. var videoInfos []models.VideoSubInfo
  28. // 把嵌套关联的 has many 的信息都查询出来
  29. dao.GetDb().Find(&videoInfos)
  30. for _, info := range videoInfos {
  31. info.IsSend = false
  32. dao.GetDb().Save(&info)
  33. }
  34. return true, nil
  35. }