fix: keep super filters with keyword
This commit is contained in:
@@ -88,13 +88,13 @@ func (s *super) CheckToken(ctx context.Context, token string) (*super_dto.LoginR
|
||||
|
||||
func (s *super) ListUsers(ctx context.Context, filter *super_dto.UserListFilter) (*requests.Pager, error) {
|
||||
tbl, q := models.UserQuery.QueryContext(ctx)
|
||||
if filter.ID != nil && *filter.ID > 0 {
|
||||
q = q.Where(tbl.ID.Eq(*filter.ID))
|
||||
}
|
||||
if filter.Username != nil && strings.TrimSpace(*filter.Username) != "" {
|
||||
keyword := "%" + strings.TrimSpace(*filter.Username) + "%"
|
||||
q = q.Where(tbl.Username.Like(keyword)).Or(tbl.Nickname.Like(keyword))
|
||||
}
|
||||
if filter.ID != nil && *filter.ID > 0 {
|
||||
q = q.Where(tbl.ID.Eq(*filter.ID))
|
||||
}
|
||||
if filter.Status != nil && *filter.Status != "" {
|
||||
q = q.Where(tbl.Status.Eq(*filter.Status))
|
||||
}
|
||||
@@ -654,6 +654,10 @@ func (s *super) ListUserTenants(ctx context.Context, userID int64, filter *super
|
||||
func (s *super) ListContents(ctx context.Context, filter *super_dto.SuperContentListFilter) (*requests.Pager, error) {
|
||||
tbl, q := models.ContentQuery.QueryContext(ctx)
|
||||
|
||||
if filter.Keyword != nil && strings.TrimSpace(*filter.Keyword) != "" {
|
||||
keyword := "%" + strings.TrimSpace(*filter.Keyword) + "%"
|
||||
q = q.Where(tbl.Title.Like(keyword)).Or(tbl.Description.Like(keyword)).Or(tbl.Summary.Like(keyword))
|
||||
}
|
||||
if filter.ID != nil && *filter.ID > 0 {
|
||||
q = q.Where(tbl.ID.Eq(*filter.ID))
|
||||
}
|
||||
@@ -669,10 +673,6 @@ func (s *super) ListContents(ctx context.Context, filter *super_dto.SuperContent
|
||||
if filter.Visibility != nil && *filter.Visibility != "" {
|
||||
q = q.Where(tbl.Visibility.Eq(*filter.Visibility))
|
||||
}
|
||||
if filter.Keyword != nil && strings.TrimSpace(*filter.Keyword) != "" {
|
||||
keyword := "%" + strings.TrimSpace(*filter.Keyword) + "%"
|
||||
q = q.Where(tbl.Title.Like(keyword)).Or(tbl.Description.Like(keyword)).Or(tbl.Summary.Like(keyword))
|
||||
}
|
||||
|
||||
tenantIDs, tenantFilter, err := s.lookupTenantIDs(ctx, filter.TenantCode, filter.TenantName)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user