이준호 문자온 api 커밋
- 요금내역 조회 개발중
This commit is contained in:
parent
820fa2d58a
commit
fd0aaa2ea5
@ -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);
|
||||
|
||||
Map<String, String>selectMberPriceInfo(String mberId);
|
||||
|
||||
}
|
||||
|
||||
@ -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; }
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
||||
@ -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<String, String> 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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<PriceResponse> selectPrice(PriceVO priceVO){
|
||||
public ResponseEntity<PriceResponse> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,14 +6,33 @@
|
||||
<mapper namespace="com.itn.mjonApi.mjon.api.inqry.mapper.PriceMapper">
|
||||
|
||||
<select id="selectUserMoney"
|
||||
resultType="com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO"
|
||||
resultType="double"
|
||||
>
|
||||
|
||||
SELECT a.MBER_ID AS mberId,
|
||||
a.USER_MONEY AS userMoney
|
||||
SELECT a.USER_MONEY AS userMoney
|
||||
FROM lettngnrlmber a
|
||||
WHERE a.MBER_ID = #{mberId}
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectMberPriceInfo"
|
||||
resultType="hashmap"
|
||||
>
|
||||
|
||||
SELECT a.SHORT_PRICE AS sysShortPrice,
|
||||
a.LONG_PRICE AS sysLongPrice,
|
||||
a.PICTURE_PRICE AS sysPicturePrice,
|
||||
a.PICTURE2_PRICE AS sysPicturePrice2,
|
||||
a.PICTURE3_PRICE AS sysPicturePrice3,
|
||||
b.SHORT_PRICE AS shortPrice,
|
||||
b.LONG_PRICE AS longPrice,
|
||||
b.PICTURE_PRICE AS picturePrice,
|
||||
b.PICTURE2_PRICE AS picturePrice2,
|
||||
b.PICTURE3_PRICE AS picturePrice3
|
||||
FROM mj_mber_setting a ,
|
||||
lettngnrlmber b
|
||||
WHERE b.mber_id = #{mberId}
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user