parent
0d338b97b1
commit
efd35230c1
|
|
@ -1,4 +1,4 @@
|
||||||
import React, {useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import { Link, NavLink, useNavigate } from 'react-router-dom';
|
import { Link, NavLink, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import * as EgovNet from 'api/egovFetch';
|
import * as EgovNet from 'api/egovFetch';
|
||||||
|
|
@ -64,6 +64,9 @@ function EgovHeader({ loginUser, onChangeLogin }) {
|
||||||
console.log("------------------------------EgovHeader [End]");
|
console.log("------------------------------EgovHeader [End]");
|
||||||
console.groupEnd("EgovHeader");
|
console.groupEnd("EgovHeader");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setMenuDiv(false);
|
||||||
|
}, [navigate]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import React, {useCallback, useEffect, useState} from 'react';
|
import React, {useCallback, useEffect, useState} from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import URL from 'constants/url';
|
import URL from 'constants/url';
|
||||||
|
|
||||||
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
||||||
import * as EgovNet from "../../../api/egovFetch";
|
import * as EgovNet from "api/egovFetch";
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import Form from "react-bootstrap/Form";
|
||||||
import SurveyModal from "./survey/SurveyModal";
|
import SurveyModal from "./survey/SurveyModal";
|
||||||
import QuestionModal from "./survey/QuestionModal";
|
import QuestionModal from "./survey/QuestionModal";
|
||||||
|
import CODE from "../../../constants/code";
|
||||||
|
|
||||||
|
|
||||||
function Survey({}) {
|
function Survey({}) {
|
||||||
|
|
@ -38,15 +38,12 @@ function Survey({}) {
|
||||||
<div>{item.svyTitle}</div>
|
<div>{item.svyTitle}</div>
|
||||||
<div>{item.svyStartDt}~{item.svyEndDt}</div>
|
<div>{item.svyStartDt}~{item.svyEndDt}</div>
|
||||||
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurveyQt(item)}}>질문관리</button></div>
|
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurveyQt(item)}}>질문관리</button></div>
|
||||||
<div></div>
|
<div><Form.Check type={"switch"} defaultChecked={item.useYn==="Y"} onChange={()=>editUseYn(item.svySeq)}/></div>
|
||||||
<div><button className={"btn btn_blue_h31 px-1"}>설문지 보기</button></div>
|
<div><button className={"btn btn_blue_h31 px-1"}>설문지 보기</button></div>
|
||||||
<div><button className={"btn btn_blue_h31 px-1"}>통계 보기</button></div>
|
<div><button className={"btn btn_blue_h31 px-1"}>통계 보기</button></div>
|
||||||
<div>
|
<div>
|
||||||
<button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurvey(item)}}>수정</button>
|
<button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurvey(item)}}>수정</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<button className={"btn btn_red_h31 px-1"} onClick={()=>{editSurvey(item)}}>삭제</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -59,6 +56,29 @@ function Survey({}) {
|
||||||
);
|
);
|
||||||
},[]);
|
},[]);
|
||||||
|
|
||||||
|
function editUseYn(svySeq){
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/survey/info-use-yn',
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({svySeq:svySeq})
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("저장되었습니다.")
|
||||||
|
retrieveList();
|
||||||
|
}else{
|
||||||
|
alert(resp.resultMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function editSurvey(item){
|
function editSurvey(item){
|
||||||
handleShow();
|
handleShow();
|
||||||
setModalSize("md")
|
setModalSize("md")
|
||||||
|
|
@ -103,7 +123,6 @@ function Survey({}) {
|
||||||
<span>사용여부</span>
|
<span>사용여부</span>
|
||||||
<span>설문지 보기</span>
|
<span>설문지 보기</span>
|
||||||
<span>통계 보기</span>
|
<span>통계 보기</span>
|
||||||
<span></span>
|
|
||||||
<span><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurvey(undefined)}}>추가</button></span>
|
<span><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurvey(undefined)}}>추가</button></span>
|
||||||
</div>
|
</div>
|
||||||
<div className="result">
|
<div className="result">
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ function QuestionModal({svySeq}){
|
||||||
|
|
||||||
const [qtList, setQtList] = useState([]);
|
const [qtList, setQtList] = useState([]);
|
||||||
const [selectedQt, setSelectedQt] = useState(null);
|
const [selectedQt, setSelectedQt] = useState(null);
|
||||||
|
const [tempSeq, setTempSeq] = useState(1);
|
||||||
|
|
||||||
function getSurveyQt(){
|
function getSurveyQt(){
|
||||||
EgovNet.requestFetch(
|
EgovNet.requestFetch(
|
||||||
'/admin/survey/edit-qt?svySeq='+svySeq,
|
'/admin/survey/info-qt?svySeq='+svySeq,
|
||||||
{
|
{
|
||||||
method: "GET"
|
method: "GET"
|
||||||
},
|
},
|
||||||
|
|
@ -27,7 +28,20 @@ function QuestionModal({svySeq}){
|
||||||
}
|
}
|
||||||
|
|
||||||
function addQt(){
|
function addQt(){
|
||||||
|
const temp = [...qtList]
|
||||||
|
temp.push({
|
||||||
|
qtSeq: null,
|
||||||
|
tempSeq: tempSeq,
|
||||||
|
svySeq: svySeq,
|
||||||
|
qtTitle: '',
|
||||||
|
qtDesc: '',
|
||||||
|
qtType: '',
|
||||||
|
maxNo: '',
|
||||||
|
etcYn: '',
|
||||||
|
itemList:[]
|
||||||
|
})
|
||||||
|
setQtList(temp);
|
||||||
|
setTempSeq(tempSeq+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addItem(){
|
function addItem(){
|
||||||
|
|
@ -42,6 +56,20 @@ function QuestionModal({svySeq}){
|
||||||
getSurveyQt()
|
getSurveyQt()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const tempQt = [...qtList];
|
||||||
|
tempQt.forEach(function (qt, index){
|
||||||
|
if(qt.qtSeq === null){
|
||||||
|
if(qt.tempSeq === selectedQt.tempSeq){
|
||||||
|
qt = selectedQt;
|
||||||
|
}
|
||||||
|
}else if(qt.qtSeq === selectedQt.qtSeq){
|
||||||
|
qt = selectedQt;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
setQtList(tempQt);
|
||||||
|
}, [selectedQt]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal.Header closeButton>
|
<Modal.Header closeButton>
|
||||||
|
|
@ -76,7 +104,7 @@ function QuestionModal({svySeq}){
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</Table>
|
</Table>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={7}>
|
<Col xs={7} className={selectedQt?"":"d-none"}>
|
||||||
<Form.Group as={Row} className="mb-3">
|
<Form.Group as={Row} className="mb-3">
|
||||||
<Form.Label column sm={3}>
|
<Form.Label column sm={3}>
|
||||||
질문유형
|
질문유형
|
||||||
|
|
@ -93,13 +121,13 @@ function QuestionModal({svySeq}){
|
||||||
최대 선택 개수
|
최대 선택 개수
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={3}>
|
<Col sm={3}>
|
||||||
<Form.Control type="text" name="maxNo" defaultValue={selectedQt?.maxNo}/>
|
<Form.Control type="text" name="maxNo" defaultValue={selectedQt?.maxNo} onChange={(e)=>{setSelectedQt({...selectedQt, maxNo:e.target.value})}}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Form.Label column sm={'auto'}>
|
<Form.Label column sm={'auto'}>
|
||||||
기타 여부
|
기타 여부
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={3} className={'my-auto'}>
|
<Col sm={3} className={'my-auto'}>
|
||||||
<Form.Check type="checkbox" name="mandatoryYn" checked={selectedQt?.mandatoryYn==='Y'}/>
|
<Form.Check type="checkbox" name="etcYn" checked={selectedQt?.etcYn==='Y'} onClick={(e)=>{setSelectedQt({...selectedQt, etcYn:e.target.checked?'Y':'N'})}}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Table>
|
<Table>
|
||||||
|
|
@ -109,11 +137,16 @@ function QuestionModal({svySeq}){
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{selectedQt?.itemList.map(item=>{
|
{selectedQt?.itemList.map((item, index)=>{
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Form.Control type={"text"} defaultValue={item.itemNm}/>
|
<Form.Control type={"text"} defaultValue={item.itemNm} value={item.itemNm}
|
||||||
|
onChange={(e)=>{
|
||||||
|
const qt = {...selectedQt}
|
||||||
|
qt.itemList[index].itemNm = e.target.value
|
||||||
|
setSelectedQt(qt);
|
||||||
|
}}/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,61 @@
|
||||||
import React from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
import Form from "react-bootstrap/Form";
|
import Form from "react-bootstrap/Form";
|
||||||
import Row from "react-bootstrap/Row";
|
import Row from "react-bootstrap/Row";
|
||||||
import Col from "react-bootstrap/Col";
|
import Col from "react-bootstrap/Col";
|
||||||
import * as EgovNet from "api/egovFetch";
|
import * as EgovNet from "api/egovFetch";
|
||||||
import CODE from "constants/code";
|
import CODE from "constants/code";
|
||||||
|
import DatePicker from "react-datepicker";
|
||||||
|
|
||||||
function SurveyModal({savedInfo, reloadFunction}){
|
function SurveyModal({savedInfo, reloadFunction}){
|
||||||
|
|
||||||
|
const [survey, setSurvey] = useState({
|
||||||
|
svySeq: savedInfo?savedInfo.svySeq:null,
|
||||||
|
svyTitle: savedInfo?savedInfo.svyTitle:'',
|
||||||
|
svyDesc: savedInfo?savedInfo.svyDesc:'',
|
||||||
|
svyStartDt: savedInfo?new Date(savedInfo.svyStartDt):new Date(),
|
||||||
|
svyEndDt: savedInfo?new Date(savedInfo.svyEndDt):new Date(),
|
||||||
|
})
|
||||||
|
|
||||||
function editSurvey(e){
|
function editSurvey(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const form = e.target;
|
|
||||||
const info = {
|
|
||||||
menuId: form.menuId.value,
|
|
||||||
menuTitle: form.menuTitle.value,
|
|
||||||
menuGroup: form.menuGroup.value,
|
|
||||||
menuLevel: form.menuLevel.value,
|
|
||||||
menuSort: form.menuSort.value,
|
|
||||||
menuUrl: form.menuUrl.value,
|
|
||||||
menuTypeCd: form.menuTypeCd.value,
|
|
||||||
}
|
|
||||||
EgovNet.requestFetch(
|
EgovNet.requestFetch(
|
||||||
'/admin/config/menu-mgt',
|
'/admin/survey/info',
|
||||||
{
|
{
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-type': 'application/json'
|
'Content-type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(info)
|
body: JSON.stringify(survey)
|
||||||
},
|
},
|
||||||
(resp) => {
|
(resp) => {
|
||||||
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
alert("저장되었습니다.")
|
alert("저장되었습니다.")
|
||||||
reloadFunction();
|
reloadFunction();
|
||||||
}else if(Number(resp.resultCode) === Number(CODE.RCV_ERROR_AUTH)){
|
}else{
|
||||||
console.log("토큰 갱신중.")
|
alert(resp.resultMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteSurvey(e,svySeq){
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/survey/info',
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({svySeq:svySeq})
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("삭제되었습니다.")
|
||||||
|
reloadFunction();
|
||||||
}else{
|
}else{
|
||||||
alert(resp.resultMessage)
|
alert(resp.resultMessage)
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +77,8 @@ function SurveyModal({savedInfo, reloadFunction}){
|
||||||
제목
|
제목
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={9}>
|
<Col sm={9}>
|
||||||
<Form.Control type="email" name="svyTitle" required defaultValue={savedInfo?.svyTitle} />
|
<Form.Control type="email" name="svyTitle" required defaultValue={survey.svyTitle}
|
||||||
|
onChange={(e)=>{setSurvey({...survey, svyTitle:e.target.value})}}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Group as={Row} className="mb-3">
|
<Form.Group as={Row} className="mb-3">
|
||||||
|
|
@ -65,37 +86,38 @@ function SurveyModal({savedInfo, reloadFunction}){
|
||||||
설명
|
설명
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={9}>
|
<Col sm={9}>
|
||||||
<Form.Control as={"textarea"} name="svyDesc" rows={3} defaultValue={savedInfo?.svyDesc}/>
|
<Form.Control as={"textarea"} name="svyDesc" rows={3} defaultValue={survey.svyDesc}
|
||||||
|
onChange={(e)=>{setSurvey({...survey, svyDesc:e.target.value})}}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Group as={Row} className="mb-3">
|
<Form.Group as={Row} className="mb-3">
|
||||||
<Form.Label column sm={3}>
|
<Form.Label column sm={3}>
|
||||||
시작일
|
설문기간
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={9}>
|
<Col sm={9}>
|
||||||
<Form.Control type="text" name="svyStartDt" required defaultValue={savedInfo?.svyStartDt} />
|
<DatePicker selectsRange inline format={"yyyy-MM-dd"}
|
||||||
|
selected={survey.svyEndDt} minDate={new Date()}
|
||||||
|
startDate={survey.svyStartDt} endDate={survey.svyEndDt}
|
||||||
|
onChange={(dates)=>{
|
||||||
|
const [start, end] = dates;
|
||||||
|
setSurvey({...survey, svyStartDt:start, svyEndDt: end})
|
||||||
|
}}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Group as={Row} className="mb-3">
|
<Form.Group as={Row} className="mb-3">
|
||||||
<Form.Label column sm={3}>
|
<Form.Label column sm={12}>
|
||||||
종료일
|
* 목록에서 사용 여부를 변경해야 설문이 노출됩니다.
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={9}>
|
|
||||||
<Form.Control type="text" name="svyEndDt" required defaultValue={savedInfo?.svyEndDt} />
|
|
||||||
</Col>
|
|
||||||
</Form.Group>
|
|
||||||
<Form.Group as={Row} className="mb-3">
|
|
||||||
<Form.Label column sm={3}>
|
|
||||||
첨부파일
|
|
||||||
</Form.Label>
|
|
||||||
<Col sm={9}>
|
|
||||||
<Form.Control type="text" name="fileGrpId" selectedValue={savedInfo?.fileGrpId}/>
|
|
||||||
</Col>
|
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Row className="mb-3">
|
<Row className="mb-3">
|
||||||
<Col xs={10}></Col>
|
{survey.svySeq?
|
||||||
|
<Col xs={2}>
|
||||||
|
<button className={"btn btn_red_h31"} onClick={(e)=>{deleteSurvey(e, survey.svySeq)}}>삭제</button>
|
||||||
|
</Col>
|
||||||
|
:''}
|
||||||
|
<Col xs={survey.svySeq?8:10}></Col>
|
||||||
<Col xs={2}>
|
<Col xs={2}>
|
||||||
<button type="submit" className={"btn btn_blue_h31 px-3"}>저장</button>
|
<button type="submit" className={"btn btn_blue_h31"}>저장</button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,20 @@ package com.dbnt.kcscbackend.admin.contents.survey;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurvey;
|
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurvey;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.service.AdminSurveyService;
|
import com.dbnt.kcscbackend.admin.contents.survey.service.AdminSurveyService;
|
||||||
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.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -32,17 +37,44 @@ public class AdminSurveyController {
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/edit")
|
@RequestMapping(method = RequestMethod.PUT, value = "/info")
|
||||||
public ResultVO surveyEdit(TnSurvey survey) throws Exception{
|
public ResultVO surveyEdit(@RequestBody @Valid TnSurvey survey, Errors errors, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||||
|
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
if(errors.hasErrors()){
|
||||||
resultMap.put("survey", adminSurveyService.selectSurvey(survey));
|
StringBuilder msg = new StringBuilder();
|
||||||
resultVO.setResult(resultMap);
|
for(FieldError error: errors.getFieldErrors()){
|
||||||
|
msg.append(error.getDefaultMessage());
|
||||||
|
msg.append("\n");
|
||||||
|
}
|
||||||
|
resultVO.setResultCode(ResponseCode.INPUT_CHECK_ERROR.getCode());
|
||||||
|
resultVO.setResultMessage(msg.toString());
|
||||||
|
}else {
|
||||||
|
adminSurveyService.insertSurvey(survey, user.getId());
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage("저장 되었습니다.");
|
||||||
|
}
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/edit-qt")
|
@RequestMapping(method = RequestMethod.DELETE, value = "/info")
|
||||||
|
public ResultVO surveyDelete(@RequestBody TnSurvey survey, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
adminSurveyService.deleteSurvey(survey.getSvySeq());
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage("저장 되었습니다.");
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.PUT, value = "/info-use-yn")
|
||||||
|
public ResultVO surveyUseYn(@RequestBody TnSurvey survey, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
adminSurveyService.updateSurveyUseYn(survey.getSvySeq(), user.getId());
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage("저장 되었습니다.");
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/info-qt")
|
||||||
public ResultVO surveyEditQt(TnSurvey survey) throws Exception{
|
public ResultVO surveyEditQt(TnSurvey survey) throws Exception{
|
||||||
|
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.hibernate.annotations.DynamicInsert;
|
import org.hibernate.annotations.DynamicInsert;
|
||||||
import org.hibernate.annotations.DynamicUpdate;
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
@ -22,16 +21,20 @@ import java.time.LocalDateTime;
|
||||||
@Table(name = "tn_survey")
|
@Table(name = "tn_survey")
|
||||||
public class TnSurvey {
|
public class TnSurvey {
|
||||||
@Id
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "svy_seq")
|
@Column(name = "svy_seq")
|
||||||
private Integer svySeq;
|
private Integer svySeq;
|
||||||
|
|
||||||
@Column(name = "svy_title")
|
@Column(name = "svy_title")
|
||||||
|
@NotBlank(message = "설문 제목을 입력해주세요.")
|
||||||
private String svyTitle;
|
private String svyTitle;
|
||||||
@Column(name = "svy_desc")
|
@Column(name = "svy_desc")
|
||||||
private String svyDesc;
|
private String svyDesc;
|
||||||
@Column(name = "svy_start_dt")
|
@Column(name = "svy_start_dt")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate svyStartDt;
|
private LocalDate svyStartDt;
|
||||||
@Column(name = "svy_end_dt")
|
@Column(name = "svy_end_dt")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate svyEndDt;
|
private LocalDate svyEndDt;
|
||||||
@Column(name = "file_grp_id")
|
@Column(name = "file_grp_id")
|
||||||
private String fileGrpId;
|
private String fileGrpId;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||||
@Table(name = "tn_survey_qt")
|
@Table(name = "tn_survey_qt")
|
||||||
public class TnSurveyQt {
|
public class TnSurveyQt {
|
||||||
@Id
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "qt_seq")
|
@Column(name = "qt_seq")
|
||||||
private Integer qtSeq;
|
private Integer qtSeq;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,7 @@ import lombok.Setter;
|
||||||
import org.hibernate.annotations.DynamicInsert;
|
import org.hibernate.annotations.DynamicInsert;
|
||||||
import org.hibernate.annotations.DynamicUpdate;
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
@ -20,6 +17,7 @@ import javax.persistence.Table;
|
||||||
@Table(name = "tn_survey_qt_item")
|
@Table(name = "tn_survey_qt_item")
|
||||||
public class TnSurveyQtItem {
|
public class TnSurveyQtItem {
|
||||||
@Id
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "qt_item_seq")
|
@Column(name = "qt_item_seq")
|
||||||
private Integer qtItemSeq;
|
private Integer qtItemSeq;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyQtRepositor
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyRepository;
|
import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -43,4 +45,36 @@ public class AdminSurveyService {
|
||||||
}
|
}
|
||||||
return qtList;
|
return qtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void insertSurvey(TnSurvey survey, String insertUser) {
|
||||||
|
if(survey.getSvySeq()==null){
|
||||||
|
survey.setFrstCrtId(insertUser);
|
||||||
|
survey.setFrstCrtDt(LocalDateTime.now());
|
||||||
|
survey.setUseYn("N");
|
||||||
|
surveyRepository.save(survey);
|
||||||
|
}else{
|
||||||
|
TnSurvey savedInfo = surveyRepository.findById(survey.getSvySeq()).orElse(null);
|
||||||
|
savedInfo.setSvyTitle(survey.getSvyTitle());
|
||||||
|
savedInfo.setSvyDesc(survey.getSvyDesc());
|
||||||
|
savedInfo.setSvyStartDt(survey.getSvyStartDt());
|
||||||
|
savedInfo.setSvyEndDt(survey.getSvyEndDt());
|
||||||
|
savedInfo.setLastChgId(insertUser);
|
||||||
|
savedInfo.setLastChgDt(LocalDateTime.now());
|
||||||
|
surveyRepository.save(savedInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void updateSurveyUseYn(Integer svySeq, String updateUser) {
|
||||||
|
TnSurvey savedInfo = surveyRepository.findById(svySeq).orElse(null);
|
||||||
|
savedInfo.setUseYn(savedInfo.getUseYn().equals("Y")?"N":"Y");
|
||||||
|
savedInfo.setLastChgId(updateUser);
|
||||||
|
savedInfo.setLastChgDt(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deleteSurvey(Integer svySeq) {
|
||||||
|
surveyRepository.deleteById(svySeq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue