package house import ( "context" communityv1 "service.xpcool.com/api/house/community" "service.xpcool.com/internal/model/dto" community "service.xpcool.com/internal/service/house/community" ) // CommunityList 分页查询小区。 func (c *Controller) CommunityList(ctx context.Context, req *communityv1.CommunityListReq) (res *communityv1.CommunityListRes, err error) { list, total, err := community.Community().List(ctx, req.Page, req.Size, req.Keyword, req.Region) if err != nil { return nil, err } out := make([]*communityv1.CommunityItem, 0, len(list)) for i := range list { e := &list[i] out = append(out, &communityv1.CommunityItem{ Id: e.Id, Name: e.Name, Region: e.Region, BusinessDistrict: e.BusinessDistrict, Address: e.Address, Lng: e.Lng, Lat: e.Lat, BuildYear: e.BuildYear, Households: e.Households, PlotRatio: e.PlotRatio, GreenRate: e.GreenRate, PropertyCompany: e.PropertyCompany, PropertyFee: e.PropertyFee, Developer: e.Developer, Source: e.Source, }) } return &communityv1.CommunityListRes{List: out, Total: total}, nil } // CommunityCreate 新增小区。 func (c *Controller) CommunityCreate(ctx context.Context, req *communityv1.CommunityCreateReq) (res *communityv1.CommunityCreateRes, err error) { id, err := community.Community().Create(ctx, dto.HouseCommunityInput{ Name: req.Name, Region: req.Region, BusinessDistrict: req.BusinessDistrict, Address: req.Address, Lng: req.Lng, Lat: req.Lat, BuildYear: req.BuildYear, Households: req.Households, PlotRatio: req.PlotRatio, GreenRate: req.GreenRate, PropertyCompany: req.PropertyCompany, PropertyFee: req.PropertyFee, Developer: req.Developer, Source: req.Source, }) if err != nil { return nil, err } return &communityv1.CommunityCreateRes{Id: id}, nil } // CommunityUpdate 更新小区。 func (c *Controller) CommunityUpdate(ctx context.Context, req *communityv1.CommunityUpdateReq) (res *communityv1.CommunityUpdateRes, err error) { err = community.Community().Update(ctx, dto.HouseCommunityInput{ Id: req.Id, Name: req.Name, Region: req.Region, BusinessDistrict: req.BusinessDistrict, Address: req.Address, Lng: req.Lng, Lat: req.Lat, BuildYear: req.BuildYear, Households: req.Households, PlotRatio: req.PlotRatio, GreenRate: req.GreenRate, PropertyCompany: req.PropertyCompany, PropertyFee: req.PropertyFee, Developer: req.Developer, }) if err != nil { return nil, err } return &communityv1.CommunityUpdateRes{}, nil } // CommunityDelete 删除小区。 func (c *Controller) CommunityDelete(ctx context.Context, req *communityv1.CommunityDeleteReq) (res *communityv1.CommunityDeleteRes, err error) { if err = community.Community().Delete(ctx, req.Id); err != nil { return nil, err } return &communityv1.CommunityDeleteRes{}, nil }