Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
Overview
Overview
Details
Activity
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
base_platform_enterprise
gic-platform-enterprise
Commits
718b9614
Commit
718b9614
authored
May 24, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
568e7c9a
2917f24c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
CustomSettingApiServiceImpl.java
...prise/service/outer/impl/CustomSettingApiServiceImpl.java
+22
-6
No files found.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/CustomSettingApiServiceImpl.java
View file @
718b9614
...
...
@@ -21,14 +21,12 @@ import org.apache.logging.log4j.Logger;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Service
(
"customSettingApiService"
)
public
class
CustomSettingApiServiceImpl
implements
CustomSettingApiService
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
CustomSettingApiServiceImpl
.
class
);
private
static
final
String
DATABASENAME
=
"
gic4_log
"
;
private
static
final
String
DATABASENAME
=
"
custom_table
"
;
private
static
final
String
PRIMARYKEY
=
"_id"
;
@Autowired
private
MongoOperApiService
mongoOperApiService
;
...
...
@@ -53,7 +51,7 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
Criteria
criteria
=
new
Criteria
(
field
,
MongoOperTypeEnum
.
EQ
,
map
.
get
(
field
));
criteriaList
.
add
(
criteria
);
}
if
(
map
.
get
(
"_id"
)
!=
null
){
if
(
map
.
get
(
PRIMARYKEY
)
!=
null
){
Criteria
criteria
=
new
Criteria
(
PRIMARYKEY
,
MongoOperTypeEnum
.
NIN
,
map
.
get
(
PRIMARYKEY
));
criteriaList
.
add
(
criteria
);
}
...
...
@@ -63,17 +61,35 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
queryDTO
.
setConllectionName
(
tableName
);
ServiceResponse
<
List
<
Map
>>
query
=
mongoOperApiService
.
query
(
queryDTO
);
if
(
CollectionUtils
.
isNotEmpty
(
query
.
getResult
())){
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"存在重复记录"
);
if
(
tableSetting
.
getRepeateOpt
()
!=
null
&&
tableSetting
.
getRepeateOpt
()
==
1
){
//等于1表示重复更新
Map
exitMap
=
query
.
getResult
().
get
(
0
);
map
.
forEach
((
k
,
v
)
->
{
if
(
k
.
equals
(
PRIMARYKEY
)){
exitMap
.
put
(
"ObjectId(\""
+
k
+
"\")"
,
v
);
}
else
{
exitMap
.
put
(
k
,
v
);
}
});
map
=
exitMap
;
}
else
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"存在重复记录"
);
}
}
}
log
.
info
(
"params:{}"
,
JSON
.
toJSONString
(
map
));
Date
date
=
new
Date
();
if
(
map
.
get
(
PRIMARYKEY
)
!=
null
){
//更新
map
.
put
(
"update_time"
,
date
);
MongoUpdateDTO
mongoUpdateDTO
=
new
MongoUpdateDTO
();
mongoUpdateDTO
.
setDataBaseAndCollectionName
(
DATABASENAME
,
tableName
);
mongoUpdateDTO
.
setData
(
map
);
ServiceResponse
<
Integer
>
update
=
mongoOperApiService
.
update
(
mongoUpdateDTO
);
log
.
info
(
"update:{}"
,
JSON
.
toJSONString
(
update
));
}
else
{
map
.
put
(
"update_time"
,
date
);
map
.
put
(
"create_time"
,
date
);
MongoSaveDTO
mongoSaveDTO
=
new
MongoSaveDTO
();
mongoSaveDTO
.
setDataBaseAndCollectionName
(
DATABASENAME
,
tableName
);
mongoSaveDTO
.
setData
(
map
);
...
...
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