fix(tenement):修正列举商户时的迁入迁出条件筛选。

This commit is contained in:
徐涛 2023-06-27 15:11:46 +08:00
parent 0c389e440a
commit 4df3efacd8
3 changed files with 13 additions and 6 deletions

View File

@ -52,7 +52,7 @@ func listTenement(c *fiber.Ctx) error {
tenementLog.Error("列出园区中的商户失败,未能解析查询结束日期", zap.Error(err)) tenementLog.Error("列出园区中的商户失败,未能解析查询结束日期", zap.Error(err))
return result.BadRequest(err.Error()) 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) tenements, total, err := repository.TenementRepository.ListTenements(parkId, uint(page), keyword, building, startDate, endDate, state)
if err != nil { if err != nil {
tenementLog.Error("列出园区中的商户失败,未能获取商户列表", zap.Error(err)) tenementLog.Error("列出园区中的商户失败,未能获取商户列表", zap.Error(err))

View File

@ -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( tr.log.Info(
"检索查询指定园区中符合条件的商户", "检索查询指定园区中符合条件的商户",
zap.String("Park", pid), zap.String("Park", pid),
@ -62,7 +62,7 @@ func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, buil
zap.Stringp("Building", building), zap.Stringp("Building", building),
logger.DateFieldp("StartDate", startDate), logger.DateFieldp("StartDate", startDate),
logger.DateFieldp("EndDate", endDate), logger.DateFieldp("EndDate", endDate),
zap.Stringp("State", state), zap.Int("State", state),
) )
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext()
defer cancel() 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( tenementQuery = tenementQuery.Where(
goqu.I("t.moved_out_at").IsNull(), goqu.I("t.moved_out_at").IsNull(),
) )
countQuery = countQuery.Where( countQuery = countQuery.Where(
goqu.I("t.moved_out_at").IsNull(), 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 startRow := (page - 1) * config.ServiceSettings.ItemsPageSize

View File

@ -25,8 +25,8 @@ type TenementQueryResponse struct {
FullName string `json:"fullName"` FullName string `json:"fullName"`
ShortName *string `json:"shortName"` ShortName *string `json:"shortName"`
Address *string `json:"address"` Address *string `json:"address"`
Contact *string `json:"contact"` Contact *string `json:"contact" copier:"ContactName"`
Phone *string `json:"phone"` Phone *string `json:"phone" copier:"ContactPhone"`
Building *string `json:"building"` Building *string `json:"building"`
BuildingName *string `json:"buildingName"` BuildingName *string `json:"buildingName"`
OnFloor *string `json:"onFloor"` OnFloor *string `json:"onFloor"`