feat(mcp): 新增代理/物业详情工具(含发票信息)+ 本机测试环境脚本
xiaoqu-agent-service CI / test (push) Canceled after 0s

- agent.detail.query / property.detail.query:主体详情 + invoice_info
  全量抬头列表(默认条优先),行权限复用列表过滤语义
- 新增 InvoiceQueries 共享发票查询助手;InvoiceInfo 实体/Mapper
  按线上库 codegen 生成(m0 白名单加 invoice_info)
- Properyt.customerId 补 @TableField("customerId"):库中驼峰列名,
  否则映射到不存在的 customer_id(prod 曾报 Unknown column)
- seed-dev.sql 补两个详情工具的 scope 绑定;PermissionServiceTest
  补详情行权限断言(合并远端 district 测试冲突)
- 新增 deploy/test-up.sh:本机测试环境一键脚本(构建→重启→刷新
  scope 绑定→自检);.env.example 修正引导变量名 APP_ 前缀误写
This commit is contained in:
xiaoqu
2026-09-09 11:41:35 +08:00
parent 40e61cd300
commit 1e42323697
11 changed files with 465 additions and 8 deletions
@@ -27,6 +27,8 @@ import java.util.Arrays;
* CODEGEN_SCHEMA_M0 默认 xiaoqu_comples_d(生产 xiaoqu_complex)
* CODEGEN_SCHEMA_M2 默认 xiaoqu_franchisee_d(生产 xiaoqu_franchisee)
* CODEGEN_SCHEMA_SVC 默认 xiaoqu_agent_svc_d(svc 表结构由 Flyway 管理,各环境一致,一般无需覆盖)
* 注意:properyt.customerId 是驼峰列名(dev/prod 一致),生成后必须保留实体上的
* @TableField("customerId") 手工补丁,否则运行时会映射成不存在的 customer_id。
*/
public class CodeGenerator {
@@ -38,7 +40,7 @@ public class CodeGenerator {
public static void main(String[] args) {
generate(envOr("CODEGEN_SCHEMA_M0", "xiaoqu_comples_d"), "m0",
"user", "agent", "authority", "properyt", "agent_manage_district_auth");
"user", "agent", "authority", "properyt", "agent_manage_district_auth", "invoice_info");
generate(envOr("CODEGEN_SCHEMA_M2", "xiaoqu_franchisee_d"), "m2",
"warehouse_agent_auth");
generate(envOr("CODEGEN_SCHEMA_SVC", "xiaoqu_agent_svc_d"), "svc",
@@ -200,6 +200,37 @@ class PermissionServiceTest {
assertTrue(wrapper.getParamNameValuePairs().values().contains(55L));
}
@Test
void propertyDetailKeepsExactIdAndAgentBoundary() {
// property.detail.query 的过滤形态:eq(id) 精确查询 + applyPropertyRowFilter 行权限
User user = user(1000L, 108L, 1L);
when(authorityMapper.selectById(108L)).thenReturn(authority(108L, 1));
LambdaQueryWrapper<Properyt> wrapper = new LambdaQueryWrapper<Properyt>()
.eq(Properyt::getId, 55L);
permissionService.applyPropertyRowFilter(wrapper, user);
String sql = wrapper.getSqlSegment();
Collection<Object> values = wrapper.getParamNameValuePairs().values();
assertTrue(sql.contains("id ="));
assertTrue(sql.contains("agent_id"));
assertTrue(values.contains(55L));
assertTrue(values.contains(1L));
}
@Test
void headquartersPropertyDetailKeepsOnlyExactId() {
User user = user(46L, 1L, 0L);
when(authorityMapper.selectById(1L)).thenReturn(authority(1L, 0));
LambdaQueryWrapper<Properyt> wrapper = new LambdaQueryWrapper<Properyt>()
.eq(Properyt::getId, 55L);
permissionService.applyPropertyRowFilter(wrapper, user);
assertTrue(wrapper.getSqlSegment().contains("id ="));
assertFalse(wrapper.getSqlSegment().contains("agent_id"));
}
private static Authority authority(Long id, int isAgent) {
Authority authority = new Authority();
authority.setId(id);