fix(tenement):修正列举商户时的迁入迁出条件筛选。
This commit is contained in:
parent
0c389e440a
commit
4df3efacd8
|
@ -52,7 +52,7 @@ func listTenement(c *fiber.Ctx) error {
|
|||
tenementLog.Error("列出园区中的商户失败,未能解析查询结束日期", zap.Error(err))
|
||||
return result.BadRequest(err.Error())
|
||||
}
|
||||
state := tools.EmptyToNil(c.Query("state"))
|
||||
state := c.QueryInt("state", 0)
|
||||
tenements, total, err := repository.TenementRepository.ListTenements(parkId, uint(page), keyword, building, startDate, endDate, state)
|
||||
if err != nil {
|
||||
tenementLog.Error("列出园区中的商户失败,未能获取商户列表", zap.Error(err))
|
||||
|
|
|
@ -53,7 +53,7 @@ func (tr _TenementRepository) IsTenementBelongs(tid, uid string) (bool, error) {
|
|||
}
|
||||
|
||||
// 列出指定园区中的所有商户
|
||||
func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, building *string, startDate, endDate *types.Date, state *string) ([]*model.Tenement, int64, error) {
|
||||
func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, building *string, startDate, endDate *types.Date, state int) ([]*model.Tenement, int64, error) {
|
||||
tr.log.Info(
|
||||
"检索查询指定园区中符合条件的商户",
|
||||
zap.String("Park", pid),
|
||||
|
@ -62,7 +62,7 @@ func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, buil
|
|||
zap.Stringp("Building", building),
|
||||
logger.DateFieldp("StartDate", startDate),
|
||||
logger.DateFieldp("EndDate", endDate),
|
||||
zap.Stringp("State", state),
|
||||
zap.Int("State", state),
|
||||
)
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
|
@ -136,13 +136,20 @@ func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, buil
|
|||
)
|
||||
}
|
||||
|
||||
if state != nil && *state == "1" {
|
||||
if state == 0 {
|
||||
tenementQuery = tenementQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNull(),
|
||||
)
|
||||
countQuery = countQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNull(),
|
||||
)
|
||||
} else {
|
||||
tenementQuery = tenementQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNotNull(),
|
||||
)
|
||||
countQuery = countQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNotNull(),
|
||||
)
|
||||
}
|
||||
|
||||
startRow := (page - 1) * config.ServiceSettings.ItemsPageSize
|
||||
|
|
|
@ -25,8 +25,8 @@ type TenementQueryResponse struct {
|
|||
FullName string `json:"fullName"`
|
||||
ShortName *string `json:"shortName"`
|
||||
Address *string `json:"address"`
|
||||
Contact *string `json:"contact"`
|
||||
Phone *string `json:"phone"`
|
||||
Contact *string `json:"contact" copier:"ContactName"`
|
||||
Phone *string `json:"phone" copier:"ContactPhone"`
|
||||
Building *string `json:"building"`
|
||||
BuildingName *string `json:"buildingName"`
|
||||
OnFloor *string `json:"onFloor"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user