initializePush 初始化bilibilipushdb数据库
(dbpath string)
| 44 | |
| 45 | // initializePush 初始化bilibilipushdb数据库 |
| 46 | func initializePush(dbpath string) *bilibilipushdb { |
| 47 | var err error |
| 48 | if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) { |
| 49 | // 生成文件 |
| 50 | f, err := os.Create(dbpath) |
| 51 | if err != nil { |
| 52 | return nil |
| 53 | } |
| 54 | defer f.Close() |
| 55 | } |
| 56 | gdb, err := gorm.Open("sqlite3", dbpath) |
| 57 | if err != nil { |
| 58 | panic(err) |
| 59 | } |
| 60 | gdb.AutoMigrate(&bilibilipush{}).AutoMigrate(&bilibiliup{}).AutoMigrate(&bilibiliAt{}) |
| 61 | return (*bilibilipushdb)(gdb) |
| 62 | } |
| 63 | |
| 64 | // insertOrUpdateLiveAndDynamic 插入或更新数据库 |
| 65 | func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]any) (err error) { |