Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>net.nurigo</groupId>
<artifactId>sdk</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

@SpringBootApplication
@ServletComponentScan
@MapperScan("com.barogagi")
//@MapperScan("com.barogagi")
@MapperScan(basePackages = "com.barogagi.**.mapper") // MyBatis 매퍼만 있는 경로로 제한
Comment on lines +10 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

매퍼 스캔 패턴 변경에 대한 검증 필요

@MapperScan 설정을 전체 패키지(com.barogagi)에서 특정 매퍼 패키지(com.barogagi.**.mapper)로 제한하는 것은 성능상 이점이 있지만, 기존 매퍼들이 새로운 패턴에 맞는 위치에 있는지 확인이 필요합니다.

또한 주석 처리된 코드는 제거하는 것이 좋습니다.

다음 스크립트를 실행하여 기존 매퍼 인터페이스들의 위치를 확인해 주세요:

-//@MapperScan("com.barogagi")
-@MapperScan(basePackages = "com.barogagi.**.mapper")  // MyBatis 매퍼만 있는 경로로 제한
+@MapperScan(basePackages = "com.barogagi.**.mapper")  // MyBatis 매퍼만 있는 경로로 제한

🏁 Script executed:

#!/bin/bash
# 기존 매퍼 인터페이스들이 새로운 스캔 패턴에 포함되는지 확인

echo "=== 현재 프로젝트의 모든 매퍼 인터페이스 위치 확인 ==="
fd -e java -x grep -l "@Mapper\|extends.*Mapper" {} \; | head -20

echo -e "\n=== com.barogagi 패키지 하위의 매퍼 관련 파일들 ==="
fd -t f -e java . src/main/java/com/barogagi | grep -i mapper

echo -e "\n=== MyBatis XML 매퍼 파일들 ==="
fd -e xml . src/main/resources | head -10

Length of output: 1852


매퍼 스캔 설정 검증 완료 및 주석 코드 제거 제안

새로 지정한 basePackages = "com.barogagi.**.mapper" 패턴이 프로젝트 내 모든 Mapper 인터페이스를 정확히 포함함을 확인했습니다. 스캔 범위 변경으로 인한 누락 이슈는 없습니다.

아래처럼 이전 주석 처리된 설정만 삭제해 주세요.

- //@MapperScan("com.barogagi")
  @MapperScan(basePackages = "com.barogagi.**.mapper")  // MyBatis 매퍼만 있는 경로로 제한
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//@MapperScan("com.barogagi")
@MapperScan(basePackages = "com.barogagi.**.mapper") // MyBatis 매퍼만 있는 경로로 제한
@MapperScan(basePackages = "com.barogagi.**.mapper") // MyBatis 매퍼만 있는 경로로 제한
🤖 Prompt for AI Agents
In src/main/java/com/Application.java around lines 10 to 11, remove the
commented-out old @MapperScan annotation to clean up the code since the new
basePackages setting "com.barogagi.**.mapper" correctly covers all Mapper
interfaces without omissions.

public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.barogagi.approval.vo.ApprovalSendVO;
import com.barogagi.approval.vo.ApprovalVO;
import com.barogagi.response.ApiResponse;
import com.barogagi.sendSms.dto.SendSmsVO;
import com.barogagi.sendSms.service.SendSmsService;
import com.barogagi.util.EncryptUtil;
import com.barogagi.util.InputValidate;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -22,26 +24,26 @@
public class ApprovalController {
private static final Logger logger = LoggerFactory.getLogger(ApprovalController.class);

private final InputValidate inputValidate;
private final EncryptUtil encryptUtil;
private final AuthCodeService authCodeService;
private final ApprovalService approvalService;
@Autowired
private InputValidate inputValidate;

private final String API_SECRET_KEY;
@Autowired
private EncryptUtil encryptUtil;

@Autowired
public ApprovalController(Environment environment,
InputValidate inputValidate,
EncryptUtil encryptUtil,
AuthCodeService authCodeService,
ApprovalService approvalService){
private AuthCodeService authCodeService;

this.API_SECRET_KEY = environment.getProperty("api.secret-key");
@Autowired
private ApprovalService approvalService;

@Autowired
private SendSmsService sendSmsService;

private final String API_SECRET_KEY;

this.inputValidate = inputValidate;
this.encryptUtil = encryptUtil;
this.authCodeService = authCodeService;
this.approvalService = approvalService;
@Autowired
public ApprovalController(Environment environment){
this.API_SECRET_KEY = environment.getProperty("api.secret-key");
}

@Operation(summary = "인증번호 발송", description = "휴대전화번호로 인증번호 발송하는 기능입니다.")
Expand All @@ -66,6 +68,10 @@ public ApiResponse approvalTelSend(@RequestBody ApprovalSendVO approvalSendVO) {
message = "인증번호를 발송할 전화번호를 입력해주세요.";

} else{

// 전화번호
String recipientTel = approvalSendVO.getTel();

// 인증번호를 DB에 INSERT 전에, 전에 발송된 기록들은 flag UPDATE 처리
approvalVO.setCompleteYn("N");
approvalVO.setType(approvalSendVO.getType());
Expand All @@ -80,20 +86,34 @@ public ApiResponse approvalTelSend(@RequestBody ApprovalSendVO approvalSendVO) {
String authCode = authCodeService.generateAuthCode();
logger.info("@@ authCode={}", authCode);

// 인증번호 메시지 발송
SendSmsVO sendSmsVO = new SendSmsVO();
sendSmsVO.setRecipientTel(recipientTel);
String messageContent = "인증번호는 [" + authCode + "] 입니다.";
sendSmsVO.setMessageContent(messageContent);
boolean sendMessageResult = sendSmsService.sendSms(sendSmsVO);
logger.info("@@ sendMessageResult={}", sendMessageResult);

// 인증번호 암호화
approvalVO.setAuthCode(encryptUtil.hashEncodeString(authCode));

// 인증번호를 DB에 insert
int insertResult = approvalService.insertApprovalRecord(approvalVO);
logger.info("@@ insertResult={}", insertResult);
if(insertResult > 0) {
// 인증번호 발송 로직
resultCode = "200";
message = "인증번호가 발송되었습니다.";

} else{
resultCode = "102";
message = "오류가 발생하였습니다.";
if(sendMessageResult){
approvalVO.setMessageContent(sendSmsVO.getMessageContent());
int insertResult = approvalService.insertApprovalRecord(approvalVO);
logger.info("@@ insertResult={}", insertResult);
if(insertResult > 0) {
// 인증번호 발송 로직
resultCode = "200";
message = "인증번호 발송에 성공하었습니다.";

} else{
resultCode = "102";
message = "오류가 발생하였습니다.";
}
} else {
resultCode = "103";
message = "인증번호 발송에 실패하였습니다.";
}
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/barogagi/approval/vo/ApprovalVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ public class ApprovalVO extends DefaultVO {

// 타입
private String type = "";

// 메시지 내용
private String messageContent = "";
}
4 changes: 3 additions & 1 deletion src/main/java/com/barogagi/member/join/dto/NickNameDTO.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.barogagi.member.join.dto;

import com.barogagi.config.vo.DefaultVO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.*;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.barogagi.member.join.dto;

import com.barogagi.config.vo.DefaultVO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.*;

@Getter
@Setter
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/barogagi/member/login/dto/LoginDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.barogagi.config.vo.DefaultVO;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.*;

@Getter
@Setter
Expand All @@ -15,7 +17,7 @@ public class LoginDTO extends DefaultVO {

@NotBlank(message = "비밀번호는 필수 입력값입니다.")
@Size(min = 8, max = 20, message = "비밀번호는 8자 이상 20자 이하여야 합니다.")
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]+$",
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]+$",
message = "비밀번호는 영문, 숫자, 특수문자를 포함해야 합니다.")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password = "";
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/barogagi/sendSms/dto/SendSmsVO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.barogagi.sendSms.dto;

import com.barogagi.config.vo.DefaultVO;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class SendSmsVO extends DefaultVO {
private String recipientTel = "";
private String messageContent = "";
}
62 changes: 62 additions & 0 deletions src/main/java/com/barogagi/sendSms/service/SendSmsService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.barogagi.sendSms.service;

import com.barogagi.sendSms.dto.SendSmsVO;
import net.nurigo.sdk.NurigoApp;
import net.nurigo.sdk.message.exception.NurigoMessageNotReceivedException;
import net.nurigo.sdk.message.model.Message;
import net.nurigo.sdk.message.service.DefaultMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class SendSmsService {

private static final Logger logger = LoggerFactory.getLogger(SendSmsService.class);

private String SEND_TEL = "";
private String API_KEY = "";
private String API_SECRET_KEY = "";

public SendSmsService(Environment environment) {
this.SEND_TEL = environment.getProperty("send.sms.tel");
this.API_KEY = environment.getProperty("send.sms.api-key");
this.API_SECRET_KEY = environment.getProperty("send.sms.api-secret-key");
}

/**
* SMS 발송
* @param sendSmsVO
* @return boolean
*/
public boolean sendSms(SendSmsVO sendSmsVO){

boolean result = true;

DefaultMessageService messageService = NurigoApp.INSTANCE.initialize(API_KEY, API_SECRET_KEY, "https://api.solapi.com");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

API URL을 설정 가능하도록 외부화하세요.

하드코딩된 API URL을 application.properties로 이동시켜 환경별 설정이 가능하도록 해야 합니다.

-        DefaultMessageService messageService =  NurigoApp.INSTANCE.initialize(API_KEY, API_SECRET_KEY, "https://api.solapi.com");
+        String apiUrl = environment.getProperty("send.sms.api-url", "https://api.solapi.com");
+        DefaultMessageService messageService = NurigoApp.INSTANCE.initialize(API_KEY, API_SECRET_KEY, apiUrl);

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/main/java/com/barogagi/sendSms/service/SendSmsService.java at line 37,
the API URL is hardcoded in the initialize method call. To fix this, move the
API URL string to application.properties as a configurable property, then inject
or read this property in the SendSmsService class and use it in the initialize
method instead of the hardcoded value. This allows environment-specific
configuration of the API URL.

// Message 패키지가 중복될 경우 net.nurigo.sdk.message.model.Message로 치환하여 주세요
Message message = new Message();
message.setFrom(SEND_TEL);
message.setTo(sendSmsVO.getRecipientTel());
message.setText(sendSmsVO.getMessageContent());

try {
// send 메소드로 ArrayList<Message> 객체를 넣어도 동작합니다!
messageService.send(message);
result = true;

} catch (NurigoMessageNotReceivedException exception) {
// 발송에 실패한 메시지 목록을 확인할 수 있습니다!
logger.info("발송에 실패한 메시지 목록: {}", exception.getFailedMessageList());
logger.error(exception.getMessage());
result = false;

} catch (Exception exception) {
logger.error(exception.getMessage());
result = false;
}

return result;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/mapper/ApprovalMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<insert id="insertApprovalRecord" parameterType="com.barogagi.approval.vo.ApprovalVO">
<![CDATA[
INSERT APPROVAL_NUM_INFO(TEL, AUTH_CODE, COMPLETE_YN, TYPE, REG_DATE)
VALUES(#{tel}, #{authCode}, #{completeYn}, #{type}, NOW())
INSERT APPROVAL_NUM_INFO(TEL, AUTH_CODE, COMPLETE_YN, TYPE, MESSAGE_CONTENT, REG_DATE)
VALUES(#{tel}, #{authCode}, #{completeYn}, #{type}, #{messageContent}, NOW())
]]>
</insert>

Expand Down