fix(report):基本完成公示报表检索部分的查询。
This commit is contained in:
parent
7f585c0452
commit
4620271fa5
@ -528,9 +528,7 @@ func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword stri
|
|||||||
reports = make([]model.Report, 0)
|
reports = make([]model.Report, 0)
|
||||||
cond = global.DB.NewSelect().
|
cond = global.DB.NewSelect().
|
||||||
Model(&reports).
|
Model(&reports).
|
||||||
Relation("Park", func(q *bun.SelectQuery) *bun.SelectQuery {
|
Relation("Park").Relation("Park.Enterprise")
|
||||||
return q.Relation("Enterprise")
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
conditions = append(conditions, strconv.Itoa(requestPage))
|
conditions = append(conditions, strconv.Itoa(requestPage))
|
||||||
if onlyPublished {
|
if onlyPublished {
|
||||||
@ -538,11 +536,11 @@ func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword stri
|
|||||||
}
|
}
|
||||||
conditions = append(conditions, strconv.FormatBool(onlyPublished))
|
conditions = append(conditions, strconv.FormatBool(onlyPublished))
|
||||||
if len(requestUser) > 0 {
|
if len(requestUser) > 0 {
|
||||||
cond = cond.Where("p.user_id = ?", requestUser)
|
cond = cond.Where("park.user_id = ?", requestUser)
|
||||||
conditions = append(conditions, requestUser)
|
conditions = append(conditions, requestUser)
|
||||||
}
|
}
|
||||||
if len(requestPark) > 0 {
|
if len(requestPark) > 0 {
|
||||||
cond = cond.Where("p.id = ?", requestPark)
|
cond = cond.Where("park.id = ?", requestPark)
|
||||||
conditions = append(conditions, requestPark)
|
conditions = append(conditions, requestPark)
|
||||||
}
|
}
|
||||||
if requestPeriod != nil {
|
if requestPeriod != nil {
|
||||||
@ -552,12 +550,12 @@ func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword stri
|
|||||||
if len(requestKeyword) > 0 {
|
if len(requestKeyword) > 0 {
|
||||||
keywordCond := "%" + requestKeyword + "%"
|
keywordCond := "%" + requestKeyword + "%"
|
||||||
cond = cond.WhereGroup(" and ", func(q *bun.SelectQuery) *bun.SelectQuery {
|
cond = cond.WhereGroup(" and ", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||||
return q.Where("p.name like ?", keywordCond).
|
return q.Where("park.name like ?", keywordCond).
|
||||||
WhereOr("d.name like ?", keywordCond).
|
WhereOr("park__enterprise.name like ?", keywordCond).
|
||||||
WhereOr("d.abbr like ?", keywordCond).
|
WhereOr("park__enterprise.abbr like ?", keywordCond).
|
||||||
WhereOr("p.abbr like ?", keywordCond).
|
WhereOr("park.abbr like ?", keywordCond).
|
||||||
WhereOr("d.address like ?", keywordCond).
|
WhereOr("park__enterprise.address like ?", keywordCond).
|
||||||
WhereOr("p.address like ?", keywordCond)
|
WhereOr("park.address like ?", keywordCond)
|
||||||
})
|
})
|
||||||
conditions = append(conditions, requestKeyword)
|
conditions = append(conditions, requestKeyword)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user