明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
jt_backend
Commits
ac597227
Commit
ac597227
authored
Mar 09, 2026
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
73d38125
Pipeline
#108124
passed with stage
in 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
projectTzController.js
controller/projectTzController.js
+28
-28
No files found.
controller/projectTzController.js
View file @
ac597227
...
...
@@ -1044,13 +1044,13 @@ async function createXmtc(req, res, next) {
if
(
!
req
.
body
.
projectId
)
{
return
res
.
sendError
(
errorMessage
.
paramsError
);
}
// 1. 文件
req
.
body
.
tcwj
=
(
req
.
body
.
tcwj
||
[]).
map
(
o
=>
{
return
o
&&
o
.
id
||
o
});
let
ret
=
await
DB
.
TzXmtc
.
create
(
req
.
body
);
//
//
1. 文件
//
req.body.tcwj = (req.body.tcwj || []).map(o => { return o && o.id || o });
//
let ret = await DB.TzXmtc.create(req.body);
let
tccwzbs
=
(
req
.
body
.
tccwzbs
||
[]).
map
(
o
=>
{
o
.
projectId
=
req
.
body
.
projectId
;
o
.
sourceId
=
ret
.
id
;
return
o
;
});
delete
req
.
body
.
tccwzbs
;
await
DB
.
TzXmtcCwzb
.
bulkCreate
(
tccwzbs
);
//
let tccwzbs = (req.body.tccwzbs || []).map(o => { o.projectId = req.body.projectId; o.sourceId = ret.id; return o; });
//
delete req.body.tccwzbs;
//
await DB.TzXmtcCwzb.bulkCreate(tccwzbs);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -1073,10 +1073,10 @@ async function getXmtcInfo(req, res, next) {
if
(
!
(
xmtc
&&
xmtc
.
id
&&
xmtc
.
projectId
))
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
let
tccwzbs
=
await
DB
.
TzXmtcCwzb
.
findAll
({
where
:
{
projectId
:
xmtc
.
projectId
,
sourceId
:
xmtc
.
id
},
raw
:
true
,
});
//
let tccwzbs = await DB.TzXmtcCwzb.findAll({
//
where: { projectId: xmtc.projectId, sourceId: xmtc.id },
//
raw: true,
//
});
xmtc
.
tccwzbs
=
tccwzbs
;
return
res
.
sendData
(
xmtc
);
...
...
@@ -1089,24 +1089,24 @@ async function updateXmtc(req, res, next) {
if
(
!
req
.
body
.
projectId
)
{
return
res
.
sendError
(
errorMessage
.
paramsError
);
}
let
tccwzbs
=
req
.
body
.
tccwzbs
||
[];
let
ids
=
[],
info
=
[],
newArr
=
[];
for
(
let
index
=
0
;
index
<
tccwzbs
.
length
;
index
++
)
{
const
element
=
tccwzbs
[
index
];
element
.
projectId
=
req
.
body
.
projectId
;
element
.
sourceId
=
req
.
body
.
id
;
element
.
wj
=
(
element
.
wj
||
[]).
map
(
o
=>
{
return
o
&&
o
.
id
||
o
});
if
(
element
.
id
)
{
ids
.
push
(
element
.
id
);
info
.
push
(
element
);
}
else
{
newArr
.
push
(
element
);
}
}
await
DB
.
TzXmtcCwzb
.
destroy
({
where
:
{
projectId
:
req
.
body
.
projectId
,
sourceId
:
req
.
body
.
id
,
id
:
{
[
Op
.
notIn
]:
ids
}
}
});
// 删除id不在传入id数组里面的(用户在界面删除的)
await
DB
.
TzXmtcCwzb
.
bulkCreate
(
newArr
);
//创建新的 没有id的
await
Promise
.
all
(
info
.
map
(
item
=>
{
return
DB
.
TzXmtcCwzb
.
update
(
item
,
{
where
:
{
id
:
item
.
id
}
})
}));
delete
req
.
body
.
tccwzbs
;
//
let tccwzbs = req.body.tccwzbs || [];
//
let ids = [], info = [], newArr = [];
//
for (let index = 0; index < tccwzbs.length; index++) {
//
const element = tccwzbs[index];
//
element.projectId = req.body.projectId;
//
element.sourceId = req.body.id;
//
element.wj = (element.wj || []).map(o => { return o && o.id || o });
//
if (element.id) {
//
ids.push(element.id);
//
info.push(element);
//
} else {
//
newArr.push(element);
//
}
//
}
//
await DB.TzXmtcCwzb.destroy({ where: { projectId: req.body.projectId, sourceId: req.body.id, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
//
await DB.TzXmtcCwzb.bulkCreate(newArr);//创建新的 没有id的
//
await Promise.all(info.map(item => { return DB.TzXmtcCwzb.update(item, { where: { id: item.id } }) }));
//
delete req.body.tccwzbs;
await
DB
.
TzXmtc
.
update
(
req
.
body
,
{
where
:
{
id
:
req
.
body
.
id
}
});
return
res
.
sendData
({});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment