service.xpcool.com/internal/controller/house/dashboard.go
夏犀麟 4aca0c7f6f
Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 5m7s
feat(house): 实现看房模块后端功能
- 新增 9 张房屋相关数据表(社区/楼宇/房源/价格快照/交易/设施/社区设施/学区/偏好)
- 添加菜单权限种子数据并绑定超级管理员角色
- 生成 DAO 层代码和实体对象
- 实现房屋模块 API 接口(社区/房源/看板)和控制器服务层
- 支持多平台软关联匹配、笋盘标记和低可信度标记功能
- 更新超级管理员账号为 xxcool/xxCool@2026
- 调整 RBAC 菜单结构,移除管理员管理功能,新增日志管理菜单
- 修复 RBAC 安全漏洞,确保禁用角色权限失效
- 重构认证模块,将登录相关接口迁移到统一包结构下
- 移除废弃的管理模块和工具类接口定义
- 为通用工具包添加中文注释和文档说明
2026-08-26 23:42:38 +08:00

68 lines
2.5 KiB
Go

package house
import (
"context"
dashboardv1 "service.xpcool.com/api/house/dashboard"
dashboard "service.xpcool.com/internal/service/house/dashboard"
)
// DashboardOverview 看板统计概览。
func (c *Controller) DashboardOverview(ctx context.Context, req *dashboardv1.OverviewReq) (res *dashboardv1.OverviewRes, err error) {
o, err := dashboard.Dashboard().Overview(ctx, req.Region)
if err != nil {
return nil, err
}
return &dashboardv1.OverviewRes{
CommunityCount: o.CommunityCount, ListingCount: o.ListingCount, BargainCount: o.BargainCount,
LowConfidence: o.LowConfidence, AvgUnitPrice: o.AvgUnitPrice, AvgTotalPrice: o.AvgTotalPrice, AvgListDays: o.AvgListDays,
}, nil
}
// DashboardMapPoints 地图点位聚合。
func (c *Controller) DashboardMapPoints(ctx context.Context, req *dashboardv1.MapPointsReq) (res *dashboardv1.MapPointsRes, err error) {
pts, err := dashboard.Dashboard().MapPoints(ctx, req.Region, req.PriceMin, req.PriceMax, req.Status)
if err != nil {
return nil, err
}
out := make([]*dashboardv1.MapPoint, 0, len(pts))
for i := range pts {
p := &pts[i]
out = append(out, &dashboardv1.MapPoint{
CommunityId: p.CommunityId, Name: p.Name, Region: p.Region, Lng: p.Lng, Lat: p.Lat,
AvgUnitPrice: p.AvgUnitPrice, ListingCount: p.ListingCount, BargainCount: p.BargainCount,
})
}
return &dashboardv1.MapPointsRes{Points: out}, nil
}
// DashboardPriceTrend 价格趋势聚合。
func (c *Controller) DashboardPriceTrend(ctx context.Context, req *dashboardv1.PriceTrendReq) (res *dashboardv1.PriceTrendRes, err error) {
trend, err := dashboard.Dashboard().PriceTrend(ctx, req.CommunityId, req.Region, req.Limit)
if err != nil {
return nil, err
}
out := make([]*dashboardv1.TrendPoint, 0, len(trend))
for i := range trend {
t := &trend[i]
out = append(out, &dashboardv1.TrendPoint{Date: t.Date, AvgListPrice: t.AvgListPrice, AvgDealPrice: t.AvgDealPrice})
}
return &dashboardv1.PriceTrendRes{Trend: out}, nil
}
// DashboardAggregateRegion 区域聚合。
func (c *Controller) DashboardAggregateRegion(ctx context.Context, req *dashboardv1.AggregateRegionReq) (res *dashboardv1.AggregateRegionRes, err error) {
list, err := dashboard.Dashboard().AggregateRegion(ctx)
if err != nil {
return nil, err
}
out := make([]*dashboardv1.RegionAgg, 0, len(list))
for i := range list {
r := &list[i]
out = append(out, &dashboardv1.RegionAgg{
Region: r.Region, AvgUnitPrice: r.AvgUnitPrice, ListingCount: r.ListingCount, BargainCount: r.BargainCount,
})
}
return &dashboardv1.AggregateRegionRes{List: out}, nil
}