Merge pull request #1139 from trheyi/main
Add keywords filter to ListJobs function for enhanced job search
This commit is contained in:
commit
c98745dec9
1 changed files with 24 additions and 4 deletions
|
|
@ -52,20 +52,40 @@ func ListJobs(c *gin.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add keywords filter if provided (search in name and description)
|
||||||
|
if keywords := c.Query("keywords"); keywords != "" {
|
||||||
|
param.Wheres = append(param.Wheres, model.QueryWhere{
|
||||||
|
Wheres: []model.QueryWhere{
|
||||||
|
{
|
||||||
|
Column: "name",
|
||||||
|
Value: "%" + keywords + "%",
|
||||||
|
OP: "like",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Column: "description",
|
||||||
|
Value: "%" + keywords + "%",
|
||||||
|
OP: "like",
|
||||||
|
Method: "orwhere",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Add enabled filter (default to show all for debugging)
|
// Add enabled filter (default to show all for debugging)
|
||||||
enabled := c.Query("enabled")
|
switch enabled := c.Query("enabled"); enabled {
|
||||||
if enabled == "true" {
|
case "true", "1", "yes", "on":
|
||||||
param.Wheres = append(param.Wheres, model.QueryWhere{
|
param.Wheres = append(param.Wheres, model.QueryWhere{
|
||||||
Column: "enabled",
|
Column: "enabled",
|
||||||
Value: true,
|
Value: true,
|
||||||
})
|
})
|
||||||
} else if enabled == "false" {
|
case "false", "0", "no", "off":
|
||||||
param.Wheres = append(param.Wheres, model.QueryWhere{
|
param.Wheres = append(param.Wheres, model.QueryWhere{
|
||||||
Column: "enabled",
|
Column: "enabled",
|
||||||
Value: false,
|
Value: false,
|
||||||
})
|
})
|
||||||
}
|
default:
|
||||||
// Default: show all records regardless of enabled status
|
// Default: show all records regardless of enabled status
|
||||||
|
}
|
||||||
|
|
||||||
// Call job.ListJobs function
|
// Call job.ListJobs function
|
||||||
result, err := job.ListJobs(param, page, pagesize)
|
result, err := job.ListJobs(param, page, pagesize)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue