Prechádzať zdrojové kódy

feat: support search channels by key (close #185)

JustSong 2 rokov pred
rodič
commit
ad1049b0cf
2 zmenil súbory, kde vykonal 3 pridanie a 3 odobranie
  1. 2 2
      model/channel.go
  2. 1 1
      web/src/components/ChannelsTable.js

+ 2 - 2
model/channel.go

@@ -8,7 +8,7 @@ import (
 type Channel struct {
 type Channel struct {
 	Id                 int     `json:"id"`
 	Id                 int     `json:"id"`
 	Type               int     `json:"type" gorm:"default:0"`
 	Type               int     `json:"type" gorm:"default:0"`
-	Key                string  `json:"key" gorm:"not null"`
+	Key                string  `json:"key" gorm:"not null;index"`
 	Status             int     `json:"status" gorm:"default:1"`
 	Status             int     `json:"status" gorm:"default:1"`
 	Name               string  `json:"name" gorm:"index"`
 	Name               string  `json:"name" gorm:"index"`
 	Weight             int     `json:"weight"`
 	Weight             int     `json:"weight"`
@@ -36,7 +36,7 @@ func GetAllChannels(startIdx int, num int, selectAll bool) ([]*Channel, error) {
 }
 }
 
 
 func SearchChannels(keyword string) (channels []*Channel, err error) {
 func SearchChannels(keyword string) (channels []*Channel, err error) {
-	err = DB.Omit("key").Where("id = ? or name LIKE ?", keyword, keyword+"%").Find(&channels).Error
+	err = DB.Omit("key").Where("id = ? or name LIKE ? or key = ?", keyword, keyword+"%", keyword).Find(&channels).Error
 	return channels, err
 	return channels, err
 }
 }
 
 

+ 1 - 1
web/src/components/ChannelsTable.js

@@ -263,7 +263,7 @@ const ChannelsTable = () => {
           icon='search'
           icon='search'
           fluid
           fluid
           iconPosition='left'
           iconPosition='left'
-          placeholder='搜索渠道的 ID 和名称 ...'
+          placeholder='搜索渠道的 ID,名称和密钥 ...'
           value={searchKeyword}
           value={searchKeyword}
           loading={searching}
           loading={searching}
           onChange={handleKeywordChange}
           onChange={handleKeywordChange}