Browse Source

绑定项目的结构物支持多id查询

dev
巴林闲侠 2 years ago
parent
commit
b1a4d03bb5
  1. 16
      api/app/lib/controllers/project/index.js
  2. 8
      script/0.10/schema/1.alter_alarm_push_config.sql

16
api/app/lib/controllers/project/index.js

@ -210,15 +210,23 @@ async function strucWithPomsProject (ctx) {
const { clickHouse } = ctx.app.fs
const { pomsProjectId } = ctx.query
const bindRes = await models.ProjectCorrelation.findOne({
const bindRes = await models.ProjectCorrelation.findAll({
where: {
id: pomsProjectId
id: { $in: pomsProjectId.split(',') }
}
})
let anxinProjectIds = new Set()
for (let b of bindRes) {
if (b.anxinProjectId.length) {
for (let aid of b.anxinProjectId) {
anxinProjectIds.add(aid)
}
}
}
let undelStruc = []
if (bindRes) {
const undelStrucRes = bindRes.anxinProjectId.length ?
const undelStrucRes = anxinProjectIds.size ?
await clickHouse.anxinyun.query(
`
SELECT
@ -249,7 +257,7 @@ async function strucWithPomsProject (ctx) {
WHERE
project_state != -1
AND
t_project.id IN (${bindRes.anxinProjectId.join(',')})
t_project.id IN (${[...anxinProjectIds].join(',')}, -1)
ORDER BY strucId
`
).toPromise() :

8
script/0.10/schema/1.alter_alarm_push_config.sql

@ -6,3 +6,11 @@ comment on column alarm_push_config.alarm_sub_type is '存对应监听模块(ala
camera.kind_id,
app_alarm.errType
)';
ALTER TABLE alarm_push_config ALTER COLUMN poms_project_id TYPE INTEGER []
USING CASE
WHEN poms_project_id is NULL
then NULL
ELSE array [poms_project_id]
END ::INTEGER [];
Loading…
Cancel
Save