Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
init-things
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
init-things
Commits
a2162e3f
Commit
a2162e3f
authored
Mar 08, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removes
parent
2d216a78
Pipeline
#10496
passed with stages
in 58 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
24 deletions
+0
-24
things/nest-typeorm/src/crud-base/crud-base.ts
things/nest-typeorm/src/crud-base/crud-base.ts
+0
-24
No files found.
things/nest-typeorm/src/crud-base/crud-base.ts
View file @
a2162e3f
...
...
@@ -17,10 +17,8 @@ import { QueryWise } from '../entities/interfaces/QueryWise';
import
{
camelCase
}
from
'
typeorm/util/StringUtils
'
;
import
{
DeletionWise
,
ImportWise
}
from
'
../entities/bases/TimeBase.entity
'
;
import
{
PageSettingsFactory
}
from
'
../dto/PageSettings.dto
'
;
import
{
generateEntityFromRaw
}
from
'
../utility/generateEntityFromRaw
'
;
import
{
ImportEntry
}
from
'
src/dto/import-entry.dto
'
;
import
_
from
'
lodash
'
;
import
{
CsvParseService
}
from
'
src/csv-parse/csv-parse/csv-parse.service
'
;
export
type
EntityId
<
T
extends
{
id
:
any
}
>
=
T
[
'
id
'
];
export
interface
RelationDef
{
...
...
@@ -312,28 +310,6 @@ export class CrudBase<
return
new
BlankReturnMessageDto
(
204
,
'
success
'
);
}
async
importCsv
(
csvService
:
CsvParseService
,
data
:
Buffer
,
encoding
=
'
utf8
'
,
extraChecking
?:
(
ent
:
T
)
=>
string
|
Promise
<
string
>
,
)
{
try
{
const
raw
=
await
csvService
.
parseCsv
<
any
>
(
data
,
{
targetEncoding
:
encoding
,
columns
:
true
,
cast
:
false
,
});
const
ents
=
raw
.
map
((
d
)
=>
generateEntityFromRaw
(
this
.
entityClass
,
d
));
return
this
.
importEntities
(
ents
,
extraChecking
);
}
catch
(
e
)
{
throw
new
BlankReturnMessageDto
(
400
,
'
文件解析失败,请检查文件格式。
'
,
).
toException
();
}
}
async
importEntities
(
ents
:
T
[],
extraChecking
?:
(
ent
:
T
)
=>
string
|
Promise
<
string
>
,
...
...
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