Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
utools_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
wuhao
utools_backend
Commits
39cc6d1c
Commit
39cc6d1c
authored
Feb 20, 2023
by
wuhao
🎯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asdl
parent
6346bb2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
item.js
app/controller/item.js
+23
-1
tag.js
app/service/tag.js
+11
-0
No files found.
app/controller/item.js
View file @
39cc6d1c
...
...
@@ -40,7 +40,29 @@ class ItemController extends Controller {
this
.
fail
(
'请完善必填项!'
);
return
;
}
const
item
=
await
ctx
.
model
.
Item
.
create
(
ctx
.
request
.
body
);
const
tags
=
ctx
.
request
.
body
.
tags
?.
filter
(
it
=>
isNaN
(
it
))
.
map
(
it
=>
{
return
{
tag_name
:
it
,
project_id
:
ctx
.
request
.
body
.
project_id
,
color
:
'#cccccc'
,
};
});
const
idtags
=
await
ctx
.
model
.
Tag
.
findAll
({
where
:
{
id
:
ctx
.
request
.
body
.
tags
?.
filter
(
it
=>
!
isNaN
(
it
)),
},
});
const
mutiadder
=
await
ctx
.
service
.
tag
.
muticreate
(
tags
);
const
tages
=
[
mutiadder
?.
map
(
it
=>
it
?.
dataValues
),
idtags
.
map
(
it
=>
it
?.
dataValues
),
].
flat
();
const
item
=
await
ctx
.
model
.
Item
.
create
({
...
ctx
.
request
.
body
,
tags
:
tages
,
});
// const tags = await ctx.model.service.tags
this
.
success
(
item
);
}
...
...
app/service/tag.js
View file @
39cc6d1c
...
...
@@ -21,6 +21,17 @@ class TagService extends Service {
return
tag
;
}
async
muticreate
(
tagarr
)
{
const
{
ctx
}
=
this
;
let
tag
;
try
{
tag
=
await
ctx
.
model
.
Tag
.
bulkCreate
(
tagarr
);
}
catch
(
error
)
{
tag
=
error
;
}
return
tag
;
}
async
getbyproject_id
(
project_id
,
status
)
{
const
{
ctx
}
=
this
;
const
where
=
...
...
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