Browse Source
Merge pull request #125 from hansonyu183/fix-bug-and-new-feature
修复优化自动代码中对bool类型搜索字段的支持
main
蒋吉兆
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
35 additions and
3 deletions
server/resource/template/fe/table.vue.tpl
server/resource/template/te/model.go.tpl
server/resource/template/te/service.go.tpl
@ -4,9 +4,32 @@
<el-form :inline="true" :model="searchInfo" class="demo-form-inline">
{ { - range . Fields } }
{ { - if . FieldSearchType } }
{ { - if eq . FieldType "bool" } }
<el-form-item label=" { { . FieldDesc } } " prop=" { { . FieldJson } } ">
<el-col :span="8">
<el-select v-model="searchInfo. { { . FieldJson } } " placeholder="请选择">
<el-option
key="true"
label="是"
value="true">
</el-option>
<el-option
key="false"
label="否"
value="false">
</el-option>
<el-option
label=""
value="">
</el-option>
</el-select>
</el-col>
</el-form-item>
{ { - else } }
<el-form-item label=" { { . FieldDesc } } ">
<el-input placeholder="搜索条件" v-model="searchInfo. { { . FieldJson } } "></el-input>
</el-form-item>
{ { end } }
{ { end } }
{ { end } }
<el-form-item>
@ -108,6 +131,10 @@ export default {
onSubmit() {
this.page = 1
this.pageSize = 10
{ { - range . Fields } } { { - if eq . FieldType "bool" } }
if (this.searchInfo. { { . FieldJson } } =="") {
this.searchInfo. { { . FieldJson } } =null
} { { end } } { { end } }
this.getTableData()
},
async update { { . StructName } } (row) {
@ -7,6 +7,11 @@ import (
// 如果含有time.Time 请自行import time包
type { { . StructName } } struct {
gorm.Model { { range . Fields } }
{ { . FieldName } } { { . FieldType } } `json:" { { . FieldJson } } " form:" { { . FieldJson } } " gorm:"column: { { . ColumnName } } ;comment:' { { . Comment } } '"` { { end } }
gorm.Model { { - range . Fields } }
{ { - if eq . FieldType "bool" } }
{ { . FieldName } } * { { . FieldType } } `json:" { { . FieldJson } } " form:" { { . FieldJson } } " gorm:"column: { { . ColumnName } } ;comment:' { { . Comment } } '"`
{ { - else } }
{ { . FieldName } } { { . FieldType } } `json:" { { . FieldJson } } " form:" { { . FieldJson } } " gorm:"column: { { . ColumnName } } ;comment:' { { . Comment } } '"`
{ { - end } } { { - end } }
}
}
@ -71,7 +71,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
db = db.Where(" { { . ColumnName } } { { . FieldSearchType } } ?", { { if eq . FieldSearchType "LIKE" } } "%"+ { { end } } info. { { . FieldName } } { { if eq . FieldSearchType "LIKE" } } +"%" { { end } } )
}
{ { - else if eq . FieldType "bool" } }
if info. { { . FieldName } } != 0 {
if info. { { . FieldName } } != nil {
db = db.Where(" { { . ColumnName } } { { . FieldSearchType } } ?", { { if eq . FieldSearchType "LIKE" } } "%"+ { { end } } info. { { . FieldName } } { { if eq . FieldSearchType "LIKE" } } +"%" { { end } } )
}
{ { - else if eq . FieldType "int" } }