설문관리 작업중.
parent
71fbb763e1
commit
543bac81ac
|
|
@ -6,12 +6,15 @@ 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 SurveyModal from "./survey/SurveyModal";
|
||||||
|
import QuestionModal from "./survey/QuestionModal";
|
||||||
|
|
||||||
|
|
||||||
function Survey({}) {
|
function Survey({}) {
|
||||||
|
|
||||||
const [listTag, setListTag] = useState([]);
|
const [listTag, setListTag] = useState([]);
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
|
const [modalSize, setModalSize] = useState("md");
|
||||||
const [modalBody, setModalBody] = useState();
|
const [modalBody, setModalBody] = useState();
|
||||||
|
|
||||||
const handleClose = () => setShow(false);
|
const handleClose = () => setShow(false);
|
||||||
|
|
@ -34,7 +37,7 @@ function Survey({}) {
|
||||||
<div className={"list_item"} key={"surveyListDiv_"+index}>
|
<div className={"list_item"} key={"surveyListDiv_"+index}>
|
||||||
<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"}>질문관리</button></div>
|
<div><button className={"btn btn_blue_h31 px-1"} onClick={()=>{editSurveyQt(item)}}>질문관리</button></div>
|
||||||
<div></div>
|
<div></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>
|
||||||
|
|
@ -56,9 +59,16 @@ function Survey({}) {
|
||||||
);
|
);
|
||||||
},[]);
|
},[]);
|
||||||
|
|
||||||
function editSurvey(){
|
function editSurvey(item){
|
||||||
handleShow();
|
handleShow();
|
||||||
setModalBody(<></>);
|
setModalSize("md")
|
||||||
|
setModalBody(<SurveyModal savedInfo={item} reloadFunction={retrieveList}></SurveyModal>);
|
||||||
|
}
|
||||||
|
|
||||||
|
function editSurveyQt(item){
|
||||||
|
handleShow();
|
||||||
|
setModalSize("xl")
|
||||||
|
setModalBody(<QuestionModal svySeq={item.svySeq}></QuestionModal>);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
|
|
@ -104,7 +114,7 @@ function Survey({}) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Modal show={show} onHide={handleClose} keyboard={false}>
|
<Modal size={modalSize} show={show} onHide={handleClose} keyboard={false}>
|
||||||
{modalBody}
|
{modalBody}
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import Form from "react-bootstrap/Form";
|
||||||
|
import Row from "react-bootstrap/Row";
|
||||||
|
import Col from "react-bootstrap/Col";
|
||||||
|
import * as EgovNet from "api/egovFetch";
|
||||||
|
|
||||||
|
function QuestionModal({svySeq}){
|
||||||
|
|
||||||
|
const [qtTag, setQtTag] = useState([]);
|
||||||
|
const [itemTag, setItemTag] = useState([]);
|
||||||
|
|
||||||
|
function getSurveyQt(){
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/survey/edit-qt?svySeq='+svySeq,
|
||||||
|
{
|
||||||
|
method: "GET"
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
|
||||||
|
const temp = [];
|
||||||
|
resp.result.qtList.forEach(function (qt, index){
|
||||||
|
temp.push(
|
||||||
|
<Row>
|
||||||
|
<Col onClick={()=>selectQt(qt.itemList)}>{qt.qtTitle}</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
setQtTag(temp);
|
||||||
|
|
||||||
|
},
|
||||||
|
function (resp) {
|
||||||
|
console.log("err response : ", resp);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectQt(itemList){
|
||||||
|
const temp = [];
|
||||||
|
itemList.forEach(function (item, index){
|
||||||
|
temp.push(
|
||||||
|
<Row>
|
||||||
|
<Col>{item.itemNm}</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
setItemTag(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
function editSurveyQt(e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getSurveyQt()
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Modal.Header closeButton>
|
||||||
|
<Modal.Title>질문관리</Modal.Title>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Body>
|
||||||
|
<Row>
|
||||||
|
<Col xs={6}>
|
||||||
|
{qtTag}
|
||||||
|
</Col>
|
||||||
|
<Col xs={6}>
|
||||||
|
{itemTag}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Modal.Body>
|
||||||
|
<Modal.Footer>
|
||||||
|
<button type="button" className={"btn btn_blue_h31 px-3"}>저장</button>
|
||||||
|
</Modal.Footer>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default QuestionModal;
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
import React from "react";
|
||||||
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import Form from "react-bootstrap/Form";
|
||||||
|
import Row from "react-bootstrap/Row";
|
||||||
|
import Col from "react-bootstrap/Col";
|
||||||
|
import * as EgovNet from "api/egovFetch";
|
||||||
|
import CODE from "constants/code";
|
||||||
|
|
||||||
|
function SurveyModal({savedInfo, reloadFunction}){
|
||||||
|
|
||||||
|
function editSurvey(e){
|
||||||
|
e.preventDefault();
|
||||||
|
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(
|
||||||
|
'/admin/config/menu-mgt',
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(info)
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("저장되었습니다.")
|
||||||
|
reloadFunction();
|
||||||
|
}else if(Number(resp.resultCode) === Number(CODE.RCV_ERROR_AUTH)){
|
||||||
|
console.log("토큰 갱신중.")
|
||||||
|
}else{
|
||||||
|
alert(resp.resultMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Modal.Header closeButton>
|
||||||
|
<Modal.Title>
|
||||||
|
{savedInfo!==undefined?savedInfo?.svyTitle:'설문 생성'}
|
||||||
|
</Modal.Title>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Body>
|
||||||
|
<Form onSubmit={(e) =>{editSurvey(e)}} noValidate>
|
||||||
|
<Form.Group as={Row} className="mb-3">
|
||||||
|
<Form.Label column sm={3}>
|
||||||
|
제목
|
||||||
|
</Form.Label>
|
||||||
|
<Col sm={9}>
|
||||||
|
<Form.Control type="email" name="svyTitle" required defaultValue={savedInfo?.svyTitle} />
|
||||||
|
</Col>
|
||||||
|
</Form.Group>
|
||||||
|
<Form.Group as={Row} className="mb-3">
|
||||||
|
<Form.Label column sm={3}>
|
||||||
|
설명
|
||||||
|
</Form.Label>
|
||||||
|
<Col sm={9}>
|
||||||
|
<Form.Control as={"textarea"} name="svyDesc" rows={3} defaultValue={savedInfo?.svyDesc}/>
|
||||||
|
</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="svyStartDt" required defaultValue={savedInfo?.svyStartDt} />
|
||||||
|
</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="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>
|
||||||
|
<Row className="mb-3">
|
||||||
|
<Col xs={10}></Col>
|
||||||
|
<Col xs={2}>
|
||||||
|
<button type="submit" className={"btn btn_blue_h31 px-3"}>저장</button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Form>
|
||||||
|
</Modal.Body>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SurveyModal;
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.survey;
|
package com.dbnt.kcscbackend.admin.contents.survey;
|
||||||
|
|
||||||
|
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.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
import com.dbnt.kcscbackend.config.util.ClientUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -22,7 +23,7 @@ public class AdminSurveyController {
|
||||||
private final AdminSurveyService adminSurveyService;
|
private final AdminSurveyService adminSurveyService;
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/list")
|
@RequestMapping(method = RequestMethod.GET, value = "/list")
|
||||||
public ResultVO getSurveyList(HttpServletRequest request, @AuthenticationPrincipal LoginVO user) throws Exception{
|
public ResultVO getSurveyList() throws Exception{
|
||||||
|
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
@ -30,4 +31,24 @@ public class AdminSurveyController {
|
||||||
resultVO.setResult(resultMap);
|
resultVO.setResult(resultMap);
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/edit")
|
||||||
|
public ResultVO surveyEdit(TnSurvey survey) throws Exception{
|
||||||
|
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("survey", adminSurveyService.selectSurvey(survey));
|
||||||
|
resultVO.setResult(resultMap);
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/edit-qt")
|
||||||
|
public ResultVO surveyEditQt(TnSurvey survey) throws Exception{
|
||||||
|
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("qtList", adminSurveyService.selectSurveyQt(survey));
|
||||||
|
resultVO.setResult(resultMap);
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,11 @@ 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;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
@ -41,4 +40,7 @@ public class TnSurveyQt {
|
||||||
private String etcYn;
|
private String etcYn;
|
||||||
@Column(name = "old_seq")
|
@Column(name = "old_seq")
|
||||||
private Integer oldSeq;
|
private Integer oldSeq;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private List<TnSurveyQtItem> itemList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,8 @@ package com.dbnt.kcscbackend.admin.contents.survey.repository;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurveyQtItem;
|
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurveyQtItem;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface TnSurveyQtItemRepository extends JpaRepository<TnSurveyQtItem, Integer> {
|
public interface TnSurveyQtItemRepository extends JpaRepository<TnSurveyQtItem, Integer> {
|
||||||
|
List<TnSurveyQtItem> findByQtSeqInOrderByQtItemSeq(List<Integer> qtSeqList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,8 @@ package com.dbnt.kcscbackend.admin.contents.survey.repository;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurveyQt;
|
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurveyQt;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface TnSurveyQtRepository extends JpaRepository<TnSurveyQt, Integer> {
|
public interface TnSurveyQtRepository extends JpaRepository<TnSurveyQt, Integer> {
|
||||||
|
List<TnSurveyQt> findBySvySeqOrderByQtSeq(Integer svySeq);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.survey.service;
|
package com.dbnt.kcscbackend.admin.contents.survey.service;
|
||||||
|
|
||||||
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.entity.TnSurveyQt;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurveyQtItem;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyQtItemRepository;
|
import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyQtItemRepository;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyQtRepository;
|
import com.dbnt.kcscbackend.admin.contents.survey.repository.TnSurveyQtRepository;
|
||||||
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 java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -19,4 +22,25 @@ public class AdminSurveyService {
|
||||||
public List<TnSurvey> selectSurveyList() {
|
public List<TnSurvey> selectSurveyList() {
|
||||||
return surveyRepository.findAllByOrderBySvySeqDesc();
|
return surveyRepository.findAllByOrderBySvySeqDesc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TnSurvey selectSurvey(TnSurvey survey) {
|
||||||
|
return surveyRepository.findById(survey.getSvySeq()).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TnSurveyQt> selectSurveyQt(TnSurvey survey) {
|
||||||
|
List<TnSurveyQt> qtList = qtRepository.findBySvySeqOrderByQtSeq(survey.getSvySeq());
|
||||||
|
List<Integer> qtSeqList = new ArrayList<>();
|
||||||
|
for(TnSurveyQt qt: qtList){
|
||||||
|
qtSeqList.add(qt.getQtSeq());
|
||||||
|
}
|
||||||
|
List<TnSurveyQtItem> itemList = itemRepository.findByQtSeqInOrderByQtItemSeq(qtSeqList);
|
||||||
|
for(TnSurveyQt qt: qtList){
|
||||||
|
for(TnSurveyQtItem item: itemList){
|
||||||
|
if(qt.getQtSeq().equals(item.getQtSeq())){
|
||||||
|
qt.getItemList().add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return qtList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue