문자 agent 테스트 mms 파일 전송 진행중

파일경로 수정 v2
This commit is contained in:
hylee 2024-08-19 18:19:45 +09:00
parent a9ede6ae58
commit 50bcf75b06
8 changed files with 54 additions and 51 deletions

View File

@ -71,9 +71,9 @@ public class AgentCOneRestController {
} }
@PostMapping("/agent/one/uploadFiles") @PostMapping("/agent/one/uploadFiles")
public ResponseEntity<RestResponse> uploadFiles(@RequestParam("filename01") MultipartFile file1, public ResponseEntity<RestResponse> uploadFiles(@RequestParam("fileName01") MultipartFile file1,
@RequestParam("filename02") MultipartFile file2, @RequestParam("fileName02") MultipartFile file2,
@RequestParam("filename03") MultipartFile file3) { @RequestParam("fileName03") MultipartFile file3) {
try { try {
Map<String, String> fileNames = new HashMap<>(); Map<String, String> fileNames = new HashMap<>();

View File

@ -52,6 +52,7 @@ public class AgentCTwoServiceImpl extends AbstractAgentService<AgentCTwoVO, Agen
@Override @Override
protected AgentCTwoVO createCopy(AgentCTwoVO originalVO, int index) { protected AgentCTwoVO createCopy(AgentCTwoVO originalVO, int index) {
log.info(" :: originalVO.getfileName01() :: [{}]", originalVO.getFileName01());
if (!originalVO.getMessage().startsWith("ITN")) { if (!originalVO.getMessage().startsWith("ITN")) {
return originalVO; return originalVO;
@ -64,6 +65,11 @@ public class AgentCTwoServiceImpl extends AbstractAgentService<AgentCTwoVO, Agen
paramVO.setSendStatus(originalVO.getSendStatus()); paramVO.setSendStatus(originalVO.getSendStatus());
paramVO.setRecvPhone(modifyPhoneNumber(originalVO.getRecvPhone(), index)); paramVO.setRecvPhone(modifyPhoneNumber(originalVO.getRecvPhone(), index));
paramVO.setSendPhone(modifyPhoneNumber(originalVO.getSendPhone(), index)); paramVO.setSendPhone(modifyPhoneNumber(originalVO.getSendPhone(), index));
paramVO.setFileName01(originalVO.getFileName01());
paramVO.setFileName02(originalVO.getFileName02());
paramVO.setFileName03(originalVO.getFileName03());
paramVO.setMessage(originalVO.getMessage() + " " + (index + 1)); paramVO.setMessage(originalVO.getMessage() + " " + (index + 1));
if (!"S".equals(msgType)) { if (!"S".equals(msgType)) {
paramVO.setSubject(originalVO.getSubject() + " " + (index + 1)); paramVO.setSubject(originalVO.getSubject() + " " + (index + 1));
@ -73,6 +79,7 @@ public class AgentCTwoServiceImpl extends AbstractAgentService<AgentCTwoVO, Agen
@Override @Override
protected void insertBatch(List<AgentCTwoVO> batchList) { protected void insertBatch(List<AgentCTwoVO> batchList) {
log.info("batchList.get(0).toString() :: [{}]", batchList.get(0).toString());
mapper.insertAgents(batchList); mapper.insertAgents(batchList);
} }

View File

@ -47,6 +47,7 @@ public class AgentCTwoRestController {
* */ * */
@PostMapping("/agent/two/findByInsertCnt") @PostMapping("/agent/two/findByInsertCnt")
public ResponseEntity<RestResponse> findByInsertCnt(@RequestBody AgentCTwoVO agentCTwoVO) throws Exception { public ResponseEntity<RestResponse> findByInsertCnt(@RequestBody AgentCTwoVO agentCTwoVO) throws Exception {
System.out.println(" :: /agent/two/findByInsertCnt :: ");
return ResponseEntity.ok().body(agentCTwoService.findByInsertCnt(agentCTwoVO)); return ResponseEntity.ok().body(agentCTwoService.findByInsertCnt(agentCTwoVO));
} }
@ -70,9 +71,9 @@ public class AgentCTwoRestController {
} }
@PostMapping("/agent/two/uploadFiles") @PostMapping("/agent/two/uploadFiles")
public ResponseEntity<RestResponse> uploadFiles(@RequestParam("filename01") MultipartFile file1, public ResponseEntity<RestResponse> uploadFiles(@RequestParam("fileName01") MultipartFile file1,
@RequestParam("filename02") MultipartFile file2, @RequestParam("fileName02") MultipartFile file2,
@RequestParam("filename03") MultipartFile file3) { @RequestParam("fileName03") MultipartFile file3) {
try { try {
Map<String, String> fileNames = new HashMap<>(); Map<String, String> fileNames = new HashMap<>();
@ -92,12 +93,8 @@ public class AgentCTwoRestController {
fileName = uploadSingleFile(file3); fileName = uploadSingleFile(file3);
fileNames.put("fileName03", fileName); fileNames.put("fileName03", fileName);
} }
// 경로와 파일명 반환
Map<String, Object> response = new HashMap<>();
response.put("fileNames", fileNames);
response.put("status", "OK");
return ResponseEntity.ok(new RestResponse(HttpStatus.OK, "",response) ); return ResponseEntity.ok(new RestResponse(HttpStatus.OK, "",fileNames) );
} catch (IOException ex) { } catch (IOException ex) {
return ResponseEntity.ok(new RestResponse(HttpStatus.INTERNAL_SERVER_ERROR, "저장실패","") ); return ResponseEntity.ok(new RestResponse(HttpStatus.INTERNAL_SERVER_ERROR, "저장실패","") );

View File

@ -30,9 +30,9 @@
, SEND_PHONE , SEND_PHONE
, SUBJECT , SUBJECT
, MESSAGE , MESSAGE
, FILENAME01 , fileName01
, FILENAME02 , fileName02
, FILENAME03 , fileName03
) )
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
@ -44,9 +44,9 @@
, #{item.sendPhone} , #{item.sendPhone}
, #{item.subject} , #{item.subject}
, #{item.message} , #{item.message}
, #{fileName01} , #{item.fileName01}
, #{fileName02} , #{item.fileName02}
, #{fileName03} , #{item.fileName03}
) )
</foreach> </foreach>
</insert> </insert>

View File

@ -30,9 +30,9 @@
, SEND_PHONE , SEND_PHONE
, SUBJECT , SUBJECT
, MESSAGE , MESSAGE
, FILENAME01 , fileName01
, FILENAME02 , fileName02
, FILENAME03 , fileName03
) )
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
@ -44,9 +44,9 @@
, #{item.sendPhone} , #{item.sendPhone}
, #{item.subject} , #{item.subject}
, #{item.message} , #{item.message}
, #{fileName01} , #{item.fileName01}
, #{fileName02} , #{item.fileName02}
, #{fileName03} , #{item.fileName03}
) )
</foreach> </foreach>
</insert> </insert>

View File

@ -62,9 +62,12 @@ function fn_twoInsertCntAndTime(){
var jsonObject = {}; var jsonObject = {};
formData.forEach((value, key) => { formData.forEach((value, key) => {
if (!(value instanceof File)) {
jsonObject[key] = value; jsonObject[key] = value;
}
}); });
console.log('fn_twoInsertCntAndTime : [{}]',jsonObject);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/agent/two/findByInsertCnt", url: "/agent/two/findByInsertCnt",

View File

@ -190,13 +190,13 @@
<div class="form-group fileUploadGroup" style="display: none;"> <div class="form-group fileUploadGroup" style="display: none;">
<label for="file2">파일첨부</label> <label for="file2">파일첨부</label>
<div class="input-group"> <div class="input-group">
<input type="file" class="form-control file1" id="file2" name="filename01"> <input type="file" class="form-control file1" id="file2" name="fileName01">
</div> </div>
<div class="input-group mt-2"> <div class="input-group mt-2">
<input type="file" class="form-control file2" name="filename02"> <input type="file" class="form-control file2" name="fileName02">
</div> </div>
<div class="input-group mt-2"> <div class="input-group mt-2">
<input type="file" class="form-control file3" name="filename03"> <input type="file" class="form-control file3" name="fileName03">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -297,13 +297,13 @@
<div class="form-group fileUploadGroup" style="display: none;"> <div class="form-group fileUploadGroup" style="display: none;">
<label for="file1">파일첨부</label> <label for="file1">파일첨부</label>
<div class="input-group"> <div class="input-group">
<input type="file" class="form-control file1" id="file1" name="filename01"> <input type="file" class="form-control file1" id="file1" name="fileName01">
</div> </div>
<div class="input-group mt-2"> <div class="input-group mt-2">
<input type="file" class="form-control file2" name="filename02"> <input type="file" class="form-control file2" name="fileName02">
</div> </div>
<div class="input-group mt-2"> <div class="input-group mt-2">
<input type="file" class="form-control file3" name="filename03"> <input type="file" class="form-control file3" name="fileName03">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -841,10 +841,11 @@
// 먼저 파일을 업로드하고 파일명만 받음 // 먼저 파일을 업로드하고 파일명만 받음
var fileUploadForm = new FormData(); var fileUploadForm = new FormData();
fileUploadForm.append("filename01", formData.get("filename01")); fileUploadForm.append("fileName01", formData.get("fileName01"));
fileUploadForm.append("filename02", formData.get("filename02")); fileUploadForm.append("fileName02", formData.get("fileName02"));
fileUploadForm.append("filename03", formData.get("filename03")); fileUploadForm.append("fileName03", formData.get("fileName03"));
console.log('fileUploadForm : ', fileUploadForm);
$.ajax({ $.ajax({
type: "POST", type: "POST",
@ -853,40 +854,35 @@
processData: false, processData: false,
contentType: false, contentType: false,
success: function(response) { success: function(response) {
console.log('response : ', response);
if (response.status === 'OK') { if (response.status === 'OK') {
// 파일명만 formData에 추가 // 파일명만 formData에 추가
// 파일명 formData에 추가 // 파일명 formData에 추가
if (response.fileNames && response.fileNames.fileName01) { if (response.data.fileName01) {
formData.append("fileName01", response.fileNames.fileName01); formData.append("fileName01", response.data.fileName01);
} else {
formData.append("fileName01", "");
} }
if (response.data.fileName02) {
if (response.fileNames && response.fileNames.fileName02) { formData.append("fileName02", response.data.fileName02);
formData.append("fileName02", response.fileNames.fileName02);
} else {
formData.append("fileName02", "");
} }
if (response.data.fileName03) {
if (response.fileNames && response.fileNames.fileName03) { formData.append("fileName03", response.data.fileName03);
formData.append("fileName03", response.fileNames.fileName03);
} else {
formData.append("fileName03", "");
} }
var jsonObject = {}; var jsonObject = {};
formData.forEach((value, key) => { formData.forEach((value, key) => {
if (!(value instanceof File)) {
jsonObject[key] = value; jsonObject[key] = value;
}
}); });
if(jsonObject['recvPhone'] === ""){ if(jsonObject['recvPhone'] === ""){
alert('정보를 입력하거나 예시입력을 클릭해주세요.') alert('정보를 입력하거나 예시입력을 클릭해주세요.')
return false; return false;
} }
console.log('jsonObject : ', jsonObject);
$.ajax({ $.ajax({
type: "POST", type: "POST",