明树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
1a47eb90
Commit
1a47eb90
authored
Dec 10, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
01517d16
Pipeline
#104418
passed with stage
in 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
19 deletions
+61
-19
fileController.js
controller/fileController.js
+1
-1
projectController.js
controller/projectController.js
+2
-0
projectModule.js
module/projectModule.js
+58
-18
No files found.
controller/fileController.js
View file @
1a47eb90
...
...
@@ -15,7 +15,7 @@ async function upload(req, res, next) {
filename
:
req
.
file
.
filename
,
path
:
req
.
file
.
path
,
// nginxpath,
size
:
req
.
file
.
size
,
size
:
(
req
.
file
.
size
/
(
1048576
)).
toFixed
(
2
)
,
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
controller/projectController.js
View file @
1a47eb90
...
...
@@ -893,7 +893,9 @@ async function listProject(req, res, next) {
search
.
attributes
=
req
.
body
.
attributes
;
}
console
.
log
(
search
)
search
.
raw
=
true
let
ret
=
await
DB
.
Project
.
findAndCountAll
(
search
);
// ret = await projectModule.handleProjectData(ret, search.attributes);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
module/projectModule.js
View file @
1a47eb90
...
...
@@ -13,26 +13,52 @@ const moment = require('moment');
async
function
handleProjectData
(
ret
,
queryAttrs
)
{
let
rawAttributes
=
_
.
cloneDeep
(
DB
.
Project
.
rawAttributes
);
console
.
log
(
ret
,
"===="
)
let
queryRawAtr
=
[],
resourceKeys
=
[];
for
(
let
index
=
0
;
index
<
queryAttrs
.
length
;
index
++
)
{
const
element
=
queryAttrs
[
index
];
if
(
rawAttributes
[
element
])
{
queryRawAtr
.
push
(
rawAttributes
[
element
]);
//查询得所有字段
if
([
'danxuan'
].
includes
(
rawAttributes
[
element
]
&&
rawAttributes
[
element
].
zjType
))
{
//其中需要处理的资源库字段,单选、
resourceKeys
.
push
(
element
);
// console.log(ret, "====")
// let queryRawAtr = [], resourceKeys = [];
// for (let index = 0; index < queryAttrs.length; index++) {
// const element = queryAttrs[index];
// if (rawAttributes[element]) {
// // queryRawAtr.push(rawAttributes[element]); //查询得所有字段
// if (['danxuan'].includes(rawAttributes[element] && rawAttributes[element].zjType)) { //其中需要处理的资源库字段,单选、
// resourceKeys.push(element);
// }
// if (['duoxuan'].includes()) {
// }
// }
// }
// let resources = await getResourceByKeys(resourceKeys);
let
newRet
=
[],
resouInfoIds
=
[];
for
(
let
index
=
0
;
index
<
ret
.
rows
.
length
;
index
++
)
{
const
element
=
ret
.
rows
[
index
];
// console.log(element);
for
(
const
key
in
element
)
{
console
.
log
(
key
)
if
(
!
_
.
isEmpty
(
element
[
key
])
&&
rawAttributes
[
key
].
zjType
)
{
if
(
rawAttributes
[
element
].
zjType
==
"danxuan"
)
{
resouInfoIds
.
push
(
element
[
key
]);
}
else
if
(
rawAttributes
[
element
].
zjType
==
"duoxuan"
)
{
resouInfoIds
=
resouInfoIds
.
concat
(
element
[
key
])
}
}
}
}
let
resources
=
await
getResourceByKeys
(
resourceKeys
);
let
newRet
=
[];
let
resMap
=
await
getResourceInfoByIds
(
resouInfoIds
);
for
(
let
index
=
0
;
index
<
ret
.
rows
.
length
;
index
++
)
{
const
element
=
ret
.
rows
[
index
];
console
.
log
(
element
);
//
console.log(element);
for
(
const
key
in
element
)
{
if
(
!
_
.
isEmpty
(
resources
[
key
]))
{
element
[
key
]
=
resources
[
key
][
element
[
key
]]
if
(
!
_
.
isEmpty
(
element
[
key
])
&&
rawAttributes
[
element
].
zjType
)
{
if
(
rawAttributes
[
element
].
zjType
==
"danxuan"
)
{
element
[
key
]
=
resMap
[
element
[
key
]];
}
else
if
(
rawAttributes
[
element
].
zjType
==
"duoxuan"
)
{
if
(
_
.
isArray
(
element
[
key
])
&&
element
[
key
].
length
>
0
)
{
element
[
key
].
map
(
o
=>
{
return
resMap
[
o
]});
element
[
key
]
=
element
[
key
].
join
(
','
)
}
}
}
}
...
...
@@ -43,6 +69,20 @@ async function handleProjectData(ret, queryAttrs) {
return
ret
;
}
async
function
getResourceInfoByIds
(
resouInfoIds
)
{
let
ris
=
await
DB
.
ResourcesInfo
.
findAll
({
where
:
{
id
:
{[
Op
.
in
]:
resouInfoIds
}},
raw
:
true
,
});
let
risMap
=
{};
for
(
let
index
=
0
;
index
<
ris
.
length
;
index
++
)
{
const
element
=
ris
[
index
];
risMap
[
element
.
id
]
=
element
.
value
;
risMap
[
String
(
element
.
id
)]
=
element
.
value
;
}
return
risMap
;
}
async
function
getResourceByKeys
(
keys
)
{
if
(
!
(
keys
&&
keys
.
length
))
{
...
...
@@ -71,7 +111,7 @@ async function getResourceByKeys(keys) {
return
obj
;
}
async
function
getProjectInfo
({
id
})
{
async
function
getProjectInfo
({
id
})
{
let
project
=
await
DB
.
Project
.
findOne
({
where
:
{
id
:
id
},
// raw: true,
...
...
@@ -150,8 +190,8 @@ async function getProjectInfo({id}) {
],
// raw: true
});
if
(
!
project
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
)
;
if
(
!
project
)
{
return
{}
;
}
project
=
project
.
toJSON
();
project
.
projectXmtzzes
=
utils
.
buildTree2
(
project
.
projectXmtzzes
,
'xh'
,
'parentXh'
);
...
...
@@ -169,7 +209,7 @@ async function getProjectInfo({id}) {
}
async
function
getProjectInfoByLixiang
({
id
})
{
async
function
getProjectInfoByLixiang
({
id
})
{
let
project
=
await
DB
.
Project
.
findOne
({
where
:
{
id
:
id
},
// raw: true,
...
...
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