(ids []int, tag *string)
| 826 | } |
| 827 | |
| 828 | func BatchSetChannelTag(ids []int, tag *string) error { |
| 829 | // 开启事务 |
| 830 | tx := DB.Begin() |
| 831 | if tx.Error != nil { |
| 832 | return tx.Error |
| 833 | } |
| 834 | |
| 835 | // 更新标签 |
| 836 | err := tx.Model(&Channel{}).Where("id in (?)", ids).Update("tag", tag).Error |
| 837 | if err != nil { |
| 838 | tx.Rollback() |
| 839 | return err |
| 840 | } |
| 841 | |
| 842 | // update ability status |
| 843 | channels, err := GetChannelsByIds(ids) |
| 844 | if err != nil { |
| 845 | tx.Rollback() |
| 846 | return err |
| 847 | } |
| 848 | |
| 849 | for _, channel := range channels { |
| 850 | err = channel.UpdateAbilities(tx) |
| 851 | if err != nil { |
| 852 | tx.Rollback() |
| 853 | return err |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | // 提交事务 |
| 858 | return tx.Commit().Error |
| 859 | } |
| 860 | |
| 861 | // CountAllChannels returns total channels in DB |
| 862 | func CountAllChannels() (int64, error) { |
no test coverage detected