fix(park):修正园区信息检索。
This commit is contained in:
parent
2f17853dc0
commit
2d17bd5f0d
|
@ -57,7 +57,7 @@ func listParksBelongsToCurrentUser(c *fiber.Ctx) error {
|
||||||
return result.Unauthorized(err.Error())
|
return result.Unauthorized(err.Error())
|
||||||
}
|
}
|
||||||
parkLog.Info("列出当前用户下的全部园区", zap.String("user id", session.Uid))
|
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 {
|
if err != nil {
|
||||||
parkLog.Error("无法获取园区列表。", zap.String("user id", session.Uid))
|
parkLog.Error("无法获取园区列表。", zap.String("user id", session.Uid))
|
||||||
return result.Error(http.StatusInternalServerError, err.Error())
|
return result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
@ -70,7 +70,7 @@ func listParksBelongsTo(c *fiber.Ctx) error {
|
||||||
result := response.NewResult(c)
|
result := response.NewResult(c)
|
||||||
userId := c.Params("userId")
|
userId := c.Params("userId")
|
||||||
parkLog.Info("列出指定用户下的全部园区", zap.String("user id", userId))
|
parkLog.Info("列出指定用户下的全部园区", zap.String("user id", userId))
|
||||||
parks, err := repository.ParkRepository.RetrieveParkbelongs(userId)
|
parks, err := repository.ParkRepository.RetrieveParkBelongs(userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
parkLog.Error("无法获取园区列表。", zap.String("user id", userId))
|
parkLog.Error("无法获取园区列表。", zap.String("user id", userId))
|
||||||
return result.Error(http.StatusInternalServerError, err.Error())
|
return result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
|
|
@ -40,9 +40,15 @@ func (pr _ParkRepository) ListAllParks(uid string) ([]*model.Park, error) {
|
||||||
ctx, cancel := global.TimeoutContext()
|
ctx, cancel := global.TimeoutContext()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
var parks []*model.Park
|
var parks = make([]*model.Park, 0)
|
||||||
parkQuerySql, parkParams, _ := pr.ds.
|
parkQuerySql, parkParams, _ := pr.ds.
|
||||||
From("park").
|
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(
|
Where(
|
||||||
goqu.I("user_id").Eq(uid),
|
goqu.I("user_id").Eq(uid),
|
||||||
goqu.I("deleted_at").IsNull(),
|
goqu.I("deleted_at").IsNull(),
|
||||||
|
@ -160,7 +166,7 @@ func (pr _ParkRepository) RetrieveParkDetail(pid string) (*model.Park, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取园区对应的用户ID
|
// 获取园区对应的用户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))
|
pr.log.Info("获取园区对应的用户ID", zap.String("pid", pid))
|
||||||
if uid, err := cache.RetrieveEntity[string]("park_belongs", pid); err == nil && uid != nil {
|
if uid, err := cache.RetrieveEntity[string]("park_belongs", pid); err == nil && uid != nil {
|
||||||
pr.log.Info("已经从缓存获取到了园区对应的用户ID。")
|
pr.log.Info("已经从缓存获取到了园区对应的用户ID。")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user