| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- /** Cross-repo contract guard for issue 65 detail endpoints (cockpit 免鉴权只读域). */
- import assert from 'node:assert/strict'
- import fs from 'node:fs'
- const root = 'E:/pipe-ner-server/pipe-network-service/'
- const read = (p) => fs.readFileSync(root + p, 'utf8')
- const entity = read('zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitEntityDetailController.java')
- const event = read('zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitEventDetailController.java')
- const order = read('zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitWorkOrderDetailController.java')
- const eventService = read('zksy-system/src/main/java/com/zksy/cockpit/event/CockpitEventDetailService.java')
- const entityService = read('zksy-system/src/main/java/com/zksy/cockpit/entity/CockpitEntityDetailService.java')
- const alarmMapper = read('zksy-system/src/main/resources/mapper/base/AlarmOperationsMapper.xml')
- // 三个详情路由都在免鉴权的 /api/cockpit/v1 下
- assert.ok(entity.includes('/api/cockpit/v1/entities/{entityId}/detail'))
- assert.ok(event.includes('/api/cockpit/v1'))
- assert.ok(event.includes('/events/{eventId}/detail'))
- assert.ok(order.includes('/work-orders/{orderId}/detail'))
- assert.ok(order.includes('workOrders.getDetail'), '工单详情必须用无鉴权的 getDetail')
- // 事件详情不得再**调用**需要登录用户的移动端方法(注释里说明原因不算)。
- const calls = eventService.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '')
- assert.ok(!calls.includes('getMobileWarningDetail('))
- assert.ok(!calls.includes('.mobileDetail('))
- assert.ok(eventService.includes('selectCockpitDetail'), '报警详情必须走无范围裁剪的查询')
- // 预警各分区都从底层 mapper 取(不经 requireVisible)
- assert.ok(eventService.includes('selectDisposalList'))
- assert.ok(eventService.includes('selectAlarmListByWarningId'))
- assert.ok(eventService.includes('selectByWarningId'))
- // 无范围报警详情 SQL 不得包含按用户的 scope 片段
- const cockpitSql = alarmMapper.split('<select id="selectCockpitDetail"')[1].split('</select>')[0]
- assert.ok(!cockpitSql.includes('mobileScope'))
- assert.ok(!cockpitSql.includes('AlarmReviewMapper.scope'))
- for (const category of ['PIPE_NETWORK', 'WATER_PLANT', 'PUMP_STATION', 'ENGINEERING_FACILITY', 'EMERGENCY_RESOURCE', 'HAZARD', 'PROTECTION_TARGET']) {
- assert.ok(entityService.includes(category), '实体详情缺类别: ' + category)
- }
- console.log('t65-backend-detail-contract: 18/18')
|