mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-24 14:54:43 +08:00
feat: 网站搜索改为模糊查询
This commit is contained in:
parent
11b40b8cf9
commit
f0923169d3
2 changed files with 8 additions and 1 deletions
|
@ -16,6 +16,7 @@ type IWebsiteRepo interface {
|
|||
WithWebsiteSSLID(sslId uint) DBOption
|
||||
WithGroupID(groupId uint) DBOption
|
||||
WithDefaultServer() DBOption
|
||||
WithDomainLike(domain string) DBOption
|
||||
Page(page, size int, opts ...DBOption) (int64, []model.Website, error)
|
||||
List(opts ...DBOption) ([]model.Website, error)
|
||||
GetFirst(opts ...DBOption) (model.Website, error)
|
||||
|
@ -45,6 +46,12 @@ func (w *WebsiteRepo) WithDomain(domain string) DBOption {
|
|||
}
|
||||
}
|
||||
|
||||
func (w *WebsiteRepo) WithDomainLike(domain string) DBOption {
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
return db.Where("primary_domain like ?", "%"+domain+"%")
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebsiteRepo) WithAlias(alias string) DBOption {
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
return db.Where("alias = ?", alias)
|
||||
|
|
|
@ -63,7 +63,7 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
|
|||
)
|
||||
opts = append(opts, commonRepo.WithOrderBy("created_at desc"))
|
||||
if req.Name != "" {
|
||||
opts = append(opts, websiteRepo.WithDomain(req.Name))
|
||||
opts = append(opts, websiteRepo.WithDomainLike(req.Name))
|
||||
}
|
||||
if req.WebsiteGroupID != 0 {
|
||||
opts = append(opts, websiteRepo.WithGroupID(req.WebsiteGroupID))
|
||||
|
|
Loading…
Reference in a new issue