Skip to content

Commit

Permalink
feat: support search channels by key (close songquanpeng#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Jun 22, 2023
1 parent d0c454c commit ad1049b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions model/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
type Channel struct {
Id int `json:"id"`
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"`
Name string `json:"name" gorm:"index"`
Weight int `json:"weight"`
Expand Down Expand Up @@ -36,7 +36,7 @@ func GetAllChannels(startIdx int, num int, selectAll bool) ([]*Channel, 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
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/ChannelsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const ChannelsTable = () => {
icon='search'
fluid
iconPosition='left'
placeholder='搜索渠道的 ID 和名称 ...'
placeholder='搜索渠道的 ID,名称和密钥 ...'
value={searchKeyword}
loading={searching}
onChange={handleKeywordChange}
Expand Down

0 comments on commit ad1049b

Please sign in to comment.