perf: add index for channel's secret field

This commit is contained in:
JustSong
2023-05-06 21:35:03 +08:00
parent c70cc3a793
commit 6cf79edfd7
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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
}