fix(stat):修正统计部分的关联设计。
This commit is contained in:
parent
1c0ebc9559
commit
2aa6939186
|
@ -61,8 +61,8 @@ type ParkSimplified struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ParkPeriodStatistics struct {
|
type ParkPeriodStatistics struct {
|
||||||
Id string `bun:",notnull" json:"id"`
|
Id string `bun:"park__id,notnull" json:"id"`
|
||||||
Name string `bun:",notnull" json:"name"`
|
Name string `bun:"park__name,notnull" json:"name"`
|
||||||
Period *time.Time `bun:"type:date" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
Period *time.Time `bun:"type:date" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,10 @@ func (_StatisticsService) ParksNewestState(userIds ...string) ([]model.ParkPerio
|
||||||
Relation("Park", func(q *bun.SelectQuery) *bun.SelectQuery {
|
Relation("Park", func(q *bun.SelectQuery) *bun.SelectQuery {
|
||||||
return q.Column("id", "name")
|
return q.Column("id", "name")
|
||||||
}).
|
}).
|
||||||
Where("p.enabled = ?", true).
|
Where("park.enabled = ?", true).
|
||||||
Where("r.publidhed = ?", true)
|
Where("r.published = ?", true)
|
||||||
if len(userIds) > 0 {
|
if len(userIds) > 0 {
|
||||||
query = query.Where("p.user_id in (?)", bun.In(userIds))
|
query = query.Where("park.user_id in (?)", bun.In(userIds))
|
||||||
}
|
}
|
||||||
parks := make([]model.ParkPeriodStatistics, 0)
|
parks := make([]model.ParkPeriodStatistics, 0)
|
||||||
groupedParks := make(map[string]model.ParkPeriodStatistics, 0)
|
groupedParks := make(map[string]model.ParkPeriodStatistics, 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user