feat(config): 支持配置名和内容模糊搜索
- 配置列表接口增加 keyword 参数,按 name 或 contents 模糊匹配 - 全局配置、应用配置和回收站页面增加关键字搜索框
This commit is contained in:
@@ -29,6 +29,7 @@ type ConfigListRequest struct {
|
|||||||
Env string `form:"env"`
|
Env string `form:"env"`
|
||||||
AppId *int `form:"appId"`
|
AppId *int `form:"appId"`
|
||||||
Deleted bool `form:"deleted"`
|
Deleted bool `form:"deleted"`
|
||||||
|
Keyword string `form:"keyword"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ConfigHandler) List(c *gin.Context) {
|
func (h *ConfigHandler) List(c *gin.Context) {
|
||||||
@@ -59,6 +60,11 @@ func (h *ConfigHandler) List(c *gin.Context) {
|
|||||||
conditions = append(conditions, "env = ?")
|
conditions = append(conditions, "env = ?")
|
||||||
args = append(args, req.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 != nil {
|
||||||
if *req.AppId <= 0 {
|
if *req.AppId <= 0 {
|
||||||
conditions = append(conditions, "(app_id is null OR app_id = 0)")
|
conditions = append(conditions, "(app_id is null OR app_id = 0)")
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-card style="margin-bottom: 16px">
|
<el-card style="margin-bottom: 16px">
|
||||||
<el-form :inline="true" @submit.native.prevent="handleSearch">
|
<el-form :inline="true" @submit.native.prevent="handleSearch">
|
||||||
|
<el-form-item label="关键字">
|
||||||
|
<el-input v-model="query.keyword" placeholder="配置名或内容" clearable style="width: 200px"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="环境">
|
<el-form-item label="环境">
|
||||||
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
|
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
|
||||||
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
|
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
|
||||||
@@ -253,7 +256,7 @@ export default {
|
|||||||
list: [],
|
list: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
total: 0,
|
total: 0,
|
||||||
query: { pageNo: 1, pageSize: 20, env: '', appId: null },
|
query: { pageNo: 1, pageSize: 20, env: '', appId: null, keyword: '' },
|
||||||
profiles: [],
|
profiles: [],
|
||||||
apps: [],
|
apps: [],
|
||||||
historyVisible: false,
|
historyVisible: false,
|
||||||
@@ -280,7 +283,7 @@ export default {
|
|||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
handleReset() {
|
handleReset() {
|
||||||
this.query = { pageNo: 1, pageSize: 20, env: '', appId: null }
|
this.query = { pageNo: 1, pageSize: 20, env: '', appId: null, keyword: '' }
|
||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
async loadData() {
|
async loadData() {
|
||||||
@@ -296,6 +299,9 @@ export default {
|
|||||||
if (this.query.appId) {
|
if (this.query.appId) {
|
||||||
params.appId = this.query.appId
|
params.appId = this.query.appId
|
||||||
}
|
}
|
||||||
|
if (this.query.keyword) {
|
||||||
|
params.keyword = this.query.keyword
|
||||||
|
}
|
||||||
const res = await getConfigList(params)
|
const res = await getConfigList(params)
|
||||||
this.list = res.data || []
|
this.list = res.data || []
|
||||||
this.total = res.total || 0
|
this.total = res.total || 0
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-card style="margin-bottom: 16px">
|
<el-card style="margin-bottom: 16px">
|
||||||
<el-form :inline="true" @submit.native.prevent="handleSearch">
|
<el-form :inline="true" @submit.native.prevent="handleSearch">
|
||||||
|
<el-form-item label="关键字">
|
||||||
|
<el-input v-model="query.keyword" placeholder="配置名或内容" clearable style="width: 200px"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="环境">
|
<el-form-item label="环境">
|
||||||
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
|
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
|
||||||
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
|
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
|
||||||
@@ -248,7 +251,7 @@ export default {
|
|||||||
list: [],
|
list: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
total: 0,
|
total: 0,
|
||||||
query: { pageNo: 1, pageSize: 20, env: '' },
|
query: { pageNo: 1, pageSize: 20, env: '', keyword: '' },
|
||||||
profiles: [],
|
profiles: [],
|
||||||
historyVisible: false,
|
historyVisible: false,
|
||||||
historyList: [],
|
historyList: [],
|
||||||
@@ -274,6 +277,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleReset() {
|
handleReset() {
|
||||||
this.query.env = ''
|
this.query.env = ''
|
||||||
|
this.query.keyword = ''
|
||||||
this.query.pageNo = 1
|
this.query.pageNo = 1
|
||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
@@ -288,6 +292,9 @@ export default {
|
|||||||
if (this.query.env) {
|
if (this.query.env) {
|
||||||
params.env = this.query.env
|
params.env = this.query.env
|
||||||
}
|
}
|
||||||
|
if (this.query.keyword) {
|
||||||
|
params.keyword = this.query.keyword
|
||||||
|
}
|
||||||
const res = await getConfigList(params)
|
const res = await getConfigList(params)
|
||||||
this.list = res.data || []
|
this.list = res.data || []
|
||||||
this.total = res.total || 0
|
this.total = res.total || 0
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-card style="margin-bottom: 16px">
|
<el-card style="margin-bottom: 16px">
|
||||||
<el-form :inline="true" @submit.native.prevent="handleSearch">
|
<el-form :inline="true" @submit.native.prevent="handleSearch">
|
||||||
|
<el-form-item label="关键字">
|
||||||
|
<el-input v-model="query.keyword" placeholder="配置名或内容" clearable style="width: 200px"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="环境">
|
<el-form-item label="环境">
|
||||||
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
|
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
|
||||||
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
|
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
|
||||||
@@ -61,7 +64,7 @@ export default {
|
|||||||
list: [],
|
list: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
total: 0,
|
total: 0,
|
||||||
query: { pageNo: 1, pageSize: 10, env: '', appId: null },
|
query: { pageNo: 1, pageSize: 10, env: '', appId: null, keyword: '' },
|
||||||
profiles: [],
|
profiles: [],
|
||||||
apps: []
|
apps: []
|
||||||
}
|
}
|
||||||
@@ -77,7 +80,7 @@ export default {
|
|||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
handleReset() {
|
handleReset() {
|
||||||
this.query = { pageNo: 1, pageSize: 10, env: '', appId: null }
|
this.query = { pageNo: 1, pageSize: 10, env: '', appId: null, keyword: '' }
|
||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
async loadData() {
|
async loadData() {
|
||||||
@@ -94,6 +97,9 @@ export default {
|
|||||||
if (this.query.appId) {
|
if (this.query.appId) {
|
||||||
params.appId = this.query.appId
|
params.appId = this.query.appId
|
||||||
}
|
}
|
||||||
|
if (this.query.keyword) {
|
||||||
|
params.keyword = this.query.keyword
|
||||||
|
}
|
||||||
const res = await getConfigList(params)
|
const res = await getConfigList(params)
|
||||||
this.list = res.data || []
|
this.list = res.data || []
|
||||||
this.total = res.total || 0
|
this.total = res.total || 0
|
||||||
|
|||||||
Reference in New Issue
Block a user