mirror of
https://github.com/songquanpeng/message-pusher.git
synced 2024-05-03 08:45:04 +08:00
perf: add index for channel's secret field
This commit is contained in:
parent
c70cc3a793
commit
6cf79edfd7
@ -33,7 +33,7 @@ func (i *WeChatCorpAccountTokenStoreItem) Key() string {
|
||||
func (i *WeChatCorpAccountTokenStoreItem) IsShared() bool {
|
||||
appId := fmt.Sprintf("%s|%s", i.CorpId, i.AgentId)
|
||||
var count int64 = 0
|
||||
model.DB.Model(&model.Channel{}).Where("type = ? and app_id = ? and secret = ?", model.TypeWeChatCorpAccount, appId, i.AgentSecret).Count(&count)
|
||||
model.DB.Model(&model.Channel{}).Where("secret = ? and app_id = ? and type = ?", model.TypeWeChatCorpAccount, appId, i.AgentSecret).Count(&count)
|
||||
return count > 1
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func (i *WeChatTestAccountTokenStoreItem) Key() string {
|
||||
|
||||
func (i *WeChatTestAccountTokenStoreItem) IsShared() bool {
|
||||
var count int64 = 0
|
||||
model.DB.Model(&model.Channel{}).Where("type = ? and app_id = ? and secret = ?", model.TypeWeChatTestAccount, i.AppID, i.AppSecret).Count(&count)
|
||||
model.DB.Model(&model.Channel{}).Where("secret = ? and app_id = ? and type = ?", model.TypeWeChatTestAccount, i.AppID, i.AppSecret).Count(&count)
|
||||
return count > 1
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ type Channel struct {
|
||||
Name string `json:"name" gorm:"type:varchar(32);uniqueIndex:name_user_id"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status" gorm:"default:1"` // enabled, disabled
|
||||
Secret string `json:"secret"`
|
||||
Secret string `json:"secret" gorm:"index"`
|
||||
AppId string `json:"app_id"`
|
||||
AccountId string `json:"account_id"`
|
||||
URL string `json:"url" gorm:"column:url"`
|
||||
|
Loading…
Reference in New Issue
Block a user