forked from free-lancers/electricity_bill_calc_service
		
	fix(tenement):修正商户查询结果的扫描以及错误返回null的问题。
This commit is contained in:
		@@ -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(
 | 
			
		||||
		"已经获取到要查询的商户。",
 | 
			
		||||
 
 | 
			
		||||
@@ -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"`
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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"`
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user