From 0246eaba276b98436dd3c0f4acf52a3674433d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Mon, 26 Jun 2023 14:03:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(tenement):=E4=BF=AE=E6=AD=A3=E5=95=86?= =?UTF-8?q?=E6=88=B7=E6=9F=A5=E8=AF=A2=E7=BB=93=E6=9E=9C=E7=9A=84=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E4=BB=A5=E5=8F=8A=E9=94=99=E8=AF=AF=E8=BF=94=E5=9B=9E?= =?UTF-8?q?null=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/tenement.go | 2 +- model/tenement.go | 3 ++- repository/tenement.go | 6 ++++-- vo/tenement.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/controller/tenement.go b/controller/tenement.go index b1bd0a8..9ba138a 100644 --- a/controller/tenement.go +++ b/controller/tenement.go @@ -58,7 +58,7 @@ func listTenement(c *fiber.Ctx) error { tenementLog.Error("列出园区中的商户失败,未能获取商户列表", zap.Error(err)) return result.Error(fiber.StatusInternalServerError, err.Error()) } - var tenementsResponse []*vo.TenementQueryResponse + tenementsResponse := make([]*vo.TenementQueryResponse, 0) copier.Copy(&tenementsResponse, &tenements) return result.Success( "已经获取到要查询的商户。", diff --git a/model/tenement.go b/model/tenement.go index 16448f4..eda08f0 100644 --- a/model/tenement.go +++ b/model/tenement.go @@ -7,10 +7,11 @@ type Tenement struct { Park string `json:"parkId" db:"park_id"` FullName string `json:"fullName" db:"full_name"` ShortName *string `json:"shortName" db:"short_name"` + Abbr string `json:"-"` Address string `json:"address"` ContactName string `json:"contactName" db:"contact_name"` ContactPhone string `json:"contactPhone" db:"contact_phone"` - Building string `json:"building"` + Building *string `json:"building"` BuildingName *string `json:"buildingName" db:"building_name"` OnFloor *string `json:"onFloor" db:"on_floor"` InvoiceInfo *InvoiceTitle `json:"invoiceInfo" db:"invoice_info"` diff --git a/repository/tenement.go b/repository/tenement.go index 2f130e7..9e1e869 100644 --- a/repository/tenement.go +++ b/repository/tenement.go @@ -70,10 +70,12 @@ func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, buil tenementQuery := tr.ds. From(goqu.T("tenement").As("t")). LeftJoin(goqu.T("park_building").As("b"), goqu.On(goqu.I("b.id").Eq(goqu.I("t.building")))). - Select("t.*", goqu.I("b.name").As("building_name")) + Select("t.*", goqu.I("b.name").As("building_name")). + Where(goqu.I("t.park_id").Eq(pid)) countQuery := tr.ds. From(goqu.T("tenement").As("t")). - Select(goqu.COUNT("t.*")) + Select(goqu.COUNT("t.*")). + Where(goqu.I("t.park_id").Eq(pid)) if keyword != nil && len(*keyword) > 0 { pattern := fmt.Sprintf("%%%s%%", *keyword) diff --git a/vo/tenement.go b/vo/tenement.go index 5963dec..c5508be 100644 --- a/vo/tenement.go +++ b/vo/tenement.go @@ -22,7 +22,7 @@ type TenementCreationForm struct { type TenementQueryResponse struct { Id string `json:"id"` - Name string `json:"name"` + FullName string `json:"fullName"` ShortName *string `json:"shortName"` Address *string `json:"address"` Contact *string `json:"contact"`