Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
service-campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
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
Nguyen Ha
service-campaign
Commits
ac82f96a
Commit
ac82f96a
authored
Sep 09, 2019
by
Đào Nhật Quang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quangdn - add download template and import template
parent
2199ddd4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
19 deletions
+12
-19
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
...ava/com/viettel/campaign/web/rest/CustomerController.java
+12
-19
No files found.
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
View file @
ac82f96a
...
...
@@ -37,7 +37,7 @@ import java.util.Map;
@RequestMapping
(
"/ipcc/customer"
)
@CrossOrigin
(
origins
=
"*"
)
public
class
CustomerController
{
private
CustomerQueryRepository
customerQueryRepo
;
private
CustomerQueryRepository
customerQueryRepo
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CustomerController
.
class
);
...
...
@@ -198,20 +198,16 @@ public class CustomerController {
try
{
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
request
.
getHeader
(
"X-Auth-Token"
));
if
(
file
.
isEmpty
())
{
return
new
ResponseEntity
<>(
"file-empty"
,
HttpStatus
.
BAD_REQUES
T
);
return
new
ResponseEntity
<>(
"file-empty"
,
HttpStatus
.
NO_CONTEN
T
);
}
String
path
=
saveUploadFile
(
file
);
List
<
CustomizeFields
>
dynamicHeaders
=
customerService
.
getDynamicHeader
(
userSession
.
getCompanySiteId
());
Map
<
String
,
Object
>
map
=
customerService
.
readAndValidateCustomer
(
path
,
dynamicHeaders
,
userSession
,
Long
.
parseLong
(
customerListId
));
String
message
=
(
String
)
map
.
get
(
"message"
);
byte
[]
content
=
(
byte
[])
map
.
get
(
"content"
);
if
(
message
.
equals
(
"import-success"
))
{
return
ResponseEntity
.
ok
()
.
header
(
"Message"
,
message
)
.
body
(
content
);
}
else
{
return
ResponseEntity
.
badRequest
().
header
(
"Message"
,
message
).
body
(
content
);
}
return
ResponseEntity
.
ok
()
.
header
(
"Message"
,
message
)
.
body
(
content
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
...
...
@@ -266,18 +262,15 @@ public class CustomerController {
}
private
String
saveUploadFile
(
MultipartFile
file
)
{
try
{
String
currentTime
=
new
SimpleDateFormat
(
"yyyy_MM_dd_hh_mm_ss"
).
format
(
new
Date
());
String
fileName
=
FilenameUtils
.
getBaseName
(
file
.
getOriginalFilename
())
+
"_"
+
currentTime
+
"."
+
FilenameUtils
.
getExtension
(
file
.
getOriginalFilename
());
byte
[]
content
=
file
.
getBytes
();
// File uploadFolder = new File(BundleUtils.getGlobalConfig("import.uploadFolder"));
File
uploadFolder
=
new
File
(
Config
.
EXCEL_DIR
);
if
(!
uploadFolder
.
exists
())
{
uploadFolder
.
mkdir
();
}
// Path path = Paths.get(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
Path
path
=
Paths
.
get
(
Config
.
EXCEL_DIR
,
fileName
);
Files
.
write
(
path
,
content
);
return
path
.
toString
();
...
...
@@ -287,7 +280,7 @@ public class CustomerController {
return
null
;
}
// @GetMapping("/query")
// @GetMapping("/query")
// public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
// List<Customer> things = customerQueryRepo.findAll(query);
// if (things.isEmpty()) {
...
...
@@ -295,16 +288,16 @@ public class CustomerController {
// }
// return ResponseEntity.ok(things);
// }
@GetMapping
(
path
=
""
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@GetMapping
(
path
=
""
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<
List
<
Customer
>>
query
(
@RequestParam
(
value
=
"search"
)
String
query
)
{
List
<
Customer
>
result
=
null
;
try
{
result
=
customerService
.
searchByQuery
(
query
);
}
catch
(
IllegalArgumentException
iae
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
)
result
=
customerService
.
searchByQuery
(
query
);
}
catch
(
IllegalArgumentException
iae
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
)
.
body
(
result
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
body
(
result
);
}
...
...
@@ -317,7 +310,7 @@ public class CustomerController {
@PostMapping
(
"/searchIndividualCustomer"
)
@ResponseBody
public
ResponseEntity
searchCustomizeFields
(
@RequestBody
CampaignCustomerDTO
campaignCustomerDTO
)
{
public
ResponseEntity
searchCustomizeFields
(
@RequestBody
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
result
=
customerService
.
searchCustomizeFields
(
campaignCustomerDTO
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
...
...
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