123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package garden
- import (
- "context"
- "encoding/json"
- "fmt"
- "property-system/errors"
- dbmodel "property-system/model"
- pb_v1 "property-system/pb/v1"
- "strings"
- "git.getensh.com/common/gopkgs/database"
- "git.getensh.com/common/gopkgs/logger"
- "go.uber.org/zap"
- "google.golang.org/grpc/status"
- )
- //
- func GardenInfos(ctx context.Context, req *pb_v1.GardenInfosRequest) (reply *pb_v1.GardenInfosReply, err error) {
- reply = &pb_v1.GardenInfosReply{}
- // 捕获各个task中的异常并返回给调用者
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%+v", r)
- e := &status.Status{}
- if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
- logger.Error("err",
- zap.String("system_err", err.Error()),
- zap.Stack("stacktrace"))
- }
- }
- }()
- if len(req.Ids) == 0 {
- return nil, errors.ParamsError
- }
- garden := &dbmodel.TGardenApproved{}
- where := map[string]interface{}{
- "id in": req.Ids,
- "in_use": true,
- }
- list, err := garden.List(database.DB(), where, nil, -1, -1)
- if err != nil {
- return nil, errors.DataBaseError
- }
- reply.List = make([]*pb_v1.GardenItem, len(list))
- for i, v := range list {
- item := &pb_v1.GardenItem{
- Province: v.Province,
- ProvinceCode: v.ProvinceCode,
- City: v.City,
- CityCode: v.CityCode,
- Area: v.Area,
- AreaCode: v.AreaCode,
- Street: v.Street,
- StreetCode: v.StreetCode,
- Committee: v.Committee,
- CommitteeCode: v.CommitteeCode,
- PropertyPerson: v.PropertyPerson,
- PropertyPhone: v.PropertyPhone,
- GardenName: v.GardenName,
- GardenAddr: v.GardenAddr,
- Cid: v.Cid,
- Id: v.ID,
- GardenDesc: v.GardenDesc,
- GardenPic: v.GardenPic,
- InUse: v.InUse,
- Lat: v.Lat,
- Lnt: v.Lnt,
- Status: GardenStatusApproved,
- PayMode: v.PayMode,
- MchId: v.MchId,
- HouseCount: v.HouseCount,
- HouseCountLimit: v.HouseCountLimit,
- ExpireAt: v.ExpireAt,
- GardenPics: strings.Split(v.GardenPics, ";"),
- BuildingStart: v.BuildingStart,
- BuildingEnd: v.BuildingEnd,
- PropertyFeeStart: v.PropertyFeeStart,
- PropertyFeeEnd: v.PropertyFeeEnd,
- GasFeeStart: v.GasFeeStart,
- GasFeeEnd: v.GasFeeEnd,
- BuildingArea: v.BuildingArea,
- BuildingCompany: v.BuildingCompany,
- CoveredArea: v.CoveredArea,
- GreenPercent: v.GreenPercent,
- AreaPercent: v.AreaPercent,
- SpaceInfo: v.SpaceInfo,
- SpaceTotal: v.SpaceTotal,
- HouseTotal: v.HouseTotal,
- BuildingType: v.BuildingType,
- WaterType: stringToInt32Array(v.WaterType),
- ElectricType: stringToInt32Array(v.ElectricType),
- AvgPrice: v.AvgPrice,
- RentCount: v.HouseRentCount,
- SellCount: v.HouseSellCount,
- }
- if v.Enable == 1 {
- item.Enable = true
- }
- reply.List[i] = item
- }
- return reply, nil
- }
|