Merge branch 'master' of http://118.219.150.34:50501/DBNT/kcscDev
commit
eef87b6e81
|
|
@ -14,15 +14,18 @@ const RichTextEditor = ({item, setText}) => {
|
||||||
const modules = {
|
const modules = {
|
||||||
toolbar: {
|
toolbar: {
|
||||||
container: [
|
container: [
|
||||||
[{ size: ["small", false, "large", "huge"] }],
|
[{ header: '1' }, { header: '2' }, { font: [] }],
|
||||||
|
[{ size: [] }],
|
||||||
[{ color: [] }],
|
[{ color: [] }],
|
||||||
["bold", "italic", "underline", "strike", "blockquote"],
|
["bold", "italic", "underline", "strike", "blockquote"],
|
||||||
[
|
[
|
||||||
{ list: "ordered" },
|
{ list: "ordered" },
|
||||||
{ list: "bullet" },
|
{ list: "bullet" },
|
||||||
|
{ indent: '-1' },
|
||||||
|
{ indent: '+1' },
|
||||||
{ align: [] }
|
{ align: [] }
|
||||||
],
|
],
|
||||||
["image", "video"],
|
["link", "image", "video"],
|
||||||
["clean"]
|
["clean"]
|
||||||
],
|
],
|
||||||
// handlers: { image: this.imageHandler }
|
// handlers: { image: this.imageHandler }
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ function Schedules(props) {
|
||||||
if (scheduleList.length > 0) {//일정 있는 경우
|
if (scheduleList.length > 0) {//일정 있는 경우
|
||||||
return (
|
return (
|
||||||
<td key={keyIdx++}>
|
<td key={keyIdx++}>
|
||||||
<Link to={{pathname: URL.ADMIN__COMMITTEE__SCHEDULES__CREATE}} sss="test" state={{test: "ddfdf", iUseDate: mutsUseYearMonth + sDate + "000000"}} className="day"
|
<Link to={{pathname: URL.ADMIN__COMMITTEE__SCHEDULES__CREATE}} sss="test" state={{ iUseDate: mutsUseYearMonth + sDate + "000000"}} className="day"
|
||||||
key={keyIdx++}>{day}</Link><br/>
|
key={keyIdx++}>{day}</Link><br/>
|
||||||
{
|
{
|
||||||
scheduleList.map((schedule, scheduleIdx) => {
|
scheduleList.map((schedule, scheduleIdx) => {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ function SchedulesDetail(props) {
|
||||||
console.log("EgovAdminScheduleDetail [location] : ", location);
|
console.log("EgovAdminScheduleDetail [location] : ", location);
|
||||||
|
|
||||||
const [scheduleDetail, setScheduleDetail] = useState({});
|
const [scheduleDetail, setScheduleDetail] = useState({});
|
||||||
const [boardAttachFiles, setBoardAttachFiles] = useState();
|
|
||||||
const [user, setUser] = useState({});
|
|
||||||
|
|
||||||
const retrieveDetail = () => {
|
const retrieveDetail = () => {
|
||||||
|
|
||||||
|
|
@ -32,17 +30,6 @@ function SchedulesDetail(props) {
|
||||||
EgovNet.requestFetch(retrieveDetailURL,
|
EgovNet.requestFetch(retrieveDetailURL,
|
||||||
requestOptions,
|
requestOptions,
|
||||||
function (resp) {
|
function (resp) {
|
||||||
/**
|
|
||||||
* dto.put("evtSeq", tnCmtEvent.getEvtSeq()); // sequence
|
|
||||||
dto.put("divMeet", tnCmtEvent.getEvtType()); // 구분
|
|
||||||
dto.put("upCommittee", tnCmtEvent.getUpCmtSeq()); // 심의위원회 상위 코드 번호
|
|
||||||
dto.put("committee", tnCmtEvent.getCmtSeq()); // 심의위원회 하위 코드 번호
|
|
||||||
dto.put("title", tnCmtEvent.getEvtTitle()); // 제목
|
|
||||||
dto.put("location", tnCmtEvent.getEvtLocation()); // 장소
|
|
||||||
dto.put("contents", tnCmtEvent.getEvtContents()); // 내용
|
|
||||||
dto.put("startDate", tnCmtEvent.getEvtStartDt()); // 날짜/시간의 시작 일시
|
|
||||||
dto.put("endDate", tnCmtEvent.getEvtEndDt()); // 날짜/시간의 종료 일시
|
|
||||||
*/
|
|
||||||
setScheduleDetail(resp.result);
|
setScheduleDetail(resp.result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -138,19 +125,17 @@ function SchedulesDetail(props) {
|
||||||
|
|
||||||
{/* <!-- 버튼영역 --> */}
|
{/* <!-- 버튼영역 --> */}
|
||||||
<div className="board_btn_area">
|
<div className="board_btn_area">
|
||||||
{user.id || true &&
|
<div className="left_col btn1">
|
||||||
<div className="left_col btn1">
|
<Link to={{pathname: URL.ADMIN__COMMITTEE__SCHEDULES__MODIFY}}
|
||||||
<Link to={{pathname: URL.ADMIN__COMMITTEE__SCHEDULES__MODIFY}}
|
state={{
|
||||||
state={{
|
schdulId: location.state?.schdulId
|
||||||
schdulId: location.state?.schdulId
|
}}
|
||||||
}}
|
className="btn btn_skyblue_h46 w_100">수정</Link>
|
||||||
className="btn btn_skyblue_h46 w_100">수정</Link>
|
<button className="btn btn_skyblue_h46 w_100"
|
||||||
<button className="btn btn_skyblue_h46 w_100"
|
onClick={(e) => {
|
||||||
onClick={(e) => {
|
onClickDeleteSchedule(location.state?.schdulId);
|
||||||
onClickDeleteSchedule(location.state?.schdulId);
|
}}>삭제</button>
|
||||||
}}>삭제</button>
|
</div>
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<div className="right_col btn1">
|
<div className="right_col btn1">
|
||||||
<Link to={URL.ADMIN__COMMITTEE__SCHEDULES} className="btn btn_blue_h46 w_100">목록</Link>
|
<Link to={URL.ADMIN__COMMITTEE__SCHEDULES} className="btn btn_blue_h46 w_100">목록</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ function PopUp(props) {
|
||||||
{listPopup.map((it)=>(
|
{listPopup.map((it)=>(
|
||||||
<div className='list_item'>
|
<div className='list_item'>
|
||||||
<div>{it.seq}</div>
|
<div>{it.seq}</div>
|
||||||
<div className="al"><Link to={URL.SUPPORT_QNA_DETAIL}>{it.popupTitle}</Link></div>
|
<div className="al"><Link to={URL.ADMIN__CONTENTS__POP_UP__MODIFY} state={{popupId: it.seq} } key={it.seq}>{it.popupTitle}</Link></div>
|
||||||
<div>{it.startDate} ~ {it.endDate}</div>
|
<div>{it.startDate} ~ {it.endDate}</div>
|
||||||
<div>{it.useYn === 'Y' ? <Switch {...label} defaultChecked /> : <Switch {...label} />}</div>
|
<div>{it.useYn === 'Y' ? <Switch {...label} defaultChecked /> : <Switch {...label} />}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ function PopupWriter(props) {
|
||||||
|
|
||||||
const [modeInfo, setModeInfo] = useState({ mode: props.mode });
|
const [modeInfo, setModeInfo] = useState({ mode: props.mode });
|
||||||
const [text, setText] = useState("");
|
const [text, setText] = useState("");
|
||||||
const [scheduleDetail, setScheduleDetail] = useState({ schdulDeptName: "관리자부서", schdulChargerName: "관리자", schdulKindCode: 2, reptitSeCode: "1", startDate: new Date(), endDate: new Date() });
|
const [popupDetail, setScheduleDetail] = useState({ startDate: new Date(), endDate: new Date() });
|
||||||
|
|
||||||
const [schdulBgndeHH, setSchdulBgndeHH] = useState();
|
const [schdulBgndeHH, setSchdulBgndeHH] = useState();
|
||||||
const [schdulBgndeMM, setSchdulBgndeMM] = useState();
|
const [schdulBgndeMM, setSchdulBgndeMM] = useState();
|
||||||
|
|
@ -43,45 +43,101 @@ function PopupWriter(props) {
|
||||||
const [boardAttachFiles, setBoardAttachFiles] = useState();
|
const [boardAttachFiles, setBoardAttachFiles] = useState();
|
||||||
|
|
||||||
useEffect(function () {
|
useEffect(function () {
|
||||||
|
initMode();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const formValidator = (formData) => {
|
const formValidator = (formData) => {
|
||||||
if (formData.get('schdulNm') === null || formData.get('schdulNm') === "") {
|
if (formData.get('title') === null || formData.get('title') === "") {
|
||||||
alert("일정명은 필수 값입니다.");
|
alert("제목은 필수 값입니다.");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('schdulCn') === null || formData.get('schdulCn') === "") {
|
|
||||||
alert("일정내용은 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('schdulSe') === null || formData.get('schdulSe') === "") {
|
|
||||||
alert("일정구분은 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('schdulIpcrCode') === null || formData.get('schdulIpcrCode') === "") {
|
|
||||||
alert("중요도는 필수 값입니다.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (formData.get('reptitSeCode') === null ||formData.get('reptitSeCode') === "") {
|
|
||||||
alert("반복구분은 필수 값입니다.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.get('schdulBgnde') > formData.get('schdulEndde')) {
|
if (formData.get('schdulBgnde') > formData.get('schdulEndde')) {
|
||||||
alert("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
alert("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (formData.get('contents') === null || formData.get('contents') === "") {
|
||||||
|
alert("내용은 필수 값입니다.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateSchedule = () => {
|
const initMode = () => {
|
||||||
|
|
||||||
|
// props.mode 값이 없으면 에러가 발생한다.
|
||||||
|
switch (props.mode) {
|
||||||
|
case CODE.MODE_CREATE:
|
||||||
|
setModeInfo({
|
||||||
|
...modeInfo,
|
||||||
|
modeTitle: "등록",
|
||||||
|
method : "POST",
|
||||||
|
editURL: '/contents/api/popup-manage'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case CODE.MODE_MODIFY:
|
||||||
|
setModeInfo({
|
||||||
|
...modeInfo,
|
||||||
|
modeTitle: "수정",
|
||||||
|
method : "PUT",
|
||||||
|
editURL: '/contents/api/popup-manage'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
navigate({pathname: URL.ERROR}, {state: {msg : ""}});
|
||||||
|
}
|
||||||
|
retrieveDetail();
|
||||||
|
}
|
||||||
|
|
||||||
|
const retrieveDetail = () => {
|
||||||
|
|
||||||
|
if (modeInfo.mode === CODE.MODE_CREATE) {// 조회/등록이면 조회 안함
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const retrieveDetailURL = `/contents/api/popup-manage/${location.state?.popupId}`;
|
||||||
|
const requestOptions = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EgovNet.requestFetch(retrieveDetailURL,
|
||||||
|
requestOptions,
|
||||||
|
function (resp) {
|
||||||
|
let rawDetail = resp.result;
|
||||||
|
//기본값 설정
|
||||||
|
setScheduleDetail({
|
||||||
|
...popupDetail,
|
||||||
|
...rawDetail,
|
||||||
|
startDate: convertDate(rawDetail.schdulBgnde),
|
||||||
|
endDate: convertDate(rawDetail.schdulEndde),
|
||||||
|
});
|
||||||
|
setText(rawDetail.contents);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const createPopup = () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
for (let key in scheduleDetail) {
|
for (let key in popupDetail) {
|
||||||
formData.append(key, scheduleDetail[key]);
|
if ( key === 'startDate' ) {
|
||||||
console.log("scheduleDetail [%s] ", key, scheduleDetail[key]);
|
formData.append(key, getDateFourteenDigit( popupDetail[key] ));
|
||||||
|
} else if( key === 'endDate' ) {
|
||||||
|
formData.append(key, getDateFourteenDigit( popupDetail[key] ));
|
||||||
|
} else {
|
||||||
|
formData.append(key, popupDetail[key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//게시글 내용
|
||||||
|
formData.delete("contents");
|
||||||
|
formData.append("contents", text);
|
||||||
|
|
||||||
if (formValidator(formData)) {
|
if (formValidator(formData)) {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: modeInfo.method,
|
method: modeInfo.method,
|
||||||
|
|
@ -89,13 +145,13 @@ function PopupWriter(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
if (modeInfo.mode === CODE.MODE_MODIFY) {
|
||||||
modeInfo.editURL = `${modeInfo.editURL}/${location.state?.schdulId}`;
|
modeInfo.editURL = `${modeInfo.editURL}/${location.state?.popupId}`;
|
||||||
}
|
}
|
||||||
EgovNet.requestFetch(modeInfo.editURL,
|
EgovNet.requestFetch(modeInfo.editURL,
|
||||||
requestOptions,
|
requestOptions,
|
||||||
(resp) => {
|
(resp) => {
|
||||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
navigate({ pathname: URL.ADMIN_SCHEDULE });
|
navigate({ pathname: URL.ADMIN__CONTENTS__POP_UP });
|
||||||
} else {
|
} else {
|
||||||
navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
|
navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
|
||||||
}
|
}
|
||||||
|
|
@ -105,8 +161,8 @@ function PopupWriter(props) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClickDeleteSchedule = (schdulId) => {
|
const onClickDelete = (popupId) => {
|
||||||
const deleteBoardURL = `/schedule/${schdulId}`;
|
const deleteBoardURL = `/schedule/${popupId}`;
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
|
|
@ -131,6 +187,14 @@ function PopupWriter(props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const convertDate = (str) => {
|
||||||
|
let year = str.substring(0, 4);
|
||||||
|
let month = str.substring(4, 6);
|
||||||
|
let date = str.substring(6, 8);
|
||||||
|
let hour = str.substring(8, 10);
|
||||||
|
let minute = str.substring(10, 12);
|
||||||
|
return new Date(year, month - 1, date, hour, minute)
|
||||||
|
}
|
||||||
const getDateFourteenDigit = (date) => {
|
const getDateFourteenDigit = (date) => {
|
||||||
return `${getYYYYMMDD(date).toString()}${makeTwoDigit(date.getHours())}${makeTwoDigit(date.getMinutes())}${makeTwoDigit(date.getSeconds())}`;
|
return `${getYYYYMMDD(date).toString()}${makeTwoDigit(date.getHours())}${makeTwoDigit(date.getMinutes())}${makeTwoDigit(date.getSeconds())}`;
|
||||||
}
|
}
|
||||||
|
|
@ -173,14 +237,14 @@ function PopupWriter(props) {
|
||||||
<div className="top_tit">
|
<div className="top_tit">
|
||||||
<h1 className="tit_1">팝업 추가</h1>
|
<h1 className="tit_1">팝업 추가</h1>
|
||||||
</div>
|
</div>
|
||||||
|
{/* <!-- 상단 입력 form --> */}
|
||||||
<div className='board_view2'>
|
<div className='board_view2'>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label htmlFor="title">제목</label><span className="req">필수</span></dt>
|
<dt><label htmlFor="title">제목</label><span className="req">필수</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<input className="f_input2 w_full" type="text" name="title" title="제목" id="title" placeholder="제목을 입력하세요."
|
<input className="f_input2 w_full" type="text" name="title" title="제목" id="title" placeholder="제목을 입력하세요."
|
||||||
value={scheduleDetail.title}
|
value={popupDetail.title}
|
||||||
onChange={(e) => setScheduleDetail({ ...scheduleDetail, title: e.target.value })}
|
onChange={(e) => setScheduleDetail({ ...popupDetail, title: e.target.value })}
|
||||||
/>
|
/>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
@ -189,14 +253,14 @@ function PopupWriter(props) {
|
||||||
<dd className="datetime">
|
<dd className="datetime">
|
||||||
<span className="line_break">
|
<span className="line_break">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
selected={scheduleDetail.startDate}
|
selected={popupDetail.startDate}
|
||||||
name="schdulBgnde"
|
name="schdulBgnde"
|
||||||
className="f_input"
|
className="f_input"
|
||||||
dateFormat="yyyy-MM-dd HH:mm"
|
dateFormat="yyyy-MM-dd HH:mm"
|
||||||
showTimeInput
|
showTimeInput
|
||||||
onChange={(date) => {
|
onChange={(date) => {
|
||||||
console.log("setStartDate : ", date);
|
console.log("setStartDate : ", date);
|
||||||
setScheduleDetail({ ...scheduleDetail, schdulBgnde: getDateFourteenDigit(date), schdulBgndeYYYMMDD: getYYYYMMDD(date), schdulBgndeHH: date.getHours(), schdulBgndeMM: date.getMinutes(), startDate: date });
|
setScheduleDetail({ ...popupDetail, schdulBgnde: getDateFourteenDigit(date), schdulBgndeYYYMMDD: getYYYYMMDD(date), schdulBgndeHH: date.getHours(), schdulBgndeMM: date.getMinutes(), startDate: date });
|
||||||
setSchdulBgndeHH(date.getHours());
|
setSchdulBgndeHH(date.getHours());
|
||||||
setSchdulBgndeMM(date.getMinutes());
|
setSchdulBgndeMM(date.getMinutes());
|
||||||
}} />
|
}} />
|
||||||
|
|
@ -206,15 +270,15 @@ function PopupWriter(props) {
|
||||||
</span>
|
</span>
|
||||||
<span className="line_break">
|
<span className="line_break">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
selected={scheduleDetail.endDate}
|
selected={popupDetail.endDate}
|
||||||
name="schdulEndde"
|
name="schdulEndde"
|
||||||
className="f_input"
|
className="f_input"
|
||||||
dateFormat="yyyy-MM-dd HH:mm"
|
dateFormat="yyyy-MM-dd HH:mm"
|
||||||
showTimeInput
|
showTimeInput
|
||||||
minDate={scheduleDetail.startDate}
|
minDate={popupDetail.startDate}
|
||||||
onChange={(date) => {
|
onChange={(date) => {
|
||||||
console.log("setEndDate: ", date);
|
console.log("setEndDate: ", date);
|
||||||
setScheduleDetail({ ...scheduleDetail, schdulEndde: getDateFourteenDigit(date), schdulEnddeYYYMMDD: getYYYYMMDD(date), schdulEnddeHH: date.getHours(), schdulEnddeMM: date.getMinutes(), endDate: date });
|
setScheduleDetail({ ...popupDetail, schdulEndde: getDateFourteenDigit(date), schdulEnddeYYYMMDD: getYYYYMMDD(date), schdulEnddeHH: date.getHours(), schdulEnddeMM: date.getMinutes(), endDate: date });
|
||||||
setSchdulEnddeHH(date.getHours());
|
setSchdulEnddeHH(date.getHours());
|
||||||
setSchdulEnddeMM(date.getMinutes());
|
setSchdulEnddeMM(date.getMinutes());
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +291,7 @@ function PopupWriter(props) {
|
||||||
<EgovAttachFile
|
<EgovAttachFile
|
||||||
fnChangeFile={(attachfile) => {
|
fnChangeFile={(attachfile) => {
|
||||||
console.log("====>>> Changed attachfile file = ", attachfile);
|
console.log("====>>> Changed attachfile file = ", attachfile);
|
||||||
const arrayConcat = { ...scheduleDetail}; // 기존 단일 파일 업로드에서 다중파일 객체 추가로 변환(아래 for문으로)
|
const arrayConcat = { ...popupDetail}; // 기존 단일 파일 업로드에서 다중파일 객체 추가로 변환(아래 for문으로)
|
||||||
for ( let i = 0; i < attachfile.length; i++) {
|
for ( let i = 0; i < attachfile.length; i++) {
|
||||||
arrayConcat[`file_${i}`] = attachfile[i];
|
arrayConcat[`file_${i}`] = attachfile[i];
|
||||||
}
|
}
|
||||||
|
|
@ -240,6 +304,7 @@ function PopupWriter(props) {
|
||||||
boardFiles={boardAttachFiles}
|
boardFiles={boardAttachFiles}
|
||||||
mode={props.mode} />
|
mode={props.mode} />
|
||||||
</div>
|
</div>
|
||||||
|
{/* <!--// 상단 입력 form --> */}
|
||||||
|
|
||||||
{/* <!-- 게시판 --> */}
|
{/* <!-- 게시판 --> */}
|
||||||
<RichTextEditor item={text} setText={setText}/>
|
<RichTextEditor item={text} setText={setText}/>
|
||||||
|
|
@ -249,22 +314,21 @@ function PopupWriter(props) {
|
||||||
<div className="board_btn_area">
|
<div className="board_btn_area">
|
||||||
<div className="left_col btn1">
|
<div className="left_col btn1">
|
||||||
<button className="btn btn_skyblue_h46 w_100"
|
<button className="btn btn_skyblue_h46 w_100"
|
||||||
onClick={() => updateSchedule()}
|
onClick={() => createPopup()}
|
||||||
> 저장</button>
|
> 저장</button>
|
||||||
{modeInfo.mode === CODE.MODE_MODIFY &&
|
{modeInfo.mode === CODE.MODE_MODIFY &&
|
||||||
<button className="btn btn_skyblue_h46 w_100"
|
<button className="btn btn_skyblue_h46 w_100"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
onClickDeleteSchedule(location.state?.schdulId);
|
onClickDelete(location.state?.popupId);
|
||||||
}}>삭제</button>
|
}}>삭제</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="right_col btn1">
|
<div className="right_col btn1">
|
||||||
<Link to={URL.ADMIN__CONTENTS__POP_UP} className="btn btn_blue_h46 w_100">목록</Link>
|
<Link to={URL.ADMIN__CONTENTS__POP_UP} className="btn btn_blue_h46 w_100">목록</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <!--// 버튼영역 --> */}
|
{/* <!--// 버튼영역 --> */}
|
||||||
|
|
||||||
</StyledDiv>
|
</StyledDiv>
|
||||||
{/* <!--// 본문 --> */}
|
{/* <!--// 본문 --> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -91,8 +91,8 @@ import AdminStandardsInfoDisclosure from 'pages/admin/standards/InfoDisclosure';
|
||||||
// 관리자 - 컨텐츠 관리
|
// 관리자 - 컨텐츠 관리
|
||||||
import AdminContentsSurvey from 'pages/admin/contents/Survey'; // 관리자 - 컨텐츠 관리/설문 관리
|
import AdminContentsSurvey from 'pages/admin/contents/Survey'; // 관리자 - 컨텐츠 관리/설문 관리
|
||||||
import AdminContentsPopUp from 'pages/admin/contents/PopUp'; // 관리자 - 컨텐츠 관리/팝업 관리
|
import AdminContentsPopUp from 'pages/admin/contents/PopUp'; // 관리자 - 컨텐츠 관리/팝업 관리
|
||||||
import AdminContentsPopUpWriter from 'pages/admin/contents/PopUp/Writer'; // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가 또는 수정
|
import AdminContentsPopUpWriter from 'pages/admin/contents/PopUp/PopupWriter'; // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가 또는 수정
|
||||||
import AdminContentsStandardResearch from 'pages/admin/contents/StandardResearch'; // 관리자 - 컨텐츠 관리/건설기준연구 관리
|
import AdminContentsStandardResearch from 'pages/admin/contents/StandardResearch'; // 관리자 - 컨텐츠 관리/건설기준연구 관리
|
||||||
import AdminContentsTextMessages from 'pages/admin/contents/TextMessages'; // 관리자 - 컨텐츠 관리/문자 발송
|
import AdminContentsTextMessages from 'pages/admin/contents/TextMessages'; // 관리자 - 컨텐츠 관리/문자 발송
|
||||||
|
|
||||||
// 관리자 - 위원회 관리
|
// 관리자 - 위원회 관리
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,12 @@ package com.dbnt.kcscbackend.admin.committee.schedules.service;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.model.CreateScheduleVO;
|
import com.dbnt.kcscbackend.admin.committee.schedules.model.CreateScheduleVO;
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.model.UpdateScheduleVO;
|
import com.dbnt.kcscbackend.admin.committee.schedules.model.UpdateScheduleVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
@ -46,4 +48,5 @@ public interface EgovIndvdlSchdulManageService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +168,7 @@ public class EgovIndvdlSchdulManageServiceImpl extends EgovAbstractServiceImpl i
|
||||||
);
|
);
|
||||||
|
|
||||||
// 유효성 검사 실시
|
// 유효성 검사 실시
|
||||||
int isValid = tnCmtEventRepository.sp_is_valid_tn_cmt_event_id( updateScheduleVO.getEvtSeq() );
|
int isValid = tnCmtEventRepository.spIsValidTnCmtEventId( updateScheduleVO.getEvtSeq() );
|
||||||
|
|
||||||
if( isValid == 0 ) {
|
if( isValid == 0 ) {
|
||||||
throw new Exception("대상이 존재하지 않습니다.");
|
throw new Exception("대상이 존재하지 않습니다.");
|
||||||
|
|
@ -253,7 +253,7 @@ public class EgovIndvdlSchdulManageServiceImpl extends EgovAbstractServiceImpl i
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
int isValid = tnCmtEventRepository.sp_is_valid_tn_cmt_event_id( scheduleId.intValue() );
|
int isValid = tnCmtEventRepository.spIsValidTnCmtEventId( scheduleId.intValue() );
|
||||||
|
|
||||||
if( isValid == 0 ) {
|
if( isValid == 0 ) {
|
||||||
throw new Exception("대상이 존재하지 않습니다.");
|
throw new Exception("대상이 존재하지 않습니다.");
|
||||||
|
|
@ -282,9 +282,6 @@ public class EgovIndvdlSchdulManageServiceImpl extends EgovAbstractServiceImpl i
|
||||||
dto.put("schdulBgnde", tnCmtEvent.getEvtStartDt().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
dto.put("schdulBgnde", tnCmtEvent.getEvtStartDt().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
||||||
dto.put("schdulEndde", tnCmtEvent.getEvtEndDt().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 종료 일시
|
dto.put("schdulEndde", tnCmtEvent.getEvtEndDt().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 종료 일시
|
||||||
|
|
||||||
// 문자열로 리턴하도록 수정해야 함.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resultVO.setResult(dto);
|
resultVO.setResult(dto);
|
||||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ package com.dbnt.kcscbackend.admin.contents.popUp.controller;
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.model.CreateScheduleVO;
|
import com.dbnt.kcscbackend.admin.committee.schedules.model.CreateScheduleVO;
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.model.UpdateScheduleVO;
|
import com.dbnt.kcscbackend.admin.committee.schedules.model.UpdateScheduleVO;
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.service.EgovIndvdlSchdulManageService;
|
import com.dbnt.kcscbackend.admin.committee.schedules.service.EgovIndvdlSchdulManageService;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovFileMngUtil;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
|
@ -16,9 +20,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,10 +37,13 @@ public class PopUpApiController {
|
||||||
@Resource(name = "popUpApiService")
|
@Resource(name = "popUpApiService")
|
||||||
private PopUpApiService popUpApiService;
|
private PopUpApiService popUpApiService;
|
||||||
|
|
||||||
|
@Resource(name = "EgovFileMngUtil")
|
||||||
|
private EgovFileMngUtil fileUtil;
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "'팝업 관리' 페이지에서 목록 불러오는 API",
|
summary = "'팝업 관리' 페이지에서 목록 불러오는 API",
|
||||||
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 목록 불러오는 API",
|
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 목록 불러오는 API",
|
||||||
tags = {"SchedulesApiController"}
|
tags = {"PopUpApiController"}
|
||||||
)
|
)
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||||
|
|
@ -69,5 +79,127 @@ public class PopUpApiController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "팝업 추가 API",
|
||||||
|
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 추가하는 API",
|
||||||
|
tags = {"PopUpApiController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "등록 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"),
|
||||||
|
@ApiResponse(responseCode = "900", description = "입력값 무결성 오류")
|
||||||
|
})
|
||||||
|
@PostMapping(value = "/contents/api/popup-manage")
|
||||||
|
public ResultVO contentsApiPopUpManageCreate(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@AuthenticationPrincipal LoginVO loginVO,
|
||||||
|
final MultipartHttpServletRequest multiRequest,
|
||||||
|
CreatePopupVO createPopupVO
|
||||||
|
) throws Exception {
|
||||||
|
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
||||||
|
try {
|
||||||
|
resultVO = popUpApiService.contentsApiPopUpManageCreate(resultVO, request, loginVO, multiRequest, createPopupVO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||||
|
resultVO.setResultMessage(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
request.getRequestURI() + " OUT:" +
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
"resultVO.toString():" + "\n" +
|
||||||
|
resultVO.toString() + "\n" +
|
||||||
|
"\n--------------------------------------------------------------\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "팝업 수정 API",
|
||||||
|
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 수정하는 API",
|
||||||
|
tags = {"PopUpApiController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "등록 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"),
|
||||||
|
@ApiResponse(responseCode = "900", description = "입력값 무결성 오류")
|
||||||
|
})
|
||||||
|
@PutMapping(value = "/contents/api/popup-manage/{popupId}")
|
||||||
|
public ResultVO contentsApiPopUpManageUpdate(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@AuthenticationPrincipal LoginVO loginVO,
|
||||||
|
UpdatePopupVO updatePopupVO,
|
||||||
|
@PathVariable("popupId") Long popupId
|
||||||
|
) throws Exception {
|
||||||
|
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
||||||
|
try {
|
||||||
|
resultVO = popUpApiService.contentsApiPopUpManageUpdate(resultVO, request, loginVO, updatePopupVO, popupId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||||
|
resultVO.setResultMessage(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
request.getRequestURI() + " OUT:" +
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
"resultVO.toString():" + "\n" +
|
||||||
|
resultVO.toString() + "\n" +
|
||||||
|
"\n--------------------------------------------------------------\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "팝업 내용 불러오기 API",
|
||||||
|
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 저장된 팝업을 불러오는 API",
|
||||||
|
tags = {"PopUpApiController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "조회 성공")
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/contents/api/popup-manage/{popupId}")
|
||||||
|
public ResultVO contentsApiPopUpManageRead(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@AuthenticationPrincipal LoginVO loginVO,
|
||||||
|
@PathVariable("popupId") Long popupId
|
||||||
|
) throws Exception {
|
||||||
|
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
||||||
|
try {
|
||||||
|
resultVO = popUpApiService.contentsApiPopUpManageRead(resultVO, request, loginVO, popupId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||||
|
resultVO.setResultMessage(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
request.getRequestURI() + " OUT:" +
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
"resultVO.toString():" + "\n" +
|
||||||
|
resultVO.toString() + "\n" +
|
||||||
|
"\n--------------------------------------------------------------\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.contents.popUp.model;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ApiModel(value = "CreatePopupVO", description =
|
||||||
|
"관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 추가하는 API에 사용된다." + ""
|
||||||
|
)
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class CreatePopupVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 719256850119704956L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "startDate")
|
||||||
|
private String startDate;
|
||||||
|
@ApiModelProperty(value = "endDate")
|
||||||
|
private String endDate;
|
||||||
|
@ApiModelProperty(value = "title")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(value = "contents")
|
||||||
|
private String contents;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.contents.popUp.model;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
@Schema(description = "파일 정보 VO")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class FileVO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 2352224849835425052L;
|
||||||
|
|
||||||
|
@Schema(description = "첨부파일 아이디")
|
||||||
|
public String atchFileId = "";
|
||||||
|
|
||||||
|
@Schema(description = "생성일자")
|
||||||
|
public String creatDt = "";
|
||||||
|
|
||||||
|
@Schema(description = "파일내용")
|
||||||
|
public String fileCn = "";
|
||||||
|
|
||||||
|
@Schema(description = "파일확장자")
|
||||||
|
public String fileExtsn = "";
|
||||||
|
|
||||||
|
@Schema(description = "파일크기")
|
||||||
|
public String fileMg = "";
|
||||||
|
|
||||||
|
@Schema(description = "파일연번")
|
||||||
|
public String fileSn = "";
|
||||||
|
|
||||||
|
@Schema(description = "파일저장경로")
|
||||||
|
public String fileStreCours = "";
|
||||||
|
|
||||||
|
@Schema(description = "원파일명")
|
||||||
|
public String orignlFileNm = "";
|
||||||
|
|
||||||
|
@Schema(description = "저장파일명")
|
||||||
|
public String streFileNm = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toString 메소드를 대치한다.
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return ToStringBuilder.reflectionToString(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.contents.popUp.model;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ApiModel(value = "UpdatePopupVO", description =
|
||||||
|
"관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 수정하는 API에 사용된다." + ""
|
||||||
|
)
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class UpdatePopupVO extends CreatePopupVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 5871943231162448850L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "popupId")
|
||||||
|
private String popupId;
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.popUp.service;
|
package com.dbnt.kcscbackend.admin.contents.popUp.service;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public interface PopUpApiService {
|
public interface PopUpApiService {
|
||||||
public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception;
|
public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception;
|
||||||
|
public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO) throws Exception;
|
||||||
|
public ResultVO contentsApiPopUpManageRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
||||||
|
public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, Long popupId) throws Exception;
|
||||||
|
|
||||||
|
public ResultVO contentsApiPopUpManageDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.popUp.service.impl;
|
package com.dbnt.kcscbackend.admin.contents.popUp.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.repository.TnPopupMngRepositoryWithoutPopupContents;
|
import com.dbnt.kcscbackend.admin.contents.popUp.repository.TnPopupMngRepositoryWithoutPopupContents;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
|
import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng;
|
||||||
import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository;
|
import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||||
import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
@ -85,5 +89,145 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO) throws Exception {
|
||||||
|
|
||||||
|
System.out.println(
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
request.getRequestURI() + " IN:" +
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
"user.getEmail():" + "\n" +
|
||||||
|
user.getEmail() + "\n" +
|
||||||
|
"\n--------------------------------------------------------------\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// 첨부파일 관련 첨부파일ID 생성
|
||||||
|
List<FileVO> _result = null;
|
||||||
|
String _atchFileId = "";
|
||||||
|
|
||||||
|
final Map<String, MultipartFile> files = multiRequest.getFileMap();
|
||||||
|
|
||||||
|
if (!files.isEmpty()) {
|
||||||
|
//_atchFileId = fileMngService.insertFileInfs(_result); //파일이 생성되고나면 생성된 첨부파일 ID를 리턴한다.
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> response = tnPopupMngRepository.spAddTnPopupMng(
|
||||||
|
createPopupVO.getTitle(),
|
||||||
|
createPopupVO.getStartDate(),
|
||||||
|
createPopupVO.getEndDate(),
|
||||||
|
null,
|
||||||
|
createPopupVO.getContents(),
|
||||||
|
"kcsc_admin",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> dto = new HashMap<String, Object>();
|
||||||
|
dto.put("popupSeq", response.get("_popup_seq") );
|
||||||
|
|
||||||
|
resultVO.setResult(dto);
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultVO contentsApiPopUpManageRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception {
|
||||||
|
|
||||||
|
System.out.println(
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
request.getRequestURI() + " IN:" +
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
"user.getEmail():" + "\n" +
|
||||||
|
user.getEmail() + "\n" +
|
||||||
|
"popupId:" + "\n" +
|
||||||
|
popupId + "\n" +
|
||||||
|
"\n--------------------------------------------------------------\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
int isValid = tnPopupMngRepository.spIsValidTnPopupMngId( popupId.intValue() );
|
||||||
|
|
||||||
|
if( isValid == 0 ) {
|
||||||
|
throw new Exception("대상이 존재하지 않습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
TnPopupMng tnPopupMng = tnPopupMngRepository.findByPopupSeq(popupId);
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> dto = new HashMap<String, Object>();
|
||||||
|
dto.put("title", tnPopupMng.getPopupTitle()); // 팝업 제목
|
||||||
|
dto.put("contents", tnPopupMng.getPopupContents()); // 팝업 내용
|
||||||
|
dto.put("schdulBgnde", tnPopupMng.getPopupStartDate().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
||||||
|
dto.put("schdulEndde", tnPopupMng.getPopupEndDate().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 종료 일시 - yyyyMMddHHmmss
|
||||||
|
|
||||||
|
|
||||||
|
resultVO.setResult(dto);
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, Long popupId) throws Exception {
|
||||||
|
System.out.println(
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
request.getRequestURI() + " IN:" +
|
||||||
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
"updatePopupVO:" + "\n" +
|
||||||
|
updatePopupVO.toString() + "\n" +
|
||||||
|
"popupId:" + "\n" +
|
||||||
|
popupId + "\n" +
|
||||||
|
"\n--------------------------------------------------------------\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// 유효성 검사 실시
|
||||||
|
int isValid = tnPopupMngRepository.spIsValidTnPopupMngId( popupId.intValue() );
|
||||||
|
|
||||||
|
if( isValid == 0 ) {
|
||||||
|
throw new Exception("대상이 존재하지 않습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if( Long.parseLong(updatePopupVO.getStartDate()) > Long.parseLong(updatePopupVO.getEndDate()) ) {
|
||||||
|
throw new Exception("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> response = tnPopupMngRepository.spUpdateTnPopupMng(
|
||||||
|
popupId.intValue(),
|
||||||
|
updatePopupVO.getTitle(),
|
||||||
|
updatePopupVO.getStartDate(),
|
||||||
|
updatePopupVO.getEndDate(),
|
||||||
|
null,
|
||||||
|
updatePopupVO.getContents(),
|
||||||
|
"kcsc_admin",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> dto = new HashMap<String, Object>();
|
||||||
|
dto.put("errorMessage", response.get("_error_message") );
|
||||||
|
dto.put("popupId", popupId);
|
||||||
|
|
||||||
|
resultVO.setResult(dto);
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultVO contentsApiPopUpManageDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,458 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.contents.popUp.utils;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.egovframe.rte.fdl.idgnr.EgovIdGnrService;
|
||||||
|
import org.egovframe.rte.fdl.property.EgovPropertyService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.FileCopyUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Class Name : EgovFileMngUtil.java
|
||||||
|
* @Description : 메시지 처리 관련 유틸리티
|
||||||
|
* @Modification Information
|
||||||
|
*
|
||||||
|
* 수정일 수정자 수정내용
|
||||||
|
* ------- -------- ---------------------------
|
||||||
|
* 2009.02.13 이삼섭 최초 생성
|
||||||
|
* 2011.08.31 JJY 경량환경 템플릿 커스터마이징버전 생성
|
||||||
|
*
|
||||||
|
* @author 공통 서비스 개발팀 이삼섭
|
||||||
|
* @since 2009. 02. 13
|
||||||
|
* @version 1.0
|
||||||
|
* @see
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("EgovFileMngUtil")
|
||||||
|
public class EgovFileMngUtil {
|
||||||
|
|
||||||
|
public static final int BUFF_SIZE = 2048;
|
||||||
|
|
||||||
|
@Resource(name = "propertiesService")
|
||||||
|
protected EgovPropertyService propertyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 첨부파일에 대한 목록 정보를 취득한다.
|
||||||
|
*
|
||||||
|
* @param files
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<FileVO> parseFileInf(Map<String, MultipartFile> files, String KeyStr, int fileKeyParam, String atchFileId, String storePath) throws Exception {
|
||||||
|
int fileKey = fileKeyParam;
|
||||||
|
|
||||||
|
String storePathString = "";
|
||||||
|
String atchFileIdString = "";
|
||||||
|
|
||||||
|
if ("".equals(storePath) || storePath == null) {
|
||||||
|
storePathString = propertyService.getString("Globals.fileStorePath");
|
||||||
|
} else {
|
||||||
|
storePathString = propertyService.getString(storePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
atchFileId = atchFileId.replaceAll("\\s", "");
|
||||||
|
|
||||||
|
if ("".equals(atchFileId) || atchFileId == null) {
|
||||||
|
atchFileIdString = "testest_thkim-temp-20240124_1446";
|
||||||
|
} else {
|
||||||
|
atchFileIdString = atchFileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
File saveFolder = new File(EgovWebUtil.filePathBlackList(storePathString));
|
||||||
|
|
||||||
|
if (!saveFolder.exists() || saveFolder.isFile()) {
|
||||||
|
saveFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<Entry<String, MultipartFile>> itr = files.entrySet().iterator();
|
||||||
|
MultipartFile file;
|
||||||
|
String filePath = "";
|
||||||
|
List<FileVO> result = new ArrayList<FileVO>();
|
||||||
|
FileVO fvo;
|
||||||
|
|
||||||
|
while (itr.hasNext()) {
|
||||||
|
Entry<String, MultipartFile> entry = itr.next();
|
||||||
|
|
||||||
|
file = entry.getValue();
|
||||||
|
String orginFileName = file.getOriginalFilename();
|
||||||
|
|
||||||
|
//--------------------------------------
|
||||||
|
// 원 파일명이 null인 경우 처리
|
||||||
|
//--------------------------------------
|
||||||
|
if (orginFileName == null) {
|
||||||
|
orginFileName = "";
|
||||||
|
}
|
||||||
|
////------------------------------------
|
||||||
|
|
||||||
|
//--------------------------------------
|
||||||
|
// 원 파일명이 없는 경우 처리
|
||||||
|
// (첨부가 되지 않은 input file type)
|
||||||
|
//--------------------------------------
|
||||||
|
if ("".equals(orginFileName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
////------------------------------------
|
||||||
|
|
||||||
|
int index = orginFileName.lastIndexOf(".");
|
||||||
|
//String fileName = orginFileName.substring(0, index);
|
||||||
|
String fileExt = orginFileName.substring(index + 1);
|
||||||
|
String newName = KeyStr + EgovStringUtil.getTimeStamp() + fileKey;
|
||||||
|
long _size = file.getSize();
|
||||||
|
|
||||||
|
if (!"".equals(orginFileName)) {
|
||||||
|
filePath = storePathString + File.separator + newName;
|
||||||
|
file.transferTo(new File(EgovWebUtil.filePathBlackList(filePath)));
|
||||||
|
}
|
||||||
|
fvo = new FileVO();
|
||||||
|
fvo.setFileExtsn(fileExt);
|
||||||
|
fvo.setFileStreCours(storePathString);
|
||||||
|
fvo.setFileMg(Long.toString(_size));
|
||||||
|
fvo.setOrignlFileNm(orginFileName);
|
||||||
|
fvo.setStreFileNm(newName);
|
||||||
|
fvo.setAtchFileId(atchFileIdString);
|
||||||
|
fvo.setFileSn(String.valueOf(fileKey));
|
||||||
|
|
||||||
|
//writeFile(file, newName, storePathString);
|
||||||
|
result.add(fvo);
|
||||||
|
|
||||||
|
fileKey++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 첨부파일을 서버에 저장한다.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @param newName
|
||||||
|
* @param stordFilePath
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected void writeUploadedFile(MultipartFile file, String newName, String stordFilePath) throws Exception {
|
||||||
|
InputStream stream = null;
|
||||||
|
OutputStream bos = null;
|
||||||
|
String stordFilePathReal = EgovWebUtil.filePathBlackList(stordFilePath);
|
||||||
|
newName = EgovWebUtil.filePathBlackList(newName);
|
||||||
|
try {
|
||||||
|
stream = file.getInputStream();
|
||||||
|
File cFile = new File(stordFilePathReal);
|
||||||
|
|
||||||
|
if (!cFile.isDirectory()) {
|
||||||
|
boolean _flag = cFile.mkdir();
|
||||||
|
if (!_flag) {
|
||||||
|
throw new IOException("Directory creation Failed ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bos = new FileOutputStream(stordFilePathReal + File.separator + newName);
|
||||||
|
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[BUFF_SIZE];
|
||||||
|
|
||||||
|
while ((bytesRead = stream.read(buffer, 0, BUFF_SIZE)) != -1) {
|
||||||
|
bos.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException fnfe) {
|
||||||
|
log.debug("fnfe: {}", fnfe);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.debug("ioe: {}", ioe);
|
||||||
|
} finally {
|
||||||
|
if (bos != null) {
|
||||||
|
try {
|
||||||
|
bos.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stream != null) {
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 서버의 파일을 다운로드한다.
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void downFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
|
String downFileName = EgovWebUtil.filePathBlackList(EgovStringUtil.isNullToString(request.getAttribute("downFile")));
|
||||||
|
String orgFileName = EgovWebUtil.filePathBlackList(EgovStringUtil.isNullToString(request.getAttribute("orgFileName")));
|
||||||
|
|
||||||
|
/*if ((String)request.getAttribute("downFile") == null) {
|
||||||
|
downFileName = "";
|
||||||
|
} else {
|
||||||
|
downFileName = EgovStringUtil.isNullToString(request.getAttribute("downFile"));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*if ((String)request.getAttribute("orgFileName") == null) {
|
||||||
|
orgFileName = "";
|
||||||
|
} else {
|
||||||
|
orgFileName = (String)request.getAttribute("orginFile");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
File file = new File(downFileName);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw new FileNotFoundException(downFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.isFile()) {
|
||||||
|
throw new FileNotFoundException(downFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] b = new byte[BUFF_SIZE]; //buffer size 2K.
|
||||||
|
String fName = (new String(orgFileName.getBytes(), "UTF-8")).replaceAll("\r\n","");
|
||||||
|
response.setContentType("application/x-msdownload");
|
||||||
|
response.setHeader("Content-Disposition:", "attachment; filename=" + fName);
|
||||||
|
response.setHeader("Content-Transfer-Encoding", "binary");
|
||||||
|
response.setHeader("Pragma", "no-cache");
|
||||||
|
response.setHeader("Expires", "0");
|
||||||
|
|
||||||
|
BufferedInputStream fin = null;
|
||||||
|
BufferedOutputStream outs = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fin = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
outs = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
int read = 0;
|
||||||
|
|
||||||
|
while ((read = fin.read(b)) != -1) {
|
||||||
|
outs.write(b, 0, read);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (outs != null) {
|
||||||
|
try {
|
||||||
|
outs.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fin != null) {
|
||||||
|
try {
|
||||||
|
fin.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 첨부로 등록된 파일을 서버에 업로드한다.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
|
||||||
|
public static HashMap<String, String> uploadFile(MultipartFile file) throws Exception {
|
||||||
|
|
||||||
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
|
//Write File 이후 Move File????
|
||||||
|
String newName = "";
|
||||||
|
String stordFilePath = EgovProperties.getProperty("Globals.fileStorePath");
|
||||||
|
String orginFileName = file.getOriginalFilename();
|
||||||
|
|
||||||
|
int index = orginFileName.lastIndexOf(".");
|
||||||
|
//String fileName = orginFileName.substring(0, _index);
|
||||||
|
String fileExt = orginFileName.substring(index + 1);
|
||||||
|
long size = file.getSize();
|
||||||
|
|
||||||
|
//newName 은 Naming Convention에 의해서 생성
|
||||||
|
newName = EgovStringUtil.getTimeStamp() + "." + fileExt;
|
||||||
|
writeFile(file, newName, stordFilePath);
|
||||||
|
//storedFilePath는 지정
|
||||||
|
map.put(Globals.ORIGIN_FILE_NM, orginFileName);
|
||||||
|
map.put(Globals.UPLOAD_FILE_NM, newName);
|
||||||
|
map.put(Globals.FILE_EXT, fileExt);
|
||||||
|
map.put(Globals.FILE_PATH, stordFilePath);
|
||||||
|
map.put(Globals.FILE_SIZE, String.valueOf(size));
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 파일을 실제 물리적인 경로에 생성한다.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @param newName
|
||||||
|
* @param stordFilePath
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected static void writeFile(MultipartFile file, String newName, String stordFilePath) throws Exception {
|
||||||
|
InputStream stream = null;
|
||||||
|
OutputStream bos = null;
|
||||||
|
newName = EgovWebUtil.filePathBlackList(EgovStringUtil.isNullToString(newName));
|
||||||
|
stordFilePath = EgovWebUtil.filePathBlackList(EgovStringUtil.isNullToString(stordFilePath));
|
||||||
|
try {
|
||||||
|
stream = file.getInputStream();
|
||||||
|
File cFile = new File(stordFilePath);
|
||||||
|
|
||||||
|
if (!cFile.isDirectory()) {
|
||||||
|
cFile.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
bos = new FileOutputStream(stordFilePath + File.separator + newName);
|
||||||
|
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[BUFF_SIZE];
|
||||||
|
|
||||||
|
while ((bytesRead = stream.read(buffer, 0, BUFF_SIZE)) != -1) {
|
||||||
|
bos.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException fnfe) {
|
||||||
|
log.debug("fnfe: {}", fnfe);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.debug("ioe: {}", ioe);
|
||||||
|
} finally {
|
||||||
|
if (bos != null) {
|
||||||
|
try {
|
||||||
|
bos.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stream != null) {
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 서버 파일에 대하여 다운로드를 처리한다.
|
||||||
|
*
|
||||||
|
* @param response
|
||||||
|
* @param streFileNm
|
||||||
|
* : 파일저장 경로가 포함된 형태
|
||||||
|
* @param orignFileNm
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void downFile(HttpServletResponse response, String streFileNm, String orignFileNm) throws Exception {
|
||||||
|
// String downFileName = EgovStringUtil.isNullToString(request.getAttribute("downFile")).replaceAll("..","");
|
||||||
|
// String orgFileName = EgovStringUtil.isNullToString(request.getAttribute("orgFileName")).replaceAll("..","");
|
||||||
|
String downFileName = EgovWebUtil.filePathBlackList(EgovStringUtil.isNullToString(streFileNm));
|
||||||
|
String orgFileName = EgovWebUtil.filePathBlackList(EgovStringUtil.isNullToString(orignFileNm));
|
||||||
|
|
||||||
|
File file = new File(downFileName);
|
||||||
|
//log.debug(this.getClass().getName()+" downFile downFileName "+downFileName);
|
||||||
|
//log.debug(this.getClass().getName()+" downFile orgFileName "+orgFileName);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw new FileNotFoundException(downFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.isFile()) {
|
||||||
|
throw new FileNotFoundException(downFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//byte[] b = new byte[BUFF_SIZE]; //buffer size 2K.
|
||||||
|
int fSize = (int)file.length();
|
||||||
|
if (fSize > 0) {
|
||||||
|
BufferedInputStream in = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
in = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
|
||||||
|
String mimetype = "text/html"; //"application/x-msdownload"
|
||||||
|
|
||||||
|
response.setBufferSize(fSize);
|
||||||
|
response.setContentType(mimetype);
|
||||||
|
response.setHeader("Content-Disposition:", "attachment; filename=" + orgFileName);
|
||||||
|
response.setContentLength(fSize);
|
||||||
|
//response.setHeader("Content-Transfer-Encoding","binary");
|
||||||
|
//response.setHeader("Pragma","no-cache");
|
||||||
|
//response.setHeader("Expires","0");
|
||||||
|
FileCopyUtils.copy(in, response.getOutputStream());
|
||||||
|
} finally {
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
log.debug("IGNORED: {}", ignore.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.getOutputStream().flush();
|
||||||
|
response.getOutputStream().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
String uploadPath = propertiesService.getString("fileDir");
|
||||||
|
|
||||||
|
File uFile = new File(uploadPath, requestedFile);
|
||||||
|
int fSize = (int) uFile.length();
|
||||||
|
|
||||||
|
if (fSize > 0) {
|
||||||
|
BufferedInputStream in = new BufferedInputStream(new FileInputStream(uFile));
|
||||||
|
|
||||||
|
String mimetype = "text/html";
|
||||||
|
|
||||||
|
response.setBufferSize(fSize);
|
||||||
|
response.setContentType(mimetype);
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=\""
|
||||||
|
+ requestedFile + "\"");
|
||||||
|
response.setContentLength(fSize);
|
||||||
|
|
||||||
|
FileCopyUtils.copy(in, response.getOutputStream());
|
||||||
|
in.close();
|
||||||
|
response.getOutputStream().flush();
|
||||||
|
response.getOutputStream().close();
|
||||||
|
} else {
|
||||||
|
response.setContentType("text/html");
|
||||||
|
PrintWriter printwriter = response.getWriter();
|
||||||
|
printwriter.println("<html>");
|
||||||
|
printwriter.println("<br><br><br><h2>Could not get file name:<br>" + requestedFile + "</h2>");
|
||||||
|
printwriter.println("<br><br><br><center><h3><a href='javascript: history.go(-1)'>Back</a></h3></center>");
|
||||||
|
printwriter.println("<br><br><br>© webAccess");
|
||||||
|
printwriter.println("</html>");
|
||||||
|
printwriter.flush();
|
||||||
|
printwriter.close();
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
response.setContentType("application/x-msdownload");
|
||||||
|
response.setHeader("Content-Disposition:", "attachment; filename=" + new String(orgFileName.getBytes(),"UTF-8" ));
|
||||||
|
response.setHeader("Content-Transfer-Encoding","binary");
|
||||||
|
response.setHeader("Pragma","no-cache");
|
||||||
|
response.setHeader("Expires","0");
|
||||||
|
|
||||||
|
BufferedInputStream fin = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
BufferedOutputStream outs = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
int read = 0;
|
||||||
|
|
||||||
|
while ((read = fin.read(b)) != -1) {
|
||||||
|
outs.write(b,0,read);
|
||||||
|
}
|
||||||
|
log.debug(this.getClass().getName()+" BufferedOutputStream Write Complete!!! ");
|
||||||
|
|
||||||
|
outs.close();
|
||||||
|
fin.close();
|
||||||
|
//*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,888 @@
|
||||||
|
/**
|
||||||
|
* @Class Name : EgovStringUtil.java
|
||||||
|
* @Description : 문자열 데이터 처리 관련 유틸리티
|
||||||
|
* @Modification Information
|
||||||
|
*
|
||||||
|
* 수정일 수정자 수정내용
|
||||||
|
* ------- -------- ---------------------------
|
||||||
|
* 2009.01.13 박정규 최초 생성
|
||||||
|
* 2009.02.13 이삼섭 내용 추가
|
||||||
|
*
|
||||||
|
* @author 공통 서비스 개발팀 박정규
|
||||||
|
* @since 2009. 01. 13
|
||||||
|
* @version 1.0
|
||||||
|
* @see
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.dbnt.kcscbackend.admin.contents.popUp.utils;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2006 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the ";License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS"; BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class EgovStringUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 빈 문자열 <code>""</code>.
|
||||||
|
*/
|
||||||
|
public static final String EMPTY = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 랜덤 객체
|
||||||
|
*/
|
||||||
|
public static SecureRandom rnd = new SecureRandom();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Padding을 할 수 있는 최대 수치</p>
|
||||||
|
*/
|
||||||
|
// private static final int PAD_LIMIT = 8192;
|
||||||
|
/**
|
||||||
|
* <p>An array of <code>String</code>s used for padding.</p>
|
||||||
|
* <p>Used for efficient space padding. The length of each String expands as needed.</p>
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
private static final String[] PADDING = new String[Character.MAX_VALUE];
|
||||||
|
|
||||||
|
static {
|
||||||
|
// space padding is most common, start with 64 chars
|
||||||
|
PADDING[32] = " ";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 문자열이 지정한 길이를 초과했을때 지정한길이에다가 해당 문자열을 붙여주는 메서드.
|
||||||
|
* @param source 원본 문자열 배열
|
||||||
|
* @param output 더할문자열
|
||||||
|
* @param slength 지정길이
|
||||||
|
* @return 지정길이로 잘라서 더할분자열 합친 문자열
|
||||||
|
*/
|
||||||
|
public static String cutString(String source, String output, int slength) {
|
||||||
|
String returnVal = null;
|
||||||
|
if (source != null) {
|
||||||
|
if (source.length() > slength) {
|
||||||
|
returnVal = source.substring(0, slength) + output;
|
||||||
|
} else {
|
||||||
|
returnVal = source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 문자열이 지정한 길이를 초과했을때 해당 문자열을 삭제하는 메서드
|
||||||
|
* @param source 원본 문자열 배열
|
||||||
|
* @param slength 지정길이
|
||||||
|
* @return 지정길이로 잘라서 더할분자열 합친 문자열
|
||||||
|
*/
|
||||||
|
public static String cutString(String source, int slength) {
|
||||||
|
String result = null;
|
||||||
|
if (source != null) {
|
||||||
|
if (source.length() > slength) {
|
||||||
|
result = source.substring(0, slength);
|
||||||
|
} else {
|
||||||
|
result = source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* String이 비었거나("") 혹은 null 인지 검증한다.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.isEmpty(null) = true
|
||||||
|
* StringUtil.isEmpty("") = true
|
||||||
|
* StringUtil.isEmpty(" ") = false
|
||||||
|
* StringUtil.isEmpty("bob") = false
|
||||||
|
* StringUtil.isEmpty(" bob ") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str - 체크 대상 스트링오브젝트이며 null을 허용함
|
||||||
|
* @return <code>true</code> - 입력받은 String 이 빈 문자열 또는 null인 경우
|
||||||
|
*/
|
||||||
|
public static boolean isEmpty(String str) {
|
||||||
|
return str == null || str.length() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>기준 문자열에 포함된 모든 대상 문자(char)를 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.remove(null, *) = null
|
||||||
|
* StringUtil.remove("", *) = ""
|
||||||
|
* StringUtil.remove("queued", 'u') = "qeed"
|
||||||
|
* StringUtil.remove("queued", 'z') = "queued"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 입력받는 기준 문자열
|
||||||
|
* @param remove 입력받는 문자열에서 제거할 대상 문자열
|
||||||
|
* @return 제거대상 문자열이 제거된 입력문자열. 입력문자열이 null인 경우 출력문자열은 null
|
||||||
|
*/
|
||||||
|
public static String remove(String str, char remove) {
|
||||||
|
if (isEmpty(str) || str.indexOf(remove) == -1) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
char[] chars = str.toCharArray();
|
||||||
|
int pos = 0;
|
||||||
|
for (int i = 0; i < chars.length; i++) {
|
||||||
|
if (chars[i] != remove) {
|
||||||
|
chars[pos++] = chars[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new String(chars, 0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>문자열 내부의 콤마 character(,)를 모두 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.removeCommaChar(null) = null
|
||||||
|
* StringUtil.removeCommaChar("") = ""
|
||||||
|
* StringUtil.removeCommaChar("asdfg,qweqe") = "asdfgqweqe"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 입력받는 기준 문자열
|
||||||
|
* @return " , "가 제거된 입력문자열
|
||||||
|
* 입력문자열이 null인 경우 출력문자열은 null
|
||||||
|
*/
|
||||||
|
public static String removeCommaChar(String str) {
|
||||||
|
return remove(str, ',');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>문자열 내부의 마이너스 character(-)를 모두 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.removeMinusChar(null) = null
|
||||||
|
* StringUtil.removeMinusChar("") = ""
|
||||||
|
* StringUtil.removeMinusChar("a-sdfg-qweqe") = "asdfgqweqe"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 입력받는 기준 문자열
|
||||||
|
* @return " - "가 제거된 입력문자열
|
||||||
|
* 입력문자열이 null인 경우 출력문자열은 null
|
||||||
|
*/
|
||||||
|
public static String removeMinusChar(String str) {
|
||||||
|
return remove(str, '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 원본 문자열의 포함된 특정 문자열을 새로운 문자열로 변환하는 메서드
|
||||||
|
* @param source 원본 문자열
|
||||||
|
* @param subject 원본 문자열에 포함된 특정 문자열
|
||||||
|
* @param object 변환할 문자열
|
||||||
|
* @return sb.toString() 새로운 문자열로 변환된 문자열
|
||||||
|
*/
|
||||||
|
public static String replace(String source, String subject, String object) {
|
||||||
|
StringBuffer rtnStr = new StringBuffer();
|
||||||
|
String preStr = "";
|
||||||
|
String nextStr = source;
|
||||||
|
String srcStr = source;
|
||||||
|
|
||||||
|
while (srcStr.indexOf(subject) >= 0) {
|
||||||
|
preStr = srcStr.substring(0, srcStr.indexOf(subject));
|
||||||
|
nextStr = srcStr.substring(srcStr.indexOf(subject) + subject.length(), srcStr.length());
|
||||||
|
srcStr = nextStr;
|
||||||
|
rtnStr.append(preStr).append(object);
|
||||||
|
}
|
||||||
|
rtnStr.append(nextStr);
|
||||||
|
return rtnStr.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 원본 문자열의 포함된 특정 문자열 첫번째 한개만 새로운 문자열로 변환하는 메서드
|
||||||
|
* @param source 원본 문자열
|
||||||
|
* @param subject 원본 문자열에 포함된 특정 문자열
|
||||||
|
* @param object 변환할 문자열
|
||||||
|
* @return sb.toString() 새로운 문자열로 변환된 문자열 / source 특정문자열이 없는 경우 원본 문자열
|
||||||
|
*/
|
||||||
|
public static String replaceOnce(String source, String subject, String object) {
|
||||||
|
StringBuffer rtnStr = new StringBuffer();
|
||||||
|
String preStr = "";
|
||||||
|
String nextStr = source;
|
||||||
|
if (source.indexOf(subject) >= 0) {
|
||||||
|
preStr = source.substring(0, source.indexOf(subject));
|
||||||
|
nextStr = source.substring(source.indexOf(subject) + subject.length(), source.length());
|
||||||
|
rtnStr.append(preStr).append(object).append(nextStr);
|
||||||
|
return rtnStr.toString();
|
||||||
|
} else {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>subject</code>에 포함된 각각의 문자를 object로 변환한다.
|
||||||
|
*
|
||||||
|
* @param source 원본 문자열
|
||||||
|
* @param subject 원본 문자열에 포함된 특정 문자열
|
||||||
|
* @param object 변환할 문자열
|
||||||
|
* @return sb.toString() 새로운 문자열로 변환된 문자열
|
||||||
|
*/
|
||||||
|
public static String replaceChar(String source, String subject, String object) {
|
||||||
|
StringBuffer rtnStr = new StringBuffer();
|
||||||
|
String preStr = "";
|
||||||
|
String nextStr = source;
|
||||||
|
String srcStr = source;
|
||||||
|
|
||||||
|
char chA;
|
||||||
|
|
||||||
|
for (int i = 0; i < subject.length(); i++) {
|
||||||
|
chA = subject.charAt(i);
|
||||||
|
|
||||||
|
if (srcStr.indexOf(chA) >= 0) {
|
||||||
|
preStr = srcStr.substring(0, srcStr.indexOf(chA));
|
||||||
|
nextStr = srcStr.substring(srcStr.indexOf(chA) + 1, srcStr.length());
|
||||||
|
srcStr = rtnStr.append(preStr).append(object).append(nextStr).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return srcStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p><code>str</code> 중 <code>searchStr</code>의 시작(index) 위치를 반환.</p>
|
||||||
|
*
|
||||||
|
* <p>입력값 중 <code>null</code>이 있을 경우 <code>-1</code>을 반환.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.indexOf(null, *) = -1
|
||||||
|
* StringUtil.indexOf(*, null) = -1
|
||||||
|
* StringUtil.indexOf("", "") = 0
|
||||||
|
* StringUtil.indexOf("aabaabaa", "a") = 0
|
||||||
|
* StringUtil.indexOf("aabaabaa", "b") = 2
|
||||||
|
* StringUtil.indexOf("aabaabaa", "ab") = 1
|
||||||
|
* StringUtil.indexOf("aabaabaa", "") = 0
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 검색 문자열
|
||||||
|
* @param searchStr 검색 대상문자열
|
||||||
|
* @return 검색 문자열 중 검색 대상문자열이 있는 시작 위치 검색대상 문자열이 없거나 null인 경우 -1
|
||||||
|
*/
|
||||||
|
public static int indexOf(String str, String searchStr) {
|
||||||
|
if (str == null || searchStr == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return str.indexOf(searchStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>오라클의 decode 함수와 동일한 기능을 가진 메서드이다.
|
||||||
|
* <code>sourStr</code>과 <code>compareStr</code>의 값이 같으면
|
||||||
|
* <code>returStr</code>을 반환하며, 다르면 <code>defaultStr</code>을 반환한다.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.decode(null, null, "foo", "bar")= "foo"
|
||||||
|
* StringUtil.decode("", null, "foo", "bar") = "bar"
|
||||||
|
* StringUtil.decode(null, "", "foo", "bar") = "bar"
|
||||||
|
* StringUtil.decode("하이", "하이", null, "bar") = null
|
||||||
|
* StringUtil.decode("하이", "하이 ", "foo", null) = null
|
||||||
|
* StringUtil.decode("하이", "하이", "foo", "bar") = "foo"
|
||||||
|
* StringUtil.decode("하이", "하이 ", "foo", "bar") = "bar"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param sourceStr 비교할 문자열
|
||||||
|
* @param compareStr 비교 대상 문자열
|
||||||
|
* @param returnStr sourceStr와 compareStr의 값이 같을 때 반환할 문자열
|
||||||
|
* @param defaultStr sourceStr와 compareStr의 값이 다를 때 반환할 문자열
|
||||||
|
* @return sourceStr과 compareStr의 값이 동일(equal)할 때 returnStr을 반환하며,
|
||||||
|
* <br/>다르면 defaultStr을 반환한다.
|
||||||
|
*/
|
||||||
|
public static String decode(String sourceStr, String compareStr, String returnStr, String defaultStr) {
|
||||||
|
if (sourceStr == null && compareStr == null) {
|
||||||
|
return returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (sourceStr != null && sourceStr.trim().equals(compareStr)) {
|
||||||
|
return returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>오라클의 decode 함수와 동일한 기능을 가진 메서드이다.
|
||||||
|
* <code>sourStr</code>과 <code>compareStr</code>의 값이 같으면
|
||||||
|
* <code>returStr</code>을 반환하며, 다르면 <code>sourceStr</code>을 반환한다.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.decode(null, null, "foo") = "foo"
|
||||||
|
* StringUtil.decode("", null, "foo") = ""
|
||||||
|
* StringUtil.decode(null, "", "foo") = null
|
||||||
|
* StringUtil.decode("하이", "하이", "foo") = "foo"
|
||||||
|
* StringUtil.decode("하이", "하이 ", "foo") = "하이"
|
||||||
|
* StringUtil.decode("하이", "바이", "foo") = "하이"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param sourceStr 비교할 문자열
|
||||||
|
* @param compareStr 비교 대상 문자열
|
||||||
|
* @param returnStr sourceStr와 compareStr의 값이 같을 때 반환할 문자열
|
||||||
|
* @return sourceStr과 compareStr의 값이 동일(equal)할 때 returnStr을 반환하며,
|
||||||
|
* <br/>다르면 sourceStr을 반환한다.
|
||||||
|
*/
|
||||||
|
public static String decode(String sourceStr, String compareStr, String returnStr) {
|
||||||
|
return decode(sourceStr, compareStr, returnStr, sourceStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 객체가 null인지 확인하고 null인 경우 "" 로 바꾸는 메서드
|
||||||
|
* @param object 원본 객체
|
||||||
|
* @return resultVal 문자열
|
||||||
|
*/
|
||||||
|
public static String isNullToString(Object object) {
|
||||||
|
String string = "";
|
||||||
|
|
||||||
|
if (object != null) {
|
||||||
|
string = object.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*<pre>
|
||||||
|
* 인자로 받은 String이 null일 경우 ""로 리턴한다.
|
||||||
|
* @param src null값일 가능성이 있는 String 값.
|
||||||
|
* @return 만약 String이 null 값일 경우 ""로 바꾼 String 값.
|
||||||
|
*</pre>
|
||||||
|
*/
|
||||||
|
public static String nullConvert(Object src) {
|
||||||
|
//if (src != null && src.getClass().getName().equals("java.math.BigDecimal")) {
|
||||||
|
if (src != null && src instanceof BigDecimal) {
|
||||||
|
return ((BigDecimal)src).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (src == null || src.equals("null")) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return ((String)src).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*<pre>
|
||||||
|
* 인자로 받은 String이 null일 경우 ""로 리턴한다.
|
||||||
|
* @param src null값일 가능성이 있는 String 값.
|
||||||
|
* @return 만약 String이 null 값일 경우 ""로 바꾼 String 값.
|
||||||
|
*</pre>
|
||||||
|
*/
|
||||||
|
public static String nullConvert(String src) {
|
||||||
|
|
||||||
|
if (src == null || src.equals("null") || "".equals(src) || " ".equals(src)) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return src.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*<pre>
|
||||||
|
* 인자로 받은 String이 null일 경우 "0"로 리턴한다.
|
||||||
|
* @param src null값일 가능성이 있는 String 값.
|
||||||
|
* @return 만약 String이 null 값일 경우 "0"로 바꾼 String 값.
|
||||||
|
*</pre>
|
||||||
|
*/
|
||||||
|
public static int zeroConvert(Object src) {
|
||||||
|
|
||||||
|
if (src == null || src.equals("null")) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return Integer.parseInt(((String)src).trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*<pre>
|
||||||
|
* 인자로 받은 String이 null일 경우 ""로 리턴한다.
|
||||||
|
* @param src null값일 가능성이 있는 String 값.
|
||||||
|
* @return 만약 String이 null 값일 경우 ""로 바꾼 String 값.
|
||||||
|
*</pre>
|
||||||
|
*/
|
||||||
|
public static int zeroConvert(String src) {
|
||||||
|
|
||||||
|
if (src == null || src.equals("null") || "".equals(src) || " ".equals(src)) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return Integer.parseInt(src.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>문자열에서 {@link Character#isWhitespace(char)}에 정의된
|
||||||
|
* 모든 공백문자를 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.removeWhitespace(null) = null
|
||||||
|
* StringUtil.removeWhitespace("") = ""
|
||||||
|
* StringUtil.removeWhitespace("abc") = "abc"
|
||||||
|
* StringUtil.removeWhitespace(" ab c ") = "abc"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 공백문자가 제거도어야 할 문자열
|
||||||
|
* @return the 공백문자가 제거된 문자열, null이 입력되면 <code>null</code>이 리턴
|
||||||
|
*/
|
||||||
|
public static String removeWhitespace(String str) {
|
||||||
|
if (isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
int sz = str.length();
|
||||||
|
char[] chs = new char[sz];
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < sz; i++) {
|
||||||
|
if (!Character.isWhitespace(str.charAt(i))) {
|
||||||
|
chs[count++] = str.charAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count == sz) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(chs, 0, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Html 코드가 들어간 문서를 표시할때 태그에 손상없이 보이기 위한 메서드
|
||||||
|
*
|
||||||
|
* @param strString
|
||||||
|
* @return HTML 태그를 치환한 문자열
|
||||||
|
*/
|
||||||
|
public static String checkHtmlView(String strString) {
|
||||||
|
String strNew = "";
|
||||||
|
|
||||||
|
StringBuffer strTxt = new StringBuffer("");
|
||||||
|
|
||||||
|
char chrBuff;
|
||||||
|
int len = strString.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
chrBuff = strString.charAt(i);
|
||||||
|
|
||||||
|
switch (chrBuff) {
|
||||||
|
case '<':
|
||||||
|
strTxt.append("<");
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
strTxt.append(">");
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
strTxt.append(""");
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
strTxt.append("<br>");
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
strTxt.append(" ");
|
||||||
|
break;
|
||||||
|
//case '&' :
|
||||||
|
//strTxt.append("&");
|
||||||
|
//break;
|
||||||
|
default:
|
||||||
|
strTxt.append(chrBuff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
strNew = strTxt.toString();
|
||||||
|
|
||||||
|
return strNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 문자열을 지정한 분리자에 의해 배열로 리턴하는 메서드.
|
||||||
|
* @param source 원본 문자열
|
||||||
|
* @param separator 분리자
|
||||||
|
* @return result 분리자로 나뉘어진 문자열 배열
|
||||||
|
*/
|
||||||
|
public static String[] split(String source, String separator) throws NullPointerException {
|
||||||
|
String[] returnVal = null;
|
||||||
|
int cnt = 1;
|
||||||
|
|
||||||
|
int index = source.indexOf(separator);
|
||||||
|
int index0 = 0;
|
||||||
|
while (index >= 0) {
|
||||||
|
cnt++;
|
||||||
|
index = source.indexOf(separator, index + 1);
|
||||||
|
}
|
||||||
|
returnVal = new String[cnt];
|
||||||
|
cnt = 0;
|
||||||
|
index = source.indexOf(separator);
|
||||||
|
while (index >= 0) {
|
||||||
|
returnVal[cnt] = source.substring(index0, index);
|
||||||
|
index0 = index + 1;
|
||||||
|
index = source.indexOf(separator, index + 1);
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
returnVal[cnt] = source.substring(index0);
|
||||||
|
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>{@link String#toLowerCase()}를 이용하여 소문자로 변환한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.lowerCase(null) = null
|
||||||
|
* StringUtil.lowerCase("") = ""
|
||||||
|
* StringUtil.lowerCase("aBc") = "abc"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 소문자로 변환되어야 할 문자열
|
||||||
|
* @return 소문자로 변환된 문자열, null이 입력되면 <code>null</code> 리턴
|
||||||
|
*/
|
||||||
|
public static String lowerCase(String str) {
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>{@link String#toUpperCase()}를 이용하여 대문자로 변환한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.upperCase(null) = null
|
||||||
|
* StringUtil.upperCase("") = ""
|
||||||
|
* StringUtil.upperCase("aBc") = "ABC"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 대문자로 변환되어야 할 문자열
|
||||||
|
* @return 대문자로 변환된 문자열, null이 입력되면 <code>null</code> 리턴
|
||||||
|
*/
|
||||||
|
public static String upperCase(String str) {
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>입력된 String의 앞쪽에서 두번째 인자로 전달된 문자(stripChars)를 모두 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.stripStart(null, *) = null
|
||||||
|
* StringUtil.stripStart("", *) = ""
|
||||||
|
* StringUtil.stripStart("abc", "") = "abc"
|
||||||
|
* StringUtil.stripStart("abc", null) = "abc"
|
||||||
|
* StringUtil.stripStart(" abc", null) = "abc"
|
||||||
|
* StringUtil.stripStart("abc ", null) = "abc "
|
||||||
|
* StringUtil.stripStart(" abc ", null) = "abc "
|
||||||
|
* StringUtil.stripStart("yxabc ", "xyz") = "abc "
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 지정된 문자가 제거되어야 할 문자열
|
||||||
|
* @param stripChars 제거대상 문자열
|
||||||
|
* @return 지정된 문자가 제거된 문자열, null이 입력되면 <code>null</code> 리턴
|
||||||
|
*/
|
||||||
|
public static String stripStart(String str, String stripChars) {
|
||||||
|
int strLen;
|
||||||
|
if (str == null || (strLen = str.length()) == 0) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
int start = 0;
|
||||||
|
if (stripChars == null) {
|
||||||
|
while ((start != strLen) && Character.isWhitespace(str.charAt(start))) {
|
||||||
|
start++;
|
||||||
|
}
|
||||||
|
} else if (stripChars.length() == 0) {
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {
|
||||||
|
start++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.substring(start);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>입력된 String의 뒤쪽에서 두번째 인자로 전달된 문자(stripChars)를 모두 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.stripEnd(null, *) = null
|
||||||
|
* StringUtil.stripEnd("", *) = ""
|
||||||
|
* StringUtil.stripEnd("abc", "") = "abc"
|
||||||
|
* StringUtil.stripEnd("abc", null) = "abc"
|
||||||
|
* StringUtil.stripEnd(" abc", null) = " abc"
|
||||||
|
* StringUtil.stripEnd("abc ", null) = "abc"
|
||||||
|
* StringUtil.stripEnd(" abc ", null) = " abc"
|
||||||
|
* StringUtil.stripEnd(" abcyx", "xyz") = " abc"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 지정된 문자가 제거되어야 할 문자열
|
||||||
|
* @param stripChars 제거대상 문자열
|
||||||
|
* @return 지정된 문자가 제거된 문자열, null이 입력되면 <code>null</code> 리턴
|
||||||
|
*/
|
||||||
|
public static String stripEnd(String str, String stripChars) {
|
||||||
|
int end;
|
||||||
|
if (str == null || (end = str.length()) == 0) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stripChars == null) {
|
||||||
|
while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
} else if (stripChars.length() == 0) {
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.substring(0, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>입력된 String의 앞, 뒤에서 두번째 인자로 전달된 문자(stripChars)를 모두 제거한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.strip(null, *) = null
|
||||||
|
* StringUtil.strip("", *) = ""
|
||||||
|
* StringUtil.strip("abc", null) = "abc"
|
||||||
|
* StringUtil.strip(" abc", null) = "abc"
|
||||||
|
* StringUtil.strip("abc ", null) = "abc"
|
||||||
|
* StringUtil.strip(" abc ", null) = "abc"
|
||||||
|
* StringUtil.strip(" abcyx", "xyz") = " abc"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str 지정된 문자가 제거되어야 할 문자열
|
||||||
|
* @param stripChars 제거대상 문자열
|
||||||
|
* @return 지정된 문자가 제거된 문자열, null이 입력되면 <code>null</code> 리턴
|
||||||
|
*/
|
||||||
|
public static String strip(String str, String stripChars) {
|
||||||
|
if (isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
String srcStr = str;
|
||||||
|
srcStr = stripStart(srcStr, stripChars);
|
||||||
|
|
||||||
|
return stripEnd(srcStr, stripChars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 문자열을 지정한 분리자에 의해 지정된 길이의 배열로 리턴하는 메서드.
|
||||||
|
* @param source 원본 문자열
|
||||||
|
* @param separator 분리자
|
||||||
|
* @param arraylength 배열 길이
|
||||||
|
* @return 분리자로 나뉘어진 문자열 배열
|
||||||
|
*/
|
||||||
|
public static String[] split(String source, String separator, int arraylength) throws NullPointerException {
|
||||||
|
String[] returnVal = new String[arraylength];
|
||||||
|
int cnt = 0;
|
||||||
|
int index0 = 0;
|
||||||
|
int index = source.indexOf(separator);
|
||||||
|
while (index >= 0 && cnt < (arraylength - 1)) {
|
||||||
|
returnVal[cnt] = source.substring(index0, index);
|
||||||
|
index0 = index + 1;
|
||||||
|
index = source.indexOf(separator, index + 1);
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
returnVal[cnt] = source.substring(index0);
|
||||||
|
if (cnt < (arraylength - 1)) {
|
||||||
|
for (int i = cnt + 1; i < arraylength; i++) {
|
||||||
|
returnVal[i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 문자열 A에서 Z사이의 랜덤 문자열을 구하는 기능을 제공 시작문자열과 종료문자열 사이의 랜덤 문자열을 구하는 기능
|
||||||
|
*
|
||||||
|
* @param startChr
|
||||||
|
* - 첫 문자
|
||||||
|
* @param endChr
|
||||||
|
* - 마지막문자
|
||||||
|
* @return 랜덤문자
|
||||||
|
* @exception MyException
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public static String getRandomStr(char startChr, char endChr) {
|
||||||
|
|
||||||
|
int randomInt;
|
||||||
|
String randomStr = null;
|
||||||
|
|
||||||
|
// 시작문자 및 종료문자를 아스키숫자로 변환한다.
|
||||||
|
int startInt = Integer.valueOf(startChr);
|
||||||
|
int endInt = Integer.valueOf(endChr);
|
||||||
|
|
||||||
|
// 시작문자열이 종료문자열보가 클경우
|
||||||
|
if (startInt > endInt) {
|
||||||
|
throw new IllegalArgumentException("Start String: " + startChr + " End String: " + endChr);
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
// 시작문자 및 종료문자 중에서 랜덤 숫자를 발생시킨다.
|
||||||
|
randomInt = rnd.nextInt(endInt + 1);
|
||||||
|
} while (randomInt < startInt); // 입력받은 문자 'A'(65)보다 작으면 다시 랜덤 숫자 발생.
|
||||||
|
|
||||||
|
// 랜덤 숫자를 문자로 변환 후 스트링으로 다시 변환
|
||||||
|
randomStr = (char)randomInt + "";
|
||||||
|
|
||||||
|
// 랜덤문자열를 리턴
|
||||||
|
return randomStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 문자열을 다양한 문자셋(EUC-KR[KSC5601],UTF-8..)을 사용하여 인코딩하는 기능 역으로 디코딩하여 원래의 문자열을
|
||||||
|
* 복원하는 기능을 제공함 String temp = new String(문자열.getBytes("바꾸기전 인코딩"),"바꿀 인코딩");
|
||||||
|
* String temp = new String(문자열.getBytes("8859_1"),"KSC5601"); => UTF-8 에서
|
||||||
|
* EUC-KR
|
||||||
|
*
|
||||||
|
* @param srcString
|
||||||
|
* - 문자열
|
||||||
|
* @param srcCharsetNm
|
||||||
|
* - 원래 CharsetNm
|
||||||
|
* @param charsetNm
|
||||||
|
* - CharsetNm
|
||||||
|
* @return 인(디)코딩 문자열
|
||||||
|
* @exception MyException
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public static String getEncdDcd(String srcString, String srcCharsetNm, String cnvrCharsetNm) {
|
||||||
|
|
||||||
|
String rtnStr = null;
|
||||||
|
|
||||||
|
if (srcString == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
rtnStr = new String(srcString.getBytes(srcCharsetNm), cnvrCharsetNm);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
rtnStr = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 특수문자를 웹 브라우저에서 정상적으로 보이기 위해 특수문자를 처리('<' -> & lT)하는 기능이다
|
||||||
|
* @param srcString - '<'
|
||||||
|
* @return 변환문자열('<' -> "<"
|
||||||
|
* @exception MyException
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public static String getSpclStrCnvr(String srcString) {
|
||||||
|
|
||||||
|
String rtnStr = null;
|
||||||
|
|
||||||
|
StringBuffer strTxt = new StringBuffer("");
|
||||||
|
|
||||||
|
char chrBuff;
|
||||||
|
int len = srcString.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
chrBuff = srcString.charAt(i);
|
||||||
|
|
||||||
|
switch (chrBuff) {
|
||||||
|
case '<':
|
||||||
|
strTxt.append("<");
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
strTxt.append(">");
|
||||||
|
break;
|
||||||
|
case '&':
|
||||||
|
strTxt.append("&");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strTxt.append(chrBuff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rtnStr = strTxt.toString();
|
||||||
|
|
||||||
|
return rtnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 응용어플리케이션에서 고유값을 사용하기 위해 시스템에서17자리의TIMESTAMP값을 구하는 기능
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return Timestamp 값
|
||||||
|
* @exception MyException
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public static String getTimeStamp() {
|
||||||
|
|
||||||
|
String rtnStr = null;
|
||||||
|
|
||||||
|
// 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초))
|
||||||
|
String pattern = "yyyyMMddhhmmssSSS";
|
||||||
|
|
||||||
|
SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA);
|
||||||
|
Timestamp ts = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
rtnStr = sdfCurrent.format(ts.getTime());
|
||||||
|
|
||||||
|
return rtnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* html의 특수문자를 표현하기 위해
|
||||||
|
*
|
||||||
|
* @param srcString
|
||||||
|
* @return String
|
||||||
|
* @exception Exception
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public static String getHtmlStrCnvr(String srcString) {
|
||||||
|
|
||||||
|
String tmpString = srcString;
|
||||||
|
|
||||||
|
tmpString = tmpString.replaceAll("<", "<");
|
||||||
|
tmpString = tmpString.replaceAll(">", ">");
|
||||||
|
tmpString = tmpString.replaceAll("&", "&");
|
||||||
|
tmpString = tmpString.replaceAll(" ", " ");
|
||||||
|
tmpString = tmpString.replaceAll("'", "\'");
|
||||||
|
tmpString = tmpString.replaceAll(""", "\"");
|
||||||
|
|
||||||
|
return tmpString;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>날짜 형식의 문자열 내부에 마이너스 character(-)를 추가한다.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtil.addMinusChar("20100901") = "2010-09-01"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param date 입력받는 문자열
|
||||||
|
* @return " - "가 추가된 입력문자열
|
||||||
|
*/
|
||||||
|
public static String addMinusChar(String date) {
|
||||||
|
if (date.length() == 8) {
|
||||||
|
return date.substring(0, 4).concat("-").concat(date.substring(4, 6)).concat("-")
|
||||||
|
.concat(date.substring(6, 8));
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,136 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.contents.popUp.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 교차접속 스크립트 공격 취약성 방지(파라미터 문자열 교체)
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* << 개정이력(Modification Information) >>
|
||||||
|
*
|
||||||
|
* 수정일 수정자 수정내용
|
||||||
|
* ----------- -------- ---------------------------
|
||||||
|
* 2011.10.10 한성곤 최초 생성
|
||||||
|
* 2017-02-07 이정은 시큐어코딩(ES) - 시큐어코딩 경로 조작 및 자원 삽입[CWE-22, CWE-23, CWE-95, CWE-99]
|
||||||
|
* 2018.08.17 신용호 filePathBlackList 수정
|
||||||
|
* 2018.10.10 신용호 . => \\.으로 수정
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EgovWebUtil {
|
||||||
|
|
||||||
|
|
||||||
|
public static ResultVO handleAuthError(int code, String msg) {
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
resultVO.setResultCode(code);
|
||||||
|
resultVO.setResultMessage(msg);
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
public static String clearXSSMinimum(String value) {
|
||||||
|
if (value == null || value.trim().equals("")) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String returnValue = value;
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("&", "&");
|
||||||
|
returnValue = returnValue.replaceAll("<", "<");
|
||||||
|
returnValue = returnValue.replaceAll(">", ">");
|
||||||
|
returnValue = returnValue.replaceAll("\"", """);
|
||||||
|
returnValue = returnValue.replaceAll("\'", "'");
|
||||||
|
returnValue = returnValue.replaceAll("\\.", ".");
|
||||||
|
returnValue = returnValue.replaceAll("%2E", ".");
|
||||||
|
returnValue = returnValue.replaceAll("%2F", "/");
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String clearXSSMaximum(String value) {
|
||||||
|
String returnValue = value;
|
||||||
|
returnValue = clearXSSMinimum(returnValue);
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("%00", null);
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("%", "%");
|
||||||
|
|
||||||
|
// \\. => .
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("\\.\\./", ""); // ../
|
||||||
|
returnValue = returnValue.replaceAll("\\.\\.\\\\", ""); // ..\
|
||||||
|
returnValue = returnValue.replaceAll("\\./", ""); // ./
|
||||||
|
returnValue = returnValue.replaceAll("%2F", "");
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filePathBlackList(String value) {
|
||||||
|
String returnValue = value;
|
||||||
|
if (returnValue == null || returnValue.trim().equals("")) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("\\.\\.", "");
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 행안부 보안취약점 점검 조치 방안.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String filePathReplaceAll(String value) {
|
||||||
|
String returnValue = value;
|
||||||
|
if (returnValue == null || returnValue.trim().equals("")) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("/", "");
|
||||||
|
returnValue = returnValue.replaceAll("\\\\", ""); // \
|
||||||
|
returnValue = returnValue.replaceAll("\\.\\.", ""); // ..
|
||||||
|
returnValue = returnValue.replaceAll("&", "");
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String fileInjectPathReplaceAll(String value) {
|
||||||
|
String returnValue = value;
|
||||||
|
if (returnValue == null || returnValue.trim().equals("")) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
returnValue = returnValue.replaceAll("/", "");
|
||||||
|
returnValue = returnValue.replaceAll("\\..", ""); // ..
|
||||||
|
returnValue = returnValue.replaceAll("\\\\", "");// \
|
||||||
|
returnValue = returnValue.replaceAll("&", "");
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filePathWhiteList(String value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIPAddress(String str) {
|
||||||
|
Pattern ipPattern = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
|
||||||
|
|
||||||
|
return ipPattern.matcher(str).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String removeCRLF(String parameter) {
|
||||||
|
return parameter.replaceAll("\r", "").replaceAll("\n", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String removeSQLInjectionRisk(String parameter) {
|
||||||
|
return parameter.replaceAll("\\p{Space}", "").replaceAll("\\*", "").replaceAll("%", "").replaceAll(";", "").replaceAll("-", "").replaceAll("\\+", "").replaceAll(",", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String removeOSCmdRisk(String parameter) {
|
||||||
|
return parameter.replaceAll("\\p{Space}", "").replaceAll("\\*", "").replaceAll("\\|", "").replaceAll(";", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -110,12 +110,8 @@ public interface TnCmtEventRepository extends JpaRepository<TnCmtEvent, TnCmtEve
|
||||||
@Param("_error_message") String errorMessage
|
@Param("_error_message") String errorMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@Procedure("sp_is_valid_tn_cmt_event_id")
|
||||||
//@Procedure
|
int spIsValidTnCmtEventId( Integer evtSeq );
|
||||||
//Map<String, Object> sp_is_valid_tn_cmt_event_id( @Param("_evt_seq") Long evtSeq );
|
|
||||||
|
|
||||||
@Procedure
|
|
||||||
int sp_is_valid_tn_cmt_event_id( Integer evtSeq );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,85 @@
|
||||||
package com.dbnt.kcscbackend.commonCode.repository;
|
package com.dbnt.kcscbackend.commonCode.repository;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.commonCode.entity.TnCmtEvent;
|
||||||
import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng;
|
import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.jpa.repository.query.Procedure;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public interface TnPopupMngRepository extends JpaRepository<TnPopupMng, TnPopupMng.TnPopupMngId> {
|
public interface TnPopupMngRepository extends JpaRepository<TnPopupMng, TnPopupMng.TnPopupMngId> {
|
||||||
|
|
||||||
|
@Query(value = "CALL sp_add_tn_popup_mng (" +
|
||||||
|
":_popup_title, " +
|
||||||
|
"TO_TIMESTAMP(" +
|
||||||
|
" :_popup_start_date," +
|
||||||
|
" 'YYYYMMDDHH24MISS'" +
|
||||||
|
")::::timestamptz AT TIME ZONE 'UTC', " +
|
||||||
|
"TO_TIMESTAMP(" +
|
||||||
|
" :_popup_end_date," +
|
||||||
|
" 'YYYYMMDDHH24MISS'" +
|
||||||
|
")::::timestamptz AT TIME ZONE 'UTC', " +
|
||||||
|
":_file_grp_id, " +
|
||||||
|
":_popup_contents, " +
|
||||||
|
":_modi_id, " +
|
||||||
|
":_popup_seq, " +
|
||||||
|
":_result_count, " +
|
||||||
|
":_result_code, " +
|
||||||
|
":_error_message)",
|
||||||
|
nativeQuery = true)
|
||||||
|
Map<String, Object> spAddTnPopupMng(
|
||||||
|
@Param("_popup_title") String popupTitle,
|
||||||
|
@Param("_popup_start_date") String popupStartDate,
|
||||||
|
@Param("_popup_end_date") String popupEndDate,
|
||||||
|
@Param("_file_grp_id") String fileGrpId,
|
||||||
|
@Param("_popup_contents") String popupContents,
|
||||||
|
@Param("_modi_id") String modiId,
|
||||||
|
@Param("_popup_seq") Integer popupSeq,
|
||||||
|
@Param("_result_count") Integer resultCount,
|
||||||
|
@Param("_result_code") String resultCode,
|
||||||
|
@Param("_error_message") String errorMessage
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = "CALL sp_update_tn_popup_mng (" +
|
||||||
|
":_popup_seq, " +
|
||||||
|
":_popup_title, " +
|
||||||
|
"TO_TIMESTAMP(" +
|
||||||
|
" :_popup_start_date," +
|
||||||
|
" 'YYYYMMDDHH24MISS'" +
|
||||||
|
")::::timestamptz AT TIME ZONE 'UTC', " +
|
||||||
|
"TO_TIMESTAMP(" +
|
||||||
|
" :_popup_end_date," +
|
||||||
|
" 'YYYYMMDDHH24MISS'" +
|
||||||
|
")::::timestamptz AT TIME ZONE 'UTC', " +
|
||||||
|
":_file_grp_id, " +
|
||||||
|
":_popup_contents, " +
|
||||||
|
":_modi_id, " +
|
||||||
|
":_result_count, " +
|
||||||
|
":_result_code, " +
|
||||||
|
":_error_message)",
|
||||||
|
nativeQuery = true)
|
||||||
|
Map<String, Object> spUpdateTnPopupMng(
|
||||||
|
@Param("_popup_seq") Integer popupSeq,
|
||||||
|
@Param("_popup_title") String popupTitle,
|
||||||
|
@Param("_popup_start_date") String popupStartDate,
|
||||||
|
@Param("_popup_end_date") String popupEndDate,
|
||||||
|
@Param("_file_grp_id") String fileGrpId,
|
||||||
|
@Param("_popup_contents") String popupContents,
|
||||||
|
@Param("_modi_id") String modiId,
|
||||||
|
@Param("_result_count") Integer resultCount,
|
||||||
|
@Param("_result_code") String resultCode,
|
||||||
|
@Param("_error_message") String errorMessage
|
||||||
|
);
|
||||||
|
|
||||||
|
@Procedure("sp_is_valid_tn_popup_mng_id")
|
||||||
|
int spIsValidTnPopupMngId( Integer popupSeq );
|
||||||
|
|
||||||
|
TnPopupMng findByPopupSeq(Long popupSeq);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue