차량번호 랜덤 생성 기능 추가

main
이범준 12 months ago
parent 3f8005ce2e
commit 55a754f0ce

@ -3,8 +3,10 @@ package externalsystem.testpool;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class RandomUtil {
public static String randomHangulName() {
List<String> seong = Arrays.asList(
"김", "이", "박", "최", "정", "강", "조", "윤", "장", "임", "한", "오", "서", "신", "권", "황", "안",
@ -32,4 +34,24 @@ public class RandomUtil {
Collections.shuffle(irum);
return seong.get(0) + irum.get(0) + irum.get(1);
}
public static String randomCarNo() {
String front_digit = "";
List<String> middle = Arrays.asList(
"하", "허", "호",
"가", "나", "다", "라", "마",
"거", "너", "더", "러", "머", "서", "어", "저",
"고", "노", "도", "로", "모", "소", "오", "조",
"구", "누", "두", "루", "무", "수", "우", "주"
);
String back_digit = "";
Collections.shuffle(middle);
Random random = new Random();
front_digit = Integer.toString(random.nextInt(799-10)+10);
back_digit = Integer.toString(random.nextInt(9999-1000)+1000);
return front_digit + middle.get(0) + back_digit;
}
}

@ -12,4 +12,5 @@ public interface TestPoolMapper extends AbstractMapper {
DataObject selectRandomCarBasic();
int insertNamePool(String name);
int insertCarNoPool(String carNo);
}

@ -29,4 +29,18 @@ public class TestPoolController extends AbstractController {
return mav;
}
@RequestMapping(name="차량번호 테스트풀 생성", value="/makeCarNoPool.do")
public ModelAndView makeCarNoPool() {
ModelAndView mav = new ModelAndView("jsonView");
String newName = RandomUtil.randomCarNo();
try {
testPoolMapper.insertCarNoPool(newName);
} catch(Exception e) {
}
return mav;
}
}

@ -25,6 +25,10 @@ INSERT INTO TESTPOOL_TB_NAME
VALUES (#{name})
</insert>
<insert id="insertCarNoPool" parameterType="string">
INSERT INTO TESTPOOL_TB_CAR_NO
VALUES (#{carNo})
</insert>
</mapper>

@ -11,6 +11,7 @@
<div class="container-xxl container-p-y ms-1">
<h5>테스트풀</h5>
<button type="button" id="btnMakePersonNamePool" class="btn btn-primary">이름 테스트풀 생성</button>
<button type="button" id="btnMakeCarNoPool" class="btn btn-primary">차량번호 테스트풀 생성</button>
</div>
<div class="container-xxl container-p-y ms-1">
<h5>국민신문고</h5>
@ -48,6 +49,19 @@
});
});
$("#btnMakeCarNoPool").on("click",function(){
$.ajax({
type : "GET",
ContentType : "text/html;charset=UTF-8",
url : "/testpool/makeCarNoPool.do",
data: {},
success: (resp) => {
}
});
});
//$("#btnSendMobileMessage").on("click",function(){
//
//});

Loading…
Cancel
Save