新增易方达接口以及添加claude技能
This commit is contained in:
@@ -0,0 +1,304 @@
|
||||
# 常用数据表参考
|
||||
|
||||
本文档记录开发OpenAPI接口时常用的数据表结构和用途,便于快速查询和复用。
|
||||
|
||||
## 数据库命名规范
|
||||
|
||||
### @Table 注解格式
|
||||
|
||||
在 `fangjia-dal` 的实体类中,MongoDB 集合通过 JPA 的 `@Table` 注解来指定:
|
||||
|
||||
```java
|
||||
@Entity
|
||||
@Table(name = "database.collection")
|
||||
public class YourEntity implements MongoEntity {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
**重要规则**:
|
||||
- **点之前**(`.`前):**数据库名**(database)
|
||||
- **点之后**(`.`后):**集合名**(collection)
|
||||
- 不同的数据库对应不同的 MongoDB URI 常量
|
||||
|
||||
### 数据库与 URI 常量的对应关系
|
||||
|
||||
| 数据库名 | MongoDB URI 常量 | 服务器地址 | 用途 |
|
||||
|---------|-----------------|-----------|------|
|
||||
| `business` | `Constants.SEAWATER_MONGO_URI` | 192.168.0.206:27020 | 业务日志、开放平台相关 |
|
||||
| `fangjia` | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 | 核心业务数据 |
|
||||
| `fangjia_stat` | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 | 统计数据 |
|
||||
| `address_analytics` | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 | 地址分析数据 |
|
||||
|
||||
**示例**:
|
||||
```java
|
||||
// business.open_uri_log → business 数据库 → 使用 SEAWATER_MONGO_URI
|
||||
@Table(name = "business.open_uri_log")
|
||||
|
||||
// fangjia_stat.district_stat → fangjia_stat 数据库 → 使用 FANGJIA_MONGO_URI
|
||||
@Table(name = "fangjia_stat.district_stat")
|
||||
|
||||
// fangjia.seaweed → fangjia 数据库,seaweed 集合 → 使用 FANGJIA_MONGO_URI
|
||||
@Table(name = "fangjia.seaweed")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## MongoDB数据表
|
||||
|
||||
### 1. business.open_uri_log
|
||||
|
||||
**服务器**:192.168.0.206 (通过 `Constants.SEAWATER_MONGO_URI` 连接)
|
||||
|
||||
**作用**:记录所有开放平台API的调用日志,包含请求参数、返回结果等
|
||||
|
||||
**常用字段**:
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|-------|------|------|
|
||||
| `user_id` | String | 调用用户ID |
|
||||
| `request_uri` | String | 请求的API路径(如 `/address/risk`) |
|
||||
| `parameter_map` | Document | 请求参数(嵌套文档) |
|
||||
| `res_map` | Document | 返回结果(嵌套文档) |
|
||||
| `c_date` | Date | 创建时间 |
|
||||
|
||||
**连接方式**:
|
||||
```groovy
|
||||
import com.fangjia.core.Constants
|
||||
import com.fangjia.core.util.Mongo3Utils
|
||||
|
||||
MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
|
||||
Constants.SEAWATER_MONGO_URI,
|
||||
"business",
|
||||
"open_uri_log"
|
||||
)
|
||||
```
|
||||
|
||||
**典型查询**:
|
||||
```groovy
|
||||
// 查询特定用户的API调用记录
|
||||
Document query = new Document("user_id", "1007569")
|
||||
.append("request_uri", "/address/risk")
|
||||
|
||||
// 使用projection优化查询
|
||||
Document projection = new Document("parameter_map", 1).append("_id", 0)
|
||||
MongoCursor<Document> cursor = coll.find(query)
|
||||
.projection(projection)
|
||||
.limit(1000)
|
||||
.iterator()
|
||||
```
|
||||
|
||||
**使用场景**:
|
||||
- 提取历史调用数据用于接口测试
|
||||
- 分析API调用量和参数分布
|
||||
- 排查接口调用问题
|
||||
|
||||
---
|
||||
|
||||
### 2. fangjia_stat.district_stat
|
||||
|
||||
**数据库**:fangjia_stat (通过 `Constants.FANGJIA_MONGO_URI` 连接)
|
||||
**集合名**:district_stat
|
||||
|
||||
**作用**:存储小区级别的价格统计数据
|
||||
|
||||
**常用字段**:
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|-------|------|------|
|
||||
| `city` | String | 城市 |
|
||||
| `region` | String | 区域 |
|
||||
| `name` | String | 小区名称 |
|
||||
| `avg_price_2b` | Integer | 均价(优先使用,元/平米) |
|
||||
| `avgPrice` | Integer | 均价(备选,元/平米) |
|
||||
| `weekend` | Date | 数据更新时间 |
|
||||
|
||||
**典型查询**:
|
||||
```groovy
|
||||
// 通过DistrictStatService查询
|
||||
DistrictStat latestStat = districtStatService.findOneDistrictStatsSort(
|
||||
city, region, name, null
|
||||
)
|
||||
|
||||
// 优先使用avg_price_2b
|
||||
Integer avgPrice = null
|
||||
if (latestStat.getAvg_price_2b() != null && latestStat.getAvg_price_2b() > 0) {
|
||||
avgPrice = latestStat.getAvg_price_2b()
|
||||
} else if (latestStat.getAvgPrice() > 0) {
|
||||
avgPrice = latestStat.getAvgPrice()
|
||||
}
|
||||
```
|
||||
|
||||
**使用场景**:
|
||||
- 查询小区参考均价
|
||||
- E基金地址匹配接口返回参考价格
|
||||
- 房价评估相关接口
|
||||
|
||||
---
|
||||
|
||||
### 3. fangjia.deal_price
|
||||
|
||||
**数据库**:fangjia (通过 `Constants.FANGJIA_MONGO_URI` 连接)
|
||||
**集合名**:deal_price
|
||||
|
||||
**作用**:存储房产成交记录
|
||||
|
||||
**常用字段**:
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|-------|------|------|
|
||||
| `city` | String | 城市 |
|
||||
| `region` | String | 区域 |
|
||||
| `name` | String | 小区名称 |
|
||||
| `avgPrice` | Integer | 成交单价(元/平米) |
|
||||
| `totalPrice` | Integer | 成交总价(万元) |
|
||||
| 成交时间 | Date | 成交日期 |
|
||||
|
||||
**典型查询**:
|
||||
```groovy
|
||||
// 通过DealPriceService查询近半年成交记录
|
||||
Date halfYearAgo = new Date(System.currentTimeMillis() - 180L * 24 * 60 * 60 * 1000)
|
||||
Date now = new Date()
|
||||
|
||||
List<DealPrice> dealPrices = dealPriceService.findDealPriceList(
|
||||
city, region, name, halfYearAgo, now
|
||||
)
|
||||
|
||||
// 找到单价最接近参考均价的成交记录
|
||||
DealPrice closestDeal = null
|
||||
int minDiff = Integer.MAX_VALUE
|
||||
for (DealPrice deal : dealPrices) {
|
||||
if (deal.getAvgPrice() != null && deal.getTotalPrice() != null) {
|
||||
int diff = Math.abs(deal.getAvgPrice() - referencePrice)
|
||||
if (diff < minDiff) {
|
||||
minDiff = diff
|
||||
closestDeal = deal
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**使用场景**:
|
||||
- 查询成交记录
|
||||
- 计算典型总价(最接近参考均价的成交总价)
|
||||
- 成交数据分析
|
||||
|
||||
---
|
||||
|
||||
### 4. fangjia_stat.region_sell_stat
|
||||
|
||||
**数据库**:fangjia_stat (通过 `Constants.FANGJIA_MONGO_URI` 连接)
|
||||
**集合名**:region_sell_stat
|
||||
|
||||
**作用**:存储区域级别的销售价格统计
|
||||
|
||||
**常用字段**:
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|-------|------|------|
|
||||
| `city` | String | 城市(简称格式) |
|
||||
| `region` | String | 区域(简称格式) |
|
||||
| `avgPrice` | Integer | 区域均价(元/平米) |
|
||||
| `date` | Integer | 数据日期(yyyyMM格式) |
|
||||
| `updateDate` | Date | 更新时间 |
|
||||
|
||||
**典型查询**:
|
||||
```groovy
|
||||
// 需要先格式化城市和区域为简称
|
||||
String formattedCity = RegionData.formatCity(city)
|
||||
String formattedRegion = RegionData.formatRegion(formattedCity, district)
|
||||
|
||||
// 通过RegionSellStatService查询最新区域价格
|
||||
RegionSellStat regionSellStat = regionSellStatService.findNewestRegionPrice(
|
||||
formattedCity, formattedRegion
|
||||
)
|
||||
|
||||
if (regionSellStat != null && regionSellStat.getAvgPrice() != null) {
|
||||
Integer avgPrice = regionSellStat.getAvgPrice()
|
||||
// 格式化日期
|
||||
String updateTime = DateUtil.formatByPattern(
|
||||
DateUtil.parseDate(regionSellStat.getDate().toString(), "yyyyMM"),
|
||||
"yyyy-MM-dd"
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**使用场景**:
|
||||
- 查询区域级别参考价格
|
||||
- 地址匹配失败时返回区域价格
|
||||
- 区域价格趋势分析
|
||||
|
||||
---
|
||||
|
||||
### 5. fangjia.seaweed
|
||||
|
||||
**数据库**:fangjia (通过 `Constants.FANGJIA_MONGO_URI` 连接)
|
||||
**集合名**:seaweed (实体类为 District,通过 @DatastoreCategory("district") 标识)
|
||||
|
||||
**作用**:存储小区、写字楼等建筑的基础信息(权威数据源)
|
||||
|
||||
**常用字段**:
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|-------|------|------|
|
||||
| `_id` | ObjectId | 小区唯一标识 |
|
||||
| `city` | String | 城市 |
|
||||
| `region` | String | 区域 |
|
||||
| `name` | String | 小区/建筑名称 |
|
||||
| `cat` | String | 分类(district=小区, office=写字楼) |
|
||||
| `estate_type2` | String | 物业类型 |
|
||||
|
||||
**典型查询**:
|
||||
```groovy
|
||||
// 通过DistrictService根据ID查询
|
||||
District district = districtService.findById(id)
|
||||
|
||||
if (district != null) {
|
||||
String city = district.getCity()
|
||||
String region = district.getRegion()
|
||||
String name = district.getName()
|
||||
}
|
||||
```
|
||||
|
||||
**使用场景**:
|
||||
- 根据ID查询小区权威信息
|
||||
- 获取小区的城市、区域、名称用于后续查询
|
||||
- 验证POI信息的准确性
|
||||
|
||||
---
|
||||
|
||||
## 如何记录新数据表
|
||||
|
||||
**遇到新数据表时,请主动询问用户是否需要记录,格式如下:**
|
||||
|
||||
> 我在开发过程中用到了数据表 `XXX.YYY`,是否需要记录到技能文档中供以后复用?
|
||||
>
|
||||
> 如果需要,请告诉我:
|
||||
> 1. 这个表的主要作用
|
||||
> 2. 常用的查询场景
|
||||
> 3. 是否有特殊的查询方式或注意事项
|
||||
|
||||
**记录模板**:
|
||||
|
||||
```markdown
|
||||
### N. database.table_name
|
||||
|
||||
**服务器/数据库**:服务器地址或数据库类型
|
||||
|
||||
**作用**:简要说明表的用途
|
||||
|
||||
**常用字段**:
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|-------|------|------|
|
||||
| `field1` | Type | 说明 |
|
||||
| `field2` | Type | 说明 |
|
||||
|
||||
**连接方式**:(如果有特殊连接方式)
|
||||
```groovy
|
||||
// 代码示例
|
||||
```
|
||||
|
||||
**典型查询**:
|
||||
```groovy
|
||||
// 常用查询示例
|
||||
```
|
||||
|
||||
**使用场景**:
|
||||
- 场景1
|
||||
- 场景2
|
||||
```
|
||||
Reference in New Issue
Block a user