diff --git a/controller/park.go b/controller/park.go index 0415709..68f27c2 100644 --- a/controller/park.go +++ b/controller/park.go @@ -57,7 +57,7 @@ func listParksBelongsToCurrentUser(c *fiber.Ctx) error { return result.Unauthorized(err.Error()) } parkLog.Info("列出当前用户下的全部园区", zap.String("user id", session.Uid)) - parks, err := repository.ParkRepository.RetrieveParkbelongs(session.Uid) + parks, err := repository.ParkRepository.ListAllParks(session.Uid) if err != nil { parkLog.Error("无法获取园区列表。", zap.String("user id", session.Uid)) return result.Error(http.StatusInternalServerError, err.Error()) @@ -70,7 +70,7 @@ func listParksBelongsTo(c *fiber.Ctx) error { result := response.NewResult(c) userId := c.Params("userId") parkLog.Info("列出指定用户下的全部园区", zap.String("user id", userId)) - parks, err := repository.ParkRepository.RetrieveParkbelongs(userId) + parks, err := repository.ParkRepository.RetrieveParkBelongs(userId) if err != nil { parkLog.Error("无法获取园区列表。", zap.String("user id", userId)) return result.Error(http.StatusInternalServerError, err.Error()) diff --git a/repository/park.go b/repository/park.go index 03f7f4a..0e83697 100644 --- a/repository/park.go +++ b/repository/park.go @@ -40,9 +40,15 @@ func (pr _ParkRepository) ListAllParks(uid string) ([]*model.Park, error) { ctx, cancel := global.TimeoutContext() defer cancel() - var parks []*model.Park + var parks = make([]*model.Park, 0) parkQuerySql, parkParams, _ := pr.ds. From("park"). + Select( + "id", "user_id", "name", "area", "tenement_quantity", "capacity", "category", + "meter_04kv_type", "region", "address", "contact", "phone", "enabled", "price_policy", "tax_rate", + "basic_pooled", "adjust_pooled", "loss_pooled", "public_pooled", "created_at", "last_modified_at", + "deleted_at", + ). Where( goqu.I("user_id").Eq(uid), goqu.I("deleted_at").IsNull(), @@ -160,7 +166,7 @@ func (pr _ParkRepository) RetrieveParkDetail(pid string) (*model.Park, error) { } // 获取园区对应的用户ID -func (pr _ParkRepository) RetrieveParkbelongs(pid string) (string, error) { +func (pr _ParkRepository) RetrieveParkBelongs(pid string) (string, error) { pr.log.Info("获取园区对应的用户ID", zap.String("pid", pid)) if uid, err := cache.RetrieveEntity[string]("park_belongs", pid); err == nil && uid != nil { pr.log.Info("已经从缓存获取到了园区对应的用户ID。")