feat(config): 支持配置名和内容模糊搜索
- 配置列表接口增加 keyword 参数,按 name 或 contents 模糊匹配 - 全局配置、应用配置和回收站页面增加关键字搜索框
This commit is contained in:
@@ -29,6 +29,7 @@ type ConfigListRequest struct {
|
||||
Env string `form:"env"`
|
||||
AppId *int `form:"appId"`
|
||||
Deleted bool `form:"deleted"`
|
||||
Keyword string `form:"keyword"`
|
||||
}
|
||||
|
||||
func (h *ConfigHandler) List(c *gin.Context) {
|
||||
@@ -59,6 +60,11 @@ func (h *ConfigHandler) List(c *gin.Context) {
|
||||
conditions = append(conditions, "env = ?")
|
||||
args = append(args, req.Env)
|
||||
}
|
||||
if req.Keyword != "" {
|
||||
like := "%" + req.Keyword + "%"
|
||||
conditions = append(conditions, "(name LIKE ? OR contents LIKE ?)")
|
||||
args = append(args, like, like)
|
||||
}
|
||||
if req.AppId != nil {
|
||||
if *req.AppId <= 0 {
|
||||
conditions = append(conditions, "(app_id is null OR app_id = 0)")
|
||||
|
||||
Reference in New Issue
Block a user