diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/HstryMapper.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/HstryMapper.java new file mode 100644 index 0000000..2b79d1c --- /dev/null +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/HstryMapper.java @@ -0,0 +1,38 @@ +package com.itn.mjonApi.mjon.api.inqry.mapper; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; + +import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO; + +/** +* @packageName : com.itn.mjonApi.mjon.api.inqry.service.mapper +* @fileName : PriceMapper.java +* @author : JunHo Lee +* @date : 2023.05.15 +* @description : +* =========================================================== +* DATE AUTHOR NOTE +* ----------------------------------------------------------- +* 2023.05.15 JunHo Lee 최초 생성 +*/ +@Mapper +public interface HstryMapper { + + /** + * @methodName : selectUserMoney + * @author : JunHo Lee + * @date : 2023.05.22 + * @description : + * @param priceVO + * @return + */ + //double selectUserMoney(String mberId); + + List selectApiInqryHstry(String mberId); + + List selectApiInqryHstryDetail(String mberId, String msgGroupId); + +} diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/PriceMapper.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/PriceMapper.java index 0ed2435..b0c2f52 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/PriceMapper.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/PriceMapper.java @@ -1,8 +1,8 @@ package com.itn.mjonApi.mjon.api.inqry.mapper; -import org.apache.ibatis.annotations.Mapper; +import java.util.Map; -import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO; +import org.apache.ibatis.annotations.Mapper; /** * @packageName : com.itn.mjonApi.mjon.api.inqry.service.mapper @@ -26,6 +26,8 @@ public interface PriceMapper { * @param priceVO * @return */ - double selectUserMoney(PriceVO priceVO); + double selectUserMoney(String mberId); + + MapselectMberPriceInfo(String mberId); } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/domain/PriceResponse.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/domain/PriceResponse.java index 8424985..4d2df95 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/domain/PriceResponse.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/mapper/domain/PriceResponse.java @@ -1,14 +1,20 @@ package com.itn.mjonApi.mjon.api.inqry.mapper.domain; -import lombok.Getter; -import lombok.Setter; +import java.time.LocalDateTime; + import org.springframework.http.HttpStatus; -import java.time.LocalDateTime; -import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; @Setter @Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor public class PriceResponse { //private HttpStatus status; @@ -17,10 +23,16 @@ public class PriceResponse { private String message; private LocalDateTime localDateTime; - - private Object object; - private List objectList; + private double shortPrice; // 단문 이용단가 + private double longPrice; // 장문 이용단가 + private double picturePrice; // 그림 이용단가 + + private double userMoney; // 잔액 + + private int shortSendPsbltEa; // 단문 발송 가능건 수 + private int longSendPsbltEa; // 장문 발송 가능건 수 + private int pictureSendPsbltEa; // 그림 발송 가능건 수 /* * 200-OK : 정상접속 @@ -34,23 +46,24 @@ public class PriceResponse { this.localDateTime = timestamp; } - public PriceResponse(HttpStatus status, String message, LocalDateTime timestamp, Object object) { - this.resultCode = status.value(); - checkMessage(status, message); - - this.object= object; - this.localDateTime = timestamp; - } +// public PriceResponse(HttpStatus status +// , String message +// , LocalDateTime timestamp +// , PriceVO priceVO +// ) { +// this.resultCode = status.value(); +// checkMessage(status, message); +// +// this.localDateTime = timestamp; +// this.shortPrice = priceVO.getShortPrice(); +// this.longPrice = priceVO.getLongPrice(); +// this.picturePrice = priceVO.getPicturePrice(); +// this.userMoney = priceVO.getUserMoney(); +// this.shortSendPsbltEa = priceVO.getShortSendPsbltEa(); +// this.longSendPsbltEa = priceVO.getLongSendPsbltEa(); +// this.pictureSendPsbltEa = priceVO.getPictureSendPsbltEa(); +// } - public PriceResponse(HttpStatus status, String message, LocalDateTime timestamp, List objectList) { - this.resultCode = status.value(); - checkMessage(status, message); - - this.objectList = objectList; - this.localDateTime = timestamp; - - } - private void checkMessage(HttpStatus status, String message) { if ("".equals(message)){ this.message = status.name(); }else { this.message = message; } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/HstryService.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/HstryService.java index 4e27d09..fa061c4 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/HstryService.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/HstryService.java @@ -1,11 +1,15 @@ package com.itn.mjonApi.mjon.api.inqry.service; +import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryDetailVO; import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryResponseVO; import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryVO; -import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO; public interface HstryService { - HstryResponseVO hstryList(MsgRequestVO msgRequestVO) throws Exception; + //HstryResponseVO hstryListOld(MsgRequestVO msgRequestVO) throws Exception; + + HstryResponseVO hstryList(HstryVO hstryVO) throws Exception; + + HstryResponseVO hstryDetailList(HstryDetailVO HstryDetailVO) throws Exception; } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/PriceService.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/PriceService.java index 81b6a61..8176c07 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/PriceService.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/PriceService.java @@ -1,6 +1,6 @@ package com.itn.mjonApi.mjon.api.inqry.service; -import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO; +import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceResponse; /** * @packageName : com.itn.mjonApi.mjon.api.inqry.service @@ -15,6 +15,6 @@ import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO; */ public interface PriceService { - double selectUserMoney(PriceVO priceVO) throws Exception; + public PriceResponse selectUserPrice(String mberId) throws Exception; } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/HstryServiceImpl.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/HstryServiceImpl.java index 18f0634..a08400b 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/HstryServiceImpl.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/HstryServiceImpl.java @@ -1,21 +1,16 @@ package com.itn.mjonApi.mjon.api.inqry.service.impl; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.catalina.connector.Response; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.itn.mjonApi.cmn.apiServer.ApiService; +import com.itn.mjonApi.mjon.api.inqry.mapper.HstryMapper; import com.itn.mjonApi.mjon.api.inqry.service.HstryService; +import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryDetailVO; import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryResponseVO; +import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryVO; import com.itn.mjonApi.mjon.api.send.mapper.SendMapper; -import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonResponseVO; -import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO; -import com.itn.mjonApi.util.MunjaUtil; import lombok.extern.slf4j.Slf4j; @@ -26,8 +21,12 @@ public class HstryServiceImpl implements HstryService { private ApiService apiService; + @Autowired + HstryMapper hstryMapper; + @Autowired SendMapper sendMapper; + @Autowired public HstryServiceImpl(ApiService apiService) { this.apiService = apiService; @@ -36,291 +35,54 @@ public class HstryServiceImpl implements HstryService { private static final String replaseStrList = "[*이름*],[*1*],[*2*],[*3*],[*4*]"; @Override - public HstryResponseVO hstryList(MsgRequestVO msgRequestVO) throws Exception { + public HstryResponseVO hstryList(HstryVO hstryVO) throws Exception { + //전체 발송 이력 log.info(" :: hstryList ::"); - //해당 id에 대한 전체 발송 리스트를 가져온다. - - - Boolean byCallFrom = sendMapper.findByCallFrom(msgRequestVO); - log.info(" :: byCallFrom ::" + byCallFrom); - if(byCallFrom){ - - } - /* - 발신번호 체크 - SELECT PHONE_NUMBER - FROM MJ_PHONE_MEMBER - WHERE 1=1 - AND USER_ID = 'goodgkdus' - AND AUTH_YN = 'Y' - AND PHM_TYPE = '01' - ORDER BY BASE_YN DESC - * */ - - //sendMsg 문자 발송 전 체크 사항 - //step1.발신자 전화번호 사용 가능 여부 체크(해당 사용자의 기 등록된 번호만 발송 가능) - // 1010 + HstryResponseVO hstryResponseVO = new HstryResponseVO(); + + try { + hstryResponseVO = HstryResponseVO.builder() + + .objectList(hstryMapper.selectApiInqryHstry(hstryVO.getMberId())) + + .build(); + + } catch (Exception e) { + log.info("selectPrice Error [{}]", e.getMessage()); + } + + return hstryResponseVO; - - //step2.수신자 전화번호 정상 여부 체크(정상 번호에 대해서만 발송 가능) - // 1020 - - //step3.문자 내용 정상 여부 확인 - 스미싱 문구는 발송 안됨 - // 1030 - - //step4.치환명 정상 여부 확인 - // 1040 - - //step5.발송일시 정상여부 확인 - // 1050 - - //step6.문자 타입에 따른 비용 처리 가능 여부 확인 - // 1060 - - - - - - - - - - String message = ""; - // 폰번호 확인 - 빈 값 -> 유효성 정규식 - message = this.getCallToListChk(msgRequestVO); - if(StringUtils.isNotEmpty(message)){ - return HstryResponseVO.builder() - .result("fail") - .message(message) - .build(); - } - - - // 치환데이터 여부 확인 - msgRequestVO.setTxtReplYn(this.getTxtReplYn(msgRequestVO)); - - if("Y".equals(msgRequestVO.getTxtReplYn())){ - - //일괄변환 문자에 콤마(,)가 들어가있으면 배열로 넘길때 문제가 발생하여 특수문자(§)로 치환하여 넘겨주도록 한다. - msgRequestVO = this.getReplaceCommaToStrSymbol(msgRequestVO); - - // 치환 후 단문 장문 개수 구하기 - msgRequestVO = getLengthOfShortAndLongMsg(msgRequestVO); - - } - - - - - - // 스팸체크 하는 부분 - MjonResponseVO spamChkEntity = apiService.postForEntity( - "/web/user/login/selectSpamTxtChkAjax.do" - , msgRequestVO - , String.class - ); - - if("spams".equals(spamChkEntity.getResult())){ - msgRequestVO.setSpamStatus("Y"); - }; - - log.info("msgRequestVO.getSpamStatus() :: [[}]",msgRequestVO.getSpamStatus()); - - // 문자 전송하는 부분 - MjonResponseVO munjaSendResponse = apiService.postForEntity( - "/web/user/login/sendMsgDataAjax.do" - , msgRequestVO - , String.class - ); - - - - System.out.println("======HstryResponseVO hstryList==="); - - return null; -// return munjaSendResponse; } - /** - * 치환 후 단문 장문 msg 개수 구하기 - * @param msgRequestVO - * @return msgRequestVO - * @throws UnsupportedEncodingException - */ - private static MsgRequestVO getLengthOfShortAndLongMsg(MsgRequestVO msgRequestVO) throws UnsupportedEncodingException { - String charset = "euc-kr"; - int totListCnt = msgRequestVO.getCallToList().length; + @Override + public HstryResponseVO hstryDetailList(HstryDetailVO hstryDetailVO) throws Exception { - int shortMsgCnt=0; // 치환 후 단문 개수 - int longMsgCnt=0; // 치환 후 장문 개수 - for(int i=0; i < totListCnt; i ++) { - String smsTxt = msgRequestVO.getSmsTxt().replaceAll(String.valueOf((char)13), ""); //발송 문자 내용 + //전체 발송 이력 + log.info(" :: hstryList ::"); - String[] nameList = msgRequestVO.getNameList(); //치환 이름 리스트 - String[] phone = msgRequestVO.getCallToList(); //수신자 휴대폰 번호 - String[] rep1 = msgRequestVO.getRep1List(); //치환 문자1 리스트 - String[] rep2 = msgRequestVO.getRep2List(); //치환 문자2 리스트 - String[] rep3 = msgRequestVO.getRep3List(); //치환 문자3 리스트 - String[] rep4 = msgRequestVO.getRep4List(); //치환 문자4 리스트 - - if (smsTxt.indexOf("[*이름*]") > -1) { - if(nameList.length > i && StringUtils.isNotEmpty(nameList[i])) { - smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", MunjaUtil.getString(nameList[i].replaceAll("§", ","))); - }else { - smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", ""); - } - } - if (smsTxt.indexOf("[*1*]") > -1) { - if(rep1.length > i && StringUtils.isNotEmpty(rep1[i])) { - smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", MunjaUtil.getString(rep1[i].replaceAll("§", ","))); - }else { - smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", ""); - } - } - if (smsTxt.indexOf("[*2*]") > -1) { - if(rep2.length > i && StringUtils.isNotEmpty(rep2[i])) { - smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", MunjaUtil.getString(rep2[i].replaceAll("§", ","))); - }else { - smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", ""); - } - } - if (smsTxt.indexOf("[*3*]") > -1) { - if(rep3.length > i && StringUtils.isNotEmpty(rep3[i])) { - smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", MunjaUtil.getString(rep3[i].replaceAll("§", ","))); - }else { - smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", ""); - } - } - if (smsTxt.indexOf("[*4*]") > -1) { - if(rep4.length > i && StringUtils.isNotEmpty(rep4[i])) { - smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", MunjaUtil.getString(rep4[i].replaceAll("§", ","))); - }else { - smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", ""); - } - } + HstryResponseVO hstryResponseVO = new HstryResponseVO(); + + try { + hstryResponseVO = HstryResponseVO.builder() + + .objectList(hstryMapper.selectApiInqryHstryDetail( + hstryDetailVO.getMberId() + , hstryDetailVO.getMsgGroupId() + )) + + .build(); + + } catch (Exception e) { + log.info("selectPrice Error [{}]", e.getMessage()); + } + + return hstryResponseVO; - int bytes = smsTxt.getBytes(charset).length; - - if(bytes > 90) {//장문문자 리스트 만들기 - longMsgCnt++; - }else {//단문문자 리스트 만들기 - shortMsgCnt++; - } - } - msgRequestVO.setLongMsgCnt(Integer.toString(longMsgCnt)); - msgRequestVO.setShortMsgCnt(Integer.toString(shortMsgCnt)); - - return msgRequestVO; - } - - /** - * 치환문자가 있으면 , => §로 치환 - * @param msgRequestVO - * @return - */ - private static MsgRequestVO getReplaceCommaToStrSymbol(MsgRequestVO msgRequestVO) { - - AtomicInteger index = new AtomicInteger(); - - // 이름 배열 - if(StringUtils.isNotEmpty(msgRequestVO.getNameStr())) - { - msgRequestVO.setNameList(msgRequestVO.getNameStr().split("\\|")); - String[] nameList = new String[msgRequestVO.getNameList().length]; - Arrays.stream(msgRequestVO.getNameList()).forEach(name -> { - nameList[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(name); - }); - msgRequestVO.setNameList(nameList); - } - - // Rep1 배열 - if(StringUtils.isNotEmpty(msgRequestVO.getRep1Str())) - { - index.set(0); - msgRequestVO.setRep1List(msgRequestVO.getRep1Str().split("\\|")); - String[] rep1List = new String[msgRequestVO.getRep1List().length]; - Arrays.stream(msgRequestVO.getRep1List()).forEach(str -> { - rep1List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str); - }); - msgRequestVO.setRep1List(rep1List); - - } - - // Rep2 배열 - if(StringUtils.isNotEmpty(msgRequestVO.getRep2Str())) - { - index.set(0); - msgRequestVO.setRep2List(msgRequestVO.getRep2Str().split("\\|")); - String[] rep2List = new String[msgRequestVO.getRep2List().length]; - Arrays.stream(msgRequestVO.getRep2List()).forEach(str -> { - rep2List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str); - }); - msgRequestVO.setRep2List(rep2List); - } - - // Rep3 배열 - if(StringUtils.isNotEmpty(msgRequestVO.getRep3Str())) - { - index.set(0); - msgRequestVO.setRep3List(msgRequestVO.getRep3Str().split("\\|")); - String[] rep3List = new String[msgRequestVO.getRep3List().length]; - Arrays.stream(msgRequestVO.getRep3List()).forEach(str -> { - rep3List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str); - }); - msgRequestVO.setRep3List(rep3List); - } - - // Rep4 배열 - if(StringUtils.isNotEmpty(msgRequestVO.getRep4Str())) - { - index.set(0); - msgRequestVO.setRep4List(msgRequestVO.getRep4Str().split("\\|")); - String[] rep4List = new String[msgRequestVO.getRep4List().length]; - Arrays.stream(msgRequestVO.getRep4List()).forEach(str -> { - rep4List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str); - }); - msgRequestVO.setRep4List(rep4List); - } - return msgRequestVO; - } - - /** - * 치환 문자 여부 확인 - * @param msgRequestVO - * @return - */ - private static String getTxtReplYn(MsgRequestVO msgRequestVO) { - - int callLen = msgRequestVO.getCallToList().length; - // 치환 데이터 확인 - Arrays.stream(replaseStrList.split(",")).forEach( - str -> { - if(msgRequestVO.getSmsTxt().indexOf(str) > -1){ - msgRequestVO.setTxtReplYn("Y"); - } - } - ); - return msgRequestVO.getTxtReplYn(); - } - - /** - * 수신자 목록 번호 검증 - * @param msgRequestVO - * @return - */ - private static String getCallToListChk(MsgRequestVO msgRequestVO) { - String message = ""; - for(String callTo : msgRequestVO.getCallToList()){ - if(!MunjaUtil.checkPhoneNumberEmpty(callTo)){ - message = "수신 목록에 핸드폰 번호가 없는 항목이 있습니다."; break;}; - if(!MunjaUtil.validatePNumWithRegex(callTo)){ - message = "휴대폰 번호가 올바르지 않습니다. : " + callTo; break;}; - } - return message; } } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/PriceServiceImpl.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/PriceServiceImpl.java index ea3b6c9..484f5cc 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/PriceServiceImpl.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/impl/PriceServiceImpl.java @@ -1,12 +1,17 @@ package com.itn.mjonApi.mjon.api.inqry.service.impl; +import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.itn.mjonApi.mjon.api.inqry.mapper.PriceMapper; +import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceResponse; import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO; import com.itn.mjonApi.mjon.api.inqry.service.PriceService; +import lombok.extern.slf4j.Slf4j; + /** * @packageName : com.itn.mjonApi.mjon.api.inqry.service.impl * @fileName : PriceServiceImpl.java @@ -18,6 +23,7 @@ import com.itn.mjonApi.mjon.api.inqry.service.PriceService; * ----------------------------------------------------------- * 2023.05.15 JunHo Lee 최초 생성 */ +@Slf4j @Service public class PriceServiceImpl implements PriceService { @@ -25,7 +31,72 @@ public class PriceServiceImpl implements PriceService { PriceMapper priceMapper; @Override - public double selectUserMoney(PriceVO priceVO) throws Exception { - return priceMapper.selectUserMoney(priceVO); + public PriceResponse selectUserPrice(String mberId) throws Exception { + + PriceResponse priceResponse = new PriceResponse(); + + try { + // 이용단가 + PriceVO priceVO = price_refine(mberId, priceMapper); + // 발송가능건수 + sendEa_refine(priceVO); + + priceResponse = PriceResponse.builder() + //1. 잔액 + .userMoney(priceMapper.selectUserMoney(mberId)) + //2. 이용단가 + .shortPrice(priceVO.getShortPrice()) + .longPrice(priceVO.getLongPrice()) + .picturePrice(priceVO.getPicturePrice()) + //3. 발송가능건수 + .shortSendPsbltEa(0) + .longSendPsbltEa(0) + .pictureSendPsbltEa(0) + .build(); + + } catch (Exception e) { + log.info("selectPrice Error [{}]", e.getMessage()); + } + + return priceResponse; } + + private PriceVO price_refine(String mberId, PriceMapper priceMapper) { + + double sys_shortPrice = 0.0f; + double sys_longPrice = 0.0f; + double sys_picturePrice = 0.0f; + + double shortPrice = 0.0f; + double longPrice = 0.0f; + double picturePrice = 0.0f; + + //1.시스템 기본 단가 정보 불러오기 + //2.사용자 개인 단가 정보 불러오기 + Map priceMap = priceMapper.selectMberPriceInfo(mberId); + + sys_shortPrice = Double.parseDouble(String.valueOf(priceMap.get("sysShortPrice"))); + sys_longPrice = Double.parseDouble(String.valueOf(priceMap.get("sysLongPrice"))); + sys_picturePrice = Double.parseDouble(String.valueOf(priceMap.get("sysPicturePrice"))); + + shortPrice = Double.parseDouble(String.valueOf(priceMap.get("shortPrice"))); + longPrice = Double.parseDouble(String.valueOf(priceMap.get("longPrice"))); + picturePrice = Double.parseDouble(String.valueOf(priceMap.get("picturePrice"))); + + // SMS 인경우 + // 사용자 개인 단가가 없으면 시스템 단가로 + PriceVO priceVO = PriceVO.builder() + .shortPrice(shortPrice == 0.0f ? sys_shortPrice : shortPrice) + .longPrice(longPrice == 0.0f ? sys_longPrice : longPrice) + .picturePrice(picturePrice == 0.0f ? sys_picturePrice : picturePrice) + .build(); + return priceVO; + } + + private PriceVO sendEa_refine(PriceVO priceVO) { + + return priceVO; + + } + } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryDetailVO.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryDetailVO.java new file mode 100644 index 0000000..b0f3dae --- /dev/null +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryDetailVO.java @@ -0,0 +1,48 @@ +package com.itn.mjonApi.mjon.api.inqry.service.mapper.domain; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(description = "전체 발송 정보에 필요한 값들을 받는 vo") +public class HstryDetailVO implements Serializable{ + + private static final long serialVersionUID = -7865729705175845268L; + + @ApiModelProperty(value = "사용자 ID", example = "goodgkdus", required = true) + private String mberId; + + @ApiModelProperty(value = "Api Key", example = "0367a25ec370d1141898a0b9767103", required = true) + private String accessKey; + + @ApiModelProperty(value = "msg_group_id", example = "MSGGID_0000000011418", required = true) + private String msgGroupId; + + @ApiModelProperty(value = "page 번호", example = "1") + private String page; + + @ApiModelProperty(value = "page 당 출력갯수 30~500", example = "30") + private String pageSize; + + + + //private String mberId; // 사용자 ID + +// private double shortPrice; // 단문 이용단가 +// private double longPrice; // 장문 이용단가 +// private double picturePrice; // 그림 이용단가 + +// private double userMoney; // 잔액 + +// private int sendPsbltEa; //발송 가능건 수 + +} diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryResponseVO.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryResponseVO.java index 5295d91..064f46f 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryResponseVO.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryResponseVO.java @@ -1,9 +1,16 @@ package com.itn.mjonApi.mjon.api.inqry.service.mapper.domain; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.*; -import org.springframework.http.ResponseEntity; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.http.HttpStatus; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * packageName : com.itn.mjonApi.cmn.msg @@ -22,28 +29,62 @@ import org.springframework.http.ResponseEntity; @NoArgsConstructor @AllArgsConstructor public class HstryResponseVO { + + //private HttpStatus status; + private int resultCode; - private String result; private String message; - private String resultSts; // 전송결과 갯수 - private String resultBlockSts; // 수신거부 갯수 - private String msgGroupId; - private String afterCash; + private LocalDateTime localDateTime; + + + private List objectList; //목록 배열 + //mid - 메시지ID + //type - 문자구분(유형) + //sender - 발신번호 + //sms_count - 전송요청수 + //reserve_state - 요청상태 + //msg - 메시지 내용 + //fail_count - 처리실패건수 + //reg_date - 등록일 + //reserve - 예약일자 + + private String next_yn; // 다음 조회 목록여부 + + /* + * 200-OK : 정상접속 + * 401-Unauthorized : 인증실패 + * + * */ - - /** - * - * @param stringResponseEntity - * @return ResponseEntity vo convert - * @throws JsonProcessingException - */ - public static HstryResponseVO getMjonResponse(ResponseEntity stringResponseEntity) throws JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - - HstryResponseVO mjonResponseVO = objectMapper.readValue(stringResponseEntity.getBody(), HstryResponseVO.class); - return mjonResponseVO; + public HstryResponseVO(HttpStatus status, String message, LocalDateTime timestamp) { + this.resultCode = status.value(); + checkMessage(status, message); + this.localDateTime = timestamp; } + +// public PriceResponse(HttpStatus status +// , String message +// , LocalDateTime timestamp +// , PriceVO priceVO +// ) { +// this.resultCode = status.value(); +// checkMessage(status, message); +// +// this.localDateTime = timestamp; +// this.shortPrice = priceVO.getShortPrice(); +// this.longPrice = priceVO.getLongPrice(); +// this.picturePrice = priceVO.getPicturePrice(); +// this.userMoney = priceVO.getUserMoney(); +// this.shortSendPsbltEa = priceVO.getShortSendPsbltEa(); +// this.longSendPsbltEa = priceVO.getLongSendPsbltEa(); +// this.pictureSendPsbltEa = priceVO.getPictureSendPsbltEa(); +// } + + private void checkMessage(HttpStatus status, String message) { + if ("".equals(message)){ this.message = status.name(); + }else { this.message = message; } + } } diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryVO.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryVO.java index 61594ad..5bacf98 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryVO.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/service/mapper/domain/HstryVO.java @@ -2,16 +2,42 @@ package com.itn.mjonApi.mjon.api.inqry.service.mapper.domain; import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(description = "전체 발송 정보에 필요한 값들을 받는 vo") public class HstryVO implements Serializable{ private static final long serialVersionUID = -7865729705175845268L; - private String mberId; // 사용자 ID + @ApiModelProperty(value = "사용자 ID", example = "goodgkdus", required = true) + private String mberId; + + @ApiModelProperty(value = "Api Key", example = "0367a25ec370d1141898a0b9767103", required = true) + private String accessKey; + + @ApiModelProperty(value = "page 번호", example = "1") + private String page; + + @ApiModelProperty(value = "page 당 출력갯수 30~500", example = "30") + private String pageSize; + + @ApiModelProperty(value = "조회시작일자 기본값 오늘", example = "20230523") + private String startDate; + + @ApiModelProperty(value = "조회마감일자 기본값 내일", example = "20230524") + private String endDate; + + + //private String mberId; // 사용자 ID // private double shortPrice; // 단문 이용단가 // private double longPrice; // 장문 이용단가 diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/HstryRestController.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/HstryRestController.java index 220ef1c..bebfa24 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/HstryRestController.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/HstryRestController.java @@ -1,14 +1,16 @@ package com.itn.mjonApi.mjon.api.inqry.web; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import com.itn.mjonApi.mjon.api.inqry.service.HstryService; +import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryDetailVO; import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryResponseVO; -import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO; +import com.itn.mjonApi.mjon.api.inqry.service.mapper.domain.HstryVO; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -39,21 +41,38 @@ public class HstryRestController { @Autowired private HstryService hstryService; - - - /** - * - * @param msgRequestVO - * @Discription 문자 발송 테스트 - * @return - */ - @CrossOrigin("*") // 모든 요청에 접근 허용 - @PostMapping("/api/inqry/hstry") - @ApiOperation(value= "전송 내역 조회", notes = "전체 전송 내역 조회") - public HstryResponseVO inqryHstry(MsgRequestVO msgRequestVO) throws Exception { - - return hstryService.hstryList(msgRequestVO); - - } + /** + * + * @param msgRequestVO + * @Discription 문자 발송 테스트 + * @return + */ + @CrossOrigin("*") // 모든 요청에 접근 허용 + @PostMapping("/api/inqry/hstry") + @ApiOperation(value= "전송 내역 조회", notes = "전체 전송 내역 조회") + public ResponseEntity apiInqryHstry(HstryVO hstryVO) throws Exception { + + return ResponseEntity.ok(hstryService.hstryList(hstryVO)); + + //return sendService.sendMsgData(msgRequestVO); + + } + + /** + * + * @param msgRequestVO + * @Discription 문자 발송 테스트 + * @return + */ + @CrossOrigin("*") // 모든 요청에 접근 허용 + @PostMapping("/api/inqry/hstryDetail") + @ApiOperation(value= "전송 내역 조회(상세)", notes = "상세 전송 내역 조회") + public ResponseEntity apiInqryHstryDetail(HstryDetailVO hstryDetailVO) throws Exception { + + return ResponseEntity.ok(hstryService.hstryDetailList(hstryDetailVO)); + + //return sendService.sendMsgData(msgRequestVO); + + } } \ No newline at end of file diff --git a/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/PriceRestController.java b/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/PriceRestController.java index f6006ff..7b58d99 100644 --- a/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/PriceRestController.java +++ b/src/main/java/com/itn/mjonApi/mjon/api/inqry/web/PriceRestController.java @@ -1,9 +1,6 @@ package com.itn.mjonApi.mjon.api.inqry.web; -import java.time.LocalDateTime; - import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -12,8 +9,6 @@ import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceResponse; import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO; import com.itn.mjonApi.mjon.api.inqry.service.PriceService; -import lombok.extern.slf4j.Slf4j; - /** * @packageName : com.itn.mjonApi.mjon.api.inqry.web * @fileName : PriceRestController.java @@ -25,7 +20,6 @@ import lombok.extern.slf4j.Slf4j; * ----------------------------------------------------------- * 2023.05.15 JunHo Lee 최초 생성 */ -@Slf4j @RestController public class PriceRestController { @@ -37,28 +31,11 @@ public class PriceRestController { * @author : JunHo Lee * @date : 2023.05.16 * @return + * @throws Exception */ @PostMapping("/api/inqry/selectPrice") - public ResponseEntity selectPrice(PriceVO priceVO){ + public ResponseEntity selectPrice(PriceVO priceVO) throws Exception{ - PriceVO resultVO = new PriceVO(); - - System.out.println(priceVO.getMberId()); - //1. 잔액 - try { -// resultVO.builder() -// .userMoney(priceService.selectUserMoney(priceVO)).b; - resultVO = PriceVO.builder() - .userMoney(priceService.selectUserMoney(priceVO)) - .build(); - //2. 이용단가 - - //3. 발송가능건수 - - } catch (Exception e) { - log.info("selectPrice Error [{}]", e.getMessage()); - } - return ResponseEntity.ok(new PriceResponse(HttpStatus.OK, "test" , LocalDateTime.now(), resultVO.getUserMoney())); - } - + return ResponseEntity.ok(priceService.selectUserPrice(priceVO.getMberId())); + } } diff --git a/src/main/resources/mapper/api/inqry/HstryMapper.xml b/src/main/resources/mapper/api/inqry/HstryMapper.xml new file mode 100644 index 0000000..7e7314a --- /dev/null +++ b/src/main/resources/mapper/api/inqry/HstryMapper.xml @@ -0,0 +1,466 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/api/inqry/PriceMapper.xml b/src/main/resources/mapper/api/inqry/PriceMapper.xml index d358f72..5f94722 100644 --- a/src/main/resources/mapper/api/inqry/PriceMapper.xml +++ b/src/main/resources/mapper/api/inqry/PriceMapper.xml @@ -6,14 +6,33 @@ + + \ No newline at end of file