MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / BatchSetChannelTag

Function BatchSetChannelTag

model/channel.go:828–859  ·  view source on GitHub ↗
(ids []int, tag *string)

Source from the content-addressed store, hash-verified

826}
827
828func 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
862func CountAllChannels() (int64, error) {

Callers 1

BatchSetChannelTagFunction · 0.92

Calls 3

GetChannelsByIdsFunction · 0.85
UpdateAbilitiesMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected