feat:系统配置增加查询

This commit is contained in:
samwaf
2023-12-28 17:28:46 +08:00
parent ddec0da56a
commit 5d1606b646
7 changed files with 63 additions and 36 deletions

View File

@@ -46,7 +46,7 @@ func (w *WafSystemConfigApi) GetDetailApi(c *gin.Context) {
}
func (w *WafSystemConfigApi) GetListApi(c *gin.Context) {
var req request.WafSystemConfigSearchReq
err := c.ShouldBind(&req)
err := c.ShouldBindJSON(&req)
if err == nil {
beans, total, _ := wafSystemConfigService.GetListApi(req)
response.OkWithDetailed(response.PageResult{

View File

@@ -1,9 +1,9 @@
import request from '@/utils/request'
//查询所有系统配置列表
export function system_config_list_api(params) {
export function system_config_list_api(data) {
return request({
url: 'system_config/list',
method: 'get',
params: params
url: 'systemconfig/list',
method: 'post',
data: data
})
}
}

View File

@@ -7,11 +7,20 @@
<t-button variant="base" theme="default" :disabled="!selectedRowKeys.length"> 导出日志 </t-button>
<p v-if="!!selectedRowKeys.length" class="selected-count">已选{{ selectedRowKeys.length }}</p>
</div>
<t-input v-model="searchValue" class="search-input" placeholder="请输入你需要搜索的系统配置" clearable>
<template #suffix-icon>
<search-icon size="20px" />
</template>
</t-input>
<div class="right-operation-container">
<t-form ref="form" :data="searchformData" :label-width="80" colon :style="{ marginBottom: '8px' }">
<t-row>
<span>配置项</span>
<t-input v-model="searchformData.item" class="search-input" style="width:200px" placeholder="请输入" clearable>
</t-input>
<span>配置备注</span>
<t-input v-model="searchformData.remarks" class="search-input" style="width:200px" placeholder="请输入" clearable>
</t-input>
<t-button theme="primary" :style="{ marginLeft: '8px' }" @click="getList('all')"> 查询 </t-button>
</t-row>
</t-form>
</div>
</t-row>
<div class="table-container">
@@ -98,14 +107,6 @@
} from '@/apis/systemconfig';
import {
SSL_STATUS,
GUARD_STATUS,
CONTRACT_STATUS,
CONTRACT_STATUS_OPTIONS,
CONTRACT_TYPES,
CONTRACT_PAYMENT_TYPES
} from '@/constants';
const INITIAL_DATA = {
item: '',
@@ -116,7 +117,6 @@
name: 'ListBase',
components: {
SearchIcon,
Trend,
},
data() {
return {
@@ -155,7 +155,7 @@
align: 'left',
width: 250,
ellipsis: true,
colKey: 'item',
colKey: 'item',
},
{
title: '值',
@@ -177,7 +177,7 @@
},
{
align: 'left',
align: 'left',
width: 200,
colKey: 'op',
title: '操作',
@@ -194,7 +194,11 @@
current: 1,
pageSize: 10
},
searchValue: '',
//顶部搜索
searchformData: {
item:"",
remarks:"",
},
//索引区域
deleteIdx: -1,
guardStatusIdx :-1,
@@ -221,14 +225,11 @@
methods: {
getList(keyword) {
let that = this
this.$request
.get('/systemconfig/list', {
params: {
system_config_list_api({
pageSize: that.pagination.pageSize,
pageIndex: that.pagination.current,
item: '',
}
})
...that.searchformData
})
.then((res) => {
let resdata = res
console.log(resdata)

View File

@@ -3,6 +3,7 @@ package request
import "SamWaf/model/common/request"
type WafSystemConfigSearchReq struct {
Item string `json:"item" form:"item"`
Item string `json:"item" form:"item"`
Remarks string `json:"remarks" form:"remarks"`
request.PageInfo
}

View File

@@ -11,7 +11,7 @@ type SystemConfigRouter struct {
func (receiver *SystemConfigRouter) InitSystemConfigRouter(group *gin.RouterGroup) {
api := api.APIGroupAPP.WafSystemConfigApi
router := group.Group("")
router.GET("/samwaf/systemconfig/list", api.GetListApi)
router.POST("/samwaf/systemconfig/list", api.GetListApi)
router.GET("/samwaf/systemconfig/detail", api.GetDetailApi)
router.POST("/samwaf/systemconfig/add", api.AddApi)
router.GET("/samwaf/systemconfig/del", api.DelApi)

View File

@@ -113,7 +113,7 @@ func (receiver *WafHostService) GetListApi(req request.WafHostSearchReq) ([]mode
whereValues = append(whereValues, req.Code)
}
if len(req.REMARKS) > 0 {
whereValues = append(whereValues, req.REMARKS)
whereValues = append(whereValues, "%"+req.REMARKS+"%")
}
global.GWAF_LOCAL_DB.Model(&model.Hosts{}).Where(whereField, whereValues...).Limit(req.PageSize).Offset(req.PageSize * (req.PageIndex - 1)).Find(&list)

View File

@@ -69,11 +69,36 @@ func (receiver *WafSystemConfigService) GetDetailByItem(item string) model.Syste
return bean
}
func (receiver *WafSystemConfigService) GetListApi(req request.WafSystemConfigSearchReq) ([]model.SystemConfig, int64, error) {
var beans []model.SystemConfig
var list []model.SystemConfig
var total int64 = 0
global.GWAF_LOCAL_DB.Limit(req.PageSize).Offset(req.PageSize * (req.PageIndex - 1)).Find(&beans)
global.GWAF_LOCAL_DB.Model(&model.SystemConfig{}).Count(&total)
return beans, total, nil
/*where条件*/
var whereField = ""
var whereValues []interface{}
//where字段
whereField = ""
if len(req.Item) > 0 {
if len(whereField) > 0 {
whereField = whereField + " and "
}
whereField = whereField + " item=? "
}
if len(req.Remarks) > 0 {
if len(whereField) > 0 {
whereField = whereField + " and "
}
whereField = whereField + " remarks like ? "
}
//where字段赋值
if len(req.Item) > 0 {
whereValues = append(whereValues, req.Item)
}
if len(req.Remarks) > 0 {
whereValues = append(whereValues, "%"+req.Remarks+"%")
}
global.GWAF_LOCAL_DB.Model(&model.SystemConfig{}).Where(whereField, whereValues...).Limit(req.PageSize).Offset(req.PageSize * (req.PageIndex - 1)).Find(&list)
global.GWAF_LOCAL_DB.Model(&model.SystemConfig{}).Where(whereField, whereValues...).Count(&total)
return list, total, nil
}
func (receiver *WafSystemConfigService) DelApi(req request.WafSystemConfigDelReq) error {
var bean model.SystemConfig