초기소스

This commit is contained in:
jazz
2025-10-29 17:08:05 +09:00
parent e531aa9540
commit 439a379a02
7551 changed files with 1234427 additions and 3 deletions

View File

@@ -0,0 +1,193 @@
package com.wb.domainserver.domain.gcone.app.controller;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wb.domainserver.common.prop.PaginationProperties;
import com.wb.domainserver.domain.gcone.app.service.BOAppService;
import com.wb.domainserver.domain.gcone.app.service.BOFCMNotificationService;
import com.wb.domainserver.domain.gcone.app.vo.BOAppMbrDvcVO;
import com.wb.domainserver.domain.gcone.bnft.bnftmngr.vo.BOBnftMngrPushVO;
import com.wb.domainserver.response.ApiResponse;
import com.wb.domainserver.security.authentication.AnonymousUser;
import com.wb.domainserver.security.authentication.MemberJwtContextHolder;
import com.wb.domainserver.security.authorization.annotation.AuthPolicy;
import com.wb.domainserver.security.authorization.annotation.Policy;
import com.wb.domainserver.util.communicate.SendToResrc;
import lombok.extern.slf4j.Slf4j;
/**
* 앱기능 처리 BO Controller
*
* @author 이훈영
* @since 2024-11-26
* @version 1.0
* @see
*
* <pre>
* == (Modification Information) == 개정이력
*
* 수정일 수정자 수정내용
* ------- -------- ---------------------------/mngr/bnft/sttus
* 2024-11-26 이훈영 최초 생성
*
* </pre>
*/
@Slf4j
@RestController
public class BOAppController {
@Autowired
private BOAppService service;
@Autowired
private BOFCMNotificationService fcmservice;
@Autowired
private SendToResrc sendToResrc;
@Autowired
private PaginationProperties paginationProperties;
/**
* 앱디바이스 정보 입력/수정
*
* @param vo
* @return ResponseEntity
*/
@Policy(AuthPolicy.PUBLIC)
@RequestMapping(value = "/gcone/app/insertBOAppDeviceInfo", method = RequestMethod.POST)
public ResponseEntity<?> insertBOAppDeviceInfo(@RequestBody BOAppMbrDvcVO vo) throws UnknownHostException {
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if ("01".equals(user.getSysDvCd())) {
vo.setSopmalCd(user.getSopmalCd());
}
//log.debug("@@@@@@@@@@ BOAppMbrDvcVO ::: {}", vo);
Integer dplct = service.selectBOAppMbrDvcDplct(vo);
Map<String, Object> message = new HashMap<>();
if(dplct < 1) {
message = service.insertBOAppDeviceInfo(vo);
} else {
// 중복된 deviceId가 있을 경우, 디바이스정보를 update한다.
message = service.updateBOAppDeviceInfo(vo);
}
return ApiResponse.of(message).ifPresentOrElse(HttpStatus.OK, HttpStatus.NOT_FOUND);
}
/**
* 앱 로그인시 디바이스-회원정보 정보 입력/수정
*
* @param vo
* @return ResponseEntity
*/
@Policy(AuthPolicy.PUBLIC)
@RequestMapping(value = "/gcone/app/insertBOAppMbrDvcInfo", method = RequestMethod.POST)
public ResponseEntity<?> insertBOMbrDvcInfo(@RequestBody BOAppMbrDvcVO vo) throws UnknownHostException {
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if ("01".equals(user.getSysDvCd())) {
vo.setSopmalCd(user.getSopmalCd());
}
if (user.getUserInnb() > 0) {
vo.setMbrInnb(Long.valueOf(user.getUserInnb()));
vo.setMbrDvCd(user.getMbrDvCd());
vo.setMbrId(user.getMbrId());
}
//log.debug("@@@@@@@@@@ BOAppMbrDvcVO ::: {}", vo);
Integer dplct = service.selectBOAppMbrDvcDplct(vo);
Map<String, Object> message = new HashMap<>();
if(dplct < 1) {
message = service.insertBOAppMbrDvcInfo(vo);
} else {
// 중복된 deviceId가 있을 경우, 디바이스 및 회원정보를 update한다.
message = service.updateBOAppMbrDvcInfo(vo);
}
return ApiResponse.of(message).ifPresentOrElse(HttpStatus.OK, HttpStatus.NOT_FOUND);
}
/**
* 푸시 발송
*
* @param vo
* @return ResponseEntity
*/
@Policy(AuthPolicy.PUBLIC)
@RequestMapping(value = "/gcone/app/procPushNotification", method = RequestMethod.POST)
public ResponseEntity<?> procPushNotification(@RequestBody BOBnftMngrPushVO vo) throws UnknownHostException {
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if ("01".equals(user.getSysDvCd())) {
vo.setSopmalCd(user.getSopmalCd());
}
Long[] arrMbrDeviceInnb = vo.getArrMbrDeviceInnb();
String[] arrFcmToken = vo.getArrFcmToken();
log.debug("@@@@@@@@@@ BOBnftMngrPushVO ::: {}", vo);
Map<String, Object> message = new HashMap<>();
for (int i = 0; i < arrFcmToken.length; i++) {
Long mbrDeviceInnb = arrMbrDeviceInnb[i];
vo.setFcmToken(arrFcmToken[i]);
// FCM 전송 로직
String resultCode = fcmservice.sendPush(vo);
message.put(mbrDeviceInnb.toString(), resultCode);
message.put("result", "success");
}
return ApiResponse.of(message).ifPresentOrElse(HttpStatus.OK, HttpStatus.NOT_FOUND);
}
/**
* 푸시 발송 임시
*
* @param vo
* @return ResponseEntity
*/
@Policy(AuthPolicy.PUBLIC)
@RequestMapping(value = "/gcone/app/procPushNotificationImsi", method = RequestMethod.POST)
public ResponseEntity<?> procPushNotificationImsi(@RequestBody BOBnftMngrPushVO vo) throws UnknownHostException {
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if ("01".equals(user.getSysDvCd())) {
vo.setSopmalCd(user.getSopmalCd());
}
//Long[] arrMbrDeviceInnb = vo.getArrMbrDeviceInnb();
String[] arrFcmToken = vo.getArrFcmToken();
log.debug("@@@@@@@@@@ BOBnftMngrPushVO ::: {}", vo);
Map<String, Object> message = new HashMap<>();
for (int i = 0; i < arrFcmToken.length; i++) {
//Long mbrDeviceInnb = arrMbrDeviceInnb[i];
vo.setFcmToken(arrFcmToken[i]);
// FCM 전송 로직
String resultCode = fcmservice.sendPush(vo);
//result.put(mbrDeviceInnb.toString(), resultCode);
message.put("result", resultCode);
}
return ApiResponse.of(message).ifPresentOrElse(HttpStatus.OK, HttpStatus.NOT_FOUND);
}
}

View File

@@ -0,0 +1,51 @@
package com.wb.domainserver.domain.gcone.app.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import com.wb.domainserver.domain.gcone.app.vo.BOAppMbrDvcVO;
import com.wb.domainserver.util.dataaccess.DataMap;
/**
*
* 앱기능 처리 BOAppMapper
* @author 이훈영
* @since 2024-11-26
* @version 1.0
* @see
*
* <pre>
* == (Modification Information) == 개정이력
*
* 수정일 수정자 수정내용
* ------- -------- ---------------------------
* 2024-11-26 이훈영 최초 생성
*
* </pre>
*/
@Mapper
@Repository
public interface BOAppMapper {
/** 앱 실행시 디바이스 정보 등록 */
public void insertBOAppDeviceInfo(BOAppMbrDvcVO vo);
/** 앱 실행시 디바이스 정보 수정 */
public void updateBOAppDeviceInfo(BOAppMbrDvcVO vo);
/** 앱 로그인시 회원-디바이스 정보 등록 */
public void insertBOAppMbrDvcInfo(BOAppMbrDvcVO vo);
/** 앱 로그인시 회원-디바이스 정보 수정 */
public void updateBOAppMbrDvcInfo(BOAppMbrDvcVO vo);
/** 앱 알림동의 선택시 수정 */
public void updateBOAppMbrDvcPushAgre(BOAppMbrDvcVO vo);
/** 앱 신체활동접근동의 선택시 수정 */
public void updateBOAppMbrDvcPhacAgre(BOAppMbrDvcVO vo);
/** 디바이스 정보 조회 */
public List<DataMap> selectBOAppMbrDvcInfo(BOAppMbrDvcVO vo);
/** 디바이스 정보 중복 조회 */
public Integer selectBOAppMbrDvcDplct(BOAppMbrDvcVO vo);
}

View File

@@ -0,0 +1,165 @@
package com.wb.domainserver.domain.gcone.app.service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.wb.domainserver.domain.gcone.app.mapper.BOAppMapper;
import com.wb.domainserver.domain.gcone.app.vo.BOAppMbrDvcVO;
import com.wb.domainserver.exception.WnbtRestException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
/**
*
* 앱기능 처리 Service
* @author 이훈영
* @since 2024-11-26
* @version 1.0
* @see
*
* <pre>
* == (Modification Information) == 개정이력
*
* 수정일 수정자 수정내용
* ------- -------- ---------------------------
* 2024-11-26 이훈영 최초 생성
*
* </pre>
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class BOAppService {
@Autowired
private BOAppMapper mapper;
private boolean enabled = false;
@Autowired
private Environment environment;
/**
* 조회
* @param BOAppMbrDvcVO vo
* @return List<DataMap>
*/
//public List<DataMap> selectBOAppMbrDvcListInqire(BOAppMbrDvcVO vo) {
// List<DataMap> resultList = mapper.selectBOBnftRwdList(vo);
// return resultList;
//}
/**
* 앱 실행시 디바이스 정보 등록
* @param vo
* @return Map
*/
public Map<String, Object> insertBOAppDeviceInfo(BOAppMbrDvcVO vo) {
Map<String, Object> message = new HashMap<>();
try {
mapper.insertBOAppDeviceInfo(vo);
message.put("deviceId", vo.getDeviceId());
message.put("result", "success");
} catch (Exception e) {
throw new WnbtRestException(e.getMessage());
}
return message;
}
/**
* 앱 실행시 디바이스 정보 수정
* @param vo
* @return Map
*/
public Map<String, Object> updateBOAppDeviceInfo(BOAppMbrDvcVO vo) {
Map<String, Object> message = new HashMap<>();
try {
mapper.updateBOAppDeviceInfo(vo);
message.put("deviceId", vo.getDeviceId());
message.put("result", "success");
} catch (Exception e) {
throw new WnbtRestException(e.getMessage());
}
return message;
}
/**
* 앱 로그인시 디바이스-회원정보 정보 등록
* @param vo
* @return Map
*/
public Map<String, Object> insertBOAppMbrDvcInfo(BOAppMbrDvcVO vo) {
Map<String, Object> message = new HashMap<>();
try {
mapper.insertBOAppMbrDvcInfo(vo);
message.put("deviceId", vo.getDeviceId());
message.put("mbrId", vo.getMbrId());
message.put("result", "success");
} catch (Exception e) {
throw new WnbtRestException(e.getMessage());
}
return message;
}
/**
* 앱 로그인시 디바이스-회원정보 정보 수정
* @param vo
* @return Map
*/
public Map<String, Object> updateBOAppMbrDvcInfo(BOAppMbrDvcVO vo) {
Map<String, Object> message = new HashMap<>();
try {
mapper.updateBOAppMbrDvcInfo(vo);
message.put("deviceId", vo.getDeviceId());
message.put("mbrId", vo.getMbrId());
message.put("result", "success");
} catch (Exception e) {
throw new WnbtRestException(e.getMessage());
}
return message;
}
/**
* 디바이스 정보 중복 조회
* @param vo
* @return Integer
*/
public Integer selectBOAppMbrDvcDplct(BOAppMbrDvcVO vo) {
return mapper.selectBOAppMbrDvcDplct(vo);
}
//@Scheduled(cron = "*/10 * * * * *") // 10초 : */10 * * * * *
//@SchedulerLock(name = "BOAppService.processTask", lockAtLeastFor = "4s", lockAtMostFor = "8s")
public void processTask() {
// 현재 활성화된 프로파일을 확인
String[] activeProfiles = environment.getActiveProfiles();
String currentProfile = "Unknown Profile";
if (activeProfiles.length > 0) {
currentProfile = activeProfiles[0]; // 첫 번째 활성 프로파일 사용
}
// 현재 시간을 "yyyy-MM-dd HH:mm:ss" 형식으로 변환
String formattedTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
System.out.println("@@@@@@@@@@@@ 실행시간 : " + formattedTime + ", Profile : " + currentProfile);
}
}

View File

@@ -0,0 +1,96 @@
package com.wb.domainserver.domain.gcone.app.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.google.firebase.messaging.Notification;
import com.wb.domainserver.domain.gcone.bnft.bnftmngr.vo.BOBnftMngrPushVO;
import com.wb.domainserver.security.authentication.AnonymousUser;
import com.wb.domainserver.security.authentication.MemberJwtContextHolder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
*
* 혜택 출석체크 관리 Service
* @author 이훈영
* @since 2024-12-02
* @version 1.0
* @see
*
* <pre>
* == (Modification Information) == 개정이력
*
* 수정일 수정자 수정내용
* ------- -------- ---------------------------
* 2024-12-02 이훈영 최초 생성
*
* </pre>
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class BOFCMNotificationService {
@Qualifier("NCFirebaseMessaging")
@Autowired
private FirebaseMessaging ncFirebaseMessaging;
@Qualifier("DTFirebaseMessaging")
@Autowired
private FirebaseMessaging dtFirebaseMessaging;
public String sendPush(@RequestBody BOBnftMngrPushVO vo) {
String resultCode = "";
String sopmalCd = vo.getSopmalCd();
String pushKey = vo.getFcmToken();
String title = vo.getPushSj();
String body = vo.getPushCn();
String pushType = vo.getPushType();
String data = vo.getPushData();
String imgsrc = vo.getImgFilCours();
// FirebaseMessaging 객체 선택
FirebaseMessaging selectedMessaging;
if ("NC".equals(sopmalCd)) {
selectedMessaging = ncFirebaseMessaging;
} else if ("DT".equals(sopmalCd)) {
selectedMessaging = dtFirebaseMessaging;
} else {
throw new IllegalArgumentException("Invalid sopmalCd: " + sopmalCd);
}
// Notification 생성
Notification notification = Notification.builder()
.setTitle(title)
.setBody(body)
.setImage(imgsrc)
.build();
// Message 생성
Message message = Message.builder()
.setToken(pushKey)
.setNotification(notification)
.putData("pushType", pushType)
.putData("data", data)
.build();
try {
// 선택된 FirebaseMessaging으로 메시지 전송
String response = selectedMessaging.send(message);
resultCode = "200";
} catch (FirebaseMessagingException fe) {
fe.printStackTrace();
resultCode = "-1";
}
return resultCode;
}
}

View File

@@ -0,0 +1,60 @@
package com.wb.domainserver.domain.gcone.app.vo;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import com.wb.domainserver.domain.comm.vo.AbstractVO;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
* 회원 디바이스정보 VO
* @author 이훈영
* @since 2024-11-26
* @version 1.0
* @see
*
* <pre>
* == (Modification Information) == 개정이력
*
* 수정일 수정자 수정내용----------------------------혜택 통계
* ------- -------- ---------------------------/mngr/bnft/sttus
* 2024-11-26 이훈영 최초 생성
*
* </pre>
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class BOAppMbrDvcVO {
private static final long serialVersionUID = 1L;
/** 쇼핑몰 코드 */
private String sopmalCd;
/** 회원 디바이스 고유번호 */
private Long mbrDeviceInnb;
/** 회원 고유번호 */
private Long mbrInnb;
/** 회원 구분 코드 */
private String mbrDvCd;
/** 회원 ID */
private String mbrId;
/** FCM 토큰 */
private String fcmToken;
/** 알림 동의 여부 */
private String pushAgreAt;
/** 신체활동접근 동의 여부 */
private String phacAgreAt;
/** 디바이스 고유 ID */
private String deviceId;
/** 운영체제 이름 */
private String deviceOsNm;
/** 운영체제 버전 */
private String deviceOsVer;
/** 앱 버전 */
private String deviceAppVer;
}